Print this page
make: translate using gettext, rather than the unmaintainable catgets
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/make/include/mksh/defs.h
+++ new/usr/src/cmd/make/include/mksh/defs.h
1 1 #ifndef _MKSH_DEFS_H
2 2 #define _MKSH_DEFS_H
3 3 /*
4 4 * CDDL HEADER START
5 5 *
6 6 * The contents of this file are subject to the terms of the
7 7 * Common Development and Distribution License (the "License").
8 8 * You may not use this file except in compliance with the License.
9 9 *
10 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 11 * or http://www.opensolaris.org/os/licensing.
12 12 * See the License for the specific language governing permissions
13 13 * and limitations under the License.
14 14 *
15 15 * When distributing Covered Code, include this CDDL HEADER in each
16 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 17 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
18 18 * fields enclosed by brackets "[]" replaced with your own identifying
19 19 * information: Portions Copyright [yyyy] [name of copyright owner]
20 20 *
21 21 * CDDL HEADER END
22 22 */
23 23 /*
24 24 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
25 25 * Use is subject to license terms.
26 26 */
27 27
28 -#include <avo/intl.h>
29 28 #include <limits.h> /* MB_LEN_MAX */
30 29 #include <stdio.h>
31 30 #include <stdlib.h> /* wchar_t */
32 31 #include <string.h> /* strcmp() */
33 -#include <nl_types.h> /* catgets() */
34 32 #include <sys/param.h> /* MAXPATHLEN */
35 33 #include <sys/types.h> /* time_t, caddr_t */
36 34 #include <vroot/vroot.h> /* pathpt */
37 35 #include <sys/time.h> /* timestruc_t */
38 36 #include <errno.h> /* errno */
39 37
40 38 #include <wctype.h>
41 39 #include <widec.h>
42 40
43 41
44 42 /*
45 43 * A type and some utilities for boolean values
46 44 */
47 45
48 46 #define false BOOLEAN_false
49 47 #define true BOOLEAN_true
50 48
51 49 typedef enum {
52 50 false = 0,
53 51 true = 1,
54 52 failed = 0,
55 53 succeeded = 1
56 54 } Boolean;
57 55 #define BOOLEAN(expr) ((expr) ? true : false)
58 56
59 57 /*
60 58 * Some random constants (in an enum so dbx knows their values)
61 59 */
62 60 enum {
63 61 update_delay = 30, /* time between rstat checks */
64 62 ar_member_name_len = 1024,
65 63 hashsize = 2048 /* size of hash table */
66 64 };
67 65
68 66
69 67 /*
70 68 * Symbols that defines all the different char constants make uses
71 69 */
72 70 enum {
73 71 ampersand_char = '&',
74 72 asterisk_char = '*',
75 73 at_char = '@',
76 74 backquote_char = '`',
77 75 backslash_char = '\\',
78 76 bar_char = '|',
79 77 braceleft_char = '{',
80 78 braceright_char = '}',
81 79 bracketleft_char = '[',
82 80 bracketright_char = ']',
83 81 colon_char = ':',
84 82 comma_char = ',',
85 83 dollar_char = '$',
86 84 doublequote_char = '"',
87 85 equal_char = '=',
88 86 exclam_char = '!',
89 87 greater_char = '>',
90 88 hat_char = '^',
91 89 hyphen_char = '-',
92 90 less_char = '<',
93 91 newline_char = '\n',
94 92 nul_char = '\0',
95 93 numbersign_char = '#',
96 94 parenleft_char = '(',
97 95 parenright_char = ')',
98 96 percent_char = '%',
99 97 period_char = '.',
100 98 plus_char = '+',
101 99 question_char = '?',
102 100 quote_char = '\'',
103 101 semicolon_char = ';',
104 102 slash_char = '/',
105 103 space_char = ' ',
106 104 tab_char = '\t',
107 105 tilde_char = '~'
108 106 };
109 107
110 108 /*
111 109 * For make i18n. Codeset independent.
112 110 * Setup character semantics by identifying all the special characters
113 111 * of make, and assigning each an entry in the char_semantics[] vector.
114 112 */
115 113 enum {
116 114 ampersand_char_entry = 0, /* 0 */
117 115 asterisk_char_entry, /* 1 */
118 116 at_char_entry, /* 2 */
119 117 backquote_char_entry, /* 3 */
120 118 backslash_char_entry, /* 4 */
121 119 bar_char_entry, /* 5 */
122 120 bracketleft_char_entry, /* 6 */
123 121 bracketright_char_entry, /* 7 */
124 122 colon_char_entry, /* 8 */
125 123 dollar_char_entry, /* 9 */
126 124 doublequote_char_entry, /* 10 */
127 125 equal_char_entry, /* 11 */
128 126 exclam_char_entry, /* 12 */
129 127 greater_char_entry, /* 13 */
130 128 hat_char_entry, /* 14 */
131 129 hyphen_char_entry, /* 15 */
132 130 less_char_entry, /* 16 */
133 131 newline_char_entry, /* 17 */
134 132 numbersign_char_entry, /* 18 */
135 133 parenleft_char_entry, /* 19 */
136 134 parenright_char_entry, /* 20 */
137 135 percent_char_entry, /* 21 */
138 136 plus_char_entry, /* 22 */
139 137 question_char_entry, /* 23 */
140 138 quote_char_entry, /* 24 */
141 139 semicolon_char_entry, /* 25 */
142 140 no_semantics_entry /* 26 */
143 141 };
144 142
145 143 /*
146 144 * CHAR_SEMANTICS_ENTRIES should be the number of entries above.
147 145 * The last entry in char_semantics[] should be blank.
148 146 */
149 147 #define CHAR_SEMANTICS_ENTRIES 27
150 148 /*
151 149 #define CHAR_SEMANTICS_STRING "&*@`\\|[]:$=!>-\n#()%+?;^<'\""
152 150 */
153 151
154 152 /*
155 153 * Some utility macros
156 154 */
157 155 #define ALLOC(x) ((struct _##x *)getmem(sizeof (struct _##x)))
158 156 #define ALLOC_WC(x) ((wchar_t *)getmem((x) * SIZEOFWCHAR_T))
159 157 #define FIND_LENGTH -1
160 158 #define GETNAME(a,b) getname_fn((a), (b), false)
161 159 #define IS_EQUAL(a,b) (!strcmp((a), (b)))
162 160 #define IS_EQUALN(a,b,n) (!strncmp((a), (b), (n)))
163 161 #define IS_WEQUAL(a,b) (!wscmp((a), (b)))
164 162 #define IS_WEQUALN(a,b,n) (!wsncmp((a), (b), (n)))
165 163 #define MBLEN(a) mblen((a), MB_LEN_MAX)
166 164 #define MBSTOWCS(a,b) (void) mbstowcs_with_check((a), (b), MAXPATHLEN)
167 165 #define MBTOWC(a,b) mbtowc((a), (b), MB_LEN_MAX)
168 166 #define SIZEOFWCHAR_T (sizeof (wchar_t))
169 167 #define VSIZEOF(v) (sizeof (v) / sizeof ((v)[0]))
170 168 #define WCSTOMBS(a,b) (void) wcstombs((a), (b), (MAXPATHLEN * MB_LEN_MAX))
171 169 #define WCTOMB(a,b) (void) wctomb((a), (b))
172 170 #define HASH(v, c) (v = (v)*31 + (unsigned int)(c))
173 171
174 172 extern void mbstowcs_with_check(wchar_t *pwcs, const char *s, size_t n);
175 173
176 174 /*
177 175 * Bits stored in funny vector to classify chars
178 176 */
179 177 enum {
180 178 dollar_sem = 0001,
181 179 meta_sem = 0002,
182 180 percent_sem = 0004,
183 181 wildcard_sem = 0010,
184 182 command_prefix_sem = 0020,
185 183 special_macro_sem = 0040,
186 184 colon_sem = 0100,
187 185 parenleft_sem = 0200
188 186 };
189 187
190 188 /*
191 189 * Type returned from doname class functions
192 190 */
193 191 typedef enum {
194 192 build_dont_know = 0,
195 193 build_failed,
196 194 build_ok,
197 195 build_in_progress,
198 196 build_running, /* PARALLEL & DISTRIBUTED */
199 197 build_pending, /* PARALLEL & DISTRIBUTED */
200 198 build_serial, /* PARALLEL & DISTRIBUTED */
201 199 build_subtree /* PARALLEL & DISTRIBUTED */
202 200 } Doname;
203 201
204 202 /*
205 203 * The String struct defines a string with the following layout
206 204 * "xxxxxxxxxxxxxxxCxxxxxxxxxxxxxxx________"
207 205 * ^ ^ ^ ^
208 206 * | | | |
209 207 * buffer.start text.p text.end buffer.end
210 208 * text.p points to the next char to read/write.
211 209 */
212 210 struct _String {
213 211 struct Text {
214 212 wchar_t *p; /* Read/Write pointer */
215 213 wchar_t *end; /* Read limit pointer */
216 214 } text;
217 215 struct Physical_buffer {
218 216 wchar_t *start; /* Points to start of buffer */
219 217 wchar_t *end; /* End of physical buffer */
220 218 } buffer;
221 219 Boolean free_after_use:1;
222 220 };
223 221
224 222 #define STRING_BUFFER_LENGTH 1024
225 223 #define INIT_STRING_FROM_STACK(str, buf) { \
226 224 str.buffer.start = (buf); \
227 225 str.text.p = (buf); \
228 226 str.text.end = NULL; \
229 227 str.buffer.end = (buf) \
230 228 + (sizeof (buf)/SIZEOFWCHAR_T); \
231 229 str.free_after_use = false; \
232 230 }
233 231
234 232 #define APPEND_NAME(np, dest, len) append_string((np)->string_mb, (dest), (len));
235 233
236 234 class Wstring {
237 235 public:
238 236 struct _String string;
239 237 wchar_t string_buf[STRING_BUFFER_LENGTH];
240 238
241 239 public:
242 240 Wstring();
243 241 Wstring(struct _Name * name);
244 242 ~Wstring();
245 243
246 244 void init(struct _Name * name);
247 245 void init(wchar_t * name, unsigned length);
248 246 unsigned length() {
249 247 return wslen(string.buffer.start);
250 248 };
251 249 void append_to_str(struct _String * str, unsigned off, unsigned length);
252 250
253 251 wchar_t * get_string() {
254 252 return string.buffer.start;
255 253 };
256 254
257 255 wchar_t * get_string(unsigned off) {
258 256 return string.buffer.start + off;
259 257 };
260 258
261 259 Boolean equaln(wchar_t * str, unsigned length);
262 260 Boolean equal(wchar_t * str);
263 261 Boolean equal(wchar_t * str, unsigned off);
264 262 Boolean equal(wchar_t * str, unsigned off, unsigned length);
265 263
266 264 Boolean equaln(Wstring * str, unsigned length);
267 265 Boolean equal(Wstring * str);
268 266 Boolean equal(Wstring * str, unsigned off);
269 267 Boolean equal(Wstring * str, unsigned off, unsigned length);
270 268 };
271 269
272 270
273 271 /*
274 272 * Used for storing the $? list and also for the "target + target:"
275 273 * construct.
276 274 */
277 275 struct _Chain {
278 276 struct _Chain *next;
279 277 struct _Name *name;
280 278 struct _Percent *percent_member;
281 279 };
282 280
283 281 /*
284 282 * Stores one command line for a rule
285 283 */
286 284 struct _Cmd_line {
287 285 struct _Cmd_line *next;
288 286 struct _Name *command_line;
289 287 Boolean make_refd:1; /* $(MAKE) referenced? */
290 288 /*
291 289 * Remember any command line prefixes given
292 290 */
293 291 Boolean ignore_command_dependency:1; /* `?' */
294 292 Boolean assign:1; /* `=' */
295 293 Boolean ignore_error:1; /* `-' */
296 294 Boolean silent:1; /* `@' */
297 295 Boolean always_exec:1; /* `+' */
298 296 };
299 297
300 298 /*
301 299 * Linked list of targets/files
302 300 */
303 301 struct _Dependency {
304 302 struct _Dependency *next;
305 303 struct _Name *name;
306 304 Boolean automatic:1;
307 305 Boolean stale:1;
308 306 Boolean built:1;
309 307 };
310 308
311 309 /*
312 310 * The specials are markers for targets that the reader should special case
313 311 */
314 312 typedef enum {
315 313 no_special,
316 314 built_last_make_run_special,
317 315 default_special,
318 316 get_posix_special,
319 317 get_special,
320 318 ignore_special,
321 319 keep_state_file_special,
322 320 keep_state_special,
323 321 make_version_special,
324 322 no_parallel_special,
325 323 parallel_special,
326 324 posix_special,
327 325 precious_special,
328 326 sccs_get_posix_special,
329 327 sccs_get_special,
330 328 silent_special,
331 329 suffixes_special,
332 330 svr4_special,
333 331 localhost_special
334 332 } Special;
335 333
336 334 typedef enum {
337 335 no_colon,
338 336 one_colon,
339 337 two_colon,
340 338 equal_seen,
341 339 conditional_seen,
342 340 none_seen
343 341 } Separator;
344 342
345 343 /*
346 344 * Magic values for the timestamp stored with each name object
347 345 */
348 346
349 347
350 348 extern const timestruc_t file_no_time;
351 349 extern const timestruc_t file_doesnt_exist;
352 350 extern const timestruc_t file_is_dir;
353 351 extern const timestruc_t file_min_time;
354 352 extern const timestruc_t file_max_time;
355 353
356 354 /*
357 355 * Each Name has a list of properties
358 356 * The properties are used to store information that only
359 357 * a subset of the Names need
360 358 */
361 359 typedef enum {
362 360 no_prop,
363 361 conditional_prop,
364 362 line_prop,
365 363 macro_prop,
366 364 makefile_prop,
367 365 member_prop,
368 366 recursive_prop,
369 367 sccs_prop,
370 368 suffix_prop,
371 369 target_prop,
372 370 time_prop,
373 371 vpath_alias_prop,
374 372 long_member_name_prop,
375 373 macro_append_prop,
376 374 env_mem_prop
377 375 } Property_id;
378 376
379 377 typedef enum {
380 378 no_daemon = 0,
381 379 chain_daemon
382 380 } Daemon;
383 381
384 382 struct _Env_mem {
385 383 char *value;
386 384 };
387 385
388 386 struct _Macro_appendix {
389 387 struct _Name *value;
390 388 struct _Name *value_to_append;
391 389 };
392 390
393 391 struct _Macro {
394 392 /*
395 393 * For "ABC = xyz" constructs
396 394 * Name "ABC" get one macro prop
397 395 */
398 396 struct _Name *value;
399 397 Boolean exported:1;
400 398 Boolean read_only:1;
401 399 /*
402 400 * This macro is defined conditionally
403 401 */
404 402 Boolean is_conditional:1;
405 403 /*
406 404 * The list for $? is stored as a structured list that
407 405 * is translated into a string iff it is referenced.
408 406 * This is why some macro values need a daemon.
409 407 */
410 408 Daemon daemon:2;
411 409 };
412 410
413 411 struct _Macro_list {
414 412 struct _Macro_list *next;
415 413 char *macro_name;
416 414 char *value;
417 415 };
418 416
419 417 enum sccs_stat {
420 418 DONT_KNOW_SCCS = 0,
421 419 NO_SCCS,
422 420 HAS_SCCS
423 421 };
424 422
425 423 struct _Name {
426 424 struct _Property *prop; /* List of properties */
427 425 char *string_mb; /* Multi-byte name string */
428 426 struct {
429 427 unsigned int length;
430 428 } hash;
431 429 struct {
432 430 timestruc_t time; /* Modification */
433 431 int stat_errno; /* error from "stat" */
434 432 off_t size; /* Of file */
435 433 mode_t mode; /* Of file */
436 434 Boolean is_file:1;
437 435 Boolean is_dir:1;
438 436 Boolean is_sym_link:1;
439 437 Boolean is_precious:1;
440 438 enum sccs_stat has_sccs:2;
441 439 } stat;
442 440 /*
443 441 * Count instances of :: definitions for this target
444 442 */
445 443 short colon_splits;
446 444 /*
447 445 * We only clear the automatic depes once per target per report
448 446 */
449 447 short temp_file_number;
450 448 /*
451 449 * Count how many conditional macros this target has defined
452 450 */
453 451 short conditional_cnt;
454 452 /*
455 453 * A conditional macro was used when building this target
456 454 */
457 455 Boolean depends_on_conditional:1;
458 456 /*
459 457 * Pointer to list of conditional macros which were used to build
460 458 * this target
461 459 */
462 460 struct _Macro_list *conditional_macro_list;
463 461 Boolean has_member_depe:1;
464 462 Boolean is_member:1;
465 463 /*
466 464 * This target is a directory that has been read
467 465 */
468 466 Boolean has_read_dir:1;
469 467 /*
470 468 * This name is a macro that is now being expanded
471 469 */
472 470 Boolean being_expanded:1;
473 471 /*
474 472 * This name is a magic name that the reader must know about
475 473 */
476 474 Special special_reader:5;
477 475 Doname state:3;
478 476 Separator colons:3;
479 477 Boolean has_depe_list_expanded:1;
480 478 Boolean suffix_scan_done:1;
481 479 Boolean has_complained:1; /* For sccs */
482 480 /*
483 481 * This target has been built during this make run
484 482 */
485 483 Boolean ran_command:1;
486 484 Boolean with_squiggle:1; /* for .SUFFIXES */
487 485 Boolean without_squiggle:1; /* for .SUFFIXES */
488 486 Boolean has_read_suffixes:1; /* Suffix list cached*/
489 487 Boolean has_suffixes:1;
490 488 Boolean has_target_prop:1;
491 489 Boolean has_vpath_alias_prop:1;
492 490 Boolean dependency_printed:1; /* For dump_make_state() */
493 491 Boolean dollar:1; /* In namestring */
494 492 Boolean meta:1; /* In namestring */
495 493 Boolean percent:1; /* In namestring */
496 494 Boolean wildcard:1; /* In namestring */
497 495 Boolean has_parent:1;
498 496 Boolean is_target:1;
499 497 Boolean has_built:1;
500 498 Boolean colon:1; /* In namestring */
501 499 Boolean parenleft:1; /* In namestring */
502 500 Boolean has_recursive_dependency:1;
503 501 Boolean has_regular_dependency:1;
504 502 Boolean is_double_colon:1;
505 503 Boolean is_double_colon_parent:1;
506 504 Boolean has_long_member_name:1;
507 505 /*
508 506 * allowed to run in parallel
509 507 */
510 508 Boolean parallel:1;
511 509 /*
512 510 * not allowed to run in parallel
513 511 */
514 512 Boolean no_parallel:1;
515 513 /*
516 514 * used in dependency_conflict
517 515 */
518 516 Boolean checking_subtree:1;
519 517 Boolean added_pattern_conditionals:1;
520 518 /*
521 519 * rechecking target for possible rebuild
522 520 */
523 521 Boolean rechecking_target:1;
524 522 /*
525 523 * build this target in silent mode
526 524 */
527 525 Boolean silent_mode:1;
528 526 /*
529 527 * build this target in ignore error mode
530 528 */
531 529 Boolean ignore_error_mode:1;
532 530 Boolean dont_activate_cond_values:1;
533 531 /*
534 532 * allowed to run serially on local host
535 533 */
536 534 Boolean localhost:1;
537 535 };
538 536
539 537 /*
540 538 * Stores the % matched default rules
541 539 */
542 540 struct _Percent {
543 541 struct _Percent *next;
544 542 struct _Name **patterns;
545 543 struct _Name *name;
546 544 struct _Percent *dependencies;
547 545 struct _Cmd_line *command_template;
548 546 struct _Chain *target_group;
549 547 int patterns_total;
550 548 Boolean being_expanded;
551 549 };
552 550
553 551 struct Conditional {
554 552 /*
555 553 * For "foo := ABC [+]= xyz" constructs
556 554 * Name "foo" gets one conditional prop
557 555 */
558 556 struct _Name *target;
559 557 struct _Name *name;
560 558 struct _Name *value;
561 559 int sequence;
562 560 Boolean append:1;
563 561 };
564 562
565 563 struct Line {
566 564 /*
567 565 * For "target : dependencies" constructs
568 566 * Name "target" gets one line prop
569 567 */
570 568 struct _Cmd_line *command_template;
571 569 struct _Cmd_line *command_used;
572 570 struct _Dependency *dependencies;
573 571 timestruc_t dependency_time;
574 572 struct _Chain *target_group;
575 573 Boolean is_out_of_date:1;
576 574 Boolean sccs_command:1;
577 575 Boolean command_template_redefined:1;
578 576 Boolean dont_rebuild_command_used:1;
579 577 /*
580 578 * Values for the dynamic macros
581 579 */
582 580 struct _Name *target;
583 581 struct _Name *star;
584 582 struct _Name *less;
585 583 struct _Name *percent;
586 584 struct _Chain *query;
587 585 };
588 586
589 587 struct Makefile {
590 588 /*
591 589 * Names that reference makefiles gets one prop
592 590 */
593 591 wchar_t *contents;
594 592 off_t size;
595 593 };
596 594
597 595 struct Member {
598 596 /*
599 597 * For "lib(member)" and "lib((entry))" constructs
600 598 * Name "lib(member)" gets one member prop
601 599 * Name "lib((entry))" gets one member prop
602 600 * The member field is filled in when the prop is refd
603 601 */
604 602 struct _Name *library;
605 603 struct _Name *entry;
606 604 struct _Name *member;
607 605 };
608 606
609 607 struct Recursive {
610 608 /*
611 609 * For "target: .RECURSIVE dir makefiles" constructs
612 610 * Used to keep track of recursive calls to make
613 611 * Name "target" gets one recursive prop
614 612 */
615 613 struct _Name *directory;
616 614 struct _Name *target;
617 615 struct _Dependency *makefiles;
618 616 Boolean has_built;
619 617 Boolean in_depinfo;
620 618 };
621 619
622 620 struct Sccs {
623 621 /*
624 622 * Each file that has a SCCS s. file gets one prop
625 623 */
626 624 struct _Name *file;
627 625 };
628 626
629 627 struct Suffix {
630 628 /*
631 629 * Cached list of suffixes that can build this target
632 630 * suffix is built from .SUFFIXES
633 631 */
634 632 struct _Name *suffix;
635 633 struct _Cmd_line *command_template;
636 634 };
637 635
638 636 struct Target {
639 637 /*
640 638 * For "target:: dependencies" constructs
641 639 * The "::" construct is handled by converting it to
642 640 * "foo: 1@foo" + "1@foo: dependecies"
643 641 * "1@foo" gets one target prop
644 642 * This target prop cause $@ to be bound to "foo"
645 643 * not "1@foo" when the rule is evaluated
646 644 */
647 645 struct _Name *target;
648 646 };
649 647
650 648 struct STime {
651 649 /*
652 650 * Save the original time for :: targets
653 651 */
654 652 timestruc_t time;
655 653 };
656 654
657 655 struct Vpath_alias {
658 656 /*
659 657 * If a file was found using the VPATH it gets
660 658 * a vpath_alias prop
661 659 */
662 660 struct _Name *alias;
663 661 };
664 662
665 663 struct Long_member_name {
666 664 /*
667 665 * Targets with a truncated member name carries
668 666 * the full lib(member) name for the state file
669 667 */
670 668 struct _Name *member_name;
671 669 };
672 670
673 671 union Body {
674 672 struct _Macro macro;
675 673 struct Conditional conditional;
676 674 struct Line line;
677 675 struct Makefile makefile;
678 676 struct Member member;
679 677 struct Recursive recursive;
680 678 struct Sccs sccs;
681 679 struct Suffix suffix;
682 680 struct Target target;
683 681 struct STime time;
684 682 struct Vpath_alias vpath_alias;
685 683 struct Long_member_name long_member_name;
686 684 struct _Macro_appendix macro_appendix;
687 685 struct _Env_mem env_mem;
688 686 };
689 687
690 688 #define PROPERTY_HEAD_SIZE (sizeof (struct _Property)-sizeof (union Body))
691 689 struct _Property {
692 690 struct _Property *next;
693 691 Property_id type:4;
694 692 union Body body;
695 693 };
696 694
697 695 /* Structure for dynamic "ascii" arrays */
698 696 struct ASCII_Dyn_Array {
699 697 char *start;
700 698 size_t size;
701 699 };
702 700
703 701 struct _Envvar {
704 702 struct _Name *name;
705 703 struct _Name *value;
706 704 struct _Envvar *next;
707 705 char *env_string;
708 706 Boolean already_put:1;
709 707 };
710 708
711 709 /*
712 710 * Macros for the reader
713 711 */
714 712 #define GOTO_STATE(new_state) { \
715 713 SET_STATE(new_state); \
716 714 goto enter_state; \
717 715 }
718 716 #define SET_STATE(new_state) state = (new_state)
719 717
720 718 #define UNCACHE_SOURCE() if (source != NULL) { \
721 719 source->string.text.p = source_p; \
722 720 }
723 721 #define CACHE_SOURCE(comp) if (source != NULL) { \
724 722 source_p = source->string.text.p - \
725 723 (comp); \
726 724 source_end = source->string.text.end; \
727 725 }
728 726 #define GET_NEXT_BLOCK_NOCHK(source) { UNCACHE_SOURCE(); \
729 727 source = get_next_block_fn(source); \
730 728 CACHE_SOURCE(0) \
731 729 }
732 730 #define GET_NEXT_BLOCK(source) { GET_NEXT_BLOCK_NOCHK(source); \
733 731 if (source != NULL && source->error_converting) { \
734 732 GOTO_STATE(illegal_bytes_state); \
735 733 } \
736 734 }
737 735 #define GET_CHAR() ((source == NULL) || \
738 736 (source_p >= source_end) ? 0 : *source_p)
739 737
740 738 struct _Source {
741 739 struct _String string;
742 740 struct _Source *previous;
743 741 off_t bytes_left_in_file;
744 742 short fd;
745 743 Boolean already_expanded:1;
746 744 Boolean error_converting:1;
747 745 char *inp_buf;
748 746 char *inp_buf_end;
749 747 char *inp_buf_ptr;
750 748 };
751 749
752 750 typedef enum {
753 751 reading_nothing,
754 752 reading_makefile,
755 753 reading_statefile,
756 754 rereading_statefile,
757 755 reading_cpp_file
758 756 } Makefile_type;
759 757
760 758 /*
761 759 * Typedefs for all structs
762 760 */
763 761 typedef struct _Chain *Chain, Chain_rec;
764 762 typedef struct _Envvar *Envvar, Envvar_rec;
765 763 typedef struct _Macro_list *Macro_list, Macro_list_rec;
766 764 typedef struct _Name *Name, Name_rec;
767 765 typedef struct _Property *Property, Property_rec;
768 766 typedef struct _Source *Source, Source_rec;
769 767 typedef struct _String *String, String_rec;
770 768
771 769 /*
772 770 * name records hash table.
773 771 */
774 772 struct Name_set {
775 773 private:
776 774 // single node in a tree
777 775 struct entry {
778 776 entry(Name name_, entry *parent_) :
779 777 name(name_),
780 778 parent(parent_),
781 779 left(0),
782 780 right(0),
783 781 depth(1)
784 782 {}
785 783
786 784 Name name;
787 785
788 786 entry *parent;
789 787 entry *left;
790 788 entry *right;
791 789 unsigned depth;
792 790
793 791 void setup_depth() {
794 792 unsigned rdepth = (right != 0) ? right->depth : 0;
795 793 unsigned ldepth = (left != 0) ? left->depth : 0;
796 794 depth = 1 + ((ldepth > rdepth) ? ldepth : rdepth);
797 795 }
798 796 };
799 797
800 798 public:
801 799 // make iterator a friend of Name_set to have access to struct entry
802 800 struct iterator;
803 801 friend struct Name_set::iterator;
804 802
805 803 // iterator over tree nodes
806 804 struct iterator {
807 805 public:
808 806 // constructors
809 807 iterator() : node(0) {}
810 808 iterator(entry *node_) : node(node_) {}
811 809
812 810 // dereference operator
813 811 Name operator->() const { return node->name; }
814 812
815 813 // conversion operator
816 814 operator Name() { return node->name; }
817 815
818 816 // assignment operator
819 817 iterator& operator=(const iterator &o) { node = o.node; return *this; }
820 818
821 819 // equality/inequality operators
822 820 int operator==(const iterator &o) const { return (node == o.node); }
823 821 int operator!=(const iterator &o) const { return (node != o.node); }
824 822
825 823 // pre/post increment operators
826 824 iterator& operator++();
827 825 iterator operator++(int) { iterator it = *this; ++*this; return it; }
828 826
829 827 private:
830 828 // the node iterator points to
831 829 entry *node;
832 830 };
833 831
834 832 public:
835 833 // constructor
836 834 Name_set() : root(0) {}
837 835
838 836 // lookup, insert and remove operations
839 837 Name lookup(const char *key);
840 838 Name insert(const char *key, Boolean &found);
841 839 void insert(Name name);
842 840
843 841 // begin/end iterators
844 842 iterator begin() const;
845 843 iterator end() const { return iterator(); }
846 844
847 845 private:
848 846 // rebalance given node
849 847 void rebalance(entry *node);
850 848
851 849 private:
852 850 // tree root
853 851 entry *root;
854 852 };
855 853
856 854 /*
857 855 * extern declarations for all global variables.
858 856 * The actual declarations are in globals.cc
859 857 */
860 858 extern char char_semantics[];
861 859 extern wchar_t char_semantics_char[];
862 860 extern Macro_list cond_macro_list;
863 861 extern Boolean conditional_macro_used;
864 862 extern Boolean do_not_exec_rule; /* `-n' */
865 863 extern Boolean dollarget_seen;
866 864 extern Boolean dollarless_flag;
867 865 extern Name dollarless_value;
868 866 extern char **environ;
869 867 extern Envvar envvar;
870 868 extern int exit_status;
871 869 extern wchar_t *file_being_read;
872 870 /* Variable gnu_style=true if env. var. SUN_MAKE_COMPAT_MODE=GNU (RFE 4866328) */
873 871 extern Boolean gnu_style;
874 872 extern Name_set hashtab;
875 873 extern Name host_arch;
876 874 extern Name host_mach;
877 875 extern int line_number;
878 876 extern char *make_state_lockfile;
879 877 extern Boolean make_word_mentioned;
880 878 extern Makefile_type makefile_type;
881 879 extern char mbs_buffer[];
882 880 extern Name path_name;
883 881 extern Boolean posix;
884 882 extern Name query;
885 883 extern Boolean query_mentioned;
886 884 extern Name hat;
887 885 extern Boolean reading_environment;
888 886 extern Name shell_name;
889 887 extern Boolean svr4;
890 888 extern Name target_arch;
↓ open down ↓ |
847 lines elided |
↑ open up ↑ |
891 889 extern Name target_mach;
892 890 extern Boolean tilde_rule;
893 891 extern wchar_t wcs_buffer[];
894 892 extern Boolean working_on_targets;
895 893 extern Name virtual_root;
896 894 extern Boolean vpath_defined;
897 895 extern Name vpath_name;
898 896 extern Boolean make_state_locked;
899 897 extern Boolean out_err_same;
900 898 extern pid_t childPid;
901 -extern nl_catd libmksh_catd;
902 899
903 900 /*
904 901 * RFE 1257407: make does not use fine granularity time info available from stat.
905 902 * High resolution time comparison.
906 903 */
907 904
908 905 inline int
909 906 operator==(const timestruc_t &t1, const timestruc_t &t2) {
910 907 return ((t1.tv_sec == t2.tv_sec) && (t1.tv_nsec == t2.tv_nsec));
911 908 }
912 909
913 910 inline int
914 911 operator!=(const timestruc_t &t1, const timestruc_t &t2) {
915 912 return ((t1.tv_sec != t2.tv_sec) || (t1.tv_nsec != t2.tv_nsec));
916 913 }
917 914
918 915 inline int
919 916 operator>(const timestruc_t &t1, const timestruc_t &t2) {
920 917 if (t1.tv_sec == t2.tv_sec) {
921 918 return (t1.tv_nsec > t2.tv_nsec);
922 919 }
923 920 return (t1.tv_sec > t2.tv_sec);
924 921 }
925 922
926 923 inline int
927 924 operator>=(const timestruc_t &t1, const timestruc_t &t2) {
928 925 if (t1.tv_sec == t2.tv_sec) {
929 926 return (t1.tv_nsec >= t2.tv_nsec);
930 927 }
931 928 return (t1.tv_sec > t2.tv_sec);
932 929 }
933 930
934 931 inline int
935 932 operator<(const timestruc_t &t1, const timestruc_t &t2) {
936 933 if (t1.tv_sec == t2.tv_sec) {
937 934 return (t1.tv_nsec < t2.tv_nsec);
938 935 }
939 936 return (t1.tv_sec < t2.tv_sec);
940 937 }
941 938
942 939 inline int
943 940 operator<=(const timestruc_t &t1, const timestruc_t &t2) {
944 941 if (t1.tv_sec == t2.tv_sec) {
945 942 return (t1.tv_nsec <= t2.tv_nsec);
946 943 }
947 944 return (t1.tv_sec < t2.tv_sec);
948 945 }
949 946
950 947 #endif
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX