Mercurial > emacs
comparison lib-src/etags.c @ 13380:12bfc1ecec61
* etags.c (lowcase): Use the standard tolower function.
(substitute): Remove some wrong and some useless code related with
escape `\` character in regexp replacement string.
(TEX_defenv): Added part, appendix, entry, index. Removed typeout.
(lang_suffixes): New suffixes: .hpp for C++; .f90 for Fortran;
.bib, .ltx, .TeX for TeX (.bbl, .dtx removed); .ml for Lisp;
.prolog for prolog (.pl removed).
(massage_name, etags_getcwd): Use lowcase instead of tolower.
(regex.h): Don't include it if REGEX_IN_LIBC is defined.
(C_entries, find_entries): Added comments about memory leakage.
(add_node): Dead code removed.
author | Francesco Potortì <pot@gnu.org> |
---|---|
date | Thu, 02 Nov 1995 16:30:14 +0000 |
parents | 3b90cbba7dad |
children | 9d6c77b66cfb |
comparison
equal
deleted
inserted
replaced
13379:45188809385d | 13380:12bfc1ecec61 |
---|---|
30 #endif | 30 #endif |
31 * | 31 * |
32 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer. | 32 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer. |
33 */ | 33 */ |
34 | 34 |
35 char pot_etags_version[] = "@(#) pot revision number is 11.30"; | 35 char pot_etags_version[] = "@(#) pot revision number is 11.42"; |
36 | 36 |
37 #define TRUE 1 | 37 #define TRUE 1 |
38 #define FALSE 0 | 38 #define FALSE 0 |
39 #ifndef DEBUG | 39 #ifndef DEBUG |
40 # define DEBUG FALSE | 40 # define DEBUG FALSE |
103 #define YACC 0x10000 /* yacc file */ | 103 #define YACC 0x10000 /* yacc file */ |
104 | 104 |
105 #define streq(s,t) (strcmp (s, t) == 0) | 105 #define streq(s,t) (strcmp (s, t) == 0) |
106 #define strneq(s,t,n) (strncmp (s, t, n) == 0) | 106 #define strneq(s,t,n) (strncmp (s, t, n) == 0) |
107 | 107 |
108 #define lowcase(c) ((c) | ' ') | 108 #define lowcase(c) tolower ((unsigned char)c) |
109 | 109 |
110 #define iswhite(arg) (_wht[arg]) /* T if char is white */ | 110 #define iswhite(arg) (_wht[arg]) /* T if char is white */ |
111 #define begtoken(arg) (_btk[arg]) /* T if char can start token */ | 111 #define begtoken(arg) (_btk[arg]) /* T if char can start token */ |
112 #define intoken(arg) (_itk[arg]) /* T if char can be in token */ | 112 #define intoken(arg) (_itk[arg]) /* T if char can be in token */ |
113 #define endtoken(arg) (_etk[arg]) /* T if char ends tokens */ | 113 #define endtoken(arg) (_etk[arg]) /* T if char ends tokens */ |
261 logical vgrind_style; /* -v: create vgrind style index output */ | 261 logical vgrind_style; /* -v: create vgrind style index output */ |
262 logical no_warnings; /* -w: suppress warnings */ | 262 logical no_warnings; /* -w: suppress warnings */ |
263 logical cxref_style; /* -x: create cxref style output */ | 263 logical cxref_style; /* -x: create cxref style output */ |
264 logical cplusplus; /* .[hc] means C++, not C */ | 264 logical cplusplus; /* .[hc] means C++, not C */ |
265 logical noindentypedefs; /* -I: ignore indentation in C */ | 265 logical noindentypedefs; /* -I: ignore indentation in C */ |
266 #define permit_duplicates TRUE /* allow duplicate tags */ | |
267 | 266 |
268 struct option longopts[] = | 267 struct option longopts[] = |
269 { | 268 { |
270 { "append", no_argument, NULL, 'a' }, | 269 { "append", no_argument, NULL, 'a' }, |
271 { "backward-search", no_argument, NULL, 'B' }, | 270 { "backward-search", no_argument, NULL, 'B' }, |
272 { "c++", no_argument, NULL, 'C' }, | 271 { "c++", no_argument, NULL, 'C' }, |
273 { "cxref", no_argument, NULL, 'x' }, | 272 { "cxref", no_argument, NULL, 'x' }, |
274 { "defines", no_argument, NULL, 'd' }, | 273 { "defines", no_argument, NULL, 'd' }, |
275 { "help", no_argument, NULL, 'h' }, | 274 { "help", no_argument, NULL, 'h' }, |
276 { "help", no_argument, NULL, 'H' }, | 275 { "help", no_argument, NULL, 'H' }, |
282 { "no-warn", no_argument, NULL, 'w' }, | 281 { "no-warn", no_argument, NULL, 'w' }, |
283 { "output", required_argument, NULL, 'o' }, | 282 { "output", required_argument, NULL, 'o' }, |
284 { "regex", required_argument, NULL, 'r' }, | 283 { "regex", required_argument, NULL, 'r' }, |
285 { "typedefs", no_argument, NULL, 't' }, | 284 { "typedefs", no_argument, NULL, 't' }, |
286 { "typedefs-and-c++", no_argument, NULL, 'T' }, | 285 { "typedefs-and-c++", no_argument, NULL, 'T' }, |
287 { "update", no_argument, NULL, 'u' }, | 286 { "update", no_argument, NULL, 'u' }, |
288 { "version", no_argument, NULL, 'V' }, | 287 { "version", no_argument, NULL, 'V' }, |
289 { "vgrind", no_argument, NULL, 'v' }, | 288 { "vgrind", no_argument, NULL, 'v' }, |
290 { 0 } | 289 { 0 } |
291 }; | 290 }; |
292 | 291 |
293 #ifdef ETAGS_REGEXPS | 292 #ifdef ETAGS_REGEXPS |
294 /* Structure defining a regular expression. Elements are | 293 /* Structure defining a regular expression. Elements are |
295 the compiled pattern, and the name string. */ | 294 the compiled pattern, and the name string. */ |
296 struct pattern | 295 struct pattern |
297 { | 296 { |
298 struct re_pattern_buffer *pattern; | 297 struct re_pattern_buffer *pattern; |
299 struct re_registers regs; | 298 struct re_registers regs; |
336 }; | 335 }; |
337 | 336 |
338 /* Table of file name suffixes and corresponding language functions. */ | 337 /* Table of file name suffixes and corresponding language functions. */ |
339 struct lang_entry lang_suffixes[] = | 338 struct lang_entry lang_suffixes[] = |
340 { | 339 { |
341 /* Assume that ".s" or ".a" is assembly code. -wolfgang. | 340 /* Assembly code */ |
342 Or even ".sa". */ | |
343 { "a", Asm_labels }, /* Unix assembler */ | 341 { "a", Asm_labels }, /* Unix assembler */ |
344 { "asm", Asm_labels }, /* Microcontroller assembly */ | 342 { "asm", Asm_labels }, /* Microcontroller assembly */ |
345 { "def", Asm_labels }, /* BSO/Tasking definition includes */ | 343 { "def", Asm_labels }, /* BSO/Tasking definition includes */ |
346 { "inc", Asm_labels }, /* Microcontroller include files */ | 344 { "inc", Asm_labels }, /* Microcontroller include files */ |
347 { "ins", Asm_labels }, /* Microcontroller include files */ | 345 { "ins", Asm_labels }, /* Microcontroller include files */ |
348 { "s", Asm_labels }, | 346 { "s", Asm_labels }, |
349 { "sa", Asm_labels }, /* Unix assembler */ | 347 { "sa", Asm_labels }, /* Unix assembler */ |
350 { "src", Asm_labels }, /* BSO/Tasking C compiler output */ | 348 { "src", Asm_labels }, /* BSO/Tasking C compiler output */ |
351 | 349 |
352 /* .aux, .bbl, .clo, .cls, .dtx or .tex implies LaTeX source code. */ | 350 /* LaTeX source code */ |
353 { "aux", TeX_functions }, | 351 { "bib", TeX_functions }, |
354 { "bbl", TeX_functions }, | |
355 { "clo", TeX_functions }, | 352 { "clo", TeX_functions }, |
356 { "cls", TeX_functions }, | 353 { "cls", TeX_functions }, |
357 { "dtx", TeX_functions }, | 354 { "ltx", TeX_functions }, |
358 { "sty", TeX_functions }, | 355 { "sty", TeX_functions }, |
356 { "TeX", TeX_functions }, | |
359 { "tex", TeX_functions }, | 357 { "tex", TeX_functions }, |
360 | 358 |
361 /* .l or .el or .lisp (or .cl or .clisp or ...) implies lisp source code */ | 359 /* Lisp source code */ |
362 { "cl", Lisp_functions }, | 360 { "cl", Lisp_functions }, |
363 { "clisp", Lisp_functions }, | 361 { "clisp", Lisp_functions }, |
364 { "el", Lisp_functions }, | 362 { "el", Lisp_functions }, |
365 { "l", Lisp_functions }, | 363 { "l", Lisp_functions }, |
366 { "lisp", Lisp_functions }, | 364 { "lisp", Lisp_functions }, |
367 { "lsp", Lisp_functions }, | 365 { "lsp", Lisp_functions }, |
368 | 366 { "ml", Lisp_functions }, |
369 /* .scm or .sm or .scheme implies scheme source code */ | 367 |
368 /* Scheme source code */ | |
370 { "SCM", Scheme_functions }, | 369 { "SCM", Scheme_functions }, |
371 { "SM", Scheme_functions }, | 370 { "SM", Scheme_functions }, |
372 { "oak", Scheme_functions }, | 371 { "oak", Scheme_functions }, |
373 { "sch", Scheme_functions }, | 372 { "sch", Scheme_functions }, |
374 { "scheme", Scheme_functions }, | 373 { "scheme", Scheme_functions }, |
380 /* Note that .c and .h can be considered C++, if the --c++ flag was | 379 /* Note that .c and .h can be considered C++, if the --c++ flag was |
381 given. That is why default_C_entries is called here. */ | 380 given. That is why default_C_entries is called here. */ |
382 { "c", default_C_entries }, | 381 { "c", default_C_entries }, |
383 { "h", default_C_entries }, | 382 { "h", default_C_entries }, |
384 | 383 |
385 /* .pc is a Pro*C file. */ | 384 /* Pro*C file. */ |
386 { "pc", plain_C_entries }, | 385 { "pc", plain_C_entries }, |
387 | 386 |
388 /* .C or .H or .c++ or .cc or .cpp or .cxx or .h++ or .hh or .hxx: | 387 /* C++ file */ |
389 a C++ file */ | |
390 { "C", Cplusplus_entries }, | 388 { "C", Cplusplus_entries }, |
391 { "H", Cplusplus_entries }, | 389 { "H", Cplusplus_entries }, |
392 { "c++", Cplusplus_entries }, | 390 { "c++", Cplusplus_entries }, |
393 { "cc", Cplusplus_entries }, | 391 { "cc", Cplusplus_entries }, |
394 { "cpp", Cplusplus_entries }, | 392 { "cpp", Cplusplus_entries }, |
395 { "cxx", Cplusplus_entries }, | 393 { "cxx", Cplusplus_entries }, |
396 { "h++", Cplusplus_entries }, | 394 { "h++", Cplusplus_entries }, |
397 { "hh", Cplusplus_entries }, | 395 { "hh", Cplusplus_entries }, |
396 { "hpp", Cplusplus_entries }, | |
398 { "hxx", Cplusplus_entries }, | 397 { "hxx", Cplusplus_entries }, |
399 | 398 |
400 /* .y: a yacc file */ | 399 /* Yacc file */ |
401 { "y", Yacc_entries }, | 400 { "y", Yacc_entries }, |
402 | 401 |
403 /* .cs or .hs: a C* file */ | 402 /* C* file */ |
404 { "cs", Cstar_entries }, | 403 { "cs", Cstar_entries }, |
405 { "hs", Cstar_entries }, | 404 { "hs", Cstar_entries }, |
406 | 405 |
407 /* .F, .f and .for are FORTRAN. */ | 406 /* Fortran */ |
408 { "F", Fortran_functions }, | 407 { "F", Fortran_functions }, |
409 { "f", Fortran_functions }, | 408 { "f", Fortran_functions }, |
409 { "f90", Fortran_functions }, | |
410 { "for", Fortran_functions }, | 410 { "for", Fortran_functions }, |
411 | 411 |
412 /* .pl implies prolog source code */ | 412 /* Prolog source code */ |
413 { "pl", Prolog_functions }, | 413 { "prolog", Prolog_functions }, |
414 | 414 |
415 /* .p or .pas: a Pascal file */ | 415 /* Pascal file */ |
416 { "p", Pascal_functions }, | 416 { "p", Pascal_functions }, |
417 { "pas", Pascal_functions }, | 417 { "pas", Pascal_functions }, |
418 | 418 |
419 { NULL, NULL } | 419 { NULL, NULL } |
420 }; | 420 }; |
442 name suffix, and `none' means only do regexp processing on files.\n\ | 442 name suffix, and `none' means only do regexp processing on files.\n\ |
443 If no language is specified and no matching suffix is found,\n\ | 443 If no language is specified and no matching suffix is found,\n\ |
444 Fortran is tried first; if no tags are found, C is tried next."); | 444 Fortran is tried first; if no tags are found, C is tried next."); |
445 } | 445 } |
446 | 446 |
447 #ifndef VERSION | |
448 # define VERSION "19" | |
449 #endif | |
447 void | 450 void |
448 print_version () | 451 print_version () |
449 { | 452 { |
450 #ifdef VERSION | 453 printf ("%s for Emacs version %s\n", (CTAGS) ? "ctags" : "etags", VERSION); |
451 printf ("%s for Emacs version %s.\n", (CTAGS) ? "CTAGS" : "ETAGS", VERSION); | |
452 #else | |
453 printf ("%s for Emacs version 19.\n", (CTAGS) ? "CTAGS" : "ETAGS"); | |
454 #endif | |
455 | 454 |
456 exit (GOOD); | 455 exit (GOOD); |
457 } | 456 } |
458 | 457 |
459 void | 458 void |
582 returning in each successive call the next filename matching the input | 581 returning in each successive call the next filename matching the input |
583 spec. The function expects that each in_spec passed | 582 spec. The function expects that each in_spec passed |
584 to it will be processed to completion; in particular, up to and | 583 to it will be processed to completion; in particular, up to and |
585 including the call following that in which the last matching name | 584 including the call following that in which the last matching name |
586 is returned, the function ignores the value of in_spec, and will | 585 is returned, the function ignores the value of in_spec, and will |
587 only start processing a new spec with the following call. | 586 only start processing a new spec with the following call. |
588 If an error occurs, on return out_spec contains the value | 587 If an error occurs, on return out_spec contains the value |
589 of in_spec when the error occurred. | 588 of in_spec when the error occurred. |
590 | 589 |
591 With each successive filename returned in out_spec, the | 590 With each successive filename returned in out_spec, the |
592 function's return value is one. When there are no more matching | 591 function's return value is one. When there are no more matching |
593 names the function returns zero. If on the first call no file | 592 names the function returns zero. If on the first call no file |
594 matches in_spec, or there is any other error, -1 is returned. | 593 matches in_spec, or there is any other error, -1 is returned. |
595 */ | 594 */ |
596 | 595 |
597 #include <rmsdef.h> | 596 #include <rmsdef.h> |
598 #include <descrip.h> | 597 #include <descrip.h> |
599 #define OUTSIZE MAX_FILE_SPEC_LEN | 598 #define OUTSIZE MAX_FILE_SPEC_LEN |
634 retval = -1; | 633 retval = -1; |
635 } | 634 } |
636 lib$find_file_end(&context); | 635 lib$find_file_end(&context); |
637 pass1 = TRUE; | 636 pass1 = TRUE; |
638 return retval; | 637 return retval; |
639 } | 638 } |
640 | 639 |
641 /* | 640 /* |
642 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the | 641 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the |
643 name of each file specified by the provided arg expanding wildcards. | 642 name of each file specified by the provided arg expanding wildcards. |
644 */ | 643 */ |
645 char * | 644 char * |
646 gfnames (arg, p_error) | 645 gfnames (arg, p_error) |
647 char *arg; | 646 char *arg; |
673 | 672 |
674 #define VERSION_DELIM ';' | 673 #define VERSION_DELIM ';' |
675 char *massage_name (s) | 674 char *massage_name (s) |
676 char *s; | 675 char *s; |
677 { | 676 { |
678 char *start = s; | 677 char *start = s; |
679 | 678 |
680 for ( ; *s; s++) | 679 for ( ; *s; s++) |
681 if (*s == VERSION_DELIM) | 680 if (*s == VERSION_DELIM) |
682 { | 681 { |
683 *s = EOS; | 682 *s = EOS; |
684 break; | 683 break; |
685 } | 684 } |
686 else | 685 else |
687 *s = tolower(*s); | 686 *s = lowcase (*s); |
688 return start; | 687 return start; |
689 } | 688 } |
690 #endif /* VMS */ | 689 #endif /* VMS */ |
691 | 690 |
692 | 691 |
703 int current_arg = 0, file_count = 0; | 702 int current_arg = 0, file_count = 0; |
704 struct linebuffer filename_lb; | 703 struct linebuffer filename_lb; |
705 #ifdef VMS | 704 #ifdef VMS |
706 logical got_err; | 705 logical got_err; |
707 #endif | 706 #endif |
708 | 707 |
709 #ifdef DOS_NT | 708 #ifdef DOS_NT |
710 _fmode = O_BINARY; /* all of files are treated as binary files */ | 709 _fmode = O_BINARY; /* all of files are treated as binary files */ |
711 #endif /* DOS_NT */ | 710 #endif /* DOS_NT */ |
712 | 711 |
713 progname = argv[0]; | 712 progname = argv[0]; |
1106 char *cp; | 1105 char *cp; |
1107 struct lang_entry *lang; | 1106 struct lang_entry *lang; |
1108 NODE *old_last_node; | 1107 NODE *old_last_node; |
1109 extern NODE *last_node; | 1108 extern NODE *last_node; |
1110 | 1109 |
1111 /* The memory block pointed by curfile is never released for simplicity. */ | 1110 /* Memory leakage here: the memory block pointed by curfile is never |
1111 released. The amount of memory leaked here is the sum of the | |
1112 lengths of the input file names. */ | |
1112 curfile = savestr (file); | 1113 curfile = savestr (file); |
1113 cp = etags_strrchr (file, '.'); | 1114 cp = etags_strrchr (file, '.'); |
1114 | 1115 |
1115 /* If user specified a language, use it. */ | 1116 /* If user specified a language, use it. */ |
1116 if (lang_func != NULL) | 1117 if (lang_func != NULL) |
1255 { | 1256 { |
1256 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n", | 1257 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n", |
1257 node->file, lineno, node->name); | 1258 node->file, lineno, node->name); |
1258 fprintf (stderr, "Second entry ignored\n"); | 1259 fprintf (stderr, "Second entry ignored\n"); |
1259 } | 1260 } |
1260 return; | 1261 } |
1261 } | 1262 else if (!cur_node->been_warned && !no_warnings) |
1262 if (!cur_node->been_warned && !no_warnings) | 1263 { |
1263 { | 1264 fprintf |
1264 fprintf (stderr, | 1265 (stderr, |
1265 "Duplicate entry in files %s and %s: %s (Warning only)\n", | 1266 "Duplicate entry in files %s and %s: %s (Warning only)\n", |
1266 node->file, cur_node->file, node->name); | 1267 node->file, cur_node->file, node->name); |
1267 } | 1268 cur_node->been_warned = TRUE; |
1268 cur_node->been_warned = TRUE; | 1269 } |
1269 return; | 1270 return; |
1270 } | |
1271 | |
1272 /* Maybe refuse to add duplicate nodes. */ | |
1273 if (!permit_duplicates) | |
1274 { | |
1275 if (streq (node->name, cur_node->name) | |
1276 && streq (node->file, cur_node->file)) | |
1277 return; | |
1278 } | 1271 } |
1279 | 1272 |
1280 /* Actually add the node */ | 1273 /* Actually add the node */ |
1281 add_node (node, dif < 0 ? &cur_node->left : &cur_node->right); | 1274 add_node (node, dif < 0 ? &cur_node->left : &cur_node->right); |
1282 } | 1275 } |
1467 register int len; | 1460 register int len; |
1468 { | 1461 { |
1469 | 1462 |
1470 static struct C_stab_entry wordlist[] = | 1463 static struct C_stab_entry wordlist[] = |
1471 { | 1464 { |
1472 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, | 1465 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, |
1473 {"",}, | 1466 {"",}, |
1474 {"volatile", 0, st_C_typespec}, | 1467 {"volatile", 0, st_C_typespec}, |
1475 {"",}, | 1468 {"",}, |
1476 {"long", 0, st_C_typespec}, | 1469 {"long", 0, st_C_typespec}, |
1477 {"char", 0, st_C_typespec}, | 1470 {"char", 0, st_C_typespec}, |
1478 {"class", C_PLPL, st_C_struct}, | 1471 {"class", C_PLPL, st_C_struct}, |
1479 {"",}, {"",}, {"",}, {"",}, | 1472 {"",}, {"",}, {"",}, {"",}, |
1480 {"const", 0, st_C_typespec}, | 1473 {"const", 0, st_C_typespec}, |
1481 {"",}, {"",}, {"",}, {"",}, | 1474 {"",}, {"",}, {"",}, {"",}, |
1482 {"auto", 0, st_C_typespec}, | 1475 {"auto", 0, st_C_typespec}, |
1483 {"",}, {"",}, | 1476 {"",}, {"",}, |
1484 {"define", 0, st_C_define}, | 1477 {"define", 0, st_C_define}, |
1485 {"",}, | 1478 {"",}, |
1486 {"void", 0, st_C_typespec}, | 1479 {"void", 0, st_C_typespec}, |
1487 {"",}, {"",}, {"",}, | 1480 {"",}, {"",}, {"",}, |
1488 {"extern", 0, st_C_typespec}, | 1481 {"extern", 0, st_C_typespec}, |
1489 {"static", 0, st_C_typespec}, | 1482 {"static", 0, st_C_typespec}, |
1490 {"",}, | 1483 {"",}, |
1491 {"domain", C_STAR, st_C_struct}, | 1484 {"domain", C_STAR, st_C_struct}, |
1492 {"",}, | 1485 {"",}, |
1493 {"typedef", 0, st_C_typedef}, | 1486 {"typedef", 0, st_C_typedef}, |
1494 {"double", 0, st_C_typespec}, | 1487 {"double", 0, st_C_typespec}, |
1495 {"enum", 0, st_C_enum}, | 1488 {"enum", 0, st_C_enum}, |
1496 {"",}, {"",}, {"",}, {"",}, | 1489 {"",}, {"",}, {"",}, {"",}, |
1497 {"int", 0, st_C_typespec}, | 1490 {"int", 0, st_C_typespec}, |
1498 {"",}, | 1491 {"",}, |
1499 {"float", 0, st_C_typespec}, | 1492 {"float", 0, st_C_typespec}, |
1500 {"",}, {"",}, {"",}, | 1493 {"",}, {"",}, {"",}, |
1501 {"struct", 0, st_C_struct}, | 1494 {"struct", 0, st_C_struct}, |
1502 {"",}, {"",}, {"",}, {"",}, | 1495 {"",}, {"",}, {"",}, {"",}, |
1503 {"union", 0, st_C_struct}, | 1496 {"union", 0, st_C_struct}, |
1504 {"",}, | 1497 {"",}, |
1505 {"short", 0, st_C_typespec}, | 1498 {"short", 0, st_C_typespec}, |
1506 {"",}, {"",}, | 1499 {"",}, {"",}, |
1507 {"unsigned", 0, st_C_typespec}, | 1500 {"unsigned", 0, st_C_typespec}, |
1508 {"signed", 0, st_C_typespec}, | 1501 {"signed", 0, st_C_typespec}, |
1509 }; | 1502 }; |
1510 | 1503 |
1511 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) | 1504 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) |
1566 tignore /* junk after typedef tag */ | 1559 tignore /* junk after typedef tag */ |
1567 } TYPEDST; | 1560 } TYPEDST; |
1568 TYPEDST typdef; | 1561 TYPEDST typdef; |
1569 | 1562 |
1570 | 1563 |
1571 /* | 1564 /* |
1572 * struct-like structures (enum, struct and union) are recognized | 1565 * struct-like structures (enum, struct and union) are recognized |
1573 * using another simple finite automaton. `structdef' is its state | 1566 * using another simple finite automaton. `structdef' is its state |
1574 * variable. | 1567 * variable. |
1575 */ | 1568 */ |
1576 typedef enum | 1569 typedef enum |
1583 } STRUCTST; | 1576 } STRUCTST; |
1584 STRUCTST structdef; | 1577 STRUCTST structdef; |
1585 | 1578 |
1586 /* | 1579 /* |
1587 * When structdef is stagseen, scolonseen, or sinbody, structtag is the | 1580 * When structdef is stagseen, scolonseen, or sinbody, structtag is the |
1588 * struct tag, and structtype is the type of the preceding struct-like | 1581 * struct tag, and structtype is the type of the preceding struct-like |
1589 * keyword. | 1582 * keyword. |
1590 */ | 1583 */ |
1591 char *structtag = "<uninited>"; | 1584 char *structtag = "<uninited>"; |
1592 enum sym_type structtype; | 1585 enum sym_type structtype; |
1593 | 1586 |
1728 * | 1721 * |
1729 * This structdef business is NOT invoked when we are ctags and the | 1722 * This structdef business is NOT invoked when we are ctags and the |
1730 * file is plain C. This is because a struct tag may have the same | 1723 * file is plain C. This is because a struct tag may have the same |
1731 * name as another tag, and this loses with ctags. | 1724 * name as another tag, and this loses with ctags. |
1732 * | 1725 * |
1733 * This if statement deals with the typdef state machine as | 1726 * This if statement deals with the typdef state machine as |
1734 * follows: if typdef==ttypedseen and token is struct/union/class/enum, | 1727 * follows: if typdef==ttypedseen and token is struct/union/class/enum, |
1735 * return FALSE. All the other code here is for the structdef | 1728 * return FALSE. All the other code here is for the structdef |
1736 * state machine. | 1729 * state machine. |
1737 */ | 1730 */ |
1738 switch (toktype) | 1731 switch (toktype) |
1739 { | 1732 { |
1740 case st_C_struct: | 1733 case st_C_struct: |
1767 } | 1760 } |
1768 | 1761 |
1769 /* Detect GNU macros. */ | 1762 /* Detect GNU macros. */ |
1770 if (definedef == dnone) | 1763 if (definedef == dnone) |
1771 if (strneq (str, "DEFUN", len) /* Used in emacs */ | 1764 if (strneq (str, "DEFUN", len) /* Used in emacs */ |
1772 #if FALSE | 1765 #if FALSE |
1773 These are defined inside C functions, so currently they | 1766 These are defined inside C functions, so currently they |
1774 are not met anyway. | 1767 are not met anyway. |
1775 || strneq (str, "EXFUN", len) /* Used in glibc */ | 1768 || strneq (str, "EXFUN", len) /* Used in glibc */ |
1776 || strneq (str, "DEFVAR_", 7) /* Used in emacs */ | 1769 || strneq (str, "DEFVAR_", 7) /* Used in emacs */ |
1777 #endif | 1770 #endif |
1966 inchar = FALSE; | 1959 inchar = FALSE; |
1967 break; | 1960 break; |
1968 } | 1961 } |
1969 continue; | 1962 continue; |
1970 } | 1963 } |
1971 else | 1964 else |
1972 switch (c) | 1965 switch (c) |
1973 { | 1966 { |
1974 case '"': | 1967 case '"': |
1975 inquote = TRUE; | 1968 inquote = TRUE; |
1976 if (funcdef != finlist && funcdef != fignore) | 1969 if (funcdef != finlist && funcdef != fignore) |
2331 cblev--; | 2324 cblev--; |
2332 if (cblev == 0) | 2325 if (cblev == 0) |
2333 { | 2326 { |
2334 if (typdef == tinbody) | 2327 if (typdef == tinbody) |
2335 typdef = tend; | 2328 typdef = tend; |
2336 if (FALSE) /* too risky */ | 2329 /* Memory leakage here: the string pointed by structtag is |
2337 if (structdef == sinbody) | 2330 never released, because I fear to miss something and |
2338 free (structtag); | 2331 break things while freeing the area. The amount of |
2332 memory leaked here is the sum of the lenghts of the | |
2333 struct tags. | |
2334 if (structdef == sinbody) | |
2335 free (structtag); */ | |
2339 | 2336 |
2340 structdef = snone; | 2337 structdef = snone; |
2341 structtag = "<error>"; | 2338 structtag = "<error>"; |
2342 } | 2339 } |
2343 break; | 2340 break; |
2786 get_tagname = TRUE; | 2783 get_tagname = TRUE; |
2787 continue; | 2784 continue; |
2788 } | 2785 } |
2789 } | 2786 } |
2790 } /* while not eof */ | 2787 } /* while not eof */ |
2791 | 2788 |
2792 free (tline.buffer); | 2789 free (tline.buffer); |
2793 } | 2790 } |
2794 | 2791 |
2795 /* | 2792 /* |
2796 * lisp tag functions | 2793 * lisp tag functions |
2834 *cp && *cp != '(' && *cp != ' ' && *cp != ')'; | 2831 *cp && *cp != '(' && *cp != ' ' && *cp != ')'; |
2835 cp++) | 2832 cp++) |
2836 continue; | 2833 continue; |
2837 if (cp == dbp) | 2834 if (cp == dbp) |
2838 return; | 2835 return; |
2839 | 2836 |
2840 pfnote (NULL, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 2837 pfnote (NULL, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
2841 } | 2838 } |
2842 | 2839 |
2843 void | 2840 void |
2844 Lisp_functions (inf) | 2841 Lisp_functions (inf) |
2972 | 2969 |
2973 /* Default set of control sequences to put into TEX_toktab. | 2970 /* Default set of control sequences to put into TEX_toktab. |
2974 The value of environment var TEXTAGS is prepended to this. */ | 2971 The value of environment var TEXTAGS is prepended to this. */ |
2975 | 2972 |
2976 char *TEX_defenv = "\ | 2973 char *TEX_defenv = "\ |
2977 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem:typeout"; | 2974 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\ |
2975 :part:appendix:entry:index"; | |
2978 | 2976 |
2979 void TEX_mode (); | 2977 void TEX_mode (); |
2980 struct TEX_tabent *TEX_decode_env (); | 2978 struct TEX_tabent *TEX_decode_env (); |
2981 int TEX_Token (); | 2979 int TEX_Token (); |
2982 #if TeX_named_tokens | 2980 #if TeX_named_tokens |
3364 patterns[num_patterns - 1].name_pattern = savestr (name); | 3362 patterns[num_patterns - 1].name_pattern = savestr (name); |
3365 patterns[num_patterns - 1].error_signaled = FALSE; | 3363 patterns[num_patterns - 1].error_signaled = FALSE; |
3366 } | 3364 } |
3367 | 3365 |
3368 /* | 3366 /* |
3369 * Do the subtitutions indicated by the regular expression and | 3367 * Do the substitutions indicated by the regular expression and |
3370 * arguments. | 3368 * arguments. |
3371 */ | 3369 */ |
3372 char * | 3370 char * |
3373 substitute (in, out, regs) | 3371 substitute (in, out, regs) |
3374 char *in, *out; | 3372 char *in, *out; |
3412 strncpy (result + size, in + regs->start[dig2], | 3410 strncpy (result + size, in + regs->start[dig2], |
3413 regs->end[dig2] - regs->start[dig2]); | 3411 regs->end[dig2] - regs->start[dig2]); |
3414 size += regs->end[dig2] - regs->start[dig2]; | 3412 size += regs->end[dig2] - regs->start[dig2]; |
3415 } | 3413 } |
3416 else | 3414 else |
3417 { | 3415 result[size++] = *out; |
3418 switch (*out) | |
3419 { | |
3420 case '\t': | |
3421 result[size++] = '\t'; | |
3422 break; | |
3423 case '\\': | |
3424 *out = '\\'; | |
3425 break; | |
3426 default: | |
3427 result[size++] = *out; | |
3428 break; | |
3429 } | |
3430 } | |
3431 } | 3416 } |
3432 else | 3417 else |
3433 result[size++] = *out; | 3418 result[size++] = *out; |
3434 } | 3419 } |
3435 result[size] = '\0'; | 3420 result[size] = '\0'; |
3686 | 3671 |
3687 return result; | 3672 return result; |
3688 } | 3673 } |
3689 | 3674 |
3690 /* Does the same work as the system V getcwd, but does not need to | 3675 /* Does the same work as the system V getcwd, but does not need to |
3691 guess buffer size in advance. */ | 3676 guess the buffer size in advance. */ |
3692 char * | 3677 char * |
3693 etags_getcwd () | 3678 etags_getcwd () |
3694 { | 3679 { |
3695 #ifdef DOS_NT | 3680 #ifdef DOS_NT |
3696 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ | 3681 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ |
3699 p = path; | 3684 p = path; |
3700 while (*p) | 3685 while (*p) |
3701 if (*p == '\\') | 3686 if (*p == '\\') |
3702 *p++ = '/'; | 3687 *p++ = '/'; |
3703 else | 3688 else |
3704 *p++ = tolower (*p); | 3689 *p++ = lowcase (*p); |
3705 | 3690 |
3706 return strdup (path); | 3691 return strdup (path); |
3707 #else /* not DOS_NT */ | 3692 #else /* not DOS_NT */ |
3708 #if HAVE_GETCWD | 3693 #if HAVE_GETCWD |
3709 int bufsize = 200; | 3694 int bufsize = 200; |