aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorFrancesco Potortì1994-03-25 14:31:24 +0000
committerFrancesco Potortì1994-03-25 14:31:24 +0000
commit32daa216192d20b884095e70e12d82ed5794fbac (patch)
treeb95cf46ad256e0992e4c3aab7b7d97c2956df754 /lib-src
parent029b623a7e3bcad33d2f97250f962ae4f5ca0add (diff)
downloademacs-32daa216192d20b884095e70e12d82ed5794fbac.tar.gz
emacs-32daa216192d20b884095e70e12d82ed5794fbac.zip
* etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
(main): don't allow the use of -t and -T in etags mode. (print_help): don't show options enabled by default. (print_version): show the emacs version number if VERSION is #defined. (find_entries): add "ss" as suffix for Chez Scheme.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c200
1 files changed, 83 insertions, 117 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index 461d9dc6042..0a77dbc1467 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -28,7 +28,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
28 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer. 28 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer.
29 */ 29 */
30 30
31char etags_version[] = "@(#) pot revision number is 10.15"; 31char pot_etags_version[] = "@(#) pot revision number is 10.18";
32 32
33#ifdef MSDOS 33#ifdef MSDOS
34#include <fcntl.h> 34#include <fcntl.h>
@@ -53,33 +53,23 @@ extern char *getenv ();
53extern char *getcwd (); 53extern char *getcwd ();
54 54
55 55
56/* Define the symbol ETAGS to make the program "etags", 56/* Define CTAGS to make the program "ctags" compatible with the usual one.
57 which makes emacs-style tag tables by default. 57 Let it undefined to make the program "etags", which makes emacs-style
58 Define CTAGS to make the program "ctags" compatible with the usual one. 58 tag tables and tags typedefs, #defines and struct/union/enum by default. */
59 Define neither one to get behavior that depends 59#ifdef CTAGS
60 on the name with which the program is invoked 60# undef CTAGS
61 (but we don't normally compile it that way). */ 61# define CTAGS TRUE
62 62#else
63#if !defined(ETAGS) && !defined(CTAGS) 63# define CTAGS FALSE
64/* If neither is defined, program can be run as either. */
65#define ETAGS
66#define CTAGS
67#endif
68
69/* On VMS, CTAGS is not useful, so always do ETAGS. */
70#ifdef VMS
71#ifndef ETAGS
72#define ETAGS
73#endif
74#endif 64#endif
75 65
76/* Exit codes for success and failure. */ 66/* Exit codes for success and failure. */
77#ifdef VMS 67#ifdef VMS
78#define GOOD (1) 68#define GOOD 1
79#define BAD (0) 69#define BAD 0
80#else 70#else
81#define GOOD (0) 71#define GOOD 0
82#define BAD (1) 72#define BAD 1
83#endif 73#endif
84 74
85/* 75/*
@@ -247,15 +237,13 @@ char *curfile, /* current input file name */
247 *intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789"; 237 *intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
248 238
249int append_to_tagfile; /* -a: append to tags */ 239int append_to_tagfile; /* -a: append to tags */
250int emacs_tags_format; /* emacs style output (no -e option any more) */
251/* The following three default to 1 for etags, but to 0 for ctags. */ 240/* The following three default to 1 for etags, but to 0 for ctags. */
252int typedefs; /* -t: create tags for typedefs */ 241int typedefs; /* -t: create tags for typedefs */
253int typedefs_and_cplusplus; /* -T: create tags for typedefs, level */ 242int typedefs_and_cplusplus; /* -T: create tags for typedefs, level */
254 /* 0 struct/enum/union decls, and C++ */ 243 /* 0 struct/enum/union decls, and C++ */
255 /* member functions */ 244 /* member functions. */
256int constantypedefs; /* -d: create tags for C #define and enum */ 245int constantypedefs; /* -d: create tags for C #define and enum */
257 /* constants. Default under etags. Enum */ 246 /* constants. Enum consts not implemented. */
258 /* constants not implemented. */
259 /* -D: opposite of -d. Default under ctags. */ 247 /* -D: opposite of -d. Default under ctags. */
260int update; /* -u: update tags */ 248int update; /* -u: update tags */
261int vgrind_style; /* -v: create vgrind style index output */ 249int vgrind_style; /* -v: create vgrind style index output */
@@ -316,16 +304,11 @@ struct
316void 304void
317print_version () 305print_version ()
318{ 306{
319#ifdef CTAGS 307#ifdef VERSION
320 printf ("CTAGS "); 308 printf ("%s for Emacs version %g.\n", (CTAGS) ? "CTAGS" : "ETAGS", VERSION);
321#ifdef ETAGS 309#else
322 printf ("and "); 310 printf ("%s for Emacs version 19.\n", (CTAGS) ? "CTAGS" : "ETAGS");
323#endif 311#endif
324#endif
325#ifdef ETAGS
326 printf ("ETAGS ");
327#endif
328 printf ("for Emacs version 19.\n");
329 312
330 exit (GOOD); 313 exit (GOOD);
331} 314}
@@ -340,48 +323,34 @@ names from stdin.\n\n", progname);
340 puts ("-a, --append\n\ 323 puts ("-a, --append\n\
341 Append tag entries to existing tags file."); 324 Append tag entries to existing tags file.");
342 325
343#ifdef CTAGS 326 if (CTAGS)
344 puts ("-B, --backward-search\n\ 327 puts ("-B, --backward-search\n\
345 Write the search commands for the tag entries using '?', the\n\ 328 Write the search commands for the tag entries using '?', the\n\
346 backward-search command."); 329 backward-search command.");
347#endif
348 330
349 puts ("-C, --c++\n\ 331 puts ("-C, --c++\n\
350 Treat files with `.c' and `.h' extensions as C++ code, not C\n\ 332 Treat files with `.c' and `.h' extensions as C++ code, not C\n\
351 code. Files with `.C', `.H', `.cxx', `.hxx', or `.cc'\n\ 333 code. Files with `.C', `.H', `.cxx', `.hxx', or `.cc'\n\
352 extensions are always assumed to be C++ code."); 334 extensions are always assumed to be C++ code.");
353 335
354#ifdef ETAGS 336 if (CTAGS)
355 puts ("-d, --defines\n\ 337 puts ("-d, --defines\n\
356 Create tag entries for #defines, too. This is the default\n\ 338 Create tag entries for C #defines, too.");
357 behavior."); 339 else
358#else 340 puts ("-D, --no-defines\n\
359 puts ("-d, --defines\n\ 341 Don't create tag entries for C #defines. This makes the tags\n\
360 Create tag entries for #defines, too."); 342 file smaller.");
361#endif
362
363#ifdef CTAGS
364 puts ("-D, --no-defines\n\
365 Don't create tag entries for #defines. This is the default\n\
366 behavior.");
367#else
368 puts ("-D, --no-defines\n\
369 Don't create tag entries for #defines.");
370#endif
371 343
372#ifdef CTAGS 344 if (CTAGS)
373 puts ("-F, --forward-search\n\ 345 puts ("-F, --forward-search\n\
374 Write the search commands for the tag entries using '/', the\n\ 346 Write the search commands for the tag entries using '/', the\n\
375 forward-search command."); 347 forward-search command.");
376#endif
377 348
378 349 if (!CTAGS)
379#ifdef ETAGS 350 puts ("-i FILE, --include=FILE\n\
380 puts ("-i FILE, --include=FILE\n\
381 Include a note in tag file indicating that, when searching for\n\ 351 Include a note in tag file indicating that, when searching for\n\
382 a tag, one should also consult the tags file FILE after\n\ 352 a tag, one should also consult the tags file FILE after\n\
383 checking the current file."); 353 checking the current file.");
384#endif
385 354
386 puts ("-o FILE, --output=FILE\n\ 355 puts ("-o FILE, --output=FILE\n\
387 Write the tags to FILE."); 356 Write the tags to FILE.");
@@ -389,35 +358,39 @@ names from stdin.\n\n", progname);
389 Don't rely on indentation quite as much as normal. Currently,\n\ 358 Don't rely on indentation quite as much as normal. Currently,\n\
390 this means not to assume that a closing brace in the first\n\ 359 this means not to assume that a closing brace in the first\n\
391 column is the final brace of a function or structure\n\ 360 column is the final brace of a function or structure\n\
392 definition."); 361 definition in C and C++.");
393 puts ("-t, --typedefs\n\
394 Generate tag entries for typedefs. This is the default\n\
395 behavior.");
396 puts ("-T, --typedefs-and-c++\n\
397 Generate tag entries for typedefs, struct/enum/union tags, and\n\
398 C++ member functions.");
399 362
400#ifdef CTAGS 363 if (CTAGS)
401 puts ("-u, --update\n\ 364 {
365 puts ("-t, --typedefs\n\
366 Generate tag entries for C typedefs.");
367 puts ("-T, --typedefs-and-c++\n\
368 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
369 and C++ member functions.");
370 }
371
372 if (CTAGS)
373 {
374 puts ("-u, --update\n\
402 Update the tag entries for the given files, leaving tag\n\ 375 Update the tag entries for the given files, leaving tag\n\
403 entries for other files in place. Currently, this is\n\ 376 entries for other files in place. Currently, this is\n\
404 implemented by deleting the existing entries for the given\n\ 377 implemented by deleting the existing entries for the given\n\
405 files and then rewriting the new entries at the end of the\n\ 378 files and then rewriting the new entries at the end of the\n\
406 tags file. It is often faster to simply rebuild the entire\n\ 379 tags file. It is often faster to simply rebuild the entire\n\
407 tag file than to use this."); 380 tag file than to use this.");
408 puts ("-v, --vgrind\n\ 381 puts ("-v, --vgrind\n\
409 Generates an index of items intended for human consumption,\n\ 382 Generates an index of items intended for human consumption,\n\
410 similar to the output of vgrind. The index is sorted, and\n\ 383 similar to the output of vgrind. The index is sorted, and\n\
411 gives the page number of each item."); 384 gives the page number of each item.");
412 puts ("-x, --cxref\n\ 385 puts ("-x, --cxref\n\
413 Like --vgrind, but in the style of cxref, rather than vgrind.\n\ 386 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
414 The output uses line numbers instead of page numbers, but\n\ 387 The output uses line numbers instead of page numbers, but\n\
415 beyond that the differences are cosmetic; try both to see\n\ 388 beyond that the differences are cosmetic; try both to see\n\
416 which you like."); 389 which you like.");
417 puts ("-w, --no-warn\n\ 390 puts ("-w, --no-warn\n\
418 Suppress warning messages about entries defined in multiple\n\ 391 Suppress warning messages about entries defined in multiple\n\
419 files."); 392 files.");
420#endif 393 }
421 394
422 puts ("-V, --version\n\ 395 puts ("-V, --version\n\
423 Print the version of the program.\n\ 396 Print the version of the program.\n\
@@ -451,23 +424,17 @@ main (argc, argv)
451 424
452 progname = argv[0]; 425 progname = argv[0];
453 426
454#ifndef CTAGS
455 emacs_tags_format = 1;
456#else
457 emacs_tags_format = 0;
458#endif
459
460 /* 427 /*
461 * If etags, always find typedefs and structure tags. Why not? 428 * If etags, always find typedefs and structure tags. Why not?
462 * Also default is to find macro constants. 429 * Also default is to find macro constants.
463 */ 430 */
464 if (emacs_tags_format) 431 if (!CTAGS)
465 typedefs = typedefs_and_cplusplus = constantypedefs = 1; 432 typedefs = typedefs_and_cplusplus = constantypedefs = 1;
466 433
467 for (;;) 434 for (;;)
468 { 435 {
469 int opt; 436 int opt;
470 opt = getopt_long (argc, argv, "aCdDo:f:StTi:BFuvxwVH", longopts, 0); 437 opt = getopt_long (argc, argv, "aCdDf:o:StTi:BFuvxwVH", longopts, 0);
471 438
472 if (opt == EOF) 439 if (opt == EOF)
473 break; 440 break;
@@ -492,7 +459,7 @@ main (argc, argv)
492 case 'D': 459 case 'D':
493 constantypedefs = 0; 460 constantypedefs = 0;
494 break; 461 break;
495 case 'f': 462 case 'f': /* for compatibility with old makefiles */
496 case 'o': 463 case 'o':
497 if (outfile) 464 if (outfile)
498 { 465 {
@@ -505,13 +472,6 @@ main (argc, argv)
505 case 'S': 472 case 'S':
506 noindentypedefs++; 473 noindentypedefs++;
507 break; 474 break;
508 case 't':
509 typedefs++;
510 break;
511 case 'T':
512 typedefs++;
513 typedefs_and_cplusplus++;
514 break;
515 case 'V': 475 case 'V':
516 print_version (); 476 print_version ();
517 break; 477 break;
@@ -521,7 +481,7 @@ main (argc, argv)
521 481
522 /* Etags options */ 482 /* Etags options */
523 case 'i': 483 case 'i':
524 if (!emacs_tags_format) 484 if (CTAGS)
525 goto usage; 485 goto usage;
526 included_files[nincluded_files++] = optarg; 486 included_files[nincluded_files++] = optarg;
527 break; 487 break;
@@ -529,31 +489,35 @@ main (argc, argv)
529 /* Ctags options. */ 489 /* Ctags options. */
530 case 'B': 490 case 'B':
531 searchar = '?'; 491 searchar = '?';
532 if (emacs_tags_format) 492 if (!CTAGS) goto usage;
533 goto usage;
534 break; 493 break;
535 case 'F': 494 case 'F':
536 searchar = '/'; 495 searchar = '/';
537 if (emacs_tags_format) 496 if (!CTAGS) goto usage;
538 goto usage; 497 break;
498 case 't':
499 typedefs++;
500 if (!CTAGS) goto usage;
501 break;
502 case 'T':
503 typedefs++;
504 typedefs_and_cplusplus++;
505 if (!CTAGS) goto usage;
539 break; 506 break;
540 case 'u': 507 case 'u':
541 update++; 508 update++;
542 if (emacs_tags_format) 509 if (!CTAGS) goto usage;
543 goto usage;
544 break; 510 break;
545 case 'v': 511 case 'v':
546 vgrind_style++; 512 vgrind_style++;
547 /*FALLTHRU*/ 513 /*FALLTHRU*/
548 case 'x': 514 case 'x':
549 cxref_style++; 515 cxref_style++;
550 if (emacs_tags_format) 516 if (!CTAGS) goto usage;
551 goto usage;
552 break; 517 break;
553 case 'w': 518 case 'w':
554 no_warnings++; 519 no_warnings++;
555 if (emacs_tags_format) 520 if (!CTAGS) goto usage;
556 goto usage;
557 break; 521 break;
558 522
559 default: 523 default:
@@ -573,7 +537,7 @@ main (argc, argv)
573 537
574 if (outfile == NULL) 538 if (outfile == NULL)
575 { 539 {
576 outfile = emacs_tags_format ? "TAGS" : "tags"; 540 outfile = CTAGS ? "tags" : "TAGS";
577 } 541 }
578 getcwd (cwd, BUFSIZ); /* the current working directory */ 542 getcwd (cwd, BUFSIZ); /* the current working directory */
579 strcat (cwd, "/"); 543 strcat (cwd, "/");
@@ -595,7 +559,7 @@ main (argc, argv)
595 /* 559 /*
596 * loop through files finding functions 560 * loop through files finding functions
597 */ 561 */
598 if (emacs_tags_format) 562 if (!CTAGS)
599 { 563 {
600 if (streq (outfile, "-")) 564 if (streq (outfile, "-"))
601 outf = stdout; 565 outf = stdout;
@@ -644,7 +608,7 @@ main (argc, argv)
644 process_file (this_file); 608 process_file (this_file);
645 } 609 }
646 610
647 if (emacs_tags_format) 611 if (!CTAGS)
648 { 612 {
649 while (nincluded_files-- > 0) 613 while (nincluded_files-- > 0)
650 fprintf (outf, "\f\n%s,include\n", *included_files++); 614 fprintf (outf, "\f\n%s,include\n", *included_files++);
@@ -711,7 +675,7 @@ process_file (file)
711 { 675 {
712 return; 676 return;
713 } 677 }
714 if (emacs_tags_format) 678 if (!CTAGS)
715 { 679 {
716 char *filename; 680 char *filename;
717 681
@@ -809,6 +773,7 @@ find_entries (file)
809 || streq (cp + 1, "scheme") 773 || streq (cp + 1, "scheme")
810 || streq (cp + 1, "t") 774 || streq (cp + 1, "t")
811 || streq (cp + 1, "sch") 775 || streq (cp + 1, "sch")
776 || streq (cp + 1, "ss")
812 || streq (cp + 1, "SM") 777 || streq (cp + 1, "SM")
813 || streq (cp + 1, "SCM") 778 || streq (cp + 1, "SCM")
814 /* The `SCM' or `scm' prefix with a version number */ 779 /* The `SCM' or `scm' prefix with a version number */
@@ -923,7 +888,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno)
923 np = xnew (1, NODE); 888 np = xnew (1, NODE);
924 if (np == NULL) 889 if (np == NULL)
925 { 890 {
926 if (!emacs_tags_format) 891 if (CTAGS)
927 { 892 {
928 /* It's okay to output early in etags -- it only disrupts the 893 /* It's okay to output early in etags -- it only disrupts the
929 * character count of the tag entries, which is no longer used 894 * character count of the tag entries, which is no longer used
@@ -937,7 +902,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno)
937 np = xnew (1, NODE); 902 np = xnew (1, NODE);
938 } 903 }
939 /* If ctags mode, change name "main" to M<thisfilename>. */ 904 /* If ctags mode, change name "main" to M<thisfilename>. */
940 if (!emacs_tags_format && !cxref_style && streq (name, "main")) 905 if (CTAGS && !cxref_style && streq (name, "main"))
941 { 906 {
942 fp = etags_rindex (curfile, '/'); 907 fp = etags_rindex (curfile, '/');
943 name = concat ("M", fp == 0 ? curfile : fp + 1, ""); 908 name = concat ("M", fp == 0 ? curfile : fp + 1, "");
@@ -954,7 +919,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno)
954 /* UNCOMMENT THE +1 HERE: */ 919 /* UNCOMMENT THE +1 HERE: */
955 np->cno = cno /* + 1 */ ; /* our char numbers are 0-base; emacs's are 1-base */ 920 np->cno = cno /* + 1 */ ; /* our char numbers are 0-base; emacs's are 1-base */
956 np->left = np->right = 0; 921 np->left = np->right = 0;
957 if (emacs_tags_format) 922 if (!CTAGS)
958 { 923 {
959 c = linestart[linelen]; 924 c = linestart[linelen];
960 linestart[linelen] = 0; 925 linestart[linelen] = 0;
@@ -965,7 +930,7 @@ pfnote (name, is_func, named, linestart, linelen, lno, cno)
965 linestart = tem; 930 linestart = tem;
966 } 931 }
967 np->pat = savestr (linestart); 932 np->pat = savestr (linestart);
968 if (emacs_tags_format) 933 if (!CTAGS)
969 { 934 {
970 linestart[linelen] = c; 935 linestart[linelen] = c;
971 } 936 }
@@ -1019,7 +984,7 @@ add_node (node, cur_node_p)
1019 return; 984 return;
1020 } 985 }
1021 986
1022 if (emacs_tags_format) 987 if (!CTAGS)
1023 { 988 {
1024 /* Etags Mode */ 989 /* Etags Mode */
1025 if (last_node == NULL) 990 if (last_node == NULL)
@@ -1085,7 +1050,7 @@ put_entries (node)
1085 1050
1086 /* Output this entry */ 1051 /* Output this entry */
1087 1052
1088 if (emacs_tags_format) 1053 if (!CTAGS)
1089 { 1054 {
1090 if (node->named) 1055 if (node->named)
1091 { 1056 {
@@ -1150,9 +1115,10 @@ number_len (num)
1150 1115
1151/* 1116/*
1152 * Return total number of characters that put_entries will output for 1117 * Return total number of characters that put_entries will output for
1153 * the nodes in the subtree of the specified node. Works only if emacs_tags_format 1118 * the nodes in the subtree of the specified node. Works only if
1154 * is set, but called only in that case. This count is irrelevant with 1119 * we are not ctags, but called only in that case. This count
1155 * the new tags.el, but is still supplied for backward compatibility. 1120 * is irrelevant with the new tags.el, but is still supplied for
1121 * backward compatibility.
1156 */ 1122 */
1157int 1123int
1158total_size_of_entries (node) 1124total_size_of_entries (node)