Changeset 4140 for trunk/lib-src/etags.c
- Timestamp:
- 08/10/06 11:19:54 (2 years ago)
- Files:
-
- trunk/lib-src/etags.c (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib-src/etags.c
r4111 r4140 42 42 */ 43 43 44 char pot_etags_version[] = "@(#) pot revision number is 17. 18";44 char pot_etags_version[] = "@(#) pot revision number is 17.20"; 45 45 46 46 #define TRUE 1 … … 60 60 of unexec. We don't want that here since we don't use unexec. */ 61 61 # undef static 62 # define ETAGS_REGEXPS /* use the regexp features */ 63 # define LONG_OPTIONS /* accept long options */ 64 # ifndef PTR /* for Xemacs */ 62 # ifndef PTR /* for XEmacs */ 65 63 # define PTR void * 66 64 # endif 67 # ifndef __P /* for X emacs */65 # ifndef __P /* for XEmacs */ 68 66 # define __P(args) args 69 67 # endif … … 83 81 #endif 84 82 85 #ifdef LONG_OPTIONS 86 # undef LONG_OPTIONS 87 # define LONG_OPTIONS TRUE 88 #else 89 # define LONG_OPTIONS FALSE 90 #endif 91 92 /* WIN32_NATIVE is for Xemacs. 83 /* WIN32_NATIVE is for XEmacs. 93 84 MSDOS, WINDOWSNT, DOS_NT are for Emacs. */ 94 85 #ifdef WIN32_NATIVE … … 168 159 #endif 169 160 170 #if LONG_OPTIONS 171 # include <getopt.h> 172 #else 161 #ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */ 162 # define NO_LONG_OPTIONS TRUE 173 163 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) 174 164 extern char *optarg; 175 165 extern int optind, opterr; 176 #endif /* LONG_OPTIONS */ 177 178 #ifdef ETAGS_REGEXPS 179 # ifndef HAVE_CONFIG_H /* this is a standalone compilation */ 180 # ifdef __CYGWIN__ /* compiling on Cygwin */ 166 #else 167 # define NO_LONG_OPTIONS FALSE 168 # include <getopt.h> 169 #endif /* NO_LONG_OPTIONS */ 170 171 #ifndef HAVE_CONFIG_H /* this is a standalone compilation */ 172 # ifdef __CYGWIN__ /* compiling on Cygwin */ 181 173 !!! NOTICE !!! 182 174 the regex.h distributed with Cygwin is not compatible with etags, alas! 183 175 If you want regular expression support, you should delete this notice and 184 176 arrange to use the GNU regex.h and regex.c. 185 # endif186 177 # endif 187 # include <regex.h>188 # endif /* ETAGS_REGEXPS */178 #endif 179 #include <regex.h> 189 180 190 181 /* Define CTAGS to make the program "ctags" compatible with the usual one. … … 313 304 } argument; 314 305 315 #ifdef ETAGS_REGEXPS316 306 /* Structure defining a regular expression. */ 317 307 typedef struct regexp … … 328 318 bool multi_line; /* do a multi-line match on the whole file */ 329 319 } regexp; 330 #endif /* ETAGS_REGEXPS */331 320 332 321 … … 376 365 static void get_tag __P((char *, char **)); 377 366 378 #ifdef ETAGS_REGEXPS379 367 static void analyse_regex __P((char *)); 380 368 static void free_regexps __P((void)); 381 369 static void regex_tag_multiline __P((void)); 382 #endif /* ETAGS_REGEXPS */383 370 static void error __P((const char *, const char *)); 384 371 static void suggest_asking_for_help __P((void)); … … 486 473 static bool parsing_stdin; /* --parse-stdin used */ 487 474 488 #ifdef ETAGS_REGEXPS489 475 static regexp *p_head; /* list of all regexps */ 490 476 static bool need_filebuf; /* some regexes are multi-line */ 491 #else 492 # define need_filebuf FALSE 493 #endif /* ETAGS_REGEXPS */ 494 495 #if LONG_OPTIONS 477 496 478 static struct option longopts[] = 497 479 { … … 508 490 { "no-members", no_argument, &members, FALSE }, 509 491 { "output", required_argument, NULL, 'o' }, 510 #ifdef ETAGS_REGEXPS511 492 { "regex", required_argument, NULL, 'r' }, 512 493 { "no-regex", no_argument, NULL, 'R' }, 513 494 { "ignore-case-regex", required_argument, NULL, 'c' }, 514 #endif /* ETAGS_REGEXPS */515 495 { "parse-stdin", required_argument, NULL, STDIN }, 516 496 { "version", no_argument, NULL, 'V' }, … … 534 514 { NULL } 535 515 }; 536 #endif /* LONG_OPTIONS */537 516 538 517 static compressor compressors[] = … … 682 661 "In Objective C code, tags include Objective C definitions for classes,\n\ 683 662 class categories, methods and protocols. Tags for variables and\n\ 684 functions in classes are named `CLASS::VARIABLE' and `CLASS::FUNCTION'."; 663 functions in classes are named `CLASS::VARIABLE' and `CLASS::FUNCTION'.\n\ 664 (Use --help --lang=c --lang=objc --lang=java for full help.)"; 685 665 686 666 static char *Pascal_suffixes [] = … … 689 669 "In Pascal code, the tags are the functions and procedures defined\n\ 690 670 in the file."; 671 /* " // this is for working around an Emacs highlighting bug... */ 691 672 692 673 static char *Perl_suffixes [] = … … 886 867 \n\ 887 868 These are the options accepted by %s.\n", progname, progname); 888 if (LONG_OPTIONS) 869 if (NO_LONG_OPTIONS) 870 puts ("WARNING: long option names do not work with this executable,\n\ 871 as it is not linked with GNU getopt."); 872 else 889 873 puts ("You may use unambiguous abbreviations for the long option names."); 890 else891 puts ("Long option names do not work with this executable, as it is not\n\892 linked with GNU getopt.");893 874 puts (" A - as file name means read names from stdin (one per line).\n\ 894 875 Absolute names are stored in the output file as they are.\n\ … … 950 931 Create tag entries for members of structures in some languages."); 951 932 952 #ifdef ETAGS_REGEXPS953 933 puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\ 954 934 Make a tag for each line matching a regular expression pattern\n\ … … 965 945 puts ("-R, --no-regex\n\ 966 946 Don't create tags from regexps for the following files."); 967 #endif /* ETAGS_REGEXPS */968 947 puts ("-I, --ignore-indentation\n\ 969 948 In C and C++ do not assume that a closing brace in the first\n\ … … 1195 1174 /* When the optstring begins with a '-' getopt_long does not rearrange the 1196 1175 non-options arguments to be at the end, but leaves them alone. */ 1197 optstring = "-"; 1198 #ifdef ETAGS_REGEXPS 1199 optstring = "-r:Rc:"; 1200 #endif /* ETAGS_REGEXPS */ 1201 if (!LONG_OPTIONS) 1202 optstring += 1; /* remove the initial '-' */ 1203 optstring = concat (optstring, 1204 "aCf:Il:o:SVhH", 1176 optstring = concat (NO_LONG_OPTIONS ? "" : "-", 1177 "ac:Cf:Il:o:r:RSVhH", 1205 1178 (CTAGS) ? "BxdtTuvw" : "Di:"); 1206 1179 … … 1376 1349 lang = argbuffer[i].lang; 1377 1350 break; 1378 #ifdef ETAGS_REGEXPS1379 1351 case at_regexp: 1380 1352 analyse_regex (argbuffer[i].what); 1381 1353 break; 1382 #endif1383 1354 case at_filename: 1384 1355 #ifdef VMS … … 1420 1391 } 1421 1392 1422 #ifdef ETAGS_REGEXPS1423 1393 free_regexps (); 1424 #endif /* ETAGS_REGEXPS */1425 1394 free (lb.buffer); 1426 1395 free (filebuf.buffer); … … 1980 1949 parser (inf); 1981 1950 1982 #ifdef ETAGS_REGEXPS1983 1951 regex_tag_multiline (); 1984 #endif /* ETAGS_REGEXPS */1985 1952 } 1986 1953 … … 3240 3207 bool incomm, inquote, inchar, quotednl, midtoken; 3241 3208 bool yacc_rules; /* in the rules part of a yacc file */ 3242 struct tok savetoken ;/* token saved during preprocessor handling */3209 struct tok savetoken = {0}; /* token saved during preprocessor handling */ 3243 3210 3244 3211 … … 5199 5166 /* Skip to next line if we hit the TeX comment char. */ 5200 5167 if (c == '%') 5201 while (c != '\n' )5168 while (c != '\n' && c != EOF) 5202 5169 c = getc (inf); 5203 5170 else if (c == TEX_LESC || c == TEX_SESC ) … … 5736 5703 5737 5704 5738 #ifdef ETAGS_REGEXPS5739 5740 5705 static char *scan_separators __P((char *)); 5741 5706 static void add_regex __P((char *, language *)); … … 6142 6107 } 6143 6108 6144 #endif /* ETAGS_REGEXPS */6145 6146 6109 6147 6110 static bool … … 6297 6260 6298 6261 if (DEBUG) start = 0; /* shut up the compiler */ 6299 if (sscanf (lbp->buffer, "#line %d \"%n", &lno, &start) == 1) 6300 { 6301 char *endp = lbp->buffer + start; 6262 if (sscanf (lbp->buffer, "#line %d %n\"", &lno, &start) >= 1 6263 && lbp->buffer[start] == '"') 6264 { 6265 char *endp = lbp->buffer + ++start; 6302 6266 6303 6267 assert (start > 0); … … 6406 6370 } /* if #line directives should be considered */ 6407 6371 6408 #ifdef ETAGS_REGEXPS6409 6372 { 6410 6373 int match; … … 6463 6426 } 6464 6427 } 6465 #endif /* ETAGS_REGEXPS */6466 6428 } 6467 6429 … … 6624 6586 { 6625 6587 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n", 6626 progname, LONG_OPTIONS ? "--help" : "-h");6588 progname, NO_LONG_OPTIONS ? "-h" : "--help"); 6627 6589 exit (EXIT_FAILURE); 6628 6590 }
