Mercurial > hg > xemacs-beta
comparison lib-src/etags.c @ 3972:6cd3955b7e4d
[xemacs-hg @ 2007-05-21 03:50:13 by stephent]
Sync etags to pot version 17.32.
author | stephent |
---|---|
date | Mon, 21 May 2007 03:50:19 +0000 |
parents | fe5bc63ff0e3 |
children | 9bab7e657255 |
comparison
equal
deleted
inserted
replaced
3971:de8a6fef7fcc | 3972:6cd3955b7e4d |
---|---|
1 /* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*- | 1 /* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*- |
2 Copyright (C) 1984, 1987, 1988, 1989, 1993, 1994, 1995, | 2 |
3 1998, 1999, 2000, 2001, 2002, 2003, 2004, | 3 Copyright (C) 1984 The Regents of the University of California |
4 2005, 2006 Free Software Foundation, Inc. and Ken Arnold | 4 |
5 | 5 Redistribution and use in source and binary forms, with or without |
6 This file is not considered part of GNU Emacs. | 6 modification, are permitted provided that the following conditions are |
7 | 7 met: |
8 This program is free software; you can redistribute it and/or modify | 8 1. Redistributions of source code must retain the above copyright |
9 it under the terms of the GNU General Public License as published by | 9 notice, this list of conditions and the following disclaimer. |
10 the Free Software Foundation; either version 2 of the License, or | 10 2. Redistributions in binary form must reproduce the above copyright |
11 (at your option) any later version. | 11 notice, this list of conditions and the following disclaimer in the |
12 | 12 documentation and/or other materials provided with the |
13 This program is distributed in the hope that it will be useful, | 13 distribution. |
14 but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 3. Neither the name of the University nor the names of its |
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 contributors may be used to endorse or promote products derived |
16 GNU General Public License for more details. | 16 from this software without specific prior written permission. |
17 | 17 |
18 You should have received a copy of the GNU General Public License | 18 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' |
19 along with this program; if not, write to the Free Software Foundation, | 19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
20 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | 20 THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS | |
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
23 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
24 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
25 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
26 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | |
27 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN | |
28 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | |
30 | |
31 Copyright (C) 1984, 1987, 1988, 1989, 1993, 1994, 1995, 1998, 1999, | |
32 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 | |
33 Free Software Foundation, Inc. | |
34 | |
35 This file is not considered part of GNU Emacs. | |
36 | |
37 This program is free software; you can redistribute it and/or modify | |
38 it under the terms of the GNU General Public License as published by | |
39 the Free Software Foundation; either version 2 of the License, or | |
40 (at your option) any later version. | |
41 | |
42 This program is distributed in the hope that it will be useful, | |
43 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
44 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
45 GNU General Public License for more details. | |
46 | |
47 You should have received a copy of the GNU General Public License | |
48 along with this program; if not, write to the Free Software Foundation, | |
49 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
50 | |
51 | |
52 /* NB To comply with the above BSD license, copyright information is | |
53 reproduced in etc/ETAGS.README. That file should be updated when the | |
54 above notices are. | |
55 | |
56 To the best of our knowledge, this code was originally based on the | |
57 ctags.c distributed with BSD4.2, which was copyrighted by the | |
58 University of California, as described above. */ | |
59 | |
21 | 60 |
22 /* | 61 /* |
23 * Authors: | 62 * Authors: |
24 * Ctags originally by Ken Arnold. | 63 * 1983 Ctags originally by Ken Arnold. |
25 * Fortran added by Jim Kleckner. | 64 * 1984 Fortran added by Jim Kleckner. |
26 * Ed Pelegri-Llopart added C typedefs. | 65 * 1984 Ed Pelegri-Llopart added C typedefs. |
27 * Gnu Emacs TAGS format and modifications by RMS? | 66 * 1985 Emacs TAGS format by Richard Stallman. |
28 * 1989 Sam Kendall added C++. | 67 * 1989 Sam Kendall added C++. |
29 * 1992 Joseph B. Wells improved C and C++ parsing. | 68 * 1992 Joseph B. Wells improved C and C++ parsing. |
30 * 1993 Francesco Potort́ reorganised C and C++. | 69 * 1993 Francesco Potort́ reorganised C and C++. |
31 * 1994 Line-by-line regexp tags by Tom Tromey. | 70 * 1994 Line-by-line regexp tags by Tom Tromey. |
32 * 2001 Nested classes by Francesco Potort́ (concept by Mykola Dzyuba). | 71 * 2001 Nested classes by Francesco Potort́ (concept by Mykola Dzyuba). |
39 * If you want to add support for a new language, start by looking at the LUA | 78 * If you want to add support for a new language, start by looking at the LUA |
40 * language, which is the simplest. Alternatively, consider shipping a | 79 * language, which is the simplest. Alternatively, consider shipping a |
41 * configuration file containing regexp definitions for etags. | 80 * configuration file containing regexp definitions for etags. |
42 */ | 81 */ |
43 | 82 |
44 char pot_etags_version[] = "@(#) pot revision number is 17.26"; | 83 char pot_etags_version[] = "@(#) pot revision number is 17.32"; |
45 | 84 |
46 #define TRUE 1 | 85 #define TRUE 1 |
47 #define FALSE 0 | 86 #define FALSE 0 |
48 | 87 |
49 #ifdef DEBUG | 88 #ifdef DEBUG |
118 #else /* not WINDOWSNT */ | 157 #else /* not WINDOWSNT */ |
119 # ifdef STDC_HEADERS | 158 # ifdef STDC_HEADERS |
120 # include <stdlib.h> | 159 # include <stdlib.h> |
121 # include <string.h> | 160 # include <string.h> |
122 # else /* no standard C headers */ | 161 # else /* no standard C headers */ |
123 extern char *getenv (); | 162 extern char *getenv (); |
163 extern char *strcpy (); | |
164 extern char *strncpy (); | |
165 extern char *strcat (); | |
166 extern char *strncat (); | |
167 extern unsigned long strlen (); | |
168 extern PTR malloc (); | |
169 extern PTR realloc (); | |
124 # ifdef VMS | 170 # ifdef VMS |
125 # define EXIT_SUCCESS 1 | 171 # define EXIT_SUCCESS 1 |
126 # define EXIT_FAILURE 0 | 172 # define EXIT_FAILURE 0 |
127 # else /* no VMS */ | 173 # else /* no VMS */ |
128 # define EXIT_SUCCESS 0 | 174 # define EXIT_SUCCESS 0 |
442 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@", | 488 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@", |
443 /* valid in-token chars */ | 489 /* valid in-token chars */ |
444 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789"; | 490 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789"; |
445 | 491 |
446 static bool append_to_tagfile; /* -a: append to tags */ | 492 static bool append_to_tagfile; /* -a: append to tags */ |
447 /* The next four default to TRUE for etags, but to FALSE for ctags. */ | 493 /* The next five default to TRUE for etags, but to FALSE for ctags. */ |
448 static bool typedefs; /* -t: create tags for C and Ada typedefs */ | 494 static bool typedefs; /* -t: create tags for C and Ada typedefs */ |
449 static bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */ | 495 static bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */ |
450 /* 0 struct/enum/union decls, and C++ */ | 496 /* 0 struct/enum/union decls, and C++ */ |
451 /* member functions. */ | 497 /* member functions. */ |
452 static bool constantypedefs; /* -d: create tags for C #define, enum */ | 498 static bool constantypedefs; /* -d: create tags for C #define, enum */ |
453 /* constants and variables. */ | 499 /* constants and variables. */ |
454 /* -D: opposite of -d. Default under ctags. */ | 500 /* -D: opposite of -d. Default under ctags. */ |
455 static bool globals; /* create tags for global variables */ | 501 static bool globals; /* create tags for global variables */ |
502 static bool members; /* create tags for C member variables */ | |
456 static bool declarations; /* --declarations: tag them and extern in C&Co*/ | 503 static bool declarations; /* --declarations: tag them and extern in C&Co*/ |
457 static bool members; /* create tags for C member variables */ | |
458 static bool no_line_directive; /* ignore #line directives (undocumented) */ | 504 static bool no_line_directive; /* ignore #line directives (undocumented) */ |
459 static bool no_duplicates; /* no duplicate tags for ctags (undocumented) */ | 505 static bool no_duplicates; /* no duplicate tags for ctags (undocumented) */ |
460 static bool update; /* -u: update tags */ | 506 static bool update; /* -u: update tags */ |
461 static bool vgrind_style; /* -v: create vgrind style index output */ | 507 static bool vgrind_style; /* -v: create vgrind style index output */ |
462 static bool no_warnings; /* -w: suppress warnings (undocumented) */ | 508 static bool no_warnings; /* -w: suppress warnings (undocumented) */ |
575 static char default_C_help [] = | 621 static char default_C_help [] = |
576 "In C code, any C function or typedef is a tag, and so are\n\ | 622 "In C code, any C function or typedef is a tag, and so are\n\ |
577 definitions of `struct', `union' and `enum'. `#define' macro\n\ | 623 definitions of `struct', `union' and `enum'. `#define' macro\n\ |
578 definitions and `enum' constants are tags unless you specify\n\ | 624 definitions and `enum' constants are tags unless you specify\n\ |
579 `--no-defines'. Global variables are tags unless you specify\n\ | 625 `--no-defines'. Global variables are tags unless you specify\n\ |
580 `--no-globals'. Use of `--no-globals' and `--no-defines'\n\ | 626 `--no-globals' and so are struct members unless you specify\n\ |
581 can make the tags table file much smaller.\n\ | 627 `--no-members'. Use of `--no-globals', `--no-defines' and\n\ |
628 `--no-members' can make the tags table file much smaller.\n\ | |
582 You can tag function declarations and external variables by\n\ | 629 You can tag function declarations and external variables by\n\ |
583 using `--declarations', and struct members by using `--members'."; | 630 using `--declarations'."; |
584 | 631 |
585 static char *Cplusplus_suffixes [] = | 632 static char *Cplusplus_suffixes [] = |
586 { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx", | 633 { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx", |
587 "M", /* Objective C++ */ | 634 "M", /* Objective C++ */ |
588 "pdb", /* Postscript with C syntax */ | 635 "pdb", /* Postscript with C syntax */ |
589 NULL }; | 636 NULL }; |
590 static char Cplusplus_help [] = | 637 static char Cplusplus_help [] = |
591 "In C++ code, all the tag constructs of C code are tagged. (Use\n\ | 638 "In C++ code, all the tag constructs of C code are tagged. (Use\n\ |
592 --help --lang=c --lang=c++ for full help.)\n\ | 639 --help --lang=c --lang=c++ for full help.)\n\ |
593 In addition to C tags, member functions are also recognized, and\n\ | 640 In addition to C tags, member functions are also recognized. Member\n\ |
594 optionally member variables if you use the `--members' option.\n\ | 641 variables are recognized unless you use the `--no-members' option.\n\ |
595 Tags for variables and functions in classes are named `CLASS::VARIABLE'\n\ | 642 Tags for variables and functions in classes are named `CLASS::VARIABLE'\n\ |
596 and `CLASS::FUNCTION'. `operator' definitions have tag names like\n\ | 643 and `CLASS::FUNCTION'. `operator' definitions have tag names like\n\ |
597 `operator+'."; | 644 `operator+'."; |
598 | 645 |
599 static char *Cjava_suffixes [] = | 646 static char *Cjava_suffixes [] = |
684 defined in the default package is `main::SUB'."; | 731 defined in the default package is `main::SUB'."; |
685 | 732 |
686 static char *PHP_suffixes [] = | 733 static char *PHP_suffixes [] = |
687 { "php", "php3", "php4", NULL }; | 734 { "php", "php3", "php4", NULL }; |
688 static char PHP_help [] = | 735 static char PHP_help [] = |
689 "In PHP code, tags are functions, classes and defines. When using\n\ | 736 "In PHP code, tags are functions, classes and defines. Unless you use\n\ |
690 the `--members' option, vars are tags too."; | 737 the `--no-members' option, vars are tags too."; |
691 | 738 |
692 static char *plain_C_suffixes [] = | 739 static char *plain_C_suffixes [] = |
693 { "pc", /* Pro*C file */ | 740 { "pc", /* Pro*C file */ |
694 NULL }; | 741 NULL }; |
695 | 742 |
832 } | 879 } |
833 | 880 |
834 #ifndef EMACS_NAME | 881 #ifndef EMACS_NAME |
835 # define EMACS_NAME "standalone" | 882 # define EMACS_NAME "standalone" |
836 #endif | 883 #endif |
837 #ifdef EMACS_VERSION | 884 #ifndef VERSION |
838 # ifdef XEMACS_EXTRA_NAME | 885 # define VERSION "17.32" |
839 # define E_VERSION EMACS_VERSION " " XEMACS_EXTRA_NAME | |
840 # else | |
841 # define E_VERSION EMACS_VERSION | |
842 # endif | |
843 #elif defined(VERSION) | |
844 # define E_VERSION VERSION | |
845 #else | |
846 # define E_VERSION "version" | |
847 #endif | 886 #endif |
848 | |
849 static void | 887 static void |
850 print_version () | 888 print_version () |
851 { | 889 { |
852 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, E_VERSION); | 890 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION); |
853 puts (pot_etags_version); | 891 puts ("Copyright (C) 2007 Free Software Foundation, Inc."); |
854 puts ("Copyright (C) 2006 Free Software Foundation, Inc. and Ken Arnold"); | 892 puts ("This program is distributed under the terms in ETAGS.README"); |
855 puts ("This program is distributed under the same terms as Emacs"); | |
856 | 893 |
857 exit (EXIT_SUCCESS); | 894 exit (EXIT_SUCCESS); |
858 } | 895 } |
859 | 896 |
860 static void | 897 static void |
937 Create tag entries for global variables in some languages."); | 974 Create tag entries for global variables in some languages."); |
938 else | 975 else |
939 puts ("--no-globals\n\ | 976 puts ("--no-globals\n\ |
940 Do not create tag entries for global variables in some\n\ | 977 Do not create tag entries for global variables in some\n\ |
941 languages. This makes the tags file smaller."); | 978 languages. This makes the tags file smaller."); |
942 puts ("--members\n\ | 979 if (CTAGS) |
980 puts ("--members\n\ | |
943 Create tag entries for members of structures in some languages."); | 981 Create tag entries for members of structures in some languages."); |
982 else | |
983 puts ("--no-members\n\ | |
984 Do not create tag entries for members of structures\n\ | |
985 in some languages."); | |
944 | 986 |
945 puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\ | 987 puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\ |
946 Make a tag for each line matching a regular expression pattern\n\ | 988 Make a tag for each line matching a regular expression pattern\n\ |
947 in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\ | 989 in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\ |
948 files only. REGEXFILE is a file containing one REGEXP per line.\n\ | 990 files only. REGEXFILE is a file containing one REGEXP per line.\n\ |
986 { | 1028 { |
987 puts ("-v, --vgrind\n\ | 1029 puts ("-v, --vgrind\n\ |
988 Print on the standard output an index of items intended for\n\ | 1030 Print on the standard output an index of items intended for\n\ |
989 human consumption, similar to the output of vgrind. The index\n\ | 1031 human consumption, similar to the output of vgrind. The index\n\ |
990 is sorted, and gives the page number of each item."); | 1032 is sorted, and gives the page number of each item."); |
991 # ifdef PRINT_UNDOCUMENTED_OPTIONS_HELP | 1033 # if PRINT_UNDOCUMENTED_OPTIONS_HELP |
992 puts ("-w, --no-duplicates\n\ | 1034 puts ("-w, --no-duplicates\n\ |
993 Do not create duplicate tag entries, for compatibility with\n\ | 1035 Do not create duplicate tag entries, for compatibility with\n\ |
994 traditional ctags."); | 1036 traditional ctags."); |
995 puts ("-w, --no-warn\n\ | 1037 puts ("-w, --no-warn\n\ |
996 Suppress warning messages about duplicate tag entries."); | 1038 Suppress warning messages about duplicate tag entries."); |
1176 is small. */ | 1218 is small. */ |
1177 argbuffer = xnew (argc, argument); | 1219 argbuffer = xnew (argc, argument); |
1178 | 1220 |
1179 /* | 1221 /* |
1180 * If etags, always find typedefs and structure tags. Why not? | 1222 * If etags, always find typedefs and structure tags. Why not? |
1181 * Also default to find macro constants, enum constants and | 1223 * Also default to find macro constants, enum constants, struct |
1182 * global variables. | 1224 * members and global variables. |
1183 */ | 1225 */ |
1184 if (!CTAGS) | 1226 if (!CTAGS) |
1185 { | 1227 { |
1186 typedefs = typedefs_or_cplusplus = constantypedefs = TRUE; | 1228 typedefs = typedefs_or_cplusplus = constantypedefs = TRUE; |
1187 globals = TRUE; | 1229 globals = members = TRUE; |
1188 } | 1230 } |
1189 | 1231 |
1190 /* When the optstring begins with a '-' getopt_long does not rearrange the | 1232 /* 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. */ | 1233 non-options arguments to be at the end, but leaves them alone. */ |
1192 optstring = concat (NO_LONG_OPTIONS ? "" : "-", | 1234 optstring = concat (NO_LONG_OPTIONS ? "" : "-", |
3364 } | 3406 } |
3365 continue; | 3407 continue; |
3366 case '/': | 3408 case '/': |
3367 if (*lp == '*') | 3409 if (*lp == '*') |
3368 { | 3410 { |
3411 incomm = TRUE; | |
3369 lp++; | 3412 lp++; |
3370 incomm = TRUE; | 3413 c = ' '; |
3371 continue; | |
3372 } | 3414 } |
3373 else if (/* cplpl && */ *lp == '/') | 3415 else if (/* cplpl && */ *lp == '/') |
3374 { | 3416 { |
3375 c = '\0'; | 3417 c = '\0'; |
3376 break; | 3418 } |
3377 } | 3419 break; |
3378 else | |
3379 break; | |
3380 case '%': | 3420 case '%': |
3381 if ((c_ext & YACC) && *lp == '%') | 3421 if ((c_ext & YACC) && *lp == '%') |
3382 { | 3422 { |
3383 /* Entering or exiting rules section in yacc file. */ | 3423 /* Entering or exiting rules section in yacc file. */ |
3384 lp++; | 3424 lp++; |
6902 * Local Variables: | 6942 * Local Variables: |
6903 * indent-tabs-mode: t | 6943 * indent-tabs-mode: t |
6904 * tab-width: 8 | 6944 * tab-width: 8 |
6905 * fill-column: 79 | 6945 * fill-column: 79 |
6906 * c-font-lock-extra-types: ("FILE" "bool" "language" "linebuffer" "fdesc" "node" "regexp") | 6946 * c-font-lock-extra-types: ("FILE" "bool" "language" "linebuffer" "fdesc" "node" "regexp") |
6947 * c-file-style: "gnu" | |
6907 * End: | 6948 * End: |
6908 */ | 6949 */ |
6909 | 6950 |
6910 /* arch-tag: 8a9b748d-390c-4922-99db-2eeefa921051 | 6951 /* arch-tag: 8a9b748d-390c-4922-99db-2eeefa921051 |
6911 (do not change this comment) */ | 6952 (do not change this comment) */ |