Print this page
make: translate using gettext, rather than the unmaintainable catgets
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/bin/read.cc
+++ new/usr/src/cmd/make/bin/read.cc
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 /*
27 27 * read.c
28 28 *
29 29 * This file contains the makefile reader.
30 30 */
31 31
32 32 /*
33 33 * Included files
↓ open down ↓ |
33 lines elided |
↑ open up ↑ |
34 34 */
35 35 #include <alloca.h> /* alloca() */
36 36 #include <errno.h> /* errno */
37 37 #include <fcntl.h> /* fcntl() */
38 38 #include <mk/defs.h>
39 39 #include <mksh/macro.h> /* expand_value(), expand_macro() */
40 40 #include <mksh/misc.h> /* getmem() */
41 41 #include <mksh/read.h> /* get_next_block_fn() */
42 42 #include <sys/uio.h> /* read() */
43 43 #include <unistd.h> /* read(), unlink() */
44 +#include <libintl.h>
44 45
45 46
46 47 /*
47 48 * typedefs & structs
48 49 */
49 50
50 51 /*
51 52 * Static variables
52 53 */
53 54
54 55 static int line_started_with_space=0; // Used to diagnose spaces instead of tabs
55 56
56 57 /*
57 58 * File table of contents
58 59 */
59 60 static void parse_makefile(register Name true_makefile_name, register Source source);
60 61 static Source push_macro_value(register Source bp, register wchar_t *buffer, int size, register Source source);
61 62 extern void enter_target_groups_and_dependencies(Name_vector target, Name_vector depes, Cmd_line command, Separator separator, Boolean target_group_seen);
62 63 extern Name normalize_name(register wchar_t *name_string, register int length);
63 64
64 65 /*
65 66 * read_simple_file(makefile_name, chase_path, doname_it,
66 67 * complain, must_exist, report_file, lock_makefile)
67 68 *
68 69 * Make the makefile and setup to read it. Actually read it if it is stdio
69 70 *
70 71 * Return value:
71 72 * false if the read failed
72 73 *
73 74 * Parameters:
74 75 * makefile_name Name of the file to read
75 76 * chase_path Use the makefile path when opening file
76 77 * doname_it Call doname() to build the file first
77 78 * complain Print message if doname/open fails
78 79 * must_exist Generate fatal if file is missing
79 80 * report_file Report file when running -P
80 81 * lock_makefile Lock the makefile when reading
81 82 *
82 83 * Static variables used:
83 84 *
84 85 * Global variables used:
85 86 * do_not_exec_rule Is -n on?
86 87 * file_being_read Set to the name of the new file
87 88 * line_number The number of the current makefile line
88 89 * makefiles_used A list of all makefiles used, appended to
89 90 */
90 91
91 92
92 93 Boolean
93 94 read_simple_file(register Name makefile_name, register Boolean chase_path, register Boolean doname_it, Boolean complain, Boolean must_exist, Boolean report_file, Boolean lock_makefile)
94 95 {
95 96 static short max_include_depth;
96 97 register Property makefile = maybe_append_prop(makefile_name,
97 98 makefile_prop);
98 99 Boolean forget_after_parse = false;
99 100 static pathpt makefile_path;
100 101 register int n;
101 102 char *path;
102 103 register Source source = ALLOC(Source);
103 104 Property orig_makefile = makefile;
104 105 Dependency *dpp;
105 106 Dependency dp;
106 107 register int length;
107 108 wchar_t *previous_file_being_read = file_being_read;
108 109 int previous_line_number = line_number;
109 110 wchar_t previous_current_makefile[MAXPATHLEN];
↓ open down ↓ |
56 lines elided |
↑ open up ↑ |
110 111 Makefile_type save_makefile_type;
111 112 Name normalized_makefile_name;
112 113 register wchar_t *string_start;
113 114 register wchar_t *string_end;
114 115
115 116
116 117
117 118 wchar_t * wcb = get_wstring(makefile_name->string_mb);
118 119
119 120 if (max_include_depth++ >= 40) {
120 - fatal(catgets(catd, 1, 66, "Too many nested include statements"));
121 + fatal(gettext("Too many nested include statements"));
121 122 }
122 123 if (makefile->body.makefile.contents != NULL) {
123 124 retmem(makefile->body.makefile.contents);
124 125 }
125 126 source->inp_buf =
126 127 source->inp_buf_ptr =
127 128 source->inp_buf_end = NULL;
128 129 source->error_converting = false;
129 130 makefile->body.makefile.contents = NULL;
130 131 makefile->body.makefile.size = 0;
131 132 if ((makefile_name->hash.length != 1) ||
132 133 (wcb[0] != (int) hyphen_char)) {
133 134 if ((makefile->body.makefile.contents == NULL) &&
134 135 (doname_it)) {
135 136 if (makefile_path == NULL) {
136 137 char *pfx = make_install_prefix();
137 138 char *path;
138 139
139 140 add_dir_to_path(".",
140 141 &makefile_path,
141 142 -1);
142 143
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
143 144 // As regularly installed
144 145 asprintf(&path, "%s/../share/lib/make", pfx);
145 146 add_dir_to_path(path, &makefile_path, -1);
146 147 free(path);
147 148
148 149 // Tools build
149 150 asprintf(&path, "%s/../../share/", pfx);
150 151 add_dir_to_path(path, &makefile_path, -1);
151 152 free(path);
152 153
153 - add_dir_to_path(NOCATGETS("/usr/share/lib/make"),
154 + add_dir_to_path("/usr/share/lib/make",
154 155 &makefile_path,
155 156 -1);
156 - add_dir_to_path(NOCATGETS("/etc/default"),
157 + add_dir_to_path("/etc/default",
157 158 &makefile_path,
158 159 -1);
159 160
160 161 free(pfx);
161 162 }
162 163 save_makefile_type = makefile_type;
163 164 makefile_type = reading_nothing;
164 165 if (doname(makefile_name, true, false) == build_dont_know) {
165 166 /* Try normalized filename */
166 167 string_start=get_wstring(makefile_name->string_mb);
167 168 for (string_end=string_start+1; *string_end != L'\0'; string_end++);
168 169 normalized_makefile_name=normalize_name(string_start, string_end - string_start);
169 170 if ((strcmp(makefile_name->string_mb, normalized_makefile_name->string_mb) == 0) ||
170 171 (doname(normalized_makefile_name, true, false) == build_dont_know)) {
171 172 n = access_vroot(makefile_name->string_mb,
172 173 4,
173 174 chase_path ?
174 175 makefile_path : NULL,
175 176 VROOT_DEFAULT);
176 177 if (n == 0) {
177 178 get_vroot_path((char **) NULL,
178 179 &path,
179 180 (char **) NULL);
180 181 if ((path[0] == (int) period_char) &&
181 182 (path[1] == (int) slash_char)) {
182 183 path += 2;
183 184 }
184 185 MBSTOWCS(wcs_buffer, path);
185 186 makefile_name = GETNAME(wcs_buffer,
186 187 FIND_LENGTH);
187 188 }
188 189 }
189 190 retmem(string_start);
190 191 /*
191 192 * Commented out: retmem_mb(normalized_makefile_name->string_mb);
192 193 * We have to return this memory, but it seems to trigger a bug
193 194 * in dmake or in Sun C++ 5.7 compiler (it works ok if this code
194 195 * is compiled using Sun C++ 5.6).
195 196 */
196 197 // retmem_mb(normalized_makefile_name->string_mb);
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
197 198 }
198 199 makefile_type = save_makefile_type;
199 200 }
200 201 source->string.free_after_use = false;
201 202 source->previous = NULL;
202 203 source->already_expanded = false;
203 204 /* Lock the file for read, but not when -n. */
204 205 if (lock_makefile &&
205 206 !do_not_exec_rule) {
206 207
207 - make_state_lockfile = getmem(strlen(make_state->string_mb) + strlen(NOCATGETS(".lock")) + 1);
208 + make_state_lockfile = getmem(strlen(make_state->string_mb) + strlen(".lock") + 1);
208 209 (void) sprintf(make_state_lockfile,
209 - NOCATGETS("%s.lock"),
210 + "%s.lock",
210 211 make_state->string_mb);
211 212 (void) file_lock(make_state->string_mb,
212 213 make_state_lockfile,
213 214 (int *) &make_state_locked,
214 215 0);
215 216 if(!make_state_locked) {
216 - printf(NOCATGETS("-- NO LOCKING for read\n"));
217 + printf("-- NO LOCKING for read\n");
217 218 retmem_mb(make_state_lockfile);
218 219 make_state_lockfile = 0;
219 220 return failed;
220 221 }
221 222 }
222 223 if (makefile->body.makefile.contents == NULL) {
223 224 save_makefile_type = makefile_type;
224 225 makefile_type = reading_nothing;
225 226 if ((doname_it) &&
226 227 (doname(makefile_name, true, false) == build_failed)) {
227 228 if (complain) {
228 229 (void) fprintf(stderr,
229 - catgets(catd, 1, 237, "make: Couldn't make `%s'\n"),
230 + gettext("make: Couldn't make `%s'\n"),
230 231 makefile_name->string_mb);
231 232 }
232 233 max_include_depth--;
233 234 makefile_type = save_makefile_type;
234 235 return failed;
235 236 }
236 237 makefile_type = save_makefile_type;
237 238 //
238 239 // Before calling exists() make sure that we have the right timestamp
239 240 //
240 241 makefile_name->stat.time = file_no_time;
241 242
242 243 if (exists(makefile_name) == file_doesnt_exist) {
243 244 if (complain ||
244 245 (makefile_name->stat.stat_errno != ENOENT)) {
245 246 if (must_exist) {
246 - fatal(catgets(catd, 1, 68, "Can't find `%s': %s"),
247 + fatal(gettext("Can't find `%s': %s"),
247 248 makefile_name->string_mb,
248 249 errmsg(makefile_name->
249 250 stat.stat_errno));
250 251 } else {
251 - warning(catgets(catd, 1, 69, "Can't find `%s': %s"),
252 + warning(gettext("Can't find `%s': %s"),
252 253 makefile_name->string_mb,
253 254 errmsg(makefile_name->
254 255 stat.stat_errno));
255 256 }
256 257 }
257 258 max_include_depth--;
258 259 if(make_state_locked && (make_state_lockfile != NULL)) {
259 260 (void) unlink(make_state_lockfile);
260 261 retmem_mb(make_state_lockfile);
261 262 make_state_lockfile = NULL;
262 263 make_state_locked = false;
263 264 }
264 265 retmem(wcb);
265 266 retmem_mb((char *)source);
266 267 return failed;
267 268 }
268 269 /*
269 270 * These values are the size and bytes of
270 271 * the MULTI-BYTE makefile.
271 272 */
272 273 orig_makefile->body.makefile.size =
273 274 makefile->body.makefile.size =
274 275 source->bytes_left_in_file =
275 276 makefile_name->stat.size;
276 277 if (report_file) {
277 278 for (dpp = &makefiles_used;
278 279 *dpp != NULL;
279 280 dpp = &(*dpp)->next);
280 281 dp = ALLOC(Dependency);
281 282 dp->next = NULL;
282 283 dp->name = makefile_name;
283 284 dp->automatic = false;
284 285 dp->stale = false;
285 286 dp->built = false;
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
286 287 *dpp = dp;
287 288 }
288 289 source->fd = open_vroot(makefile_name->string_mb,
289 290 O_RDONLY,
290 291 0,
291 292 NULL,
292 293 VROOT_DEFAULT);
293 294 if (source->fd < 0) {
294 295 if (complain || (errno != ENOENT)) {
295 296 if (must_exist) {
296 - fatal(catgets(catd, 1, 70, "Can't open `%s': %s"),
297 + fatal(gettext("Can't open `%s': %s"),
297 298 makefile_name->string_mb,
298 299 errmsg(errno));
299 300 } else {
300 - warning(catgets(catd, 1, 71, "Can't open `%s': %s"),
301 + warning(gettext("Can't open `%s': %s"),
301 302 makefile_name->string_mb,
302 303 errmsg(errno));
303 304 }
304 305 }
305 306 max_include_depth--;
306 307 return failed;
307 308 }
308 309 (void) fcntl(source->fd, F_SETFD, 1);
309 310 orig_makefile->body.makefile.contents =
310 311 makefile->body.makefile.contents =
311 312 source->string.text.p =
312 313 source->string.buffer.start =
313 314 ALLOC_WC((int) (makefile_name->stat.size + 2));
314 315 if (makefile_type == reading_cpp_file) {
315 316 forget_after_parse = true;
316 317 }
317 318 source->string.text.end = source->string.text.p;
318 319 source->string.buffer.end =
319 320 source->string.text.p + makefile_name->stat.size;
320 321 } else {
321 322 /* Do we ever reach here? */
322 323 source->fd = -1;
323 324 source->string.text.p =
324 325 source->string.buffer.start =
325 326 makefile->body.makefile.contents;
326 327 source->string.text.end =
327 328 source->string.buffer.end =
328 329 source->string.text.p + makefile->body.makefile.size;
329 330 source->bytes_left_in_file =
330 331 makefile->body.makefile.size;
331 332 }
↓ open down ↓ |
21 lines elided |
↑ open up ↑ |
332 333 file_being_read = wcb;
333 334 } else {
334 335 char *stdin_text_p;
335 336 char *stdin_text_end;
336 337 char *stdin_buffer_start;
337 338 char *stdin_buffer_end;
338 339 char *p_mb;
339 340 int num_mb_chars;
340 341 size_t num_wc_chars;
341 342
342 - MBSTOWCS(wcs_buffer, NOCATGETS("Standard in"));
343 + MBSTOWCS(wcs_buffer, "Standard in");
343 344 makefile_name = GETNAME(wcs_buffer, FIND_LENGTH);
344 345 /*
345 346 * Memory to read standard in, then convert it
346 347 * to wide char strings.
347 348 */
348 349 stdin_buffer_start =
349 350 stdin_text_p = getmem(length = 1024);
350 351 stdin_buffer_end = stdin_text_p + length;
351 - MBSTOWCS(wcs_buffer, NOCATGETS("standard input"));
352 + MBSTOWCS(wcs_buffer, "standard input");
352 353 file_being_read = (wchar_t *) wsdup(wcs_buffer);
353 354 line_number = 0;
354 355 while ((n = read(fileno(stdin),
355 356 stdin_text_p,
356 357 length)) > 0) {
357 358 length -= n;
358 359 stdin_text_p += n;
359 360 if (length == 0) {
360 361 p_mb = getmem(length = 1024 +
361 362 (stdin_buffer_end -
362 363 stdin_buffer_start));
363 364 (void) strncpy(p_mb,
364 365 stdin_buffer_start,
365 366 (stdin_buffer_end -
366 367 stdin_buffer_start));
↓ open down ↓ |
5 lines elided |
↑ open up ↑ |
367 368 retmem_mb(stdin_buffer_start);
368 369 stdin_text_p = p_mb +
369 370 (stdin_buffer_end - stdin_buffer_start);
370 371 stdin_buffer_start = p_mb;
371 372 stdin_buffer_end =
372 373 stdin_buffer_start + length;
373 374 length = 1024;
374 375 }
375 376 }
376 377 if (n < 0) {
377 - fatal(catgets(catd, 1, 72, "Error reading standard input: %s"),
378 + fatal(gettext("Error reading standard input: %s"),
378 379 errmsg(errno));
379 380 }
380 381 stdin_text_p = stdin_buffer_start;
381 382 stdin_text_end = stdin_buffer_end - length;
382 383 num_mb_chars = stdin_text_end - stdin_text_p;
383 384
384 385 /*
385 386 * Now, convert the sequence of multibyte chars into
386 387 * a sequence of corresponding wide character codes.
387 388 */
388 389 source->string.free_after_use = false;
389 390 source->previous = NULL;
390 391 source->bytes_left_in_file = 0;
391 392 source->fd = -1;
392 393 source->already_expanded = false;
393 394 source->string.buffer.start =
394 395 source->string.text.p = ALLOC_WC(num_mb_chars + 1);
395 396 source->string.buffer.end =
396 397 source->string.text.p + num_mb_chars;
397 398 num_wc_chars = mbstowcs(source->string.text.p,
↓ open down ↓ |
10 lines elided |
↑ open up ↑ |
398 399 stdin_text_p,
399 400 num_mb_chars);
400 401 if ((int) num_wc_chars >= 0) {
401 402 source->string.text.end =
402 403 source->string.text.p + num_wc_chars;
403 404 }
404 405 (void) retmem_mb(stdin_text_p);
405 406 }
406 407 line_number = 1;
407 408 if (trace_reader) {
408 - (void) printf(catgets(catd, 1, 73, ">>>>>>>>>>>>>>>> Reading makefile %s\n"),
409 + (void) printf(gettext(">>>>>>>>>>>>>>>> Reading makefile %s\n"),
409 410 makefile_name->string_mb);
410 411 }
411 412 parse_makefile(makefile_name, source);
412 413 if (trace_reader) {
413 - (void) printf(catgets(catd, 1, 74, ">>>>>>>>>>>>>>>> End of makefile %s\n"),
414 + (void) printf(gettext(">>>>>>>>>>>>>>>> End of makefile %s\n"),
414 415 makefile_name->string_mb);
415 416 }
416 417 if(file_being_read) {
417 418 retmem(file_being_read);
418 419 }
419 420 file_being_read = previous_file_being_read;
420 421 line_number = previous_line_number;
421 422 makefile_type = reading_nothing;
422 423 max_include_depth--;
423 424 if (make_state_locked) {
424 425 /* Unlock .make.state. */
425 426 unlink(make_state_lockfile);
426 427 make_state_locked = false;
427 428 retmem_mb(make_state_lockfile);
428 429 }
429 430 if (forget_after_parse) {
430 431 retmem(makefile->body.makefile.contents);
431 432 makefile->body.makefile.contents = NULL;
432 433 }
433 434 retmem_mb((char *)source);
434 435 return succeeded;
435 436 }
436 437
437 438 /*
438 439 * parse_makefile(true_makefile_name, source)
439 440 *
440 441 * Strings are read from Sources.
441 442 * When macros are found, their values are represented by a
442 443 * Source that is pushed on a stack. At end of string
443 444 * (that is returned from GET_CHAR() as 0), the block is popped.
444 445 *
445 446 * Parameters:
446 447 * true_makefile_name The name of makefile we are parsing
447 448 * source The source block to read from
448 449 *
449 450 * Global variables used:
450 451 * do_not_exec_rule Is -n on?
451 452 * line_number The number of the current makefile line
452 453 * makefile_type What kind of makefile are we reading?
453 454 * empty_name The Name ""
454 455 */
455 456 static void
456 457 parse_makefile(register Name true_makefile_name, register Source source)
457 458 {
458 459 /*
459 460 char mb_buffer[MB_LEN_MAX];
460 461 */
461 462 register wchar_t *source_p;
462 463 register wchar_t *source_end;
463 464 register wchar_t *string_start;
464 465 wchar_t *string_end;
465 466 register Boolean macro_seen_in_string;
466 467 Boolean append;
467 468 String_rec name_string;
468 469 wchar_t name_buffer[STRING_BUFFER_LENGTH];
469 470 register int distance;
470 471 register int paren_count;
471 472 int brace_count;
472 473 int char_number;
473 474 Cmd_line command;
474 475 Cmd_line command_tail;
475 476 Name macro_value;
476 477
477 478 Name_vector_rec target;
478 479 Name_vector_rec depes;
479 480 Name_vector_rec extra_name_vector;
480 481 Name_vector current_names;
481 482 Name_vector extra_names = &extra_name_vector;
482 483 Name_vector nvp;
483 484 Boolean target_group_seen;
484 485
485 486 register Reader_state state;
486 487 register Reader_state on_eoln_state;
487 488 register Separator separator;
488 489
489 490 wchar_t buffer[4 * STRING_BUFFER_LENGTH];
490 491 Source extrap;
491 492
492 493 Boolean save_do_not_exec_rule = do_not_exec_rule;
493 494 Name makefile_name;
494 495
495 496 static Name sh_name;
496 497 static Name shell_name;
497 498 int i;
498 499
499 500 static wchar_t include_space[10];
500 501 static wchar_t include_tab[10];
501 502 int tmp_bytes_left_in_string;
502 503 Boolean tmp_maybe_include = false;
503 504 int emptycount = 0;
504 505 Boolean first_target;
505 506
506 507 String_rec include_name;
507 508 wchar_t include_buffer[STRING_BUFFER_LENGTH];
508 509
509 510 target.next = depes.next = NULL;
510 511 /* Move some values from their struct to register declared locals */
511 512 CACHE_SOURCE(0);
512 513
513 514 start_new_line:
514 515 /*
515 516 * Read whitespace on old line. Leave pointer on first char on
516 517 * next line.
517 518 */
518 519 first_target = true;
519 520 on_eoln_state = exit_state;
520 521 /*
521 522 for (WCTOMB(mb_buffer, GET_CHAR());
522 523 1;
523 524 source_p++, WCTOMB(mb_buffer, GET_CHAR()))
524 525 switch (mb_buffer[0]) {
525 526 */
526 527 for (char_number=0; 1; source_p++,char_number++) switch (GET_CHAR()) {
527 528 case nul_char:
528 529 /* End of this string. Pop it and return to the previous one */
529 530 GET_NEXT_BLOCK(source);
530 531 source_p--;
531 532 if (source == NULL) {
532 533 GOTO_STATE(on_eoln_state);
533 534 }
534 535 break;
535 536 case newline_char:
536 537 end_of_line:
537 538 source_p++;
538 539 if (source->fd >= 0) {
539 540 line_number++;
540 541 }
541 542 switch (GET_CHAR()) {
542 543 case nul_char:
543 544 GET_NEXT_BLOCK(source);
544 545 if (source == NULL) {
545 546 GOTO_STATE(on_eoln_state);
546 547 }
547 548 /* Go back to the top of this loop */
548 549 goto start_new_line;
549 550 case newline_char:
550 551 case numbersign_char:
551 552 case dollar_char:
552 553 case space_char:
553 554 case tab_char:
554 555 /*
555 556 * Go back to the top of this loop since the
556 557 * new line does not start with a regular char.
557 558 */
558 559 goto start_new_line;
559 560 default:
560 561 /* We found the first proper char on the new line */
561 562 goto start_new_line_no_skip;
562 563 }
563 564 case space_char:
564 565 if (char_number == 0)
565 566 line_started_with_space=line_number;
566 567 case tab_char:
567 568 /* Whitespace. Just keep going in this loop */
568 569 break;
569 570 case numbersign_char:
570 571 /* Comment. Skip over it */
571 572 for (; 1; source_p++) {
572 573 switch (GET_CHAR()) {
573 574 case nul_char:
574 575 GET_NEXT_BLOCK_NOCHK(source);
575 576 if (source == NULL) {
576 577 GOTO_STATE(on_eoln_state);
577 578 }
578 579 if (source->error_converting) {
579 580 // Illegal byte sequence - skip its first byte
580 581 source->inp_buf_ptr++;
581 582 }
582 583 source_p--;
583 584 break;
584 585 case backslash_char:
585 586 /* Comments can be continued */
586 587 if (*++source_p == (int) nul_char) {
587 588 GET_NEXT_BLOCK_NOCHK(source);
588 589 if (source == NULL) {
589 590 GOTO_STATE(on_eoln_state);
590 591 }
591 592 if (source->error_converting) {
592 593 // Illegal byte sequence - skip its first byte
593 594 source->inp_buf_ptr++;
594 595 source_p--;
595 596 break;
596 597 }
597 598 }
598 599 if(*source_p == (int) newline_char) {
599 600 if (source->fd >= 0) {
600 601 line_number++;
601 602 }
602 603 }
603 604 break;
604 605 case newline_char:
605 606 /*
606 607 * After we skip the comment we go to
607 608 * the end of line handler since end of
608 609 * line terminates comments.
609 610 */
610 611 goto end_of_line;
611 612 }
612 613 }
613 614 case dollar_char:
614 615 /* Macro reference */
615 616 if (source->already_expanded) {
616 617 /*
617 618 * If we are reading from the expansion of a
618 619 * macro we already expanded everything enough.
619 620 */
620 621 goto start_new_line_no_skip;
621 622 }
622 623 /*
623 624 * Expand the value and push the Source on the stack of
624 625 * things being read.
625 626 */
626 627 source_p++;
627 628 UNCACHE_SOURCE();
628 629 {
629 630 Source t = (Source) alloca((int) sizeof (Source_rec));
630 631 source = push_macro_value(t,
631 632 buffer,
632 633 sizeof buffer,
633 634 source);
634 635 }
635 636 CACHE_SOURCE(1);
636 637 break;
637 638 default:
638 639 /* We found the first proper char on the new line */
639 640 goto start_new_line_no_skip;
640 641 }
641 642
642 643 /*
643 644 * We found the first normal char (one that starts an identifier)
644 645 * on the newline.
645 646 */
646 647 start_new_line_no_skip:
647 648 /* Inspect that first char to see if it maybe is special anyway */
648 649 switch (GET_CHAR()) {
649 650 case nul_char:
650 651 GET_NEXT_BLOCK(source);
651 652 if (source == NULL) {
652 653 GOTO_STATE(on_eoln_state);
653 654 }
654 655 goto start_new_line_no_skip;
655 656 case newline_char:
656 657 /* Just in case */
657 658 goto start_new_line;
658 659 case exclam_char:
659 660 /* Evaluate the line before it is read */
660 661 string_start = source_p + 1;
661 662 macro_seen_in_string = false;
662 663 /* Stuff the line in a string so we can eval it. */
663 664 for (; 1; source_p++) {
664 665 switch (GET_CHAR()) {
665 666 case newline_char:
666 667 goto eoln_1;
667 668 case nul_char:
668 669 if (source->fd > 0) {
669 670 if (!macro_seen_in_string) {
670 671 macro_seen_in_string = true;
671 672 INIT_STRING_FROM_STACK(
672 673 name_string, name_buffer);
673 674 }
674 675 append_string(string_start,
675 676 &name_string,
676 677 source_p - string_start);
677 678 GET_NEXT_BLOCK(source);
678 679 string_start = source_p;
679 680 source_p--;
680 681 break;
681 682 }
682 683 eoln_1:
683 684 if (!macro_seen_in_string) {
684 685 INIT_STRING_FROM_STACK(name_string,
685 686 name_buffer);
686 687 }
687 688 append_string(string_start,
688 689 &name_string,
689 690 source_p - string_start);
690 691 extrap = (Source)
691 692 alloca((int) sizeof (Source_rec));
692 693 extrap->string.buffer.start = NULL;
693 694 extrap->inp_buf =
694 695 extrap->inp_buf_ptr =
695 696 extrap->inp_buf_end = NULL;
696 697 extrap->error_converting = false;
697 698 if (*source_p == (int) nul_char) {
698 699 source_p++;
699 700 }
700 701 /* Eval the macro */
701 702 expand_value(GETNAME(name_string.buffer.start,
702 703 FIND_LENGTH),
703 704 &extrap->string,
704 705 false);
705 706 if (name_string.free_after_use) {
706 707 retmem(name_string.buffer.start);
707 708 }
708 709 UNCACHE_SOURCE();
709 710 extrap->string.text.p =
710 711 extrap->string.buffer.start;
711 712 extrap->fd = -1;
712 713 /* And push the value */
713 714 extrap->previous = source;
714 715 source = extrap;
715 716 CACHE_SOURCE(0);
716 717 goto line_evald;
717 718 }
718 719 }
719 720 default:
720 721 goto line_evald;
721 722 }
↓ open down ↓ |
298 lines elided |
↑ open up ↑ |
722 723
723 724 /* We now have a line we can start reading */
724 725 line_evald:
725 726 if (source == NULL) {
726 727 GOTO_STATE(exit_state);
727 728 }
728 729 /* Check if this is an include command */
729 730 if ((makefile_type == reading_makefile) &&
730 731 !source->already_expanded) {
731 732 if (include_space[0] == (int) nul_char) {
732 - MBSTOWCS(include_space, NOCATGETS("include "));
733 - MBSTOWCS(include_tab, NOCATGETS("include\t"));
733 + MBSTOWCS(include_space, "include ");
734 + MBSTOWCS(include_tab, "include\t");
734 735 }
735 736 if ((IS_WEQUALN(source_p, include_space, 8)) ||
736 737 (IS_WEQUALN(source_p, include_tab, 8))) {
737 738 source_p += 7;
738 739 if (iswspace(*source_p)) {
739 740 Makefile_type save_makefile_type;
740 741 wchar_t *name_start;
741 742 int name_length;
742 743
743 744 /*
744 745 * Yes, this is an include.
745 746 * Skip spaces to get to the filename.
746 747 */
747 748 while (iswspace(*source_p) ||
748 749 (*source_p == (int) nul_char)) {
749 750 switch (GET_CHAR()) {
750 751 case nul_char:
751 752 GET_NEXT_BLOCK(source);
752 753 if (source == NULL) {
753 754 GOTO_STATE(on_eoln_state);
754 755 }
755 756 break;
756 757
757 758 default:
758 759 source_p++;
759 760 break;
760 761 }
761 762 }
762 763
763 764 string_start = source_p;
764 765 /* Find the end of the filename */
765 766 macro_seen_in_string = false;
766 767 while (!iswspace(*source_p) ||
767 768 (*source_p == (int) nul_char)) {
768 769 switch (GET_CHAR()) {
769 770 case nul_char:
770 771 if (!macro_seen_in_string) {
771 772 INIT_STRING_FROM_STACK(name_string,
772 773 name_buffer);
773 774 }
774 775 append_string(string_start,
775 776 &name_string,
776 777 source_p - string_start);
777 778 macro_seen_in_string = true;
778 779 GET_NEXT_BLOCK(source);
779 780 string_start = source_p;
780 781 if (source == NULL) {
781 782 GOTO_STATE(on_eoln_state);
782 783 }
783 784 break;
784 785
785 786 default:
786 787 source_p++;
787 788 break;
788 789 }
789 790 }
790 791
791 792 source->string.text.p = source_p;
792 793 if (macro_seen_in_string) {
793 794 append_string(string_start,
794 795 &name_string,
795 796 source_p - string_start);
796 797 name_start = name_string.buffer.start;
797 798 name_length = name_string.text.p - name_start;
798 799 } else {
799 800 name_start = string_start;
800 801 name_length = source_p - string_start;
801 802 }
802 803
803 804 /* Strip "./" from the head of the name */
804 805 if ((name_start[0] == (int) period_char) &&
805 806 (name_start[1] == (int) slash_char)) {
806 807 name_start += 2;
807 808 name_length -= 2;
808 809 }
809 810 /* if include file name is surrounded by double quotes */
810 811 if ((name_start[0] == (int) doublequote_char) &&
811 812 (name_start[name_length - 1] == (int) doublequote_char)) {
812 813 name_start += 1;
813 814 name_length -= 2;
814 815
815 816 /* if name does not begin with a slash char */
816 817 if (name_start[0] != (int) slash_char) {
817 818 if ((name_start[0] == (int) period_char) &&
818 819 (name_start[1] == (int) slash_char)) {
819 820 name_start += 2;
820 821 name_length -= 2;
821 822 }
822 823
823 824 INIT_STRING_FROM_STACK(include_name, include_buffer);
824 825 APPEND_NAME(true_makefile_name,
825 826 &include_name,
826 827 true_makefile_name->hash.length);
827 828
828 829 wchar_t *slash = wsrchr(include_name.buffer.start, (int) slash_char);
829 830 if (slash != NULL) {
830 831 include_name.text.p = slash + 1;
831 832 append_string(name_start,
832 833 &include_name,
833 834 name_length);
834 835
835 836 name_start = include_name.buffer.start;
836 837 name_length = include_name.text.p - name_start;
837 838 }
838 839 }
839 840 }
840 841
841 842 /* Even when we run -n we want to create makefiles */
842 843 do_not_exec_rule = false;
843 844 makefile_name = GETNAME(name_start, name_length);
844 845 if (makefile_name->dollar) {
845 846 String_rec destination;
846 847 wchar_t buffer[STRING_BUFFER_LENGTH];
847 848 wchar_t *p;
848 849 wchar_t *q;
849 850
850 851 INIT_STRING_FROM_STACK(destination, buffer);
851 852 expand_value(makefile_name,
852 853 &destination,
853 854 false);
854 855 for (p = destination.buffer.start;
855 856 (*p != (int) nul_char) && iswspace(*p);
856 857 p++);
857 858 for (q = p;
858 859 (*q != (int) nul_char) && !iswspace(*q);
859 860 q++);
860 861 makefile_name = GETNAME(p, q-p);
861 862 if (destination.free_after_use) {
862 863 retmem(destination.buffer.start);
863 864 }
864 865 }
865 866 source_p++;
↓ open down ↓ |
122 lines elided |
↑ open up ↑ |
866 867 UNCACHE_SOURCE();
867 868 /* Read the file */
868 869 save_makefile_type = makefile_type;
869 870 if (read_simple_file(makefile_name,
870 871 true,
871 872 true,
872 873 true,
873 874 false,
874 875 true,
875 876 false) == failed) {
876 - fatal_reader(catgets(catd, 1, 75, "Read of include file `%s' failed"),
877 + fatal_reader(gettext("Read of include file `%s' failed"),
877 878 makefile_name->string_mb);
878 879 }
879 880 makefile_type = save_makefile_type;
880 881 do_not_exec_rule = save_do_not_exec_rule;
881 882 CACHE_SOURCE(0);
882 883 goto start_new_line;
883 884 } else {
884 885 source_p -= 7;
885 886 }
886 887 } else {
887 888 /* Check if the word include was split across 8K boundary. */
888 889
889 890 tmp_bytes_left_in_string = source->string.text.end - source_p;
890 891 if (tmp_bytes_left_in_string < 8) {
891 892 tmp_maybe_include = false;
892 893 if (IS_WEQUALN(source_p,
893 894 include_space,
894 895 tmp_bytes_left_in_string)) {
895 896 tmp_maybe_include = true;
896 897 }
897 898 if (tmp_maybe_include) {
898 899 GET_NEXT_BLOCK(source);
899 900 tmp_maybe_include = false;
900 901 goto line_evald;
901 902 }
902 903 }
903 904 }
904 905 }
905 906
906 907 /* Reset the status in preparation for the new line */
907 908 for (nvp = ⌖ nvp != NULL; nvp = nvp->next) {
908 909 nvp->used = 0;
909 910 }
910 911 for (nvp = &depes; nvp != NULL; nvp = nvp->next) {
911 912 nvp->used = 0;
912 913 }
913 914 target_group_seen = false;
914 915 command = command_tail = NULL;
915 916 macro_value = NULL;
916 917 append = false;
917 918 current_names = ⌖
918 919 SET_STATE(scan_name_state);
919 920 on_eoln_state = illegal_eoln_state;
920 921 separator = none_seen;
921 922
922 923 /* The state machine starts here */
923 924 enter_state:
924 925 while (1) switch (state) {
925 926
926 927 /****************************************************************
927 928 * Scan name state
928 929 */
929 930 case scan_name_state:
930 931 /* Scan an identifier. We skip over chars until we find a break char */
931 932 /* First skip white space. */
932 933 for (; 1; source_p++) switch (GET_CHAR()) {
933 934 case nul_char:
934 935 GET_NEXT_BLOCK(source);
935 936 source_p--;
936 937 if (source == NULL) {
937 938 GOTO_STATE(on_eoln_state);
938 939 }
939 940 break;
940 941 case newline_char:
941 942 /* We found the end of the line. */
942 943 /* Do postprocessing or return error */
943 944 source_p++;
944 945 if (source->fd >= 0) {
945 946 line_number++;
946 947 }
947 948 GOTO_STATE(on_eoln_state);
948 949 case backslash_char:
949 950 /* Continuation */
950 951 if (*++source_p == (int) nul_char) {
951 952 GET_NEXT_BLOCK(source);
952 953 if (source == NULL) {
953 954 GOTO_STATE(on_eoln_state);
954 955 }
955 956 }
956 957 if (*source_p == (int) newline_char) {
957 958 if (source->fd >= 0) {
958 959 line_number++;
959 960 }
960 961 } else {
961 962 source_p--;
962 963 }
963 964 break;
964 965 case tab_char:
965 966 case space_char:
966 967 /* Whitespace is skipped */
967 968 break;
968 969 case numbersign_char:
969 970 /* Comment. Skip over it */
970 971 for (; 1; source_p++) {
971 972 switch (GET_CHAR()) {
972 973 case nul_char:
973 974 GET_NEXT_BLOCK_NOCHK(source);
974 975 if (source == NULL) {
975 976 GOTO_STATE(on_eoln_state);
976 977 }
977 978 if (source->error_converting) {
978 979 // Illegal byte sequence - skip its first byte
979 980 source->inp_buf_ptr++;
980 981 }
981 982 source_p--;
982 983 break;
983 984 case backslash_char:
984 985 if (*++source_p == (int) nul_char) {
985 986 GET_NEXT_BLOCK_NOCHK(source);
986 987 if (source == NULL) {
987 988 GOTO_STATE(on_eoln_state);
988 989 }
989 990 if (source->error_converting) {
990 991 // Illegal byte sequence - skip its first byte
991 992 source->inp_buf_ptr++;
992 993 source_p--;
993 994 break;
994 995 }
995 996 }
996 997 if(*source_p == (int) newline_char) {
997 998 if (source->fd >= 0) {
998 999 line_number++;
999 1000 }
1000 1001 }
1001 1002 break;
1002 1003 case newline_char:
1003 1004 source_p++;
1004 1005 if (source->fd >= 0) {
1005 1006 line_number++;
1006 1007 }
1007 1008 GOTO_STATE(on_eoln_state);
1008 1009 }
1009 1010 }
1010 1011 case dollar_char:
1011 1012 /* Macro reference. Expand and push value */
1012 1013 if (source->already_expanded) {
1013 1014 goto scan_name;
1014 1015 }
1015 1016 source_p++;
1016 1017 UNCACHE_SOURCE();
1017 1018 {
1018 1019 Source t = (Source) alloca((int) sizeof (Source_rec));
1019 1020 source = push_macro_value(t,
1020 1021 buffer,
1021 1022 sizeof buffer,
1022 1023 source);
1023 1024 }
1024 1025 CACHE_SOURCE(1);
1025 1026 break;
1026 1027 default:
1027 1028 /* End of white space */
1028 1029 goto scan_name;
1029 1030 }
1030 1031
1031 1032 /* First proper identifier character */
1032 1033 scan_name:
1033 1034
1034 1035 string_start = source_p;
1035 1036 paren_count = brace_count = 0;
1036 1037 macro_seen_in_string = false;
1037 1038 resume_name_scan:
1038 1039 for (; 1; source_p++) {
1039 1040 switch (GET_CHAR()) {
1040 1041 case nul_char:
1041 1042 /* Save what we have seen so far of the identifier */
1042 1043 if (source_p != string_start) {
1043 1044 if (!macro_seen_in_string) {
1044 1045 INIT_STRING_FROM_STACK(name_string,
1045 1046 name_buffer);
1046 1047 }
1047 1048 append_string(string_start,
1048 1049 &name_string,
1049 1050 source_p - string_start);
1050 1051 macro_seen_in_string = true;
1051 1052 }
↓ open down ↓ |
165 lines elided |
↑ open up ↑ |
1052 1053 /* Get more text to read */
1053 1054 GET_NEXT_BLOCK(source);
1054 1055 string_start = source_p;
1055 1056 source_p--;
1056 1057 if (source == NULL) {
1057 1058 GOTO_STATE(on_eoln_state);
1058 1059 }
1059 1060 break;
1060 1061 case newline_char:
1061 1062 if (paren_count > 0) {
1062 - fatal_reader(catgets(catd, 1, 76, "Unmatched `(' on line"));
1063 + fatal_reader(gettext("Unmatched `(' on line"));
1063 1064 }
1064 1065 if (brace_count > 0) {
1065 - fatal_reader(catgets(catd, 1, 77, "Unmatched `{' on line"));
1066 + fatal_reader(gettext("Unmatched `{' on line"));
1066 1067 }
1067 1068 source_p++;
1068 1069 /* Enter name */
1069 1070 current_names = enter_name(&name_string,
1070 1071 macro_seen_in_string,
1071 1072 string_start,
1072 1073 source_p - 1,
1073 1074 current_names,
1074 1075 &extra_names,
1075 1076 &target_group_seen);
1076 1077 first_target = false;
1077 1078 if (extra_names == NULL) {
1078 1079 extra_names = (Name_vector)
1079 1080 alloca((int) sizeof (Name_vector_rec));
1080 1081 }
1081 1082 /* Do postprocessing or return error */
1082 1083 if (source->fd >= 0) {
1083 1084 line_number++;
1084 1085 }
1085 1086 GOTO_STATE(on_eoln_state);
1086 1087 case backslash_char:
1087 1088 /* Check if this is a quoting backslash */
1088 1089 if (!macro_seen_in_string) {
1089 1090 INIT_STRING_FROM_STACK(name_string,
1090 1091 name_buffer);
1091 1092 macro_seen_in_string = true;
1092 1093 }
1093 1094 append_string(string_start,
1094 1095 &name_string,
1095 1096 source_p - string_start);
1096 1097 if (*++source_p == (int) nul_char) {
1097 1098 GET_NEXT_BLOCK(source);
1098 1099 if (source == NULL) {
1099 1100 GOTO_STATE(on_eoln_state);
1100 1101 }
1101 1102 }
1102 1103 if (*source_p == (int) newline_char) {
1103 1104 if (source->fd >= 0) {
1104 1105 line_number++;
1105 1106 }
1106 1107 *source_p = (int) space_char;
1107 1108 string_start = source_p;
↓ open down ↓ |
32 lines elided |
↑ open up ↑ |
1108 1109 goto resume_name_scan;
1109 1110 } else {
1110 1111 string_start = source_p;
1111 1112 break;
1112 1113 }
1113 1114 break;
1114 1115 case numbersign_char:
1115 1116 if (paren_count + brace_count > 0) {
1116 1117 break;
1117 1118 }
1118 - fatal_reader(catgets(catd, 1, 78, "Unexpected comment seen"));
1119 + fatal_reader(gettext("Unexpected comment seen"));
1119 1120 case dollar_char:
1120 1121 if (source->already_expanded) {
1121 1122 break;
1122 1123 }
1123 1124 /* Save the identifier so far */
1124 1125 if (source_p != string_start) {
1125 1126 if (!macro_seen_in_string) {
1126 1127 INIT_STRING_FROM_STACK(name_string,
1127 1128 name_buffer);
1128 1129 }
1129 1130 append_string(string_start,
1130 1131 &name_string,
1131 1132 source_p - string_start);
1132 1133 macro_seen_in_string = true;
1133 1134 }
1134 1135 /* Eval and push the macro */
1135 1136 source_p++;
1136 1137 UNCACHE_SOURCE();
1137 1138 {
1138 1139 Source t =
1139 1140 (Source) alloca((int) sizeof (Source_rec));
1140 1141 source = push_macro_value(t,
1141 1142 buffer,
1142 1143 sizeof buffer,
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
1143 1144 source);
1144 1145 }
1145 1146 CACHE_SOURCE(1);
1146 1147 string_start = source_p + 1;
1147 1148 break;
1148 1149 case parenleft_char:
1149 1150 paren_count++;
1150 1151 break;
1151 1152 case parenright_char:
1152 1153 if (--paren_count < 0) {
1153 - fatal_reader(catgets(catd, 1, 79, "Unmatched `)' on line"));
1154 + fatal_reader(gettext("Unmatched `)' on line"));
1154 1155 }
1155 1156 break;
1156 1157 case braceleft_char:
1157 1158 brace_count++;
1158 1159 break;
1159 1160 case braceright_char:
1160 1161 if (--brace_count < 0) {
1161 - fatal_reader(catgets(catd, 1, 80, "Unmatched `}' on line"));
1162 + fatal_reader(gettext("Unmatched `}' on line"));
1162 1163 }
1163 1164 break;
1164 1165 case ampersand_char:
1165 1166 case greater_char:
1166 1167 case bar_char:
1167 1168 if (paren_count + brace_count == 0) {
1168 1169 source_p++;
1169 1170 }
1170 1171 /* Fall into */
1171 1172 case tab_char:
1172 1173 case space_char:
1173 1174 if (paren_count + brace_count > 0) {
1174 1175 break;
1175 1176 }
1176 1177 current_names = enter_name(&name_string,
1177 1178 macro_seen_in_string,
1178 1179 string_start,
1179 1180 source_p,
1180 1181 current_names,
1181 1182 &extra_names,
1182 1183 &target_group_seen);
1183 1184 first_target = false;
1184 1185 if (extra_names == NULL) {
1185 1186 extra_names = (Name_vector)
1186 1187 alloca((int) sizeof (Name_vector_rec));
1187 1188 }
1188 1189 goto enter_state;
1189 1190 case colon_char:
1190 1191 if (paren_count + brace_count > 0) {
1191 1192 break;
1192 1193 }
1193 1194 if (separator == conditional_seen) {
1194 1195 break;
1195 1196 }
↓ open down ↓ |
24 lines elided |
↑ open up ↑ |
1196 1197 /** POSIX **/
1197 1198 #if 0
1198 1199 if(posix) {
1199 1200 emptycount = 0;
1200 1201 }
1201 1202 #endif
1202 1203 /** END POSIX **/
1203 1204 /* End of the target list. We now start reading */
1204 1205 /* dependencies or a conditional assignment */
1205 1206 if (separator != none_seen) {
1206 - fatal_reader(catgets(catd, 1, 81, "Extra `:', `::', or `:=' on dependency line"));
1207 + fatal_reader(gettext("Extra `:', `::', or `:=' on dependency line"));
1207 1208 }
1208 1209 /* Enter the last target */
1209 1210 if ((string_start != source_p) ||
1210 1211 macro_seen_in_string) {
1211 1212 current_names =
1212 1213 enter_name(&name_string,
1213 1214 macro_seen_in_string,
1214 1215 string_start,
1215 1216 source_p,
1216 1217 current_names,
1217 1218 &extra_names,
1218 1219 &target_group_seen);
1219 1220 first_target = false;
1220 1221 if (extra_names == NULL) {
1221 1222 extra_names = (Name_vector)
1222 1223 alloca((int)
1223 1224 sizeof (Name_vector_rec));
1224 1225 }
1225 1226 }
1226 1227 /* Check if it is ":" "::" or ":=" */
1227 1228 scan_colon_label:
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
1228 1229 switch (*++source_p) {
1229 1230 case nul_char:
1230 1231 GET_NEXT_BLOCK(source);
1231 1232 source_p--;
1232 1233 if (source == NULL) {
1233 1234 GOTO_STATE(enter_dependencies_state);
1234 1235 }
1235 1236 goto scan_colon_label;
1236 1237 case equal_char:
1237 1238 if(svr4) {
1238 - fatal_reader(catgets(catd, 1, 82, "syntax error"));
1239 + fatal_reader(gettext("syntax error"));
1239 1240 }
1240 1241 separator = conditional_seen;
1241 1242 source_p++;
1242 1243 current_names = &depes;
1243 1244 GOTO_STATE(scan_name_state);
1244 1245 case colon_char:
1245 1246 separator = two_colon;
1246 1247 source_p++;
1247 1248 break;
1248 1249 default:
1249 1250 separator = one_colon;
1250 1251 }
↓ open down ↓ |
2 lines elided |
↑ open up ↑ |
1251 1252 current_names = &depes;
1252 1253 on_eoln_state = enter_dependencies_state;
1253 1254 GOTO_STATE(scan_name_state);
1254 1255 case semicolon_char:
1255 1256 if (paren_count + brace_count > 0) {
1256 1257 break;
1257 1258 }
1258 1259 /* End of reading names. Start reading the rule */
1259 1260 if ((separator != one_colon) &&
1260 1261 (separator != two_colon)) {
1261 - fatal_reader(catgets(catd, 1, 83, "Unexpected command seen"));
1262 + fatal_reader(gettext("Unexpected command seen"));
1262 1263 }
1263 1264 /* Enter the last dependency */
1264 1265 if ((string_start != source_p) ||
1265 1266 macro_seen_in_string) {
1266 1267 current_names =
1267 1268 enter_name(&name_string,
1268 1269 macro_seen_in_string,
1269 1270 string_start,
1270 1271 source_p,
1271 1272 current_names,
1272 1273 &extra_names,
1273 1274 &target_group_seen);
1274 1275 first_target = false;
1275 1276 if (extra_names == NULL) {
1276 1277 extra_names = (Name_vector)
1277 1278 alloca((int)
1278 1279 sizeof (Name_vector_rec));
1279 1280 }
1280 1281 }
1281 1282 source_p++;
1282 1283 /* Make sure to enter a rule even if the is */
1283 1284 /* no text here */
1284 1285 command = command_tail = ALLOC(Cmd_line);
1285 1286 command->next = NULL;
1286 1287 command->command_line = empty_name;
1287 1288 command->make_refd = false;
1288 1289 command->ignore_command_dependency = false;
1289 1290 command->assign = false;
1290 1291 command->ignore_error = false;
1291 1292 command->silent = false;
1292 1293
1293 1294 GOTO_STATE(scan_command_state);
1294 1295 case plus_char:
1295 1296 /*
1296 1297 ** following code drops the target separator plus char if it starts
1297 1298 ** a line.
1298 1299 */
1299 1300 if(first_target && !macro_seen_in_string &&
1300 1301 source_p == string_start) {
1301 1302 for (; 1; source_p++)
1302 1303 switch (GET_CHAR()) {
1303 1304 case nul_char:
1304 1305 if (source_p != string_start) {
1305 1306 if (!macro_seen_in_string) {
1306 1307 INIT_STRING_FROM_STACK(name_string,
1307 1308 name_buffer);
1308 1309 }
1309 1310 append_string(string_start,
1310 1311 &name_string,
1311 1312 source_p - string_start);
1312 1313 macro_seen_in_string = true;
1313 1314 }
1314 1315 GET_NEXT_BLOCK(source);
1315 1316 string_start = source_p;
1316 1317 source_p--;
1317 1318 if (source == NULL) {
1318 1319 GOTO_STATE(on_eoln_state);
1319 1320 }
1320 1321 break;
1321 1322 case plus_char:
1322 1323 source_p++;
1323 1324 while (*source_p == (int) nul_char) {
1324 1325 if (source_p != string_start) {
1325 1326 if (!macro_seen_in_string) {
1326 1327 INIT_STRING_FROM_STACK(name_string,
1327 1328 name_buffer);
1328 1329 }
1329 1330 append_string(string_start,
1330 1331 &name_string,
1331 1332 source_p - string_start);
1332 1333 macro_seen_in_string = true;
1333 1334 }
1334 1335 GET_NEXT_BLOCK(source);
1335 1336 string_start = source_p;
1336 1337 if (source == NULL) {
1337 1338 GOTO_STATE(on_eoln_state);
1338 1339 }
1339 1340 }
1340 1341 if (*source_p == (int) tab_char ||
1341 1342 *source_p == (int) space_char) {
1342 1343 macro_seen_in_string = false;
1343 1344 string_start = source_p + 1;
1344 1345 } else {
1345 1346 goto resume_name_scan;
1346 1347 }
1347 1348 break;
1348 1349 case tab_char:
1349 1350 case space_char:
1350 1351 string_start = source_p + 1;
1351 1352 break;
1352 1353 default:
1353 1354 goto resume_name_scan;
1354 1355 }
1355 1356 }
1356 1357 if (paren_count + brace_count > 0) {
1357 1358 break;
1358 1359 }
1359 1360 /* We found "+=" construct */
1360 1361 if (source_p != string_start) {
1361 1362 /* "+" is not a break char. */
1362 1363 /* Ignore it if it is part of an identifier */
1363 1364 source_p++;
1364 1365 goto resume_name_scan;
1365 1366 }
1366 1367 /* Make sure the "+" is followed by a "=" */
1367 1368 scan_append:
1368 1369 switch (*++source_p) {
1369 1370 case nul_char:
1370 1371 if (!macro_seen_in_string) {
1371 1372 INIT_STRING_FROM_STACK(name_string,
1372 1373 name_buffer);
1373 1374 }
1374 1375 append_string(string_start,
1375 1376 &name_string,
1376 1377 source_p - string_start);
1377 1378 GET_NEXT_BLOCK(source);
↓ open down ↓ |
106 lines elided |
↑ open up ↑ |
1378 1379 source_p--;
1379 1380 string_start = source_p;
1380 1381 if (source == NULL) {
1381 1382 GOTO_STATE(illegal_eoln_state);
1382 1383 }
1383 1384 goto scan_append;
1384 1385 case equal_char:
1385 1386 if(!svr4) {
1386 1387 append = true;
1387 1388 } else {
1388 - fatal_reader(catgets(catd, 1, 84, "Must be a separator on rules"));
1389 + fatal_reader(gettext("Must be a separator on rules"));
1389 1390 }
1390 1391 break;
1391 1392 default:
1392 1393 /* The "+" just starts a regular name. */
1393 1394 /* Start reading that name */
1394 1395 goto resume_name_scan;
1395 1396 }
1396 1397 /* Fall into */
1397 1398 case equal_char:
1398 1399 if (paren_count + brace_count > 0) {
1399 1400 break;
1400 1401 }
1401 1402 /* We found macro assignment. */
1402 1403 /* Check if it is legal and if it is appending */
1403 1404 switch (separator) {
1404 1405 case none_seen:
↓ open down ↓ |
6 lines elided |
↑ open up ↑ |
1405 1406 separator = equal_seen;
1406 1407 on_eoln_state = enter_equal_state;
1407 1408 break;
1408 1409 case conditional_seen:
1409 1410 on_eoln_state = enter_conditional_state;
1410 1411 break;
1411 1412 default:
1412 1413 /* Reader must special check for "MACRO:sh=" */
1413 1414 /* notation */
1414 1415 if (sh_name == NULL) {
1415 - MBSTOWCS(wcs_buffer, NOCATGETS("sh"));
1416 + MBSTOWCS(wcs_buffer, "sh");
1416 1417 sh_name = GETNAME(wcs_buffer, FIND_LENGTH);
1417 - MBSTOWCS(wcs_buffer, NOCATGETS("shell"));
1418 + MBSTOWCS(wcs_buffer, "shell");
1418 1419 shell_name = GETNAME(wcs_buffer, FIND_LENGTH);
1419 1420 }
1420 1421
1421 1422 if (!macro_seen_in_string) {
1422 1423 INIT_STRING_FROM_STACK(name_string,
1423 1424 name_buffer);
1424 1425 }
1425 1426 append_string(string_start,
1426 1427 &name_string,
1427 1428 source_p - string_start
1428 1429 );
1429 1430
1430 1431 if ( (((target.used == 1) &&
1431 1432 (depes.used == 1) &&
1432 1433 (depes.names[0] == sh_name)) ||
1433 1434 ((target.used == 1) &&
1434 1435 (depes.used == 0) &&
1435 1436 (separator == one_colon) &&
1436 1437 (GETNAME(name_string.buffer.start,FIND_LENGTH) == sh_name))) &&
1437 1438 (!svr4)) {
1438 1439 String_rec macro_name;
1439 1440 wchar_t buffer[100];
1440 1441
1441 1442 INIT_STRING_FROM_STACK(macro_name,
1442 1443 buffer);
1443 1444 APPEND_NAME(target.names[0],
1444 1445 ¯o_name,
1445 1446 FIND_LENGTH);
1446 1447 append_char((int) colon_char,
1447 1448 ¯o_name);
1448 1449 APPEND_NAME(sh_name,
1449 1450 ¯o_name,
1450 1451 FIND_LENGTH);
1451 1452 target.names[0] =
1452 1453 GETNAME(macro_name.buffer.start,
1453 1454 FIND_LENGTH);
1454 1455 separator = equal_seen;
1455 1456 on_eoln_state = enter_equal_state;
1456 1457 break;
1457 1458 } else if ( (((target.used == 1) &&
1458 1459 (depes.used == 1) &&
1459 1460 (depes.names[0] == shell_name)) ||
1460 1461 ((target.used == 1) &&
1461 1462 (depes.used == 0) &&
1462 1463 (separator == one_colon) &&
1463 1464 (GETNAME(name_string.buffer.start,FIND_LENGTH) == shell_name))) &&
1464 1465 (!svr4)) {
1465 1466 String_rec macro_name;
1466 1467 wchar_t buffer[100];
1467 1468
1468 1469 INIT_STRING_FROM_STACK(macro_name,
1469 1470 buffer);
1470 1471 APPEND_NAME(target.names[0],
1471 1472 ¯o_name,
1472 1473 FIND_LENGTH);
1473 1474 append_char((int) colon_char,
1474 1475 ¯o_name);
1475 1476 APPEND_NAME(shell_name,
↓ open down ↓ |
48 lines elided |
↑ open up ↑ |
1476 1477 ¯o_name,
1477 1478 FIND_LENGTH);
1478 1479 target.names[0] =
1479 1480 GETNAME(macro_name.buffer.start,
1480 1481 FIND_LENGTH);
1481 1482 separator = equal_seen;
1482 1483 on_eoln_state = enter_equal_state;
1483 1484 break;
1484 1485 }
1485 1486 if(svr4) {
1486 - fatal_reader(catgets(catd, 1, 85, "syntax error"));
1487 + fatal_reader(gettext("syntax error"));
1487 1488 }
1488 1489 else {
1489 - fatal_reader(catgets(catd, 1, 86, "Macro assignment on dependency line"));
1490 + fatal_reader(gettext("Macro assignment on dependency line"));
1490 1491 }
1491 1492 }
1492 1493 if (append) {
1493 1494 source_p--;
1494 1495 }
1495 1496 /* Enter the macro name */
1496 1497 if ((string_start != source_p) ||
1497 1498 macro_seen_in_string) {
1498 1499 current_names =
1499 1500 enter_name(&name_string,
1500 1501 macro_seen_in_string,
1501 1502 string_start,
1502 1503 source_p,
1503 1504 current_names,
1504 1505 &extra_names,
1505 1506 &target_group_seen);
1506 1507 first_target = false;
1507 1508 if (extra_names == NULL) {
1508 1509 extra_names = (Name_vector)
1509 1510 alloca((int)
1510 1511 sizeof (Name_vector_rec));
1511 1512 }
1512 1513 }
1513 1514 if (append) {
1514 1515 source_p++;
1515 1516 }
1516 1517 macro_value = NULL;
1517 1518 source_p++;
1518 1519 distance = 0;
1519 1520 /* Skip whitespace to the start of the value */
1520 1521 macro_seen_in_string = false;
1521 1522 for (; 1; source_p++) {
1522 1523 switch (GET_CHAR()) {
1523 1524 case nul_char:
1524 1525 GET_NEXT_BLOCK(source);
1525 1526 source_p--;
1526 1527 if (source == NULL) {
1527 1528 GOTO_STATE(on_eoln_state);
1528 1529 }
1529 1530 break;
1530 1531 case backslash_char:
1531 1532 if (*++source_p == (int) nul_char) {
1532 1533 GET_NEXT_BLOCK(source);
1533 1534 if (source == NULL) {
1534 1535 GOTO_STATE(on_eoln_state);
1535 1536 }
1536 1537 }
1537 1538 if (*source_p != (int) newline_char) {
1538 1539 if (!macro_seen_in_string) {
1539 1540 macro_seen_in_string =
1540 1541 true;
1541 1542 INIT_STRING_FROM_STACK(name_string,
1542 1543 name_buffer);
1543 1544 }
1544 1545 append_char((int)
1545 1546 backslash_char,
1546 1547 &name_string);
1547 1548 append_char(*source_p,
1548 1549 &name_string);
1549 1550 string_start = source_p+1;
1550 1551 goto macro_value_start;
1551 1552 } else {
1552 1553 if (source->fd >= 0) {
1553 1554 line_number++;
1554 1555 }
1555 1556 }
1556 1557 break;
1557 1558 case newline_char:
1558 1559 case numbersign_char:
1559 1560 string_start = source_p;
1560 1561 goto macro_value_end;
1561 1562 case tab_char:
1562 1563 case space_char:
1563 1564 break;
1564 1565 default:
1565 1566 string_start = source_p;
1566 1567 goto macro_value_start;
1567 1568 }
1568 1569 }
1569 1570 macro_value_start:
1570 1571 /* Find the end of the value */
1571 1572 for (; 1; source_p++) {
1572 1573 if (distance != 0) {
1573 1574 *source_p = *(source_p + distance);
1574 1575 }
1575 1576 switch (GET_CHAR()) {
1576 1577 case nul_char:
1577 1578 if (!macro_seen_in_string) {
1578 1579 macro_seen_in_string = true;
1579 1580 INIT_STRING_FROM_STACK(name_string,
1580 1581 name_buffer);
1581 1582 }
1582 1583 append_string(string_start,
1583 1584 &name_string,
1584 1585 source_p - string_start);
1585 1586 GET_NEXT_BLOCK(source);
1586 1587 string_start = source_p;
1587 1588 source_p--;
1588 1589 if (source == NULL) {
1589 1590 GOTO_STATE(on_eoln_state);
1590 1591 }
1591 1592 break;
1592 1593 case backslash_char:
1593 1594 source_p++;
1594 1595 if (distance != 0) {
1595 1596 *source_p =
1596 1597 *(source_p + distance);
1597 1598 }
1598 1599 if (*source_p == (int) nul_char) {
1599 1600 if (!macro_seen_in_string) {
1600 1601 macro_seen_in_string =
1601 1602 true;
1602 1603 INIT_STRING_FROM_STACK(name_string,
1603 1604 name_buffer);
1604 1605 }
1605 1606
1606 1607 /* BID_1225561 */
1607 1608 *(source_p - 1) = (int) space_char;
1608 1609 append_string(string_start,
1609 1610 &name_string,
1610 1611 source_p -
1611 1612 string_start - 1);
1612 1613 GET_NEXT_BLOCK(source);
1613 1614 string_start = source_p;
1614 1615 if (source == NULL) {
1615 1616 GOTO_STATE(on_eoln_state);
1616 1617 }
1617 1618 if (distance != 0) {
1618 1619 *source_p =
1619 1620 *(source_p +
1620 1621 distance);
1621 1622 }
1622 1623 if (*source_p == (int) newline_char) {
1623 1624 append_char((int) space_char, &name_string);
1624 1625 } else {
1625 1626 append_char((int) backslash_char, &name_string);
1626 1627 }
1627 1628 /****************/
1628 1629 }
1629 1630 if (*source_p == (int) newline_char) {
1630 1631 source_p--;
1631 1632 line_number++;
1632 1633 distance++;
1633 1634 *source_p = (int) space_char;
1634 1635 while ((*(source_p +
1635 1636 distance + 1) ==
1636 1637 (int) tab_char) ||
1637 1638 (*(source_p +
1638 1639 distance + 1) ==
1639 1640 (int) space_char)) {
1640 1641 distance++;
1641 1642 }
1642 1643 }
1643 1644 break;
1644 1645 case newline_char:
1645 1646 case numbersign_char:
1646 1647 goto macro_value_end;
1647 1648 }
1648 1649 }
1649 1650 macro_value_end:
1650 1651 /* Complete the value in the string */
1651 1652 if (!macro_seen_in_string) {
1652 1653 macro_seen_in_string = true;
1653 1654 INIT_STRING_FROM_STACK(name_string,
1654 1655 name_buffer);
1655 1656 }
1656 1657 append_string(string_start,
1657 1658 &name_string,
1658 1659 source_p - string_start);
1659 1660 if (name_string.buffer.start != name_string.text.p) {
1660 1661 macro_value =
1661 1662 GETNAME(name_string.buffer.start,
1662 1663 FIND_LENGTH);
1663 1664 }
1664 1665 if (name_string.free_after_use) {
1665 1666 retmem(name_string.buffer.start);
1666 1667 }
1667 1668 for (; distance > 0; distance--) {
1668 1669 *source_p++ = (int) space_char;
1669 1670 }
1670 1671 GOTO_STATE(on_eoln_state);
1671 1672 }
1672 1673 }
1673 1674
1674 1675 /****************************************************************
1675 1676 * enter dependencies state
1676 1677 */
1677 1678 case enter_dependencies_state:
1678 1679 enter_dependencies_label:
1679 1680 /* Expects pointer on first non whitespace char after last dependency. (On */
1680 1681 /* next line.) We end up here after having read a "targets : dependencies" */
1681 1682 /* line. The state checks if there is a rule to read and if so dispatches */
1682 1683 /* to scan_command_state scan_command_state reads one rule line and the */
1683 1684 /* returns here */
1684 1685
1685 1686 /* First check if the first char on the next line is special */
1686 1687 switch (GET_CHAR()) {
1687 1688 case nul_char:
1688 1689 GET_NEXT_BLOCK(source);
1689 1690 if (source == NULL) {
1690 1691 break;
1691 1692 }
1692 1693 goto enter_dependencies_label;
1693 1694 case exclam_char:
1694 1695 /* The line should be evaluate before it is read */
1695 1696 macro_seen_in_string = false;
1696 1697 string_start = source_p + 1;
1697 1698 for (; 1; source_p++) {
1698 1699 switch (GET_CHAR()) {
1699 1700 case newline_char:
1700 1701 goto eoln_2;
1701 1702 case nul_char:
1702 1703 if (source->fd > 0) {
1703 1704 if (!macro_seen_in_string) {
1704 1705 macro_seen_in_string = true;
1705 1706 INIT_STRING_FROM_STACK(name_string,
1706 1707 name_buffer);
1707 1708 }
1708 1709 append_string(string_start,
1709 1710 &name_string,
1710 1711 source_p - string_start);
1711 1712 GET_NEXT_BLOCK(source);
1712 1713 string_start = source_p;
1713 1714 source_p--;
1714 1715 break;
1715 1716 }
1716 1717 eoln_2:
1717 1718 if (!macro_seen_in_string) {
1718 1719 INIT_STRING_FROM_STACK(name_string,
1719 1720 name_buffer);
1720 1721 }
1721 1722 append_string(string_start,
1722 1723 &name_string,
1723 1724 source_p - string_start);
1724 1725 extrap = (Source)
1725 1726 alloca((int) sizeof (Source_rec));
1726 1727 extrap->string.buffer.start = NULL;
1727 1728 extrap->inp_buf =
1728 1729 extrap->inp_buf_ptr =
1729 1730 extrap->inp_buf_end = NULL;
1730 1731 extrap->error_converting = false;
1731 1732 expand_value(GETNAME(name_string.buffer.start,
1732 1733 FIND_LENGTH),
1733 1734 &extrap->string,
1734 1735 false);
1735 1736 if (name_string.free_after_use) {
1736 1737 retmem(name_string.buffer.start);
1737 1738 }
1738 1739 UNCACHE_SOURCE();
1739 1740 extrap->string.text.p =
1740 1741 extrap->string.buffer.start;
1741 1742 extrap->fd = -1;
1742 1743 extrap->previous = source;
1743 1744 source = extrap;
1744 1745 CACHE_SOURCE(0);
1745 1746 goto enter_dependencies_label;
1746 1747 }
1747 1748 }
1748 1749 case dollar_char:
1749 1750 if (source->already_expanded) {
1750 1751 break;
1751 1752 }
1752 1753 source_p++;
1753 1754 UNCACHE_SOURCE();
1754 1755 {
1755 1756 Source t = (Source) alloca((int) sizeof (Source_rec));
1756 1757 source = push_macro_value(t,
1757 1758 buffer,
1758 1759 sizeof buffer,
1759 1760 source);
1760 1761 }
1761 1762 CACHE_SOURCE(0);
1762 1763 goto enter_dependencies_label;
1763 1764 case numbersign_char:
1764 1765 if (makefile_type != reading_makefile) {
1765 1766 source_p++;
1766 1767 GOTO_STATE(scan_command_state);
1767 1768 }
1768 1769 for (; 1; source_p++) {
1769 1770 switch (GET_CHAR()) {
1770 1771 case nul_char:
1771 1772 GET_NEXT_BLOCK_NOCHK(source);
1772 1773 if (source == NULL) {
1773 1774 GOTO_STATE(on_eoln_state);
1774 1775 }
1775 1776 if (source->error_converting) {
1776 1777 // Illegal byte sequence - skip its first byte
1777 1778 source->inp_buf_ptr++;
1778 1779 }
1779 1780 source_p--;
1780 1781 break;
1781 1782 case backslash_char:
1782 1783 if (*++source_p == (int) nul_char) {
1783 1784 GET_NEXT_BLOCK_NOCHK(source);
1784 1785 if (source == NULL) {
1785 1786 GOTO_STATE(on_eoln_state);
1786 1787 }
1787 1788 if (source->error_converting) {
1788 1789 // Illegal byte sequence - skip its first byte
1789 1790 source->inp_buf_ptr++;
1790 1791 source_p--;
1791 1792 break;
1792 1793 }
1793 1794 }
1794 1795 if(*source_p == (int) newline_char) {
1795 1796 if (source->fd >= 0) {
1796 1797 line_number++;
1797 1798 }
1798 1799 }
1799 1800 break;
1800 1801 case newline_char:
1801 1802 source_p++;
1802 1803 if (source->fd >= 0) {
1803 1804 line_number++;
1804 1805 }
1805 1806 goto enter_dependencies_label;
1806 1807 }
1807 1808 }
1808 1809
1809 1810 case tab_char:
1810 1811 GOTO_STATE(scan_command_state);
1811 1812 }
1812 1813
1813 1814 /* We read all the command lines for the target/dependency line. */
1814 1815 /* Enter the stuff */
1815 1816 enter_target_groups_and_dependencies( &target, &depes, command,
1816 1817 separator, target_group_seen);
1817 1818
1818 1819 goto start_new_line;
1819 1820
1820 1821 /****************************************************************
1821 1822 * scan command state
1822 1823 */
1823 1824 case scan_command_state:
1824 1825 /* We need to read one rule line. Do that and return to */
1825 1826 /* the enter dependencies state */
1826 1827 string_start = source_p;
1827 1828 macro_seen_in_string = false;
1828 1829 for (; 1; source_p++) {
1829 1830 switch (GET_CHAR()) {
1830 1831 case backslash_char:
1831 1832 if (!macro_seen_in_string) {
1832 1833 INIT_STRING_FROM_STACK(name_string,
1833 1834 name_buffer);
1834 1835 }
1835 1836 append_string(string_start,
1836 1837 &name_string,
1837 1838 source_p - string_start);
1838 1839 macro_seen_in_string = true;
1839 1840 if (*++source_p == (int) nul_char) {
1840 1841 GET_NEXT_BLOCK(source);
1841 1842 if (source == NULL) {
1842 1843 string_start = source_p;
1843 1844 goto command_newline;
1844 1845 }
1845 1846 }
1846 1847 append_char((int) backslash_char, &name_string);
1847 1848 append_char(*source_p, &name_string);
1848 1849 if (*source_p == (int) newline_char) {
1849 1850 if (source->fd >= 0) {
1850 1851 line_number++;
1851 1852 }
1852 1853 if (*++source_p == (int) nul_char) {
1853 1854 GET_NEXT_BLOCK(source);
1854 1855 if (source == NULL) {
1855 1856 string_start = source_p;
1856 1857 goto command_newline;
1857 1858 }
1858 1859 }
1859 1860 if (*source_p == (int) tab_char) {
1860 1861 source_p++;
1861 1862 }
1862 1863 } else {
1863 1864 if (*++source_p == (int) nul_char) {
1864 1865 GET_NEXT_BLOCK(source);
1865 1866 if (source == NULL) {
1866 1867 string_start = source_p;
1867 1868 goto command_newline;
1868 1869 }
1869 1870 }
1870 1871 }
1871 1872 string_start = source_p;
1872 1873 if ((*source_p == (int) newline_char) ||
1873 1874 (*source_p == (int) backslash_char) ||
1874 1875 (*source_p == (int) nul_char)) {
1875 1876 source_p--;
1876 1877 }
1877 1878 break;
1878 1879 case newline_char:
1879 1880 command_newline:
1880 1881 if ((string_start != source_p) ||
1881 1882 macro_seen_in_string) {
1882 1883 if (macro_seen_in_string) {
1883 1884 append_string(string_start,
1884 1885 &name_string,
1885 1886 source_p - string_start);
1886 1887 string_start =
1887 1888 name_string.buffer.start;
1888 1889 string_end = name_string.text.p;
1889 1890 } else {
1890 1891 string_end = source_p;
1891 1892 }
1892 1893 while ((*string_start != (int) newline_char) &&
1893 1894 iswspace(*string_start)){
1894 1895 string_start++;
1895 1896 }
1896 1897 if ((string_end > string_start) ||
1897 1898 (makefile_type == reading_statefile)) {
1898 1899 if (command_tail == NULL) {
1899 1900 command =
1900 1901 command_tail =
1901 1902 ALLOC(Cmd_line);
1902 1903 } else {
1903 1904 command_tail->next =
1904 1905 ALLOC(Cmd_line);
1905 1906 command_tail =
1906 1907 command_tail->next;
1907 1908 }
1908 1909 command_tail->next = NULL;
1909 1910 command_tail->make_refd = false;
1910 1911 command_tail->ignore_command_dependency = false;
1911 1912 command_tail->assign = false;
1912 1913 command_tail->ignore_error = false;
1913 1914 command_tail->silent = false;
1914 1915 command_tail->command_line =
1915 1916 GETNAME(string_start,
1916 1917 string_end - string_start);
1917 1918 if (macro_seen_in_string &&
1918 1919 name_string.free_after_use) {
1919 1920 retmem(name_string.
1920 1921 buffer.start);
1921 1922 }
1922 1923 }
1923 1924 }
1924 1925 do {
1925 1926 if ((source != NULL) && (source->fd >= 0)) {
1926 1927 line_number++;
1927 1928 }
1928 1929 if ((source != NULL) &&
1929 1930 (*++source_p == (int) nul_char)) {
1930 1931 GET_NEXT_BLOCK(source);
1931 1932 if (source == NULL) {
1932 1933 GOTO_STATE(on_eoln_state);
1933 1934 }
1934 1935 }
1935 1936 } while (*source_p == (int) newline_char);
1936 1937
1937 1938 GOTO_STATE(enter_dependencies_state);
1938 1939 case nul_char:
1939 1940 if (!macro_seen_in_string) {
1940 1941 INIT_STRING_FROM_STACK(name_string,
1941 1942 name_buffer);
1942 1943 }
1943 1944 append_string(string_start,
1944 1945 &name_string,
1945 1946 source_p - string_start);
1946 1947 macro_seen_in_string = true;
1947 1948 GET_NEXT_BLOCK(source);
1948 1949 string_start = source_p;
1949 1950 source_p--;
1950 1951 if (source == NULL) {
1951 1952 GOTO_STATE(enter_dependencies_state);
1952 1953 }
1953 1954 break;
1954 1955 }
1955 1956 }
1956 1957
1957 1958 /****************************************************************
1958 1959 * enter equal state
1959 1960 */
1960 1961 case enter_equal_state:
1961 1962 if (target.used != 1) {
1962 1963 GOTO_STATE(poorly_formed_macro_state);
1963 1964 }
1964 1965 enter_equal(target.names[0], macro_value, append);
1965 1966 goto start_new_line;
1966 1967
1967 1968 /****************************************************************
1968 1969 * enter conditional state
1969 1970 */
1970 1971 case enter_conditional_state:
1971 1972 if (depes.used != 1) {
1972 1973 GOTO_STATE(poorly_formed_macro_state);
1973 1974 }
1974 1975 for (nvp = ⌖ nvp != NULL; nvp = nvp->next) {
1975 1976 for (i = 0; i < nvp->used; i++) {
1976 1977 enter_conditional(nvp->names[i],
1977 1978 depes.names[0],
↓ open down ↓ |
478 lines elided |
↑ open up ↑ |
1978 1979 macro_value,
1979 1980 append);
1980 1981 }
1981 1982 }
1982 1983 goto start_new_line;
1983 1984
1984 1985 /****************************************************************
1985 1986 * Error states
1986 1987 */
1987 1988 case illegal_bytes_state:
1988 - fatal_reader(catgets(catd, 1, 340, "Invalid byte sequence"));
1989 + fatal_reader(gettext("Invalid byte sequence"));
1989 1990 case illegal_eoln_state:
1990 1991 if (line_number > 1) {
1991 1992 if (line_started_with_space == (line_number - 1)) {
1992 1993 line_number--;
1993 - fatal_reader(catgets(catd, 1, 90, "Unexpected end of line seen\n\t*** missing separator (did you mean TAB instead of 8 spaces?)"));
1994 + fatal_reader(gettext("Unexpected end of line seen\n\t*** missing separator (did you mean TAB instead of 8 spaces?)"));
1994 1995 }
1995 1996 }
1996 - fatal_reader(catgets(catd, 1, 87, "Unexpected end of line seen"));
1997 + fatal_reader(gettext("Unexpected end of line seen"));
1997 1998 case poorly_formed_macro_state:
1998 - fatal_reader(catgets(catd, 1, 88, "Badly formed macro assignment"));
1999 + fatal_reader(gettext("Badly formed macro assignment"));
1999 2000 case exit_state:
2000 2001 return;
2001 2002 default:
2002 - fatal_reader(catgets(catd, 1, 89, "Internal error. Unknown reader state"));
2003 + fatal_reader(gettext("Internal error. Unknown reader state"));
2003 2004 }
2004 2005 }
2005 2006
2006 2007 /*
2007 2008 * push_macro_value(bp, buffer, size, source)
2008 2009 *
2009 2010 * Macro and function that evaluates one macro
2010 2011 * and makes the reader read from the value of it
2011 2012 *
2012 2013 * Return value:
2013 2014 * The source block to read the macro from
2014 2015 *
2015 2016 * Parameters:
2016 2017 * bp The new source block to fill in
2017 2018 * buffer Buffer to read from
2018 2019 * size size of the buffer
2019 2020 * source The old source block
2020 2021 *
2021 2022 * Global variables used:
2022 2023 */
2023 2024 static Source
2024 2025 push_macro_value(register Source bp, register wchar_t *buffer, int size, register Source source)
2025 2026 {
2026 2027 bp->string.buffer.start = bp->string.text.p = buffer;
2027 2028 bp->string.text.end = NULL;
2028 2029 bp->string.buffer.end = buffer + (size/SIZEOFWCHAR_T);
2029 2030 bp->string.free_after_use = false;
2030 2031 bp->inp_buf =
2031 2032 bp->inp_buf_ptr =
2032 2033 bp->inp_buf_end = NULL;
2033 2034 bp->error_converting = false;
2034 2035 expand_macro(source, &bp->string, (wchar_t *) NULL, false);
2035 2036 bp->string.text.p = bp->string.buffer.start;
2036 2037
2037 2038 /* 4209588: 'make' doesn't understand a macro with whitespaces in the head as target.
2038 2039 * strip whitespace from the begining of the macro value
2039 2040 */
2040 2041 while (iswspace(*bp->string.text.p)) {
2041 2042 bp->string.text.p++;
2042 2043 }
2043 2044
2044 2045 bp->fd = -1;
2045 2046 bp->already_expanded = true;
2046 2047 bp->previous = source;
2047 2048 return bp;
2048 2049 }
2049 2050
2050 2051 /*
2051 2052 * enter_target_groups_and_dependencies(target, depes, command, separator,
2052 2053 * target_group_seen)
2053 2054 *
2054 2055 * Parameters:
2055 2056 * target Structure that shows the target(s) on the line
2056 2057 * we are currently parsing. This can looks like
2057 2058 * target1 .. targetN : dependencies
2058 2059 * commands
2059 2060 * or
2060 2061 * target1 + .. + targetN : dependencies
2061 2062 * commands
2062 2063 * depes Dependencies
2063 2064 * command Points to the command(s) to be executed for
2064 2065 * this target.
2065 2066 * separator : or :: or :=
2066 2067 * target_group_seen Set if we have target1 + .. + targetN
2067 2068 *
2068 2069 *
2069 2070 * After reading the command lines for a target, this routine
2070 2071 * is called to setup the dependencies and the commands for it.
2071 2072 * If the target is a % pattern or part of a target group, then
2072 2073 * the appropriate routines are called.
2073 2074 */
2074 2075
2075 2076 void
2076 2077 enter_target_groups_and_dependencies(Name_vector target, Name_vector depes, Cmd_line command, Separator separator, Boolean target_group_seen)
2077 2078 {
2078 2079 int i;
2079 2080 Boolean reset= true;
↓ open down ↓ |
67 lines elided |
↑ open up ↑ |
2080 2081 Chain target_group_member;
2081 2082 Percent percent_ptr;
2082 2083
2083 2084 for (; target != NULL; target = target->next) {
2084 2085 for (i = 0; i < target->used; i++) {
2085 2086 if (target->names[i] != NULL) {
2086 2087 if (target_group_seen) {
2087 2088 target_group_member =
2088 2089 find_target_groups(target, i, reset);
2089 2090 if(target_group_member == NULL) {
2090 - fatal_reader(catgets(catd, 1, 328, "Unexpected '+' on dependency line"));
2091 + fatal_reader(gettext("Unexpected '+' on dependency line"));
2091 2092 }
2092 2093 }
2093 2094 reset = false;
2094 2095
2095 2096 /* If we saw it in the makefile it must be
2096 2097 * a file */
2097 2098 target->names[i]->stat.is_file = true;
2098 2099 /* Make sure that we use dependencies
2099 2100 * entered for makefiles */
2100 2101 target->names[i]->state = build_dont_know;
2101 2102
2102 2103 /* If the target is special we delegate
2103 2104 * the processing */
2104 2105 if (target->names[i]->special_reader
2105 2106 != no_special) {
2106 2107 special_reader(target->names[i],
2107 2108 depes,
2108 2109 command);
2109 2110 }
2110 2111 /* Check if this is a "a%b : x%y" type rule */
2111 2112 else if (target->names[i]->percent) {
2112 2113 percent_ptr =
2113 2114 enter_percent(target->names[i],
2114 2115 target->target_group[i],
2115 2116 depes, command);
2116 2117 if (target_group_seen) {
2117 2118 target_group_member->percent_member =
2118 2119 percent_ptr;
2119 2120 }
2120 2121 } else if (target->names[i]->dollar) {
2121 2122 enter_dyntarget(target->names[i]);
2122 2123 enter_dependencies
2123 2124 (target->names[i],
2124 2125 target->target_group[i],
2125 2126 depes,
2126 2127 command,
2127 2128 separator);
2128 2129 } else {
2129 2130 if (target_group_seen) {
2130 2131 target_group_member->percent_member =
2131 2132 NULL;
2132 2133 }
2133 2134
2134 2135 enter_dependencies
2135 2136 (target->names[i],
2136 2137 target->target_group[i],
2137 2138 depes,
2138 2139 command,
2139 2140 separator);
2140 2141 }
2141 2142 }
2142 2143 }
2143 2144 }
2144 2145 }
2145 2146
2146 2147
↓ open down ↓ |
46 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX