aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorJim Blandy1992-04-24 08:11:54 +0000
committerJim Blandy1992-04-24 08:11:54 +0000
commit4746118aca2d5cbdd054b4af4814d56550dfbc79 (patch)
tree370e07c6950794f936bc8d434cb0560d883e4a0b /lib-src
parentd4327fecc103493bc8275c3580b05c06c9fcc019 (diff)
downloademacs-4746118aca2d5cbdd054b4af4814d56550dfbc79.tar.gz
emacs-4746118aca2d5cbdd054b4af4814d56550dfbc79.zip
*** empty log message ***
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c380
-rw-r--r--lib-src/timer.c4
2 files changed, 259 insertions, 125 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index fed3f584eff..69d29109b69 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -1,5 +1,5 @@
1/* Tags file maker to go with GNU Emacs 1/* Tags file maker to go with GNU Emacs
2 Copyright (C) 1984, 1987, 1988, 1989 Free Software Foundation, Inc. and Ken Arnold 2 Copyright (C) 1984, 1987, 1988, 1989, 1992 Free Software Foundation, Inc. and Ken Arnold
3 3
4This file is part of GNU Emacs. 4This file is part of GNU Emacs.
5 5
@@ -31,6 +31,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/stat.h> 32#include <sys/stat.h>
33 33
34#include "getopt.h"
35
34#ifdef __GNUC__ 36#ifdef __GNUC__
35#define alloca __builtin_alloca 37#define alloca __builtin_alloca
36#else 38#else
@@ -410,6 +412,12 @@ DEFINEST definedef;
410#define LEVEL_OK_FOR_FUNCDEF() \ 412#define LEVEL_OK_FOR_FUNCDEF() \
411 (level==0 || c_ext && level==1 && structdef==sinbody) 413 (level==0 || c_ext && level==1 && structdef==sinbody)
412 414
415/*
416 * next_token_is_func
417 * set this to TRUE, and the next token considered is called a function.
418 */
419logical next_token_is_func;
420
413/* C extensions. Currently all listed extensions are C++ dialects, so 421/* C extensions. Currently all listed extensions are C++ dialects, so
414 * `c_ext' is used as an abbreviation for `c_ext&C_PLPL'. If a non-C++ 422 * `c_ext' is used as an abbreviation for `c_ext&C_PLPL'. If a non-C++
415 * dialect is added, this must change. 423 * dialect is added, this must change.
@@ -436,7 +444,6 @@ char *curfile, /* current input file name */
436 *intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789", /* valid in-token chars */ 444 *intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789", /* valid in-token chars */
437 *notgd = ",;"; /* non-valid after-function chars */ 445 *notgd = ",;"; /* non-valid after-function chars */
438 446
439int file_num; /* current file number */
440int append_to_tagfile; /* -a: append to tags */ 447int append_to_tagfile; /* -a: append to tags */
441int emacs_tags_format; /* emacs style output (no -e option any more) */ 448int emacs_tags_format; /* emacs style output (no -e option any more) */
442/* The following three default to 1 for etags, but to 0 for ctags. */ 449/* The following three default to 1 for etags, but to 0 for ctags. */
@@ -458,6 +465,27 @@ int noindentypedefs; /* -S: ignore indentation in C */
458/* Name this program was invoked with. */ 465/* Name this program was invoked with. */
459char *progname; 466char *progname;
460 467
468struct option longopts[] = {
469 { "append", no_argument, NULL, 'a' },
470 { "backward-search", no_argument, NULL, 'B' },
471 { "c++", no_argument, NULL, 'C' },
472 { "cxref", no_argument, NULL, 'x' },
473 { "defines", no_argument, NULL, 'd' },
474 { "forward-search", no_argument, NULL, 'F' },
475 { "help", no_argument, NULL, 'H' },
476 { "ignore-indentation", no_argument, NULL, 'S' },
477 { "include", required_argument, NULL, 'i' },
478 { "no-defines", no_argument, NULL, 'D' },
479 { "no-warn", no_argument, NULL, 'w' },
480 { "output", required_argument, NULL, 'o' },
481 { "typedefs", no_argument, NULL, 't' },
482 { "typedefs-and-c++", no_argument, NULL, 'T' },
483 { "update", no_argument, NULL, 'u' },
484 { "version", no_argument, NULL, 'V' },
485 { "vgrind", no_argument, NULL, 'v' },
486 { 0 }
487};
488
461FILE *inf, /* ioptr for current input file */ 489FILE *inf, /* ioptr for current input file */
462 *outf; /* ioptr for tags file */ 490 *outf; /* ioptr for tags file */
463 491
@@ -481,13 +509,118 @@ struct linebuffer filename_lb; /* used to read in filenames */
481 509
482 510
483void 511void
512print_version ()
513{
514#ifdef CTAGS
515 printf ("CTAGS ");
516#ifdef ETAGS
517 printf ("and ");
518#endif
519#endif
520#ifdef ETAGS
521 printf ("ETAGS ");
522#endif
523 printf ("for Emacs version 19.0.\n");
524
525 exit (0);
526}
527
528void
529print_help ()
530{
531 printf ("These are the options accepted by %s. You may use unambiguous\n\
532abbreviations for the long option names.\n\n", progname);
533
534 fputs ("\
535-a, --append\n\
536 Append tag entries to existing tags file.\n\
537-C, --c++\n\
538 Treat files with `.c' and `.h' extensions as C++ code, not C\n\
539 code. Files with `.C', `.H', `.cxx', `.hxx', or `.cc'\n\
540 extensions are always assumed to be C++ code.\n\
541-d, --defines\n\
542 Create tag entries for #defines, too.", stdout);
543
544#ifdef ETAGS
545 fputs (" This is the default\n\
546 behavior.", stdout);
547#endif
548
549 fputs ("\n\
550-D, --no-defines\n\
551 Don't create tag entries for #defines.", stdout);
552
553#ifdef CTAGS
554 fputs (" This is the default\n\
555 behavior.", stdout);
556#endif
557
558 puts ("\n\
559-o FILE, --output=FILE\n\
560 Write the tags to FILE.\n\
561-S, --ignore-indentation\n\
562 Don't rely on indentation quite as much as normal. Currently,\n\
563 this means not to assume that a closing brace in the first\n\
564 column is the final brace of a function or structure\n\
565 definition.\n\
566-t, --typedefs\n\
567 Generate tag entries for typedefs. This is the default\n\
568 behavior.\n\
569-T, --typedefs-and-c++\n\
570 Generate tag entries for typedefs, struct/enum/union tags, and\n\
571 C++ member functions.");
572
573#ifdef ETAGS
574 puts ("-i FILE, --include=FILE\n\
575 Include a note in tag file indicating that, when searching for\n\
576 a tag, one should also consult the tags file FILE after\n\
577 checking the current file.");
578#endif
579
580#ifdef CTAGS
581 puts ("-B, --backward-search\n\
582 Write the search commands for the tag entries using '?', the\n\
583 backward-search command.\n\
584-F, --forward-search\n\
585 Write the search commands for the tag entries using '/', the\n\
586 forward-search command.\n\
587-u, --update\n\
588 Update the tag entries for the given files, leaving tag\n\
589 entries for other files in place. Currently, this is\n\
590 implemented by deleting the existing entries for the given\n\
591 files and then rewriting the new entries at the end of the\n\
592 tags file. It is often faster to simply rebuild the entire\n\
593 tag file than to use this.\n\
594-v, --vgrind\n\
595 Generates an index of items intended for human consumption,\n\
596 similar to the output of vgrind. The index is sorted, and\n\
597 gives the page number of each item.\n\
598-x, --cxref\n\
599 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
600 The output uses line numbers instead of page numbers, but\n\
601 beyond that the differences are cosmetic; try both to see\n\
602 which you like.\n\
603-w, --no-warn\n\
604 Suppress warning messages about entries defined in multiple\n\
605 files.");
606#endif
607
608 puts ("-V, --version\n\
609 Print the version of the program.\n\
610-H, --help\n\
611 Print this help message.");
612
613 exit (0);
614}
615
616
617void
484main (argc, argv) 618main (argc, argv)
485 int argc; 619 int argc;
486 char *argv[]; 620 char *argv[];
487{ 621{
488 char cmd[100]; 622 char cmd[100];
489 int i; 623 int i;
490 int outfflag = 0;
491 unsigned int nincluded_files = 0; 624 unsigned int nincluded_files = 0;
492 char **included_files = (char **) alloca (argc * sizeof (char *)); 625 char **included_files = (char **) alloca (argc * sizeof (char *));
493 char *this_file; 626 char *this_file;
@@ -513,116 +646,109 @@ main (argc, argv)
513 if (emacs_tags_format) 646 if (emacs_tags_format)
514 typedefs = typedefs_and_cplusplus = constantypedefs = 1; 647 typedefs = typedefs_and_cplusplus = constantypedefs = 1;
515 648
516 for (; argc > 1 && argv[1][0] == '-' && argv[1][1] != '\0'; argc--, argv++) 649 for (;;)
517 { 650 {
518 for (i = 1; argv[1][i]; i++) 651 int opt;
652 opt = getopt_long (argc, argv, "aCdDo:StTi:BFuvxwVH", longopts, 0);
653
654 if (opt == EOF)
655 break;
656
657 switch (opt)
519 { 658 {
520 switch (argv[1][i]) 659 case '\0':
660 /* If getopt returns '\0', then it has already processed a
661 long-named option. We should do nothing. */
662 break;
663
664 /* Common options. */
665 case 'a':
666 append_to_tagfile++;
667 break;
668 case 'C':
669 cplusplus = 1;
670 break;
671 case 'd':
672 constantypedefs = 1;
673 break;
674 case 'D':
675 constantypedefs = 0;
676 break;
677 case 'o':
678 if (outfile)
521 { 679 {
522 /* Common options. */ 680 fprintf (stderr,
523 case 'a': 681 "%s: -o flag may only be given once\n", progname);
524 append_to_tagfile++;
525 break;
526 case 'C':
527 cplusplus = 1;
528 break;
529 case 'd':
530 constantypedefs = 1;
531 break;
532 case 'D':
533 constantypedefs = 0;
534 break;
535 case 'o':
536 if (outfflag)
537 {
538 fprintf (stderr,
539 "%s: -o flag may only be given once\n", progname);
540 goto usage;
541 }
542 outfflag++, argc--;
543 argv++;
544 if (argc <= 1 || argv[1][0] == '\0')
545 {
546 fprintf (stderr,
547 "%s: -o flag must be followed by a filename\n",
548 progname);
549 goto usage;
550 }
551 outfile = argv[1];
552 goto next_arg;
553 case 'S':
554 noindentypedefs++;
555 break;
556 case 't':
557 typedefs++;
558 break;
559 case 'T':
560 typedefs++;
561 typedefs_and_cplusplus++;
562 break;
563
564 /* Etags options */
565 case 'i':
566 if (!emacs_tags_format)
567 goto usage;
568 --argc;
569 ++argv;
570 if (argc <= 1 || argv[1][0] == '\0')
571 {
572 fprintf (stderr,
573 "%s: -i flag must be followed by a filename\n",
574 progname);
575 goto usage;
576 }
577 included_files[nincluded_files++] = argv[1];
578 goto next_arg;
579
580 /* Ctags options. */
581 case 'B':
582 searchar = '?';
583 if (emacs_tags_format)
584 goto usage;
585 break;
586 case 'F':
587 searchar = '/';
588 if (emacs_tags_format)
589 goto usage;
590 break;
591 case 'u':
592 update++;
593 if (emacs_tags_format)
594 goto usage;
595 break;
596 case 'v':
597 vgrind_style++;
598 /*FALLTHRU*/
599 case 'x':
600 cxref_style++;
601 if (emacs_tags_format)
602 goto usage;
603 break;
604 case 'w':
605 no_warnings++;
606 if (emacs_tags_format)
607 goto usage;
608 break;
609
610 default:
611 goto usage; 682 goto usage;
612 } 683 }
684 outfile = optarg;
685 break;
686 case 'S':
687 noindentypedefs++;
688 break;
689 case 't':
690 typedefs++;
691 break;
692 case 'T':
693 typedefs++;
694 typedefs_and_cplusplus++;
695 break;
696 case 'V':
697 print_version ();
698 break;
699 case 'H':
700 print_help ();
701 break;
702
703 /* Etags options */
704 case 'i':
705 if (!emacs_tags_format)
706 goto usage;
707 included_files[nincluded_files++] = optarg;
708 break;
709
710 /* Ctags options. */
711 case 'B':
712 searchar = '?';
713 if (emacs_tags_format)
714 goto usage;
715 break;
716 case 'F':
717 searchar = '/';
718 if (emacs_tags_format)
719 goto usage;
720 break;
721 case 'u':
722 update++;
723 if (emacs_tags_format)
724 goto usage;
725 break;
726 case 'v':
727 vgrind_style++;
728 /*FALLTHRU*/
729 case 'x':
730 cxref_style++;
731 if (emacs_tags_format)
732 goto usage;
733 break;
734 case 'w':
735 no_warnings++;
736 if (emacs_tags_format)
737 goto usage;
738 break;
739
740 default:
741 goto usage;
613 } 742 }
614 next_arg:;
615 } 743 }
616 744
617 if (argc <= 1) 745 if (optind == argc)
618 { 746 {
747 fprintf (stderr, "%s: No input files specified.\n", progname);
748
619 usage: 749 usage:
620 fprintf (stderr, "Usage:\n"); 750 fprintf (stderr, "%s: Try '%s --help' for a complete list of options.\n",
621#ifndef CTAGS 751 progname, progname);
622 fprintf (stderr, "\tetags [-aDiS] [-o tagsfile] file ...\n");
623#else
624 fprintf (stderr, "\tctags [-aBdeFTStuwvx] [-o tagsfile] file ...\n");
625#endif
626 exit (BAD); 752 exit (BAD);
627 } 753 }
628 754
@@ -652,10 +778,10 @@ main (argc, argv)
652 } 778 }
653 } 779 }
654 780
655 file_num = 1;
656#ifdef VMS 781#ifdef VMS
657 for (argc--, argv++; 782 argc -= optind;
658 (this_file = gfnames (&argc, &argv, &got_err)) != NULL; file_num++) 783 argv += optind;
784 while (gfnames (&argc, &argv, &got_err) != NULL)
659 { 785 {
660 if (got_err) 786 if (got_err)
661 { 787 {
@@ -670,9 +796,9 @@ main (argc, argv)
670 } /* solely to balance out the ifdef'd parens above */ 796 } /* solely to balance out the ifdef'd parens above */
671#endif 797#endif
672#else 798#else
673 for (; file_num < argc; file_num++) 799 for (; optind < argc; optind++)
674 { 800 {
675 this_file = argv[file_num]; 801 this_file = argv[optind];
676 if (1) 802 if (1)
677 { 803 {
678#endif 804#endif
@@ -706,9 +832,11 @@ main (argc, argv)
706 put_entries (head); 832 put_entries (head);
707 exit (GOOD); 833 exit (GOOD);
708 } 834 }
709 if (update) /* update cannot be set under VMS */ 835 if (update)
710 { 836 {
711 for (i = 1; i < argc; i++) 837 /* update cannot be set under VMS, so we may assume that argc
838 and argv have not been munged. */
839 for (i = optind; i < argc; i++)
712 { 840 {
713 sprintf (cmd, 841 sprintf (cmd,
714 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS", 842 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
@@ -905,7 +1033,9 @@ find_entries (file)
905 goto close_and_return; 1033 goto close_and_return;
906 } 1034 }
907 /* if not a .c or .h or .y file, try fortran */ 1035 /* if not a .c or .h or .y file, try fortran */
908 else if (cp && ((cp[1] != 'c' && cp[1] != 'h' && cp[1] != 'y') 1036 else if (cp && ((cp[1] != 'c'
1037 && cp[1] != 'h'
1038 && cp[1] != 'y')
909 || (cp[1] != 0 && cp[2] != 0))) 1039 || (cp[1] != 0 && cp[2] != 0)))
910 { 1040 {
911 if (PF_funcs (inf) != 0) 1041 if (PF_funcs (inf) != 0)
@@ -1308,6 +1438,8 @@ C_entries (c_ext)
1308 definedef = dnone; 1438 definedef = dnone;
1309 gotone = midtoken = inquote = inchar = incomm = FALSE; 1439 gotone = midtoken = inquote = inchar = incomm = FALSE;
1310 level = 0; 1440 level = 0;
1441 tydef = none;
1442 next_token_is_func = 0;
1311 1443
1312 C_create_stabs (); 1444 C_create_stabs ();
1313 1445
@@ -1316,6 +1448,9 @@ C_entries (c_ext)
1316 c = *lp++; 1448 c = *lp++;
1317 if (c == '\\') 1449 if (c == '\\')
1318 { 1450 {
1451 /* If we're at the end of the line, the next character is a
1452 '\0'; don't skip it, because it's the thing that tells us
1453 to read the next line. */
1319 if (*lp == 0) 1454 if (*lp == 0)
1320 continue; 1455 continue;
1321 lp++; 1456 lp++;
@@ -1331,10 +1466,6 @@ C_entries (c_ext)
1331 } 1466 }
1332 else if (inquote) 1467 else if (inquote)
1333 { 1468 {
1334 /*
1335 * Too dumb to know about \" not being magic, but
1336 * they usually occur in pairs anyway.
1337 */
1338 if (c == '"') 1469 if (c == '"')
1339 inquote = FALSE; 1470 inquote = FALSE;
1340 continue; 1471 continue;
@@ -1569,11 +1700,6 @@ consider_token (c, lpp, tokp, is_func, c_ext, level)
1569 int level; /* IN */ 1700 int level; /* IN */
1570{ 1701{
1571 reg char *lp = *lpp; 1702 reg char *lp = *lpp;
1572 /*
1573 * next_token_is_func
1574 * set this to TRUE, and the next token considered is called a function.
1575 */
1576 static logical next_token_is_func;
1577 logical firsttok; /* TRUE if have seen first token in ()'s */ 1703 logical firsttok; /* TRUE if have seen first token in ()'s */
1578 Stab_entry *tokse = stab_find (get_C_stab (c_ext), tokp->p, tokp->len); 1704 Stab_entry *tokse = stab_find (get_C_stab (c_ext), tokp->p, tokp->len);
1579 enum sym_type toktype = stab_type (tokse); 1705 enum sym_type toktype = stab_type (tokse);
@@ -1758,10 +1884,18 @@ consider_token (c, lpp, tokp, is_func, c_ext, level)
1758 goto goodone; 1884 goto goodone;
1759 } 1885 }
1760 /* Detect GNUmacs's function-defining macros. */ 1886 /* Detect GNUmacs's function-defining macros. */
1761 if (definedef == dnone && strneq (tokp->p, "DEF", 3)) 1887 if (definedef == dnone)
1762 { 1888 {
1763 next_token_is_func = TRUE; 1889 if (strneq (tokp->p, "DEF", 3))
1764 goto badone; 1890 {
1891 next_token_is_func = TRUE;
1892 goto badone;
1893 }
1894 else if (strneq (tokp->p, "EXFUN", 5))
1895 {
1896 next_token_is_func = FALSE;
1897 goto badone;
1898 }
1765 } 1899 }
1766 if (next_token_is_func) 1900 if (next_token_is_func)
1767 { 1901 {
diff --git a/lib-src/timer.c b/lib-src/timer.c
index 149625f2995..d7084bfcdc4 100644
--- a/lib-src/timer.c
+++ b/lib-src/timer.c
@@ -105,7 +105,7 @@ void
105getevent() 105getevent()
106 106
107{ 107{
108 extern char *memcpy(), *fgets(); 108 extern char *fgets();
109 struct event *ep; 109 struct event *ep;
110 char buf[256]; 110 char buf[256];
111 111
@@ -127,7 +127,7 @@ getevent()
127 free((char *)events[slot]), events[slot] = 0; 127 free((char *)events[slot]), events[slot] = 0;
128 128
129 else { 129 else {
130 (void)memcpy((char *)events[slot],(char *)ep,sizeof(struct event)); 130 memcpy((char *)events[slot],(char *)ep,sizeof(struct event));
131 if (slot == mevent) mevent++; 131 if (slot == mevent) mevent++;
132 } /* schedule */ 132 } /* schedule */
133 } /* malloc */ 133 } /* malloc */