Mercurial > hg > xemacs-beta
comparison lib-src/etags.c @ 155:43dd3413c7c7 r20-3b4
Import from CVS: tag r20-3b4
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:39:39 +0200 |
parents | 25f70ba0133c |
children | 6b37e6ddd302 |
comparison
equal
deleted
inserted
replaced
154:94141801dd7e | 155:43dd3413c7c7 |
---|---|
29 * Regexp tags by Tom Tromey. | 29 * Regexp tags by Tom Tromey. |
30 * | 30 * |
31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer. | 31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer. |
32 */ | 32 */ |
33 | 33 |
34 char pot_etags_version[] = "@(#) pot revision number is 12.7"; | 34 char pot_etags_version[] = "@(#) pot revision number is 12.11"; |
35 | 35 |
36 #define TRUE 1 | 36 #define TRUE 1 |
37 #define FALSE 0 | 37 #define FALSE 0 |
38 | 38 |
39 #ifndef DEBUG | 39 #ifndef DEBUG |
57 #ifdef HAVE_CONFIG_H | 57 #ifdef HAVE_CONFIG_H |
58 # include <config.h> | 58 # include <config.h> |
59 /* On some systems, Emacs defines static as nothing for the sake | 59 /* On some systems, Emacs defines static as nothing for the sake |
60 of unexec. We don't want that here since we don't use unexec. */ | 60 of unexec. We don't want that here since we don't use unexec. */ |
61 # undef static | 61 # undef static |
62 # define ETAGS_REGEXPS | |
63 # define LONG_OPTIONS | |
62 #endif | 64 #endif |
63 | 65 |
64 #if !defined (MSDOS) && !defined (WINDOWSNT) && defined (STDC_HEADERS) | 66 #if !defined (MSDOS) && !defined (WINDOWSNT) && defined (STDC_HEADERS) |
65 #include <stdlib.h> | 67 #include <stdlib.h> |
66 #include <string.h> | 68 #include <string.h> |
77 | 79 |
78 #if !defined (S_ISREG) && defined (S_IFREG) | 80 #if !defined (S_ISREG) && defined (S_IFREG) |
79 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | 81 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) |
80 #endif | 82 #endif |
81 | 83 |
82 #include <getopt.h> | 84 #ifdef HAVE_UNISTD_H |
85 #include <unistd.h> | |
86 #endif | |
87 | |
88 #ifdef LONG_OPTIONS | |
89 # include <getopt.h> | |
90 #else | |
91 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) | |
92 extern char *optarg; | |
93 extern int optind, opterr; | |
94 #endif /* LONG_OPTIONS */ | |
83 | 95 |
84 #ifdef ETAGS_REGEXPS | 96 #ifdef ETAGS_REGEXPS |
85 # include <regex.h> | 97 # include <regex.h> |
86 #endif /* ETAGS_REGEXPS */ | 98 #endif /* ETAGS_REGEXPS */ |
87 | 99 |
144 (n) * sizeof (Type))) | 156 (n) * sizeof (Type))) |
145 #else | 157 #else |
146 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type))) | 158 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type))) |
147 #endif | 159 #endif |
148 | 160 |
149 typedef int logical; | 161 typedef int bool; |
150 | 162 |
151 typedef struct nd_st | 163 typedef struct nd_st |
152 { /* sorting structure */ | 164 { /* sorting structure */ |
153 char *name; /* function or type name */ | 165 char *name; /* function or type name */ |
154 char *file; /* file name */ | 166 char *file; /* file name */ |
155 logical is_func; /* use pattern or line no */ | 167 bool is_func; /* use pattern or line no */ |
156 logical been_warned; /* set if noticed dup */ | 168 bool been_warned; /* set if noticed dup */ |
157 int lno; /* line number tag is on */ | 169 int lno; /* line number tag is on */ |
158 long cno; /* character number line starts on */ | 170 long cno; /* character number line starts on */ |
159 char *pat; /* search pattern */ | 171 char *pat; /* search pattern */ |
160 struct nd_st *left, *right; /* left and right sons */ | 172 struct nd_st *left, *right; /* left and right sons */ |
161 } NODE; | 173 } NODE; |
201 long readline (); | 213 long readline (); |
202 long readline_internal (); | 214 long readline_internal (); |
203 #ifdef ETAGS_REGEXPS | 215 #ifdef ETAGS_REGEXPS |
204 void analyse_regex (); | 216 void analyse_regex (); |
205 void add_regex (); | 217 void add_regex (); |
206 #endif | 218 #endif /* ETAGS_REGEXPS */ |
207 void add_node (); | 219 void add_node (); |
208 void error (); | 220 void error (); |
209 void suggest_asking_for_help (); | 221 void suggest_asking_for_help (); |
210 void fatal (), pfatal (); | 222 void fatal (), pfatal (); |
211 void find_entries (); | 223 void find_entries (); |
255 long linepos; | 267 long linepos; |
256 struct linebuffer lb; /* used by C_entries instead of lb */ | 268 struct linebuffer lb; /* used by C_entries instead of lb */ |
257 } lbs[2]; | 269 } lbs[2]; |
258 | 270 |
259 /* boolean "functions" (see init) */ | 271 /* boolean "functions" (see init) */ |
260 logical _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS]; | 272 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS]; |
261 char | 273 char |
262 /* white chars */ | 274 /* white chars */ |
263 *white = " \f\t\n\013", | 275 *white = " \f\t\n\013", |
264 /* not in a name */ | 276 /* not in a name */ |
265 *nonam =" \f\t\n\013(=,[;", | 277 *nonam =" \f\t\n\013(=,[;", |
268 /* token starting chars */ | 280 /* token starting chars */ |
269 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@", | 281 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@", |
270 /* valid in-token chars */ | 282 /* valid in-token chars */ |
271 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789"; | 283 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789"; |
272 | 284 |
273 logical append_to_tagfile; /* -a: append to tags */ | 285 bool append_to_tagfile; /* -a: append to tags */ |
274 /* The following three default to TRUE for etags, but to FALSE for ctags. */ | 286 /* The following four default to TRUE for etags, but to FALSE for ctags. */ |
275 logical typedefs; /* -t: create tags for C typedefs */ | 287 bool typedefs; /* -t: create tags for C typedefs */ |
276 logical typedefs_and_cplusplus; /* -T: create tags for C typedefs, level */ | 288 bool typedefs_and_cplusplus; /* -T: create tags for C typedefs, level */ |
277 /* 0 struct/enum/union decls, and C++ */ | 289 /* 0 struct/enum/union decls, and C++ */ |
278 /* member functions. */ | 290 /* member functions. */ |
279 logical constantypedefs; /* -d: create tags for C #define, enum */ | 291 bool constantypedefs; /* -d: create tags for C #define, enum */ |
280 /* constants and variables. */ | 292 /* constants and variables. */ |
281 /* -D: opposite of -d. Default under ctags. */ | 293 /* -D: opposite of -d. Default under ctags. */ |
282 logical variables; /* create tags for C global variables */ | 294 bool globals; /* create tags for C global variables */ |
283 logical variables_and_cplusplus; /* tags for C++ variables inside classes */ | 295 bool members; /* create tags for C member variables */ |
284 logical update; /* -u: update tags */ | 296 bool update; /* -u: update tags */ |
285 logical vgrind_style; /* -v: create vgrind style index output */ | 297 bool vgrind_style; /* -v: create vgrind style index output */ |
286 logical no_warnings; /* -w: suppress warnings */ | 298 bool no_warnings; /* -w: suppress warnings */ |
287 logical cxref_style; /* -x: create cxref style output */ | 299 bool cxref_style; /* -x: create cxref style output */ |
288 logical cplusplus; /* .[hc] means C++, not C */ | 300 bool cplusplus; /* .[hc] means C++, not C */ |
289 logical noindentypedefs; /* -I: ignore indentation in C */ | 301 bool noindentypedefs; /* -I: ignore indentation in C */ |
290 | 302 |
291 enum { tagsopt = 1000 }; | 303 #ifdef LONG_OPTIONS |
292 | |
293 struct option longopts[] = | 304 struct option longopts[] = |
294 { | 305 { |
295 { "append", no_argument, NULL, 'a' }, | 306 { "append", no_argument, NULL, 'a' }, |
296 { "backward-search", no_argument, NULL, 'B' }, | 307 { "backward-search", no_argument, NULL, 'B' }, |
297 { "c++", no_argument, NULL, 'C' }, | 308 { "c++", no_argument, NULL, 'C' }, |
298 { "cxref", no_argument, NULL, 'x' }, | 309 { "cxref", no_argument, NULL, 'x' }, |
299 { "defines", no_argument, NULL, 'd' }, | 310 { "defines", no_argument, NULL, 'd' }, |
300 { "help", no_argument, NULL, 'h' }, | 311 { "no-defines", no_argument, NULL, 'D' }, |
301 { "help", no_argument, NULL, 'H' }, | 312 { "globals", no_argument, &globals, TRUE }, |
302 { "ignore-indentation", no_argument, NULL, 'I' }, | 313 { "no-globals", no_argument, &globals, FALSE }, |
303 { "include", required_argument, NULL, 'i' }, | 314 { "help", no_argument, NULL, 'h' }, |
304 { "language", required_argument, NULL, 'l' }, | 315 { "help", no_argument, NULL, 'H' }, |
305 { "no-defines", no_argument, NULL, 'D' }, | 316 { "ignore-indentation", no_argument, NULL, 'I' }, |
306 { "no-regex", no_argument, NULL, 'R' }, | 317 { "include", required_argument, NULL, 'i' }, |
307 { "no-warn", no_argument, NULL, 'w' }, | 318 { "language", required_argument, NULL, 'l' }, |
308 { "output", required_argument, NULL, 'o' }, | 319 { "members", no_argument, &members, TRUE }, |
309 { "regex", required_argument, NULL, 'r' }, | 320 { "no-members", no_argument, &members, FALSE }, |
310 { "tags", required_argument, NULL, tagsopt }, | 321 { "no-warn", no_argument, NULL, 'w' }, |
311 { "typedefs", no_argument, NULL, 't' }, | 322 { "output", required_argument, NULL, 'o' }, |
312 { "typedefs-and-c++", no_argument, NULL, 'T' }, | 323 #ifdef ETAGS_REGEXPS |
313 { "update", no_argument, NULL, 'u' }, | 324 { "regex", required_argument, NULL, 'r' }, |
314 { "version", no_argument, NULL, 'V' }, | 325 { "no-regex", no_argument, NULL, 'R' }, |
315 { "vgrind", no_argument, NULL, 'v' }, | 326 #endif /* ETAGS_REGEXPS */ |
327 { "typedefs", no_argument, NULL, 't' }, | |
328 { "typedefs-and-c++", no_argument, NULL, 'T' }, | |
329 { "update", no_argument, NULL, 'u' }, | |
330 { "version", no_argument, NULL, 'V' }, | |
331 { "vgrind", no_argument, NULL, 'v' }, | |
316 { 0 } | 332 { 0 } |
317 }; | 333 }; |
334 #endif /* LONG_OPTIONS */ | |
318 | 335 |
319 #ifdef ETAGS_REGEXPS | 336 #ifdef ETAGS_REGEXPS |
320 /* Structure defining a regular expression. Elements are | 337 /* Structure defining a regular expression. Elements are |
321 the compiled pattern, and the name string. */ | 338 the compiled pattern, and the name string. */ |
322 struct pattern | 339 struct pattern |
323 { | 340 { |
324 struct re_pattern_buffer *pattern; | 341 struct re_pattern_buffer *pattern; |
325 struct re_registers regs; | 342 struct re_registers regs; |
326 char *name_pattern; | 343 char *name_pattern; |
327 logical error_signaled; | 344 bool error_signaled; |
328 }; | 345 }; |
329 | 346 |
330 /* Number of regexps found. */ | 347 /* Number of regexps found. */ |
331 int num_patterns = 0; | 348 int num_patterns = 0; |
332 | 349 |
486 } | 503 } |
487 | 504 |
488 void | 505 void |
489 print_help () | 506 print_help () |
490 { | 507 { |
491 printf ("These are the options accepted by %s. You may use unambiguous\n\ | 508 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\ |
492 abbreviations for the long option names. A - as file name means read\n\ | 509 \n\ |
493 names from stdin.", progname); | 510 These are the options accepted by %s.\n", progname, progname); |
511 #ifdef LONG_OPTIONS | |
512 puts ("You may use unambiguous abbreviations for the long option names."); | |
513 #else | |
514 puts ("Long option names do not work with this executable, as it is not\n\ | |
515 linked with GNU getopt."); | |
516 #endif /* LONG_OPTIONS */ | |
517 puts ("A - as file name means read names from stdin."); | |
494 if (!CTAGS) | 518 if (!CTAGS) |
495 printf (" Absolute names are stored in the output file as they\n\ | 519 printf (" Absolute names are stored in the output file as they\n\ |
496 are. Relative ones are stored relative to the output file's directory."); | 520 are. Relative ones are stored relative to the output file's directory."); |
497 puts ("\n"); | 521 puts ("\n"); |
498 | 522 |
507 puts ("-C, --c++\n\ | 531 puts ("-C, --c++\n\ |
508 Treat files whose name suffix defaults to C language as C++ files."); | 532 Treat files whose name suffix defaults to C language as C++ files."); |
509 | 533 |
510 if (CTAGS) | 534 if (CTAGS) |
511 puts ("-d, --defines\n\ | 535 puts ("-d, --defines\n\ |
512 Create tag entries for C #define constants, enum constants,\n\ | 536 Create tag entries for C #define constants and enum constants, too."); |
513 and variables, too."); | |
514 else | 537 else |
515 puts ("-D, --no-defines\n\ | 538 puts ("-D, --no-defines\n\ |
516 Don't create tag entries for C #define constants, enum constants,\n\ | 539 Don't create tag entries for C #define constants and enum constants.\n\ |
517 and variables. This makes the tags file smaller."); | 540 This makes the tags file smaller."); |
518 | 541 |
519 if (!CTAGS) | 542 if (!CTAGS) |
520 { | 543 { |
521 puts ("-i FILE, --include=FILE\n\ | 544 puts ("-i FILE, --include=FILE\n\ |
522 Include a note in tag file indicating that, when searching for\n\ | 545 Include a note in tag file indicating that, when searching for\n\ |
524 checking the current file."); | 547 checking the current file."); |
525 puts ("-l LANG, --language=LANG\n\ | 548 puts ("-l LANG, --language=LANG\n\ |
526 Force the following files to be considered as written in the\n\ | 549 Force the following files to be considered as written in the\n\ |
527 named language up to the next --language=LANG option."); | 550 named language up to the next --language=LANG option."); |
528 } | 551 } |
552 | |
553 if (CTAGS) | |
554 puts ("--globals\n\ | |
555 Create tag entries for global variables in C and derived languages."); | |
556 else | |
557 puts ("--no-globals\n\ | |
558 Do not create tag entries for global variables in C and\n\ | |
559 derived languages. This makes the tags file smaller."); | |
560 puts ("--members\n\ | |
561 Create tag entries for member variables in C and derived languages."); | |
529 | 562 |
530 #ifdef ETAGS_REGEXPS | 563 #ifdef ETAGS_REGEXPS |
531 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\ | 564 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\ |
532 Make a tag for each line matching pattern REGEXP in the\n\ | 565 Make a tag for each line matching pattern REGEXP in the\n\ |
533 following files. regexfile is a file containing one REGEXP\n\ | 566 following files. regexfile is a file containing one REGEXP\n\ |
641 char *in; | 674 char *in; |
642 { | 675 { |
643 static long context = 0; | 676 static long context = 0; |
644 static struct dsc$descriptor_s o; | 677 static struct dsc$descriptor_s o; |
645 static struct dsc$descriptor_s i; | 678 static struct dsc$descriptor_s i; |
646 static logical pass1 = TRUE; | 679 static bool pass1 = TRUE; |
647 long status; | 680 long status; |
648 short retval; | 681 short retval; |
649 | 682 |
650 if (pass1) | 683 if (pass1) |
651 { | 684 { |
681 name of each file specified by the provided arg expanding wildcards. | 714 name of each file specified by the provided arg expanding wildcards. |
682 */ | 715 */ |
683 char * | 716 char * |
684 gfnames (arg, p_error) | 717 gfnames (arg, p_error) |
685 char *arg; | 718 char *arg; |
686 logical *p_error; | 719 bool *p_error; |
687 { | 720 { |
688 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"}; | 721 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"}; |
689 | 722 |
690 switch (fn_exp (&filename, arg)) | 723 switch (fn_exp (&filename, arg)) |
691 { | 724 { |
739 char *this_file; | 772 char *this_file; |
740 argument *argbuffer; | 773 argument *argbuffer; |
741 int current_arg, file_count; | 774 int current_arg, file_count; |
742 struct linebuffer filename_lb; | 775 struct linebuffer filename_lb; |
743 #ifdef VMS | 776 #ifdef VMS |
744 logical got_err; | 777 bool got_err; |
745 #endif | 778 #endif |
746 | 779 |
747 #ifdef DOS_NT | 780 #ifdef DOS_NT |
748 _fmode = O_BINARY; /* all of files are treated as binary files */ | 781 _fmode = O_BINARY; /* all of files are treated as binary files */ |
749 #endif /* DOS_NT */ | 782 #endif /* DOS_NT */ |
764 #endif /* ETAGS_REGEXPS */ | 797 #endif /* ETAGS_REGEXPS */ |
765 | 798 |
766 /* | 799 /* |
767 * If etags, always find typedefs and structure tags. Why not? | 800 * If etags, always find typedefs and structure tags. Why not? |
768 * Also default is to find macro constants, enum constants and | 801 * Also default is to find macro constants, enum constants and |
769 * variables. | 802 * global variables. |
770 */ | 803 */ |
771 if (!CTAGS) | 804 if (!CTAGS) |
772 { | 805 { |
773 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE; | 806 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE; |
774 variables = variables_and_cplusplus = TRUE; | 807 globals = TRUE; |
808 members = FALSE; | |
775 } | 809 } |
776 | 810 |
777 while (1) | 811 while (1) |
778 { | 812 { |
779 int opt = getopt_long (argc, argv, | 813 int opt; |
780 "-aCdDf:Il:o:r:RStTi:BuvxwVhH", longopts, 0); | 814 char *optstring; |
781 | 815 |
816 #ifdef ETAGS_REGEXPS | |
817 optstring = "-aCdDf:Il:o:r:RStTi:BuvxwVhH"; | |
818 #else | |
819 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH"; | |
820 #endif /* ETAGS_REGEXPS */ | |
821 | |
822 #ifndef LONG_OPTIONS | |
823 optstring = optstring + 1; | |
824 #endif /* LONG_OPTIONS */ | |
825 | |
826 opt = getopt_long (argc, argv, optstring, longopts, 0); | |
782 if (opt == EOF) | 827 if (opt == EOF) |
783 break; | 828 break; |
784 | 829 |
785 switch (opt) | 830 switch (opt) |
786 { | 831 { |
856 case 'u': update = TRUE; break; | 901 case 'u': update = TRUE; break; |
857 case 'v': vgrind_style = TRUE; /*FALLTHRU*/ | 902 case 'v': vgrind_style = TRUE; /*FALLTHRU*/ |
858 case 'x': cxref_style = TRUE; break; | 903 case 'x': cxref_style = TRUE; break; |
859 case 'w': no_warnings = TRUE; break; | 904 case 'w': no_warnings = TRUE; break; |
860 #endif /* CTAGS */ | 905 #endif /* CTAGS */ |
861 case tagsopt: | |
862 { | |
863 char *t; | |
864 logical value = TRUE; | |
865 | |
866 for (t = optarg; *t != '\0'; t++) | |
867 switch (*t) | |
868 { | |
869 case '-': value = FALSE; break; | |
870 case '+': value = TRUE; break; | |
871 case 'd': constantypedefs = value; break; | |
872 case 't': typedefs = value; break; | |
873 case 'T': typedefs_and_cplusplus = value; break; | |
874 case 'v': variables = value; break; | |
875 case 'V': variables_and_cplusplus = value; break; | |
876 default: | |
877 suggest_asking_for_help (); | |
878 } | |
879 break; | |
880 } | |
881 default: | 906 default: |
882 suggest_asking_for_help (); | 907 suggest_asking_for_help (); |
883 } | 908 } |
884 } | 909 } |
885 | 910 |
891 ++file_count; | 916 ++file_count; |
892 } | 917 } |
893 | 918 |
894 if (nincluded_files == 0 && file_count == 0) | 919 if (nincluded_files == 0 && file_count == 0) |
895 { | 920 { |
896 error ("%s", "No input files specified."); | 921 error ("no input files specified.", 0); |
897 suggest_asking_for_help (); | 922 suggest_asking_for_help (); |
898 } | 923 } |
899 | 924 |
900 if (tagfile == NULL) | 925 if (tagfile == NULL) |
901 tagfile = CTAGS ? "tags" : "TAGS"; | 926 tagfile = CTAGS ? "tags" : "TAGS"; |
956 #ifdef VMS | 981 #ifdef VMS |
957 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL) | 982 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL) |
958 { | 983 { |
959 if (got_err) | 984 if (got_err) |
960 { | 985 { |
961 error ("Can't find file %s\n", this_file); | 986 error ("can't find file %s\n", this_file); |
962 argc--, argv++; | 987 argc--, argv++; |
963 } | 988 } |
964 else | 989 else |
965 { | 990 { |
966 this_file = massage_name (this_file); | 991 this_file = massage_name (this_file); |
1120 *p = '/'; | 1145 *p = '/'; |
1121 #endif | 1146 #endif |
1122 | 1147 |
1123 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode)) | 1148 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode)) |
1124 { | 1149 { |
1125 error ("Skipping %s: it is not a regular file.", file); | 1150 error ("skipping %s: it is not a regular file.", file); |
1126 return; | 1151 return; |
1127 } | 1152 } |
1128 if (streq (file, tagfile) && !streq (tagfile, "-")) | 1153 if (streq (file, tagfile) && !streq (tagfile, "-")) |
1129 { | 1154 { |
1130 error ("Skipping inclusion of %s in self.", file); | 1155 error ("skipping inclusion of %s in self.", file); |
1131 return; | 1156 return; |
1132 } | 1157 } |
1133 inf = fopen (file, "r"); | 1158 inf = fopen (file, "r"); |
1134 if (inf == NULL) | 1159 if (inf == NULL) |
1135 { | 1160 { |
1277 | 1302 |
1278 /* Record a tag. */ | 1303 /* Record a tag. */ |
1279 void | 1304 void |
1280 pfnote (name, is_func, linestart, linelen, lno, cno) | 1305 pfnote (name, is_func, linestart, linelen, lno, cno) |
1281 char *name; /* tag name, or NULL if unnamed */ | 1306 char *name; /* tag name, or NULL if unnamed */ |
1282 logical is_func; /* tag is a function */ | 1307 bool is_func; /* tag is a function */ |
1283 char *linestart; /* start of the line where tag is */ | 1308 char *linestart; /* start of the line where tag is */ |
1284 int linelen; /* length of the line where tag is */ | 1309 int linelen; /* length of the line where tag is */ |
1285 int lno; /* line number */ | 1310 int lno; /* line number */ |
1286 long cno; /* character number */ | 1311 long cno; /* character number */ |
1287 { | 1312 { |
1344 #define traditional_tag_style TRUE | 1369 #define traditional_tag_style TRUE |
1345 void | 1370 void |
1346 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno) | 1371 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno) |
1347 char *name; /* tag name, or NULL if unnamed */ | 1372 char *name; /* tag name, or NULL if unnamed */ |
1348 int namelen; /* tag length */ | 1373 int namelen; /* tag length */ |
1349 logical is_func; /* tag is a function */ | 1374 bool is_func; /* tag is a function */ |
1350 char *linestart; /* start of the line where tag is */ | 1375 char *linestart; /* start of the line where tag is */ |
1351 int linelen; /* length of the line where tag is */ | 1376 int linelen; /* length of the line where tag is */ |
1352 int lno; /* line number */ | 1377 int lno; /* line number */ |
1353 long cno; /* character number */ | 1378 long cno; /* character number */ |
1354 { | 1379 { |
1355 register char *cp; | 1380 register char *cp; |
1356 logical named; | 1381 bool named; |
1357 | 1382 |
1358 named = TRUE; | 1383 named = TRUE; |
1359 if (!CTAGS) | 1384 if (!CTAGS) |
1360 { | 1385 { |
1361 for (cp = name; !notinname (*cp); cp++) | 1386 for (cp = name; !notinname (*cp); cp++) |
1582 /* | 1607 /* |
1583 * The C symbol tables. | 1608 * The C symbol tables. |
1584 */ | 1609 */ |
1585 enum sym_type | 1610 enum sym_type |
1586 { | 1611 { |
1587 st_none, st_C_objprot, st_C_objimpl, st_C_objend, st_C_gnumacro, | 1612 st_none, |
1588 st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec, | 1613 st_C_objprot, st_C_objimpl, st_C_objend, |
1589 st_C_javastruct, st_C_javapack | 1614 st_C_gnumacro, |
1615 st_C_ignore, | |
1616 st_C_javastruct, | |
1617 st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec | |
1590 }; | 1618 }; |
1591 | 1619 |
1592 /* Feed stuff between (but not including) %[ and %] lines to: | 1620 /* Feed stuff between (but not including) %[ and %] lines to: |
1593 gperf -c -k 1,3 -o -p -r -t | 1621 gperf -c -k 1,3 -o -p -r -t |
1594 %[ | 1622 %[ |
1596 %% | 1624 %% |
1597 @interface, 0, st_C_objprot | 1625 @interface, 0, st_C_objprot |
1598 @protocol, 0, st_C_objprot | 1626 @protocol, 0, st_C_objprot |
1599 @implementation,0, st_C_objimpl | 1627 @implementation,0, st_C_objimpl |
1600 @end, 0, st_C_objend | 1628 @end, 0, st_C_objend |
1601 import, C_JAVA, st_C_javapack | 1629 import, C_JAVA, st_C_ignore |
1602 package, C_JAVA, st_C_javapack | 1630 package, C_JAVA, st_C_ignore |
1631 friend, C_PLPL, st_C_ignore | |
1603 extends, C_JAVA, st_C_javastruct | 1632 extends, C_JAVA, st_C_javastruct |
1604 implements, C_JAVA, st_C_javastruct | 1633 implements, C_JAVA, st_C_javastruct |
1605 class, C_PLPL, st_C_struct | 1634 class, C_PLPL, st_C_struct |
1606 namespace, C_PLPL, st_C_struct | 1635 namespace, C_PLPL, st_C_struct |
1607 domain, C_STAR, st_C_struct | 1636 domain, C_STAR, st_C_struct |
1638 #EXFUN, 0, st_C_gnumacro | 1667 #EXFUN, 0, st_C_gnumacro |
1639 #DEFVAR_, 0, st_C_gnumacro | 1668 #DEFVAR_, 0, st_C_gnumacro |
1640 %] | 1669 %] |
1641 and replace lines between %< and %> with its output. */ | 1670 and replace lines between %< and %> with its output. */ |
1642 /*%<*/ | 1671 /*%<*/ |
1643 /* starting time is 18:48:7 */ | 1672 /* starting time is 10:31:16 */ |
1644 /* C code produced by gperf version 2.1 (K&R C version) */ | 1673 /* C code produced by gperf version 2.1 (K&R C version) */ |
1645 /* Command-line: gperf -c -k 1,3 -o -p -r -t */ | 1674 /* Command-line: gperf -c -k 1,3 -o -p -r -t */ |
1646 | 1675 |
1647 | 1676 |
1648 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }; | 1677 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }; |
1649 | 1678 |
1650 #define MIN_WORD_LENGTH 3 | 1679 #define MIN_WORD_LENGTH 3 |
1651 #define MAX_WORD_LENGTH 15 | 1680 #define MAX_WORD_LENGTH 15 |
1652 #define MIN_HASH_VALUE 8 | 1681 #define MIN_HASH_VALUE 15 |
1653 #define MAX_HASH_VALUE 103 | 1682 #define MAX_HASH_VALUE 128 |
1654 /* | 1683 /* |
1655 38 keywords | 1684 39 keywords |
1656 96 is the maximum key range | 1685 114 is the maximum key range |
1657 */ | 1686 */ |
1658 | 1687 |
1659 static int | 1688 static int |
1660 hash (str, len) | 1689 hash (str, len) |
1661 register char *str; | 1690 register char *str; |
1662 register unsigned int len; | 1691 register unsigned int len; |
1663 { | 1692 { |
1664 static unsigned char hash_table[] = | 1693 static unsigned char hash_table[] = |
1665 { | 1694 { |
1666 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, | 1695 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
1667 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, | 1696 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
1668 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, | 1697 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
1669 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, | 1698 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
1670 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, | 1699 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
1671 103, 103, 103, 103, 103, 103, 103, 103, 103, 103, | 1700 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
1672 103, 103, 103, 103, 50, 103, 103, 103, 44, 15, | 1701 128, 128, 128, 128, 39, 128, 128, 128, 54, 48, |
1673 28, 103, 103, 103, 103, 103, 103, 103, 103, 103, | 1702 46, 128, 128, 128, 128, 128, 128, 128, 128, 128, |
1674 41, 103, 103, 27, 45, 103, 103, 103, 103, 103, | 1703 28, 128, 128, 40, 32, 128, 128, 128, 128, 128, |
1675 103, 103, 103, 103, 103, 103, 103, 26, 10, 52, | 1704 128, 128, 128, 128, 128, 128, 128, 24, 30, 47, |
1676 41, 38, 8, 21, 103, 47, 103, 103, 0, 27, | 1705 62, 7, 60, 27, 128, 60, 128, 128, 59, 16, |
1677 42, 17, 41, 103, 44, 22, 8, 33, 0, 103, | 1706 31, 23, 45, 128, 4, 14, 2, 55, 5, 128, |
1678 103, 103, 103, 103, 103, 103, 103, 103, | 1707 128, 128, 128, 128, 128, 128, 128, 128, |
1679 }; | 1708 }; |
1680 return len + hash_table[str[2]] + hash_table[str[0]]; | 1709 return len + hash_table[str[2]] + hash_table[str[0]]; |
1681 } | 1710 } |
1682 | 1711 |
1683 struct C_stab_entry * | 1712 struct C_stab_entry * |
1686 register unsigned int len; | 1715 register unsigned int len; |
1687 { | 1716 { |
1688 | 1717 |
1689 static struct C_stab_entry wordlist[] = | 1718 static struct C_stab_entry wordlist[] = |
1690 { | 1719 { |
1691 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, | |
1692 {"volatile", 0, st_C_typespec}, | |
1693 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, | 1720 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, |
1721 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, | |
1722 {"extern", 0, st_C_typespec}, | |
1723 {"extends", C_JAVA, st_C_javastruct}, | |
1724 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, | |
1725 {"struct", 0, st_C_struct}, | |
1726 {"mutable", C_PLPL, st_C_typespec}, | |
1727 {"",}, {"",}, {"",}, {"",}, | |
1728 {"auto", 0, st_C_typespec}, | |
1694 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, | 1729 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, |
1695 {"",}, {"",}, {"",}, | 1730 {"",}, {"",}, |
1696 {"float", 0, st_C_typespec}, | |
1697 {"bool", C_PLPL, st_C_typespec}, | |
1698 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, | |
1699 {"auto", 0, st_C_typespec}, | |
1700 {"",}, {"",}, {"",}, | |
1701 {"mutable", C_PLPL, st_C_typespec}, | |
1702 {"",}, | |
1703 {"short", 0, st_C_typespec}, | 1731 {"short", 0, st_C_typespec}, |
1704 {"",}, | 1732 {"",}, |
1705 {"long", 0, st_C_typespec}, | 1733 {"static", 0, st_C_typespec}, |
1706 {"",}, {"",}, | 1734 {"",}, {"",}, |
1707 {"signed", 0, st_C_typespec}, | 1735 {"signed", 0, st_C_typespec}, |
1736 {"",}, {"",}, {"",}, {"",}, | |
1737 {"@protocol", 0, st_C_objprot}, | |
1708 {"",}, | 1738 {"",}, |
1709 {"void", 0, st_C_typespec}, | |
1710 {"extern", 0, st_C_typespec}, | |
1711 {"extends", C_JAVA, st_C_javastruct}, | |
1712 {"static", 0, st_C_typespec}, | |
1713 {"define", 0, st_C_define}, | |
1714 {"typedef", 0, st_C_typedef}, | 1739 {"typedef", 0, st_C_typedef}, |
1715 {"typename", C_PLPL, st_C_typespec}, | 1740 {"typename", C_PLPL, st_C_typespec}, |
1741 {"namespace", C_PLPL, st_C_struct}, | |
1742 {"bool", C_PLPL, st_C_typespec}, | |
1743 {"",}, {"",}, | |
1744 {"explicit", C_PLPL, st_C_typespec}, | |
1745 {"",}, {"",}, {"",}, {"",}, | |
1716 {"int", 0, st_C_typespec}, | 1746 {"int", 0, st_C_typespec}, |
1747 {"enum", 0, st_C_enum}, | |
1717 {"",}, {"",}, | 1748 {"",}, {"",}, |
1718 {"SYSCALL", 0, st_C_gnumacro}, | 1749 {"void", 0, st_C_typespec}, |
1719 {"PSEUDO", 0, st_C_gnumacro}, | 1750 {"@implementation", 0, st_C_objimpl}, |
1720 {"unsigned", 0, st_C_typespec}, | |
1721 {"",}, | 1751 {"",}, |
1722 {"ENTRY", 0, st_C_gnumacro}, | 1752 {"volatile", 0, st_C_typespec}, |
1723 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, | |
1724 {"struct", 0, st_C_struct}, | |
1725 {"",}, | 1753 {"",}, |
1726 {"domain", C_STAR, st_C_struct}, | 1754 {"@end", 0, st_C_objend}, |
1727 {"enum", 0, st_C_enum}, | |
1728 {"",}, | |
1729 {"DEFUN", 0, st_C_gnumacro}, | |
1730 {"namespace", C_PLPL, st_C_struct}, | |
1731 {"",}, | |
1732 {"double", 0, st_C_typespec}, | |
1733 {"",}, | |
1734 {"char", 0, st_C_typespec}, | 1755 {"char", 0, st_C_typespec}, |
1735 {"class", C_PLPL, st_C_struct}, | 1756 {"class", C_PLPL, st_C_struct}, |
1757 {"unsigned", 0, st_C_typespec}, | |
1758 {"",}, {"",}, | |
1759 {"@interface", 0, st_C_objprot}, | |
1736 {"",}, | 1760 {"",}, |
1761 {"PSEUDO", 0, st_C_gnumacro}, | |
1762 {"const", 0, st_C_typespec}, | |
1763 {"domain", C_STAR, st_C_struct}, | |
1764 {"ENTRY", 0, st_C_gnumacro}, | |
1765 {"",}, | |
1766 {"SYSCALL", 0, st_C_gnumacro}, | |
1767 {"float", 0, st_C_typespec}, | |
1768 {"",}, {"",}, {"",}, {"",}, {"",}, | |
1769 {"long", 0, st_C_typespec}, | |
1770 {"",}, {"",}, {"",}, {"",}, | |
1771 {"package", C_JAVA, st_C_ignore}, | |
1772 {"",}, {"",}, {"",}, {"",}, {"",}, | |
1773 {"DEFUN", 0, st_C_gnumacro}, | |
1774 {"",}, {"",}, {"",}, {"",}, {"",}, | |
1775 {"import", C_JAVA, st_C_ignore}, | |
1776 {"",}, {"",}, {"",}, | |
1777 {"implements", C_JAVA, st_C_javastruct}, | |
1778 {"",}, {"",}, {"",}, {"",}, | |
1737 {"union", 0, st_C_struct}, | 1779 {"union", 0, st_C_struct}, |
1780 {"",}, {"",}, | |
1781 {"double", 0, st_C_typespec}, | |
1782 {"",}, {"",}, | |
1783 {"friend", C_PLPL, st_C_ignore}, | |
1738 {"",}, | 1784 {"",}, |
1739 {"explicit", C_PLPL, st_C_typespec}, | 1785 {"define", 0, st_C_define}, |
1740 {"",}, {"",}, {"",}, {"",}, | |
1741 {"@implementation", 0, st_C_objimpl}, | |
1742 {"",}, | |
1743 {"import", C_JAVA, st_C_javapack}, | |
1744 {"",}, | |
1745 {"@end", 0, st_C_objend}, | |
1746 {"",}, | |
1747 {"implements", C_JAVA, st_C_javastruct}, | |
1748 {"const", 0, st_C_typespec}, | |
1749 {"package", C_JAVA, st_C_javapack}, | |
1750 {"",}, | |
1751 {"@interface", 0, st_C_objprot}, | |
1752 {"@protocol", 0, st_C_objprot}, | |
1753 }; | 1786 }; |
1754 | 1787 |
1755 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) | 1788 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) |
1756 { | 1789 { |
1757 register int key = hash (str, len); | 1790 register int key = hash (str, len); |
1764 return &wordlist[key]; | 1797 return &wordlist[key]; |
1765 } | 1798 } |
1766 } | 1799 } |
1767 return 0; | 1800 return 0; |
1768 } | 1801 } |
1769 /* ending time is 18:48:7 */ | 1802 /* ending time is 10:31:16 */ |
1770 /*%>*/ | 1803 /*%>*/ |
1771 | 1804 |
1772 enum sym_type | 1805 enum sym_type |
1773 C_symtype (str, len, c_ext) | 1806 C_symtype (str, len, c_ext) |
1774 char *str; | 1807 char *str; |
1782 return se->type; | 1815 return se->type; |
1783 } | 1816 } |
1784 | 1817 |
1785 /* | 1818 /* |
1786 * C functions and variables are recognized using a simple | 1819 * C functions and variables are recognized using a simple |
1787 * finite automaton. fvdev is its state variable. | 1820 * finite automaton. fvdef is its state variable. |
1788 */ | 1821 */ |
1789 enum | 1822 enum |
1790 { | 1823 { |
1791 fvnone, /* nothing seen */ | 1824 fvnone, /* nothing seen */ |
1792 fvnameseen, /* function or variable name seen */ | 1825 fvnameseen, /* function or variable name seen */ |
1793 fstartlist, /* func: just after open parenthesis */ | 1826 fstartlist, /* func: just after open parenthesis */ |
1794 finlist, /* func: in parameter list */ | 1827 finlist, /* func: in parameter list */ |
1795 flistseen, /* func: after parameter list */ | 1828 flistseen, /* func: after parameter list */ |
1796 fignore, /* func: before open brace */ | 1829 fignore, /* func: before open brace */ |
1797 vignore /* var: ignore until ';' */ | 1830 vignore /* var-like: ignore until ';' */ |
1798 } fvdev; | 1831 } fvdef; |
1799 | 1832 |
1800 | 1833 |
1801 /* | 1834 /* |
1802 * typedefs are recognized using a simple finite automaton. | 1835 * typedefs are recognized using a simple finite automaton. |
1803 * typdef is its state variable. | 1836 * typdef is its state variable. |
1868 omethodcolon, /* after method colon */ | 1901 omethodcolon, /* after method colon */ |
1869 omethodparm, /* after method parameter */ | 1902 omethodparm, /* after method parameter */ |
1870 oignore /* wait for @end */ | 1903 oignore /* wait for @end */ |
1871 } objdef; | 1904 } objdef; |
1872 | 1905 |
1906 | |
1907 /* | |
1908 * Use this structure to keep info about the token read, and how it | |
1909 * should be tagged. Used by the make_C_tag function to build a tag. | |
1910 */ | |
1911 typedef struct | |
1912 { | |
1913 bool valid; | |
1914 char *str; | |
1915 bool named; | |
1916 int linelen; | |
1917 int lineno; | |
1918 long linepos; | |
1919 char *buffer; | |
1920 } TOKEN; | |
1921 TOKEN tok; /* latest token read */ | |
1922 | |
1923 | |
1873 /* | 1924 /* |
1874 * Set this to TRUE, and the next token considered is called a function. | 1925 * Set this to TRUE, and the next token considered is called a function. |
1875 * Used only for GNU emacs's function-defining macros. | 1926 * Used only for GNU emacs's function-defining macros. |
1876 */ | 1927 */ |
1877 logical next_token_is_func; | 1928 bool next_token_is_func; |
1878 | 1929 |
1879 /* | 1930 /* |
1880 * TRUE in the rules part of a yacc file, FALSE outside (parse as C). | 1931 * TRUE in the rules part of a yacc file, FALSE outside (parse as C). |
1881 */ | 1932 */ |
1882 logical yacc_rules; | 1933 bool yacc_rules; |
1883 | 1934 |
1884 /* | 1935 /* |
1885 * methodlen is the length of the method name stored in token_name. | 1936 * methodlen is the length of the method name stored in token_name. |
1886 */ | 1937 */ |
1887 int methodlen; | 1938 int methodlen; |
1899 * the token is; for instance, implementing the C++ keyword | 1950 * the token is; for instance, implementing the C++ keyword |
1900 * `operator' properly will adjust the end of the token to be after | 1951 * `operator' properly will adjust the end of the token to be after |
1901 * whatever follows `operator'. | 1952 * whatever follows `operator'. |
1902 * | 1953 * |
1903 * Globals | 1954 * Globals |
1904 * fvdev IN OUT | 1955 * fvdef IN OUT |
1905 * structdef IN OUT | 1956 * structdef IN OUT |
1906 * definedef IN OUT | 1957 * definedef IN OUT |
1907 * typdef IN OUT | 1958 * typdef IN OUT |
1908 * objdef IN OUT | 1959 * objdef IN OUT |
1909 * next_token_is_func IN OUT | 1960 * next_token_is_func IN OUT |
1910 */ | 1961 */ |
1911 | 1962 |
1912 logical | 1963 bool |
1913 consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var) | 1964 consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var) |
1914 register char *str; /* IN: token pointer */ | 1965 register char *str; /* IN: token pointer */ |
1915 register int len; /* IN: token length */ | 1966 register int len; /* IN: token length */ |
1916 register char c; /* IN: first char after the token */ | 1967 register char c; /* IN: first char after the token */ |
1917 int c_ext; /* IN: C extensions mask */ | 1968 int c_ext; /* IN: C extensions mask */ |
1918 int cblev; /* IN: curly brace level */ | 1969 int cblev; /* IN: curly brace level */ |
1919 int parlev; /* IN: parenthesis level */ | 1970 int parlev; /* IN: parenthesis level */ |
1920 logical *is_func_or_var; /* OUT: function or variable found */ | 1971 bool *is_func_or_var; /* OUT: function or variable found */ |
1921 { | 1972 { |
1922 enum sym_type toktype = C_symtype (str, len, c_ext); | 1973 enum sym_type toktype = C_symtype (str, len, c_ext); |
1923 | 1974 |
1924 /* | 1975 /* |
1925 * Advance the definedef state machine. | 1976 * Advance the definedef state machine. |
1964 case tnone: | 2015 case tnone: |
1965 if (toktype == st_C_typedef) | 2016 if (toktype == st_C_typedef) |
1966 { | 2017 { |
1967 if (typedefs) | 2018 if (typedefs) |
1968 typdef = ttypedseen; | 2019 typdef = ttypedseen; |
1969 fvdev = fvnone; | 2020 fvdef = fvnone; |
1970 return FALSE; | 2021 return FALSE; |
1971 } | 2022 } |
1972 break; | 2023 break; |
1973 case ttypedseen: | 2024 case ttypedseen: |
1974 switch (toktype) | 2025 switch (toktype) |
2008 { | 2059 { |
2009 case st_C_javastruct: | 2060 case st_C_javastruct: |
2010 if (structdef == stagseen) | 2061 if (structdef == stagseen) |
2011 structdef = scolonseen; | 2062 structdef = scolonseen; |
2012 return FALSE; | 2063 return FALSE; |
2013 break; | |
2014 case st_C_struct: | 2064 case st_C_struct: |
2015 case st_C_enum: | 2065 case st_C_enum: |
2016 if (typdef == ttypedseen | 2066 if (typdef == ttypedseen |
2017 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone)) | 2067 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone)) |
2018 { | 2068 { |
2032 structtag = "<enum>"; | 2082 structtag = "<enum>"; |
2033 structdef = stagseen; | 2083 structdef = stagseen; |
2034 return TRUE; | 2084 return TRUE; |
2035 } | 2085 } |
2036 | 2086 |
2037 /* Avoid entering fvdev stuff if typdef is going on. */ | 2087 /* Avoid entering fvdef stuff if typdef is going on. */ |
2038 if (typdef != tnone) | 2088 if (typdef != tnone) |
2039 { | 2089 { |
2040 definedef = dnone; | 2090 definedef = dnone; |
2041 return FALSE; | 2091 return FALSE; |
2042 } | 2092 } |
2061 return FALSE; | 2111 return FALSE; |
2062 } | 2112 } |
2063 if (next_token_is_func) | 2113 if (next_token_is_func) |
2064 { | 2114 { |
2065 next_token_is_func = FALSE; | 2115 next_token_is_func = FALSE; |
2066 fvdev = fignore; | 2116 fvdef = fignore; |
2067 *is_func_or_var = TRUE; | 2117 *is_func_or_var = TRUE; |
2068 return TRUE; | 2118 return TRUE; |
2069 } | 2119 } |
2070 | 2120 |
2071 /* Detect Objective C constructs. */ | 2121 /* Detect Objective C constructs. */ |
2142 | 2192 |
2143 /* A function, variable or enum constant? */ | 2193 /* A function, variable or enum constant? */ |
2144 switch (toktype) | 2194 switch (toktype) |
2145 { | 2195 { |
2146 case st_C_typespec: | 2196 case st_C_typespec: |
2147 if (fvdev != finlist && fvdev != fignore && fvdev != vignore) | 2197 if (fvdef != finlist && fvdef != fignore && fvdef != vignore) |
2148 fvdev = fvnone; /* should be useless */ | 2198 fvdef = fvnone; /* should be useless */ |
2149 return FALSE; | 2199 return FALSE; |
2150 case st_C_javapack: | 2200 case st_C_ignore: |
2151 fvdev = vignore; | 2201 fvdef = vignore; |
2152 return FALSE; | 2202 return FALSE; |
2153 case st_none: | 2203 case st_none: |
2154 if (constantypedefs && structdef == sinbody && structtype == st_C_enum) | 2204 if (constantypedefs && structdef == sinbody && structtype == st_C_enum) |
2155 return TRUE; | 2205 return TRUE; |
2156 if (fvdev == fvnone) | 2206 if (fvdef == fvnone) |
2157 { | 2207 { |
2158 fvdev = fvnameseen; /* function or variable */ | 2208 fvdef = fvnameseen; /* function or variable */ |
2159 *is_func_or_var = TRUE; | 2209 *is_func_or_var = TRUE; |
2160 return TRUE; | 2210 return TRUE; |
2161 } | 2211 } |
2162 } | 2212 } |
2163 | 2213 |
2168 * C_entries () | 2218 * C_entries () |
2169 * This routine finds functions, variables, typedefs, | 2219 * This routine finds functions, variables, typedefs, |
2170 * #define's, enum constants and struct/union/enum definitions in | 2220 * #define's, enum constants and struct/union/enum definitions in |
2171 * #C syntax and adds them to the list. | 2221 * #C syntax and adds them to the list. |
2172 */ | 2222 */ |
2173 typedef struct | |
2174 { | |
2175 logical valid; | |
2176 char *str; | |
2177 logical named; | |
2178 int linelen; | |
2179 int lineno; | |
2180 long linepos; | |
2181 char *buffer; | |
2182 } TOKEN; | |
2183 | |
2184 #define current_lb_is_new (newndx == curndx) | 2223 #define current_lb_is_new (newndx == curndx) |
2185 #define switch_line_buffers() (curndx = 1 - curndx) | 2224 #define switch_line_buffers() (curndx = 1 - curndx) |
2186 | 2225 |
2187 #define curlb (lbs[curndx].lb) | 2226 #define curlb (lbs[curndx].lb) |
2188 #define othlb (lbs[1-curndx].lb) | 2227 #define othlb (lbs[1-curndx].lb) |
2213 definedef = dnone; \ | 2252 definedef = dnone; \ |
2214 } while (0) | 2253 } while (0) |
2215 | 2254 |
2216 | 2255 |
2217 void | 2256 void |
2218 make_C_tag (isfun, tokp) | 2257 make_C_tag (isfun) |
2219 logical isfun; | 2258 bool isfun; |
2220 TOKEN *tokp; | |
2221 { | 2259 { |
2222 /* This function should never be called when tok.valid is FALSE, but | 2260 /* This function should never be called when tok.valid is FALSE, but |
2223 we must protect against invalid input or internal errors. */ | 2261 we must protect against invalid input or internal errors. */ |
2224 if (tokp->valid) | 2262 if (tok.valid) |
2225 { | 2263 { |
2226 if (traditional_tag_style) | 2264 if (traditional_tag_style) |
2227 { | 2265 { |
2228 /* This was the original code. Now we call new_pfnote instead, | 2266 /* This was the original code. Now we call new_pfnote instead, |
2229 which uses the new method for naming tags (see new_pfnote). */ | 2267 which uses the new method for naming tags (see new_pfnote). */ |
2230 char *name = NULL; | 2268 char *name = NULL; |
2231 | 2269 |
2232 if (CTAGS || tokp->named) | 2270 if (CTAGS || tok.named) |
2233 name = savestr (token_name.buffer); | 2271 name = savestr (token_name.buffer); |
2234 pfnote (name, isfun, | 2272 pfnote (name, isfun, |
2235 tokp->buffer, tokp->linelen, tokp->lineno, tokp->linepos); | 2273 tok.buffer, tok.linelen, tok.lineno, tok.linepos); |
2236 } | 2274 } |
2237 else | 2275 else |
2238 new_pfnote (token_name.buffer, token_name.len, isfun, | 2276 new_pfnote (token_name.buffer, token_name.len, isfun, |
2239 tokp->buffer, tokp->linelen, tokp->lineno, tokp->linepos); | 2277 tok.buffer, tok.linelen, tok.lineno, tok.linepos); |
2240 tokp->valid = FALSE; | 2278 tok.valid = FALSE; |
2241 } | 2279 } |
2242 else if (DEBUG) | 2280 else if (DEBUG) |
2243 abort (); | 2281 abort (); |
2244 } | 2282 } |
2245 | 2283 |
2250 FILE *inf; /* input file */ | 2288 FILE *inf; /* input file */ |
2251 { | 2289 { |
2252 register char c; /* latest char read; '\0' for end of line */ | 2290 register char c; /* latest char read; '\0' for end of line */ |
2253 register char *lp; /* pointer one beyond the character `c' */ | 2291 register char *lp; /* pointer one beyond the character `c' */ |
2254 int curndx, newndx; /* indices for current and new lb */ | 2292 int curndx, newndx; /* indices for current and new lb */ |
2255 TOKEN tok; /* latest token read */ | |
2256 register int tokoff; /* offset in line of start of current token */ | 2293 register int tokoff; /* offset in line of start of current token */ |
2257 register int toklen; /* length of current token */ | 2294 register int toklen; /* length of current token */ |
2258 char *qualifier; /* string used to qualify names */ | 2295 char *qualifier; /* string used to qualify names */ |
2259 int qlen; /* length of qualifier */ | 2296 int qlen; /* length of qualifier */ |
2260 int cblev; /* current curly brace level */ | 2297 int cblev; /* current curly brace level */ |
2261 int parlev; /* current parenthesis level */ | 2298 int parlev; /* current parenthesis level */ |
2262 logical incomm, inquote, inchar, quotednl, midtoken; | 2299 bool incomm, inquote, inchar, quotednl, midtoken; |
2263 logical cplpl, cjava; | 2300 bool cplpl, cjava; |
2264 TOKEN savetok; /* token saved during preprocessor handling */ | 2301 TOKEN savetok; /* token saved during preprocessor handling */ |
2265 | 2302 |
2266 | 2303 |
2267 curndx = newndx = 0; | 2304 curndx = newndx = 0; |
2268 lineno = 0; | 2305 lineno = 0; |
2269 charno = 0; | 2306 charno = 0; |
2270 lp = curlb.buffer; | 2307 lp = curlb.buffer; |
2271 *lp = 0; | 2308 *lp = 0; |
2272 | 2309 |
2273 fvdev = fvnone; typdef = tnone; structdef = snone; | 2310 fvdef = fvnone; typdef = tnone; structdef = snone; |
2274 definedef = dnone; objdef = onone; | 2311 definedef = dnone; objdef = onone; |
2275 next_token_is_func = yacc_rules = FALSE; | 2312 next_token_is_func = yacc_rules = FALSE; |
2276 midtoken = inquote = inchar = incomm = quotednl = FALSE; | 2313 midtoken = inquote = inchar = incomm = quotednl = FALSE; |
2277 tok.valid = savetok.valid = FALSE; | 2314 tok.valid = savetok.valid = FALSE; |
2278 cblev = 0; | 2315 cblev = 0; |
2352 else | 2389 else |
2353 switch (c) | 2390 switch (c) |
2354 { | 2391 { |
2355 case '"': | 2392 case '"': |
2356 inquote = TRUE; | 2393 inquote = TRUE; |
2357 if (fvdev != finlist && fvdev != fignore && fvdev !=vignore) | 2394 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore) |
2358 fvdev = fvnone; | 2395 fvdef = fvnone; |
2359 continue; | 2396 continue; |
2360 case '\'': | 2397 case '\'': |
2361 inchar = TRUE; | 2398 inchar = TRUE; |
2362 if (fvdev != finlist && fvdev != fignore && fvdev !=vignore) | 2399 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore) |
2363 fvdev = fvnone; | 2400 fvdef = fvnone; |
2364 continue; | 2401 continue; |
2365 case '/': | 2402 case '/': |
2366 if (*lp == '*') | 2403 if (*lp == '*') |
2367 { | 2404 { |
2368 lp++; | 2405 lp++; |
2379 case '%': | 2416 case '%': |
2380 if ((c_ext & YACC) && *lp == '%') | 2417 if ((c_ext & YACC) && *lp == '%') |
2381 { | 2418 { |
2382 /* entering or exiting rules section in yacc file */ | 2419 /* entering or exiting rules section in yacc file */ |
2383 lp++; | 2420 lp++; |
2384 definedef = dnone; fvdev = fvnone; | 2421 definedef = dnone; fvdef = fvnone; |
2385 typdef = tnone; structdef = snone; | 2422 typdef = tnone; structdef = snone; |
2386 next_token_is_func = FALSE; | 2423 next_token_is_func = FALSE; |
2387 midtoken = inquote = inchar = incomm = quotednl = FALSE; | 2424 midtoken = inquote = inchar = incomm = quotednl = FALSE; |
2388 cblev = 0; | 2425 cblev = 0; |
2389 yacc_rules = !yacc_rules; | 2426 yacc_rules = !yacc_rules; |
2393 break; | 2430 break; |
2394 case '#': | 2431 case '#': |
2395 if (definedef == dnone) | 2432 if (definedef == dnone) |
2396 { | 2433 { |
2397 char *cp; | 2434 char *cp; |
2398 logical cpptoken = TRUE; | 2435 bool cpptoken = TRUE; |
2399 | 2436 |
2400 /* Look back on this line. If all blanks, or nonblanks | 2437 /* Look back on this line. If all blanks, or nonblanks |
2401 followed by an end of comment, this is a preprocessor | 2438 followed by an end of comment, this is a preprocessor |
2402 token. */ | 2439 token. */ |
2403 for (cp = newlb.buffer; cp < lp-1; cp++) | 2440 for (cp = newlb.buffer; cp < lp-1; cp++) |
2424 || (cblev == 0 && structdef != scolonseen) | 2461 || (cblev == 0 && structdef != scolonseen) |
2425 || (cblev == 1 && cplpl && structdef == sinbody) | 2462 || (cblev == 1 && cplpl && structdef == sinbody) |
2426 || (structdef == sinbody && structtype == st_C_enum)) | 2463 || (structdef == sinbody && structtype == st_C_enum)) |
2427 && typdef != tignore | 2464 && typdef != tignore |
2428 && definedef != dignorerest | 2465 && definedef != dignorerest |
2429 && fvdev != finlist) | 2466 && fvdef != finlist) |
2430 { | 2467 { |
2431 if (midtoken) | 2468 if (midtoken) |
2432 { | 2469 { |
2433 if (endtoken (c)) | 2470 if (endtoken (c)) |
2434 { | 2471 { |
2441 lp += 2; | 2478 lp += 2; |
2442 toklen += 3; | 2479 toklen += 3; |
2443 } | 2480 } |
2444 else | 2481 else |
2445 { | 2482 { |
2446 logical funorvar = FALSE; | 2483 bool funorvar = FALSE; |
2447 | 2484 |
2448 if (yacc_rules | 2485 if (yacc_rules |
2449 || consider_token (newlb.buffer + tokoff, toklen, c, | 2486 || consider_token (newlb.buffer + tokoff, toklen, c, |
2450 c_ext, cblev, parlev, &funorvar)) | 2487 c_ext, cblev, parlev, &funorvar)) |
2451 { | 2488 { |
2501 tok.buffer = newlb.buffer; | 2538 tok.buffer = newlb.buffer; |
2502 tok.linepos = newlinepos; | 2539 tok.linepos = newlinepos; |
2503 tok.valid = TRUE; | 2540 tok.valid = TRUE; |
2504 | 2541 |
2505 if (definedef == dnone | 2542 if (definedef == dnone |
2506 && (fvdev == fvnameseen | 2543 && (fvdef == fvnameseen |
2507 || structdef == stagseen | 2544 || structdef == stagseen |
2508 || typdef == tend | 2545 || typdef == tend |
2509 || objdef != onone)) | 2546 || objdef != onone)) |
2510 { | 2547 { |
2511 if (current_lb_is_new) | 2548 if (current_lb_is_new) |
2512 switch_line_buffers (); | 2549 switch_line_buffers (); |
2513 } | 2550 } |
2514 else | 2551 else |
2515 make_C_tag (funorvar, &tok); | 2552 make_C_tag (funorvar); |
2516 } | 2553 } |
2517 midtoken = FALSE; | 2554 midtoken = FALSE; |
2518 } | 2555 } |
2519 } /* if (endtoken (c)) */ | 2556 } /* if (endtoken (c)) */ |
2520 else if (intoken (c)) | 2557 else if (intoken (c)) |
2526 else if (begtoken (c)) | 2563 else if (begtoken (c)) |
2527 { | 2564 { |
2528 switch (definedef) | 2565 switch (definedef) |
2529 { | 2566 { |
2530 case dnone: | 2567 case dnone: |
2531 switch (fvdev) | 2568 switch (fvdef) |
2532 { | 2569 { |
2533 case fstartlist: | 2570 case fstartlist: |
2534 fvdev = finlist; | 2571 fvdef = finlist; |
2535 continue; | 2572 continue; |
2536 case flistseen: | 2573 case flistseen: |
2537 make_C_tag (TRUE, &tok); /* a function */ | 2574 make_C_tag (TRUE); /* a function */ |
2538 fvdev = fignore; | 2575 fvdef = fignore; |
2539 break; | 2576 break; |
2540 case fvnameseen: | 2577 case fvnameseen: |
2541 fvdev = fvnone; | 2578 fvdef = fvnone; |
2542 break; | 2579 break; |
2543 } | 2580 } |
2544 if (structdef == stagseen && !cjava) | 2581 if (structdef == stagseen && !cjava) |
2545 structdef = snone; | 2582 structdef = snone; |
2546 break; | 2583 break; |
2567 break; | 2604 break; |
2568 switch (objdef) | 2605 switch (objdef) |
2569 { | 2606 { |
2570 case otagseen: | 2607 case otagseen: |
2571 objdef = oignore; | 2608 objdef = oignore; |
2572 make_C_tag (TRUE, &tok); /* an Objective C class */ | 2609 make_C_tag (TRUE); /* an Objective C class */ |
2573 break; | 2610 break; |
2574 case omethodtag: | 2611 case omethodtag: |
2575 case omethodparm: | 2612 case omethodparm: |
2576 objdef = omethodcolon; | 2613 objdef = omethodcolon; |
2577 methodlen += 1; | 2614 methodlen += 1; |
2581 break; | 2618 break; |
2582 } | 2619 } |
2583 if (structdef == stagseen) | 2620 if (structdef == stagseen) |
2584 structdef = scolonseen; | 2621 structdef = scolonseen; |
2585 else | 2622 else |
2586 switch (fvdev) | 2623 switch (fvdef) |
2587 { | 2624 { |
2588 case fvnameseen: | 2625 case fvnameseen: |
2589 if (yacc_rules) | 2626 if (yacc_rules) |
2590 { | 2627 { |
2591 make_C_tag (FALSE, &tok); /* a yacc function */ | 2628 make_C_tag (FALSE); /* a yacc function */ |
2592 fvdev = fignore; | 2629 fvdef = fignore; |
2593 } | 2630 } |
2594 break; | 2631 break; |
2595 case fstartlist: | 2632 case fstartlist: |
2596 fvdev = fvnone; | 2633 fvdef = fvnone; |
2597 break; | 2634 break; |
2598 } | 2635 } |
2599 break; | 2636 break; |
2600 case ';': | 2637 case ';': |
2601 if (definedef != dnone) | 2638 if (definedef != dnone) |
2602 break; | 2639 break; |
2603 if (cblev == 0) | 2640 if (cblev == 0) |
2604 switch (typdef) | 2641 switch (typdef) |
2605 { | 2642 { |
2606 case tend: | 2643 case tend: |
2607 make_C_tag (FALSE, &tok); /* a typedef */ | 2644 make_C_tag (FALSE); /* a typedef */ |
2608 /* FALLTHRU */ | 2645 /* FALLTHRU */ |
2609 default: | 2646 default: |
2610 typdef = tnone; | 2647 typdef = tnone; |
2611 } | 2648 } |
2612 switch (fvdev) | 2649 switch (fvdef) |
2613 { | 2650 { |
2614 case fignore: | 2651 case fignore: |
2615 break; | 2652 break; |
2616 case fvnameseen: | 2653 case fvnameseen: |
2617 if ((variables && cblev == 0) | 2654 if ((globals && cblev == 0) || (members && cblev == 1)) |
2618 || (cplpl && variables_and_cplusplus && cblev == 1)) | 2655 make_C_tag (FALSE); /* a variable */ |
2619 make_C_tag (FALSE, &tok); /* a variable */ | |
2620 /* FALLTHRU */ | 2656 /* FALLTHRU */ |
2621 default: | 2657 default: |
2622 fvdev = fvnone; | 2658 fvdef = fvnone; |
2623 /* The following instruction invalidates the token. | 2659 /* The following instruction invalidates the token. |
2624 Probably the token should be invalidated in all | 2660 Probably the token should be invalidated in all |
2625 other cases where some state machine is reset. */ | 2661 other cases where some state machine is reset. */ |
2626 tok.valid = FALSE; | 2662 tok.valid = FALSE; |
2627 } | 2663 } |
2633 break; | 2669 break; |
2634 switch (objdef) | 2670 switch (objdef) |
2635 { | 2671 { |
2636 case omethodtag: | 2672 case omethodtag: |
2637 case omethodparm: | 2673 case omethodparm: |
2638 make_C_tag (TRUE, &tok); /* an Objective C method */ | 2674 make_C_tag (TRUE); /* an Objective C method */ |
2639 objdef = oinbody; | 2675 objdef = oinbody; |
2640 break; | 2676 break; |
2641 } | 2677 } |
2642 switch (fvdev) | 2678 switch (fvdef) |
2643 { | 2679 { |
2644 case finlist: | 2680 case finlist: |
2645 case fignore: | 2681 case fignore: |
2646 case vignore: | 2682 case vignore: |
2647 break; | 2683 break; |
2648 case fvnameseen: | 2684 case fvnameseen: |
2649 if ((variables && cblev == 0) | 2685 if ((globals && cblev == 0) || (members && cblev == 1)) |
2650 || (cplpl && variables_and_cplusplus && cblev == 1)) | 2686 make_C_tag (FALSE); /* a variable */ |
2651 make_C_tag (FALSE, &tok); /* a variable */ | |
2652 break; | 2687 break; |
2653 default: | 2688 default: |
2654 fvdev = fvnone; | 2689 fvdef = fvnone; |
2655 } | 2690 } |
2656 break; | |
2657 if (structdef == stagseen) | 2691 if (structdef == stagseen) |
2658 structdef = snone; | 2692 structdef = snone; |
2659 break; | 2693 break; |
2660 case '[': | 2694 case '[': |
2661 if (definedef != dnone) | 2695 if (definedef != dnone) |
2662 break; | 2696 break; |
2663 if (cblev == 0 && typdef == tend) | 2697 if (cblev == 0 && typdef == tend) |
2664 { | 2698 { |
2665 typdef = tignore; | 2699 typdef = tignore; |
2666 make_C_tag (FALSE, &tok); /* a typedef */ | 2700 make_C_tag (FALSE); /* a typedef */ |
2667 break; | 2701 break; |
2668 } | 2702 } |
2669 switch (fvdev) | 2703 switch (fvdef) |
2670 { | 2704 { |
2671 case finlist: | 2705 case finlist: |
2672 case fignore: | 2706 case fignore: |
2673 case vignore: | 2707 case vignore: |
2674 break; | 2708 break; |
2675 case fvnameseen: | 2709 case fvnameseen: |
2676 if ((variables && cblev == 0) | 2710 if ((globals && cblev == 0) || (members && cblev == 1)) |
2677 || (cplpl && variables_and_cplusplus && cblev == 1)) | 2711 make_C_tag (FALSE); /* a variable */ |
2678 make_C_tag (FALSE, &tok); /* a variable */ | |
2679 /* FALLTHRU */ | 2712 /* FALLTHRU */ |
2680 default: | 2713 default: |
2681 fvdev = fvnone; | 2714 fvdef = fvnone; |
2682 } | 2715 } |
2683 if (structdef == stagseen) | 2716 if (structdef == stagseen) |
2684 structdef = snone; | 2717 structdef = snone; |
2685 break; | 2718 break; |
2686 case '(': | 2719 case '(': |
2687 if (definedef != dnone) | 2720 if (definedef != dnone) |
2688 break; | 2721 break; |
2689 if (objdef == otagseen && parlev == 0) | 2722 if (objdef == otagseen && parlev == 0) |
2690 objdef = oparenseen; | 2723 objdef = oparenseen; |
2691 switch (fvdev) | 2724 switch (fvdef) |
2692 { | 2725 { |
2693 case fvnone: | 2726 case fvnone: |
2694 switch (typdef) | 2727 switch (typdef) |
2695 { | 2728 { |
2696 case ttypedseen: | 2729 case ttypedseen: |
2697 case tend: | 2730 case tend: |
2698 if (tok.valid && *lp != '*') | 2731 if (tok.valid && *lp != '*') |
2699 { | 2732 { |
2700 /* This handles constructs like: | 2733 /* This handles constructs like: |
2701 typedef void OperatorFun (int fun); */ | 2734 typedef void OperatorFun (int fun); */ |
2702 make_C_tag (FALSE, &tok); | 2735 make_C_tag (FALSE); |
2703 typdef = tignore; | 2736 typdef = tignore; |
2704 } | 2737 } |
2705 break; | 2738 break; |
2706 } /* switch (typdef) */ | 2739 } /* switch (typdef) */ |
2707 break; | 2740 break; |
2708 case fvnameseen: | 2741 case fvnameseen: |
2709 fvdev = fstartlist; | 2742 fvdef = fstartlist; |
2710 break; | 2743 break; |
2711 case flistseen: | 2744 case flistseen: |
2712 fvdev = finlist; | 2745 fvdef = finlist; |
2713 break; | 2746 break; |
2714 } | 2747 } |
2715 parlev++; | 2748 parlev++; |
2716 break; | 2749 break; |
2717 case ')': | 2750 case ')': |
2718 if (definedef != dnone) | 2751 if (definedef != dnone) |
2719 break; | 2752 break; |
2720 if (objdef == ocatseen && parlev == 1) | 2753 if (objdef == ocatseen && parlev == 1) |
2721 { | 2754 { |
2722 make_C_tag (TRUE, &tok); /* an Objective C category */ | 2755 make_C_tag (TRUE); /* an Objective C category */ |
2723 objdef = oignore; | 2756 objdef = oignore; |
2724 } | 2757 } |
2725 if (--parlev == 0) | 2758 if (--parlev == 0) |
2726 { | 2759 { |
2727 switch (fvdev) | 2760 switch (fvdef) |
2728 { | 2761 { |
2729 case fstartlist: | 2762 case fstartlist: |
2730 case finlist: | 2763 case finlist: |
2731 fvdev = flistseen; | 2764 fvdef = flistseen; |
2732 break; | 2765 break; |
2733 } | 2766 } |
2734 if (cblev == 0 && typdef == tend) | 2767 if (cblev == 0 && typdef == tend) |
2735 { | 2768 { |
2736 typdef = tignore; | 2769 typdef = tignore; |
2737 make_C_tag (FALSE, &tok); /* a typedef */ | 2770 make_C_tag (FALSE); /* a typedef */ |
2738 } | 2771 } |
2739 } | 2772 } |
2740 else if (parlev < 0) /* can happen due to ill-conceived #if's. */ | 2773 else if (parlev < 0) /* can happen due to ill-conceived #if's. */ |
2741 parlev = 0; | 2774 parlev = 0; |
2742 break; | 2775 break; |
2752 structtag = "_anonymous_"; | 2785 structtag = "_anonymous_"; |
2753 break; | 2786 break; |
2754 case stagseen: | 2787 case stagseen: |
2755 case scolonseen: /* named struct */ | 2788 case scolonseen: /* named struct */ |
2756 structdef = sinbody; | 2789 structdef = sinbody; |
2757 make_C_tag (FALSE, &tok); /* a struct */ | 2790 make_C_tag (FALSE); /* a struct */ |
2758 break; | 2791 break; |
2759 } | 2792 } |
2760 switch (fvdev) | 2793 switch (fvdef) |
2761 { | 2794 { |
2762 case flistseen: | 2795 case flistseen: |
2763 make_C_tag (TRUE, &tok); /* a function */ | 2796 make_C_tag (TRUE); /* a function */ |
2764 /* FALLTHRU */ | 2797 /* FALLTHRU */ |
2765 case fignore: | 2798 case fignore: |
2766 fvdev = fvnone; | 2799 fvdef = fvnone; |
2767 break; | 2800 break; |
2768 case fvnone: | 2801 case fvnone: |
2769 switch (objdef) | 2802 switch (objdef) |
2770 { | 2803 { |
2771 case otagseen: | 2804 case otagseen: |
2772 make_C_tag (TRUE, &tok); /* an Objective C class */ | 2805 make_C_tag (TRUE); /* an Objective C class */ |
2773 objdef = oignore; | 2806 objdef = oignore; |
2774 break; | 2807 break; |
2775 case omethodtag: | 2808 case omethodtag: |
2776 case omethodparm: | 2809 case omethodparm: |
2777 make_C_tag (TRUE, &tok); /* an Objective C method */ | 2810 make_C_tag (TRUE); /* an Objective C method */ |
2778 objdef = oinbody; | 2811 objdef = oinbody; |
2779 break; | 2812 break; |
2780 default: | 2813 default: |
2781 /* Neutralize `extern "C" {' grot. */ | 2814 /* Neutralize `extern "C" {' grot. */ |
2782 if (cblev == 0 && structdef == snone && typdef == tnone) | 2815 if (cblev == 0 && structdef == snone && typdef == tnone) |
2786 cblev++; | 2819 cblev++; |
2787 break; | 2820 break; |
2788 case '*': | 2821 case '*': |
2789 if (definedef != dnone) | 2822 if (definedef != dnone) |
2790 break; | 2823 break; |
2791 if (fvdev == fstartlist) | 2824 if (fvdef == fstartlist) |
2792 fvdev = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */ | 2825 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */ |
2793 break; | 2826 break; |
2794 case '}': | 2827 case '}': |
2795 if (definedef != dnone) | 2828 if (definedef != dnone) |
2796 break; | 2829 break; |
2797 if (!noindentypedefs && lp == newlb.buffer + 1) | 2830 if (!noindentypedefs && lp == newlb.buffer + 1) |
2818 } | 2851 } |
2819 break; | 2852 break; |
2820 case '=': | 2853 case '=': |
2821 if (definedef != dnone) | 2854 if (definedef != dnone) |
2822 break; | 2855 break; |
2823 switch (fvdev) | 2856 switch (fvdef) |
2824 { | 2857 { |
2825 case finlist: | 2858 case finlist: |
2826 case fignore: | 2859 case fignore: |
2827 case vignore: | 2860 case vignore: |
2828 break; | 2861 break; |
2829 case fvnameseen: | 2862 case fvnameseen: |
2830 if ((variables && cblev == 0) | 2863 if ((globals && cblev == 0) || (members && cblev == 1)) |
2831 || (cplpl && variables_and_cplusplus && cblev == 1)) | 2864 make_C_tag (FALSE); /* a variable */ |
2832 make_C_tag (FALSE, &tok); /* a variable */ | |
2833 /* FALLTHRU */ | 2865 /* FALLTHRU */ |
2834 default: | 2866 default: |
2835 fvdev = vignore; | 2867 fvdef = vignore; |
2836 } | 2868 } |
2837 break; | 2869 break; |
2838 case '+': | 2870 case '+': |
2839 case '-': | 2871 case '-': |
2840 if (objdef == oinbody && cblev == 0) | 2872 if (objdef == oinbody && cblev == 0) |
2846 case '#': case '~': case '&': case '%': case '/': case '|': | 2878 case '#': case '~': case '&': case '%': case '/': case '|': |
2847 case '^': case '!': case '<': case '>': case '.': case '?': case ']': | 2879 case '^': case '!': case '<': case '>': case '.': case '?': case ']': |
2848 if (definedef != dnone) | 2880 if (definedef != dnone) |
2849 break; | 2881 break; |
2850 /* These surely cannot follow a function tag. */ | 2882 /* These surely cannot follow a function tag. */ |
2851 if (fvdev != finlist && fvdev != fignore && fvdev != vignore) | 2883 if (fvdef != finlist && fvdef != fignore && fvdef != vignore) |
2852 fvdev = fvnone; | 2884 fvdef = fvnone; |
2853 break; | 2885 break; |
2854 case '\0': | 2886 case '\0': |
2855 if (objdef == otagseen) | 2887 if (objdef == otagseen) |
2856 { | 2888 { |
2857 make_C_tag (TRUE, &tok); /* an Objective C class */ | 2889 make_C_tag (TRUE); /* an Objective C class */ |
2858 objdef = oignore; | 2890 objdef = oignore; |
2859 } | 2891 } |
2860 /* If a macro spans multiple lines don't reset its state. */ | 2892 /* If a macro spans multiple lines don't reset its state. */ |
2861 if (quotednl) | 2893 if (quotednl) |
2862 CNL_SAVE_DEFINEDEF; | 2894 CNL_SAVE_DEFINEDEF; |
2895 C_entries (C_PLPL, inf); | 2927 C_entries (C_PLPL, inf); |
2896 } | 2928 } |
2897 | 2929 |
2898 /* Always do Java. */ | 2930 /* Always do Java. */ |
2899 void | 2931 void |
2900 Cjava_entries (FILE *inf) | 2932 Cjava_entries (inf) |
2933 FILE *inf; | |
2901 { | 2934 { |
2902 C_entries (C_JAVA, inf); | 2935 C_entries (C_JAVA, inf); |
2903 } | 2936 } |
2904 | 2937 |
2905 /* Always do C*. */ | 2938 /* Always do C*. */ |
2920 | 2953 |
2921 /* Fortran parsing */ | 2954 /* Fortran parsing */ |
2922 | 2955 |
2923 char *dbp; | 2956 char *dbp; |
2924 | 2957 |
2925 logical | 2958 bool |
2926 tail (cp) | 2959 tail (cp) |
2927 char *cp; | 2960 char *cp; |
2928 { | 2961 { |
2929 register int len = 0; | 2962 register int len = 0; |
2930 | 2963 |
3200 struct linebuffer tline; /* mostly copied from C_entries */ | 3233 struct linebuffer tline; /* mostly copied from C_entries */ |
3201 long save_lcno; | 3234 long save_lcno; |
3202 int save_lineno, save_len; | 3235 int save_lineno, save_len; |
3203 char c, *cp, *namebuf; | 3236 char c, *cp, *namebuf; |
3204 | 3237 |
3205 logical /* each of these flags is TRUE iff: */ | 3238 bool /* each of these flags is TRUE iff: */ |
3206 incomment, /* point is inside a comment */ | 3239 incomment, /* point is inside a comment */ |
3207 inquote, /* point is inside '..' string */ | 3240 inquote, /* point is inside '..' string */ |
3208 get_tagname, /* point is after PROCEDURE/FUNCTION | 3241 get_tagname, /* point is after PROCEDURE/FUNCTION |
3209 keyword, so next item = potential tag */ | 3242 keyword, so next item = potential tag */ |
3210 found_tag, /* point is after a potential tag */ | 3243 found_tag, /* point is after a potential tag */ |
4138 scan_separators (name) | 4171 scan_separators (name) |
4139 char *name; | 4172 char *name; |
4140 { | 4173 { |
4141 char sep = name[0]; | 4174 char sep = name[0]; |
4142 char *copyto = name; | 4175 char *copyto = name; |
4143 logical quoted = FALSE; | 4176 bool quoted = FALSE; |
4144 | 4177 |
4145 for (++name; *name != '\0'; ++name) | 4178 for (++name; *name != '\0'; ++name) |
4146 { | 4179 { |
4147 if (quoted) | 4180 if (quoted) |
4148 { | 4181 { |