Changeset 3894 for trunk/lib-src/etags.c
- Timestamp:
- 10/02/05 09:47:43 (3 years ago)
- Files:
-
- trunk/lib-src/etags.c (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib-src/etags.c
r3809 r3894 42 42 */ 43 43 44 char pot_etags_version[] = "@(#) pot revision number is 17. 5";44 char pot_etags_version[] = "@(#) pot revision number is 17.14"; 45 45 46 46 #define TRUE 1 … … 344 344 static void Cstar_entries __P((FILE *)); 345 345 static void Erlang_functions __P((FILE *)); 346 static void Forth_words __P((FILE *)); 346 347 static void Fortran_functions __P((FILE *)); 347 348 static void HTML_labels __P((FILE *)); … … 490 491 static struct option longopts[] = 491 492 { 493 { "append", no_argument, NULL, 'a' }, 492 494 { "packages-only", no_argument, &packages_only, TRUE }, 493 495 { "c++", no_argument, NULL, 'C' }, … … 509 511 { "version", no_argument, NULL, 'V' }, 510 512 511 #if CTAGS /* Etags options */513 #if CTAGS /* Ctags options */ 512 514 { "backward-search", no_argument, NULL, 'B' }, 513 515 { "cxref", no_argument, NULL, 'x' }, … … 520 522 { "no-warn", no_argument, NULL, 'w' }, 521 523 522 #else /* Ctags options */ 523 { "append", no_argument, NULL, 'a' }, 524 #else /* Etags options */ 524 525 { "no-defines", no_argument, NULL, 'D' }, 525 526 { "no-globals", no_argument, &globals, FALSE }, … … 632 633 defined in the file."; 633 634 635 char *Forth_suffixes [] = 636 { "fth", "tok", NULL }; 637 static char Forth_help [] = 638 "In Forth code, tags are words defined by `:',\n\ 639 constant, code, create, defer, value, variable, buffer:, field."; 640 634 641 static char *Fortran_suffixes [] = 635 642 { "F", "f", "f90", "for", NULL }; … … 779 786 { "cobol", Cobol_help, Cobol_paragraphs, Cobol_suffixes }, 780 787 { "erlang", Erlang_help, Erlang_functions, Erlang_suffixes }, 788 { "forth", Forth_help, Forth_words, Forth_suffixes }, 781 789 { "fortran", Fortran_help, Fortran_functions, Fortran_suffixes }, 782 790 { "html", HTML_help, HTML_labels, HTML_suffixes }, … … 882 890 Relative ones are stored relative to the output file's directory.\n"); 883 891 884 if (!CTAGS) 885 puts ("-a, --append\n\ 892 puts ("-a, --append\n\ 886 893 Append tag entries to existing tags file."); 887 894 … … 1181 1188 } 1182 1189 1190 /* When the optstring begins with a '-' getopt_long does not rearrange the 1191 non-options arguments to be at the end, but leaves them alone. */ 1183 1192 optstring = "-"; 1184 1193 #ifdef ETAGS_REGEXPS … … 1186 1195 #endif /* ETAGS_REGEXPS */ 1187 1196 if (!LONG_OPTIONS) 1188 optstring += 1; 1197 optstring += 1; /* remove the initial '-' */ 1189 1198 optstring = concat (optstring, 1190 " Cf:Il:o:SVhH",1191 (CTAGS) ? "BxdtTuvw" : " aDi:");1192 1193 while ((opt = getopt_long (argc, argv, optstring, longopts, 0)) != EOF)1199 "aCf:Il:o:SVhH", 1200 (CTAGS) ? "BxdtTuvw" : "Di:"); 1201 1202 while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) 1194 1203 switch (opt) 1195 1204 { … … 1219 1228 1220 1229 /* Common options. */ 1230 case 'a': append_to_tagfile = TRUE; break; 1221 1231 case 'C': cplusplus = TRUE; break; 1222 1232 case 'f': /* for compatibility with old makefiles */ … … 1268 1278 1269 1279 /* Etags options */ 1270 case 'a': append_to_tagfile = TRUE; break;1271 1280 case 'D': constantypedefs = FALSE; break; 1272 1281 case 'i': included_files[nincluded_files++] = optarg; break; … … 1286 1295 } 1287 1296 1297 /* No more options. Store the rest of arguments. */ 1288 1298 for (; optind < argc; optind++) 1289 1299 { … … 1414 1424 if (!CTAGS || cxref_style) 1415 1425 { 1416 put_entries (nodehead); /* write the remaini g tags (ETAGS) */1426 put_entries (nodehead); /* write the remaining tags (ETAGS) */ 1417 1427 free_tree (nodehead); 1418 1428 nodehead = NULL; … … 1466 1476 pfatal (tagfile); 1467 1477 1468 if (update) 1469 { 1470 char cmd[2*BUFSIZ+10]; 1471 sprintf (cmd, "sort -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile); 1472 exit (system (cmd)); 1473 } 1478 if (CTAGS) 1479 if (append_to_tagfile || update) 1480 { 1481 char cmd[2*BUFSIZ+10]; 1482 sprintf (cmd, "sort -o %.*s %.*s", BUFSIZ, tagfile, BUFSIZ, tagfile); 1483 exit (system (cmd)); 1484 } 1474 1485 return EXIT_SUCCESS; 1475 1486 } … … 4076 4087 TRUE); \ 4077 4088 ) 4078 #define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \ 4079 (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */ \ 4080 && notinname ((cp)[sizeof(keyword)-1]) /* end of keyword */ \ 4081 && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */ 4089 4090 #define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \ 4091 ((assert("" kw), TRUE) /* syntax error if not a literal string */ \ 4092 && strneq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ 4093 && notinname ((cp)[sizeof(kw)-1]) /* end of kw */ \ 4094 && ((cp) = skip_spaces((cp)+sizeof(kw)-1))) /* skip spaces */ 4095 4096 /* Similar to LOOKING_AT but does not use notinname, does not skip */ 4097 #define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \ 4098 ((assert("" kw), TRUE) /* syntax error if not a literal string */ \ 4099 && strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \ 4100 && ((cp) += sizeof(kw)-1)) /* skip spaces */ 4082 4101 4083 4102 /* … … 4957 4976 4958 4977 /* 4959 * Postscript tag functions4978 * Postscript tags 4960 4979 * Just look for lines where the first character is '/' 4961 4980 * Also look at "defineps" for PSWrap … … 4988 5007 4989 5008 /* 5009 * Forth tags 5010 * Ignore anything after \ followed by space or in ( ) 5011 * Look for words defined by : 5012 * Look for constant, code, create, defer, value, and variable 5013 * OBP extensions: Look for buffer:, field, 5014 * Ideas by Eduardo Horvath <eeh@netbsd.org> (2004) 5015 */ 5016 static void 5017 Forth_words (inf) 5018 FILE *inf; 5019 { 5020 register char *bp; 5021 5022 LOOP_ON_INPUT_LINES (inf, lb, bp) 5023 while ((bp = skip_spaces (bp))[0] != '\0') 5024 if (bp[0] == '\\' && iswhite(bp[1])) 5025 break; /* read next line */ 5026 else if (bp[0] == '(' && iswhite(bp[1])) 5027 do /* skip to ) or eol */ 5028 bp++; 5029 while (*bp != ')' && *bp != '\0'); 5030 else if ((bp[0] == ':' && iswhite(bp[1]) && bp++) 5031 || LOOKING_AT_NOCASE (bp, "constant") 5032 || LOOKING_AT_NOCASE (bp, "code") 5033 || LOOKING_AT_NOCASE (bp, "create") 5034 || LOOKING_AT_NOCASE (bp, "defer") 5035 || LOOKING_AT_NOCASE (bp, "value") 5036 || LOOKING_AT_NOCASE (bp, "variable") 5037 || LOOKING_AT_NOCASE (bp, "buffer:") 5038 || LOOKING_AT_NOCASE (bp, "field")) 5039 get_tag (skip_spaces (bp), NULL); /* Yay! A definition! */ 5040 else 5041 bp = skip_non_spaces (bp); 5042 } 5043 5044 5045 /* 4990 5046 * Scheme tag functions 4991 5047 * look for (def... xyzzy … … 4995 5051 * Original code by Ken Haase (1985?) 4996 5052 */ 4997 4998 5053 static void 4999 5054 Scheme_functions (inf) … … 5214 5269 5215 5270 5216 /* Similar to LOOKING_AT but does not use notinname, does not skip */5217 #define LOOKING_AT_NOCASE(cp, kw) /* kw is a constant string */ \5218 (strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \5219 && ((cp) += sizeof(kw)-1)) /* skip spaces */5220 5221 5271 /* 5222 5272 * HTML support. … … 5435 5485 || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2))) 5436 5486 && (last == NULL /* save only the first clause */ 5437 || len != strlen (last)5487 || len != (int)strlen (last) 5438 5488 || !strneq (s, last, len))) 5439 5489 { … … 6503 6553 } 6504 6554 6505 /* Skip spaces , return new pointer. */6555 /* Skip spaces (end of string is not space), return new pointer. */ 6506 6556 static char * 6507 6557 skip_spaces (cp) … … 6513 6563 } 6514 6564 6515 /* Skip non spaces, return new pointer. */6565 /* Skip non spaces, except end of string, return new pointer. */ 6516 6566 static char * 6517 6567 skip_non_spaces (cp)
