aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorFrancesco Potortì1997-05-12 16:10:08 +0000
committerFrancesco Potortì1997-05-12 16:10:08 +0000
commitcec68fcb05ab34c1ba2af45ccf5673673671c1a5 (patch)
treee8d3da95365a23e8710ba6843eaedadcf5d6aac4 /lib-src
parent567b103cfa245b77736bd8339f274f42b5c8a0c0 (diff)
downloademacs-cec68fcb05ab34c1ba2af45ccf5673673671c1a5.tar.gz
emacs-cec68fcb05ab34c1ba2af45ccf5673673671c1a5.zip
* etags.c: (Cplusplus_suffixes): .pdb is Postscript with C syntax.
(Postscript_suffixes): .ps is Postscript. (lang_names): Add Postscript. (Postscript_functions): New function. (TEX_decode_env): Close minor memory leak. (just_read_file): Correct the char number of the tag.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c302
1 files changed, 207 insertions, 95 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c
index b07028296a4..1c53e26ec05 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -31,7 +31,7 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer. 31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
32 */ 32 */
33 33
34char pot_etags_version[] = "@(#) pot revision number is 11.85"; 34char pot_etags_version[] = "@(#) pot revision number is 11.90";
35 35
36#define TRUE 1 36#define TRUE 1
37#define FALSE 0 37#define FALSE 0
@@ -58,11 +58,6 @@ char pot_etags_version[] = "@(#) pot revision number is 11.85";
58# define MAXPATHLEN _MAX_PATH 58# define MAXPATHLEN _MAX_PATH
59#endif 59#endif
60 60
61#if !defined (MSDOS) && !defined (WINDOWSNT) && defined (STDC_HEADERS)
62#include <stdlib.h>
63#include <string.h>
64#endif
65
66#ifdef HAVE_CONFIG_H 61#ifdef HAVE_CONFIG_H
67# include <config.h> 62# include <config.h>
68 /* On some systems, Emacs defines static as nothing for the sake 63 /* On some systems, Emacs defines static as nothing for the sake
@@ -70,6 +65,11 @@ char pot_etags_version[] = "@(#) pot revision number is 11.85";
70# undef static 65# undef static
71#endif 66#endif
72 67
68#if !defined (MSDOS) && !defined (WINDOWSNT) && defined (STDC_HEADERS)
69#include <stdlib.h>
70#include <string.h>
71#endif
72
73#include <stdio.h> 73#include <stdio.h>
74#include <ctype.h> 74#include <ctype.h>
75#include <errno.h> 75#include <errno.h>
@@ -111,6 +111,7 @@ extern int errno;
111/* C extensions. */ 111/* C extensions. */
112#define C_PLPL 0x00001 /* C++ */ 112#define C_PLPL 0x00001 /* C++ */
113#define C_STAR 0x00003 /* C* */ 113#define C_STAR 0x00003 /* C* */
114#define C_JAVA 0x00005 /* JAVA */
114#define YACC 0x10000 /* yacc file */ 115#define YACC 0x10000 /* yacc file */
115 116
116#define streq(s,t) ((DEBUG && (s) == NULL && (t) == NULL \ 117#define streq(s,t) ((DEBUG && (s) == NULL && (t) == NULL \
@@ -176,6 +177,7 @@ Lang_function Asm_labels;
176Lang_function default_C_entries; 177Lang_function default_C_entries;
177Lang_function C_entries; 178Lang_function C_entries;
178Lang_function Cplusplus_entries; 179Lang_function Cplusplus_entries;
180Lang_function Cjava_entries;
179Lang_function Cstar_entries; 181Lang_function Cstar_entries;
180Lang_function Erlang_functions; 182Lang_function Erlang_functions;
181Lang_function Fortran_functions; 183Lang_function Fortran_functions;
@@ -183,6 +185,7 @@ Lang_function Yacc_entries;
183Lang_function Lisp_functions; 185Lang_function Lisp_functions;
184Lang_function Pascal_functions; 186Lang_function Pascal_functions;
185Lang_function Perl_functions; 187Lang_function Perl_functions;
188Lang_function Postscript_functions;
186Lang_function Prolog_functions; 189Lang_function Prolog_functions;
187Lang_function Scheme_functions; 190Lang_function Scheme_functions;
188Lang_function TeX_functions; 191Lang_function TeX_functions;
@@ -192,6 +195,7 @@ void Asm_labels ();
192void C_entries (); 195void C_entries ();
193void default_C_entries (); 196void default_C_entries ();
194void plain_C_entries (); 197void plain_C_entries ();
198void Cjava_entries ();
195void Cplusplus_entries (); 199void Cplusplus_entries ();
196void Cstar_entries (); 200void Cstar_entries ();
197void Erlang_functions (); 201void Erlang_functions ();
@@ -200,6 +204,7 @@ void Yacc_entries ();
200void Lisp_functions (); 204void Lisp_functions ();
201void Pascal_functions (); 205void Pascal_functions ();
202void Perl_functions (); 206void Perl_functions ();
207void Postscript_functions ();
203void Prolog_functions (); 208void Prolog_functions ();
204void Scheme_functions (); 209void Scheme_functions ();
205void TeX_functions (); 210void TeX_functions ();
@@ -213,6 +218,7 @@ int total_size_of_entries ();
213long readline (); 218long readline ();
214long readline_internal (); 219long readline_internal ();
215#ifdef ETAGS_REGEXPS 220#ifdef ETAGS_REGEXPS
221void analyse_regex ();
216void add_regex (); 222void add_regex ();
217#endif 223#endif
218void add_node (); 224void add_node ();
@@ -361,9 +367,14 @@ char *Asm_suffixes [] = { "a", /* Unix assembler */
361char *default_C_suffixes [] = 367char *default_C_suffixes [] =
362 { "c", "h", NULL }; 368 { "c", "h", NULL };
363 369
364/* .M is for Objective C++ files. */
365char *Cplusplus_suffixes [] = 370char *Cplusplus_suffixes [] =
366 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx", "M", NULL}; 371 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx",
372 "M", /* Objective C++ */
373 "pdb", /* Postscript with C syntax */
374 NULL };
375
376char *Cjava_suffixes [] =
377 { "java", NULL };
367 378
368char *Cstar_suffixes [] = 379char *Cstar_suffixes [] =
369 { "cs", "hs", NULL }; 380 { "cs", "hs", NULL };
@@ -391,6 +402,9 @@ char *plain_C_suffixes [] =
391 "lm", /* Objective lex file */ 402 "lm", /* Objective lex file */
392 NULL }; 403 NULL };
393 404
405char *Postscript_suffixes [] =
406 { "ps", NULL };
407
394char *Prolog_suffixes [] = 408char *Prolog_suffixes [] =
395 { "prolog", NULL }; 409 { "prolog", NULL };
396 410
@@ -418,20 +432,22 @@ struct lang_entry
418 432
419struct lang_entry lang_names [] = 433struct lang_entry lang_names [] =
420{ 434{
421 { "asm", Asm_labels, Asm_suffixes, NULL }, 435 { "asm", Asm_labels, Asm_suffixes, NULL },
422 { "c", default_C_entries, default_C_suffixes, NULL }, 436 { "c", default_C_entries, default_C_suffixes, NULL },
423 { "c++", Cplusplus_entries, Cplusplus_suffixes, NULL }, 437 { "c++", Cplusplus_entries, Cplusplus_suffixes, NULL },
424 { "c*", Cstar_entries, Cstar_suffixes, NULL }, 438 { "c*", Cstar_entries, Cstar_suffixes, NULL },
425 { "erlang", Erlang_functions, Erlang_suffixes, NULL }, 439 { "erlang", Erlang_functions, Erlang_suffixes, NULL },
426 { "fortran", Fortran_functions, Fortran_suffixes, NULL }, 440 { "fortran", Fortran_functions, Fortran_suffixes, NULL },
427 { "lisp", Lisp_functions, Lisp_suffixes, NULL }, 441/*{ "java", Cjava_entries, Cjava_suffixes, NULL },*/
428 { "pascal", Pascal_functions, Pascal_suffixes, NULL }, 442 { "lisp", Lisp_functions, Lisp_suffixes, NULL },
429 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters }, 443 { "pascal", Pascal_functions, Pascal_suffixes, NULL },
430 { "proc", plain_C_entries, plain_C_suffixes, NULL }, 444 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters },
431 { "prolog", Prolog_functions, Prolog_suffixes, NULL }, 445 { "postscript", Postscript_functions, Postscript_suffixes, NULL },
432 { "scheme", Scheme_functions, Scheme_suffixes, NULL }, 446 { "proc", plain_C_entries, plain_C_suffixes, NULL },
433 { "tex", TeX_functions, TeX_suffixes, NULL }, 447 { "prolog", Prolog_functions, Prolog_suffixes, NULL },
434 { "yacc", Yacc_entries, Yacc_suffixes, NULL }, 448 { "scheme", Scheme_functions, Scheme_suffixes, NULL },
449 { "tex", TeX_functions, TeX_suffixes, NULL },
450 { "yacc", Yacc_entries, Yacc_suffixes, NULL },
435 { "auto", NULL }, /* default guessing scheme */ 451 { "auto", NULL }, /* default guessing scheme */
436 { "none", just_read_file }, /* regexp matching only */ 452 { "none", just_read_file }, /* regexp matching only */
437 { NULL, NULL } /* end of list */ 453 { NULL, NULL } /* end of list */
@@ -517,9 +533,10 @@ are. Relative ones are stored relative to the output file's directory.");
517 } 533 }
518 534
519#ifdef ETAGS_REGEXPS 535#ifdef ETAGS_REGEXPS
520 puts ("-r /REGEXP/, --regex=/REGEXP/\n\ 536 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
521 Make a tag for each line matching pattern REGEXP in the\n\ 537 Make a tag for each line matching pattern REGEXP in the\n\
522 following files. REGEXP is anchored (as if preceded by ^).\n\ 538 following files. regexfile is a file containing one REGEXP\n\
539 per line. REGEXP is anchored (as if preceded by ^).\n\
523 The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\ 540 The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\
524 named tags can be created with:\n\ 541 named tags can be created with:\n\
525 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/."); 542 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
@@ -883,7 +900,11 @@ main (argc, argv)
883 tagfile = CTAGS ? "tags" : "TAGS"; 900 tagfile = CTAGS ? "tags" : "TAGS";
884 cwd = etags_getcwd (); /* the current working directory */ 901 cwd = etags_getcwd (); /* the current working directory */
885 if (cwd[strlen (cwd) - 1] != '/') 902 if (cwd[strlen (cwd) - 1] != '/')
886 cwd = concat (cwd, "/", ""); 903 {
904 char *oldcwd = cwd;
905 cwd = concat (oldcwd, "/", "");
906 free (oldcwd);
907 }
887 if (streq (tagfile, "-")) 908 if (streq (tagfile, "-"))
888 tagfiledir = cwd; 909 tagfiledir = cwd;
889 else 910 else
@@ -927,7 +948,7 @@ main (argc, argv)
927 break; 948 break;
928#ifdef ETAGS_REGEXPS 949#ifdef ETAGS_REGEXPS
929 case at_regexp: 950 case at_regexp:
930 add_regex (argbuffer[i].what); 951 analyse_regex (argbuffer[i].what);
931 break; 952 break;
932#endif 953#endif
933 case at_filename: 954 case at_filename:
@@ -1517,7 +1538,8 @@ total_size_of_entries (node)
1517enum sym_type 1538enum sym_type
1518{ 1539{
1519 st_none, st_C_objprot, st_C_objimpl, st_C_objend, st_C_gnumacro, 1540 st_none, st_C_objprot, st_C_objimpl, st_C_objend, st_C_gnumacro,
1520 st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec 1541 st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec,
1542 st_C_jstruct
1521}; 1543};
1522 1544
1523/* Feed stuff between (but not including) %[ and %] lines to: 1545/* Feed stuff between (but not including) %[ and %] lines to:
@@ -1529,6 +1551,8 @@ struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
1529@protocol, 0, st_C_objprot 1551@protocol, 0, st_C_objprot
1530@implementation,0, st_C_objimpl 1552@implementation,0, st_C_objimpl
1531@end, 0, st_C_objend 1553@end, 0, st_C_objend
1554extends, C_JAVA, st_C_jstruct
1555implements, C_JAVA, st_C_jstruct
1532class, C_PLPL, st_C_struct 1556class, C_PLPL, st_C_struct
1533namespace, C_PLPL, st_C_struct 1557namespace, C_PLPL, st_C_struct
1534domain, C_STAR, st_C_struct 1558domain, C_STAR, st_C_struct
@@ -1575,33 +1599,33 @@ struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
1575 1599
1576#define MIN_WORD_LENGTH 3 1600#define MIN_WORD_LENGTH 3
1577#define MAX_WORD_LENGTH 15 1601#define MAX_WORD_LENGTH 15
1578#define MIN_HASH_VALUE 34 1602#define MIN_HASH_VALUE 33
1579#define MAX_HASH_VALUE 121 1603#define MAX_HASH_VALUE 126
1580/* 1604/*
1581 34 keywords 1605 36 keywords
1582 88 is the maximum key range 1606 94 is the maximum key range
1583*/ 1607*/
1584 1608
1585static int 1609int
1586hash (str, len) 1610hash (str, len)
1587 register char *str; 1611 register char *str;
1588 register unsigned int len; 1612 register unsigned int len;
1589{ 1613{
1590 static unsigned char hash_table[] = 1614 static unsigned char hash_table[] =
1591 { 1615 {
1592 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 1616 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1593 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 1617 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1594 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 1618 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1595 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 1619 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1596 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 1620 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1597 121, 121, 121, 121, 121, 121, 121, 121, 121, 121, 1621 126, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1598 121, 121, 121, 121, 45, 121, 121, 121, 16, 19, 1622 126, 126, 126, 126, 15, 126, 126, 126, 53, 24,
1599 61, 121, 121, 121, 121, 121, 121, 121, 121, 121, 1623 41, 126, 126, 126, 126, 126, 126, 126, 126, 126,
1600 10, 121, 121, 20, 53, 121, 121, 121, 121, 121, 1624 51, 126, 126, 26, 47, 126, 126, 126, 126, 126,
1601 121, 121, 121, 121, 121, 121, 121, 41, 45, 22, 1625 126, 126, 126, 126, 126, 126, 126, 11, 36, 26,
1602 60, 47, 37, 28, 121, 55, 121, 121, 20, 14, 1626 35, 13, 22, 39, 126, 34, 126, 126, 43, 21,
1603 29, 30, 5, 121, 50, 59, 30, 54, 6, 121, 1627 36, 6, 49, 126, 47, 61, 28, 57, 35, 126,
1604 121, 121, 121, 121, 121, 121, 121, 121, 1628 126, 126, 126, 126, 126, 126, 126, 126,
1605 }; 1629 };
1606 return len + hash_table[str[2]] + hash_table[str[0]]; 1630 return len + hash_table[str[2]] + hash_table[str[0]];
1607} 1631}
@@ -1617,56 +1641,61 @@ in_word_set (str, len)
1617 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 1641 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1618 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 1642 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1619 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 1643 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1620 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1621 {"volatile", 0, st_C_typespec},
1622 {"PSEUDO", 0, st_C_gnumacro},
1623 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 1644 {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1624 {"typedef", 0, st_C_typedef}, 1645 {"float", 0, st_C_typespec},
1625 {"typename", C_PLPL, st_C_typespec}, 1646 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1626 {"",}, {"",}, {"",}, 1647 {"char", 0, st_C_typespec},
1627 {"SYSCALL", 0, st_C_gnumacro}, 1648 {"class", C_PLPL, st_C_struct},
1649 {"auto", 0, st_C_typespec},
1650 {"",}, {"",},
1651 {"bool", C_PLPL, st_C_typespec},
1652 {"extern", 0, st_C_typespec},
1653 {"extends", C_JAVA, st_C_jstruct},
1654 {"",}, {"",},
1655 {"@implementation", 0, st_C_objimpl},
1628 {"",}, {"",}, {"",}, 1656 {"",}, {"",}, {"",},
1657 {"@end", 0, st_C_objend},
1629 {"mutable", C_PLPL, st_C_typespec}, 1658 {"mutable", C_PLPL, st_C_typespec},
1630 {"namespace", C_PLPL, st_C_struct},
1631 {"long", 0, st_C_typespec},
1632 {"",}, {"",}, 1659 {"",}, {"",},
1660 {"SYSCALL", 0, st_C_gnumacro},
1661 {"",},
1662 {"@interface", 0, st_C_objprot},
1663 {"domain", C_STAR, st_C_struct},
1664 {"define", 0, st_C_define},
1665 {"",},
1666 {"int", 0, st_C_typespec},
1667 {"namespace", C_PLPL, st_C_struct},
1633 {"const", 0, st_C_typespec}, 1668 {"const", 0, st_C_typespec},
1634 {"",}, {"",}, {"",}, 1669 {"",}, {"",},
1635 {"explicit", C_PLPL, st_C_typespec}, 1670 {"explicit", C_PLPL, st_C_typespec},
1636 {"",}, {"",}, {"",}, {"",}, 1671 {"@protocol", 0, st_C_objprot},
1672 {"short", 0, st_C_typespec},
1637 {"void", 0, st_C_typespec}, 1673 {"void", 0, st_C_typespec},
1674 {"enum", 0, st_C_enum},
1638 {"",}, 1675 {"",},
1639 {"char", 0, st_C_typespec}, 1676 {"ENTRY", 0, st_C_gnumacro},
1640 {"class", C_PLPL, st_C_struct},
1641 {"",}, {"",}, {"",},
1642 {"float", 0, st_C_typespec},
1643 {"",}, 1677 {"",},
1644 {"@implementation", 0, st_C_objimpl}, 1678 {"static", 0, st_C_typespec},
1645 {"auto", 0, st_C_typespec}, 1679 {"",}, {"",},
1680 {"PSEUDO", 0, st_C_gnumacro},
1646 {"",}, 1681 {"",},
1647 {"ENTRY", 0, st_C_gnumacro}, 1682 {"long", 0, st_C_typespec},
1648 {"@end", 0, st_C_objend}, 1683 {"typedef", 0, st_C_typedef},
1649 {"bool", C_PLPL, st_C_typespec}, 1684 {"typename", C_PLPL, st_C_typespec},
1650 {"domain", C_STAR, st_C_struct}, 1685 {"volatile", 0, st_C_typespec},
1686 {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1687 {"implements", C_JAVA, st_C_jstruct},
1688 {"",}, {"",},
1689 {"union", 0, st_C_struct},
1651 {"",}, 1690 {"",},
1691 {"double", 0, st_C_typespec},
1652 {"DEFUN", 0, st_C_gnumacro}, 1692 {"DEFUN", 0, st_C_gnumacro},
1653 {"extern", 0, st_C_typespec}, 1693 {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1654 {"@interface", 0, st_C_objprot},
1655 {"",}, {"",}, {"",},
1656 {"int", 0, st_C_typespec},
1657 {"",}, {"",}, {"",}, {"",},
1658 {"signed", 0, st_C_typespec}, 1694 {"signed", 0, st_C_typespec},
1659 {"short", 0, st_C_typespec},
1660 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1661 {"define", 0, st_C_define},
1662 {"@protocol", 0, st_C_objprot},
1663 {"enum", 0, st_C_enum},
1664 {"static", 0, st_C_typespec},
1665 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, 1695 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1666 {"union", 0, st_C_struct},
1667 {"struct", 0, st_C_struct}, 1696 {"struct", 0, st_C_struct},
1668 {"",}, {"",}, {"",}, {"",}, 1697 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
1669 {"double", 0, st_C_typespec}, 1698 {"",}, {"",},
1670 {"unsigned", 0, st_C_typespec}, 1699 {"unsigned", 0, st_C_typespec},
1671 }; 1700 };
1672 1701
@@ -1921,6 +1950,11 @@ consider_token (str, len, c, c_ext, cblev, parlev, is_func)
1921 */ 1950 */
1922 switch (toktype) 1951 switch (toktype)
1923 { 1952 {
1953 case st_C_jstruct:
1954 if (structdef == stagseen)
1955 structdef = scolonseen;
1956 return FALSE;
1957 break;
1924 case st_C_struct: 1958 case st_C_struct:
1925 case st_C_enum: 1959 case st_C_enum:
1926 if (typdef == ttypedseen 1960 if (typdef == ttypedseen
@@ -2155,7 +2189,7 @@ C_entries (c_ext, inf)
2155 int cblev; /* current curly brace level */ 2189 int cblev; /* current curly brace level */
2156 int parlev; /* current parenthesis level */ 2190 int parlev; /* current parenthesis level */
2157 logical incomm, inquote, inchar, quotednl, midtoken; 2191 logical incomm, inquote, inchar, quotednl, midtoken;
2158 logical cplpl; 2192 logical cplpl, cjava;
2159 TOKEN savetok; /* token saved during preprocessor handling */ 2193 TOKEN savetok; /* token saved during preprocessor handling */
2160 2194
2161 2195
@@ -2173,6 +2207,7 @@ C_entries (c_ext, inf)
2173 cblev = 0; 2207 cblev = 0;
2174 parlev = 0; 2208 parlev = 0;
2175 cplpl = c_ext & C_PLPL; 2209 cplpl = c_ext & C_PLPL;
2210 cjava = c_ext & C_JAVA;
2176 2211
2177 while (!feof (inf)) 2212 while (!feof (inf))
2178 { 2213 {
@@ -2429,7 +2464,7 @@ C_entries (c_ext, inf)
2429 funcdef = fnone; 2464 funcdef = fnone;
2430 break; 2465 break;
2431 } 2466 }
2432 if (structdef == stagseen) 2467 if (structdef == stagseen && !cjava)
2433 structdef = snone; 2468 structdef = snone;
2434 break; 2469 break;
2435 case dsharpseen: 2470 case dsharpseen:
@@ -2732,6 +2767,13 @@ Cplusplus_entries (inf)
2732 C_entries (C_PLPL, inf); 2767 C_entries (C_PLPL, inf);
2733} 2768}
2734 2769
2770/* Always do Java. */
2771void
2772Cjava_entries (FILE *inf)
2773{
2774 C_entries (C_JAVA, inf);
2775}
2776
2735/* Always do C*. */ 2777/* Always do C*. */
2736void 2778void
2737Cstar_entries (inf) 2779Cstar_entries (inf)
@@ -3259,6 +3301,36 @@ Lisp_functions (inf)
3259} 3301}
3260 3302
3261/* 3303/*
3304 * Postscript tag functions
3305 * Just look for lines where the first character is '/'
3306 */
3307void
3308Postscript_functions (inf)
3309 FILE *inf;
3310{
3311 lineno = 0;
3312 charno = 0;
3313 while (!feof (inf))
3314 {
3315 lineno++;
3316 linecharno = charno;
3317 charno += readline (&lb, inf);
3318 dbp = lb.buffer;
3319 if (dbp[0] == '/')
3320 {
3321 register char *cp;
3322 for (cp = dbp+1;
3323 *cp != '\0' && *cp != ' ' && *cp != '{';
3324 cp++)
3325 continue;
3326 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
3327 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3328 }
3329 }
3330}
3331
3332
3333/*
3262 * Scheme tag functions 3334 * Scheme tag functions
3263 * look for (def... xyzzy 3335 * look for (def... xyzzy
3264 * look for (def... (xyzzy 3336 * look for (def... (xyzzy
@@ -3381,7 +3453,7 @@ TeX_functions (inf)
3381 charno += readline (&lb, inf); 3453 charno += readline (&lb, inf);
3382 dbp = lb.buffer; 3454 dbp = lb.buffer;
3383 lasthit = dbp; 3455 lasthit = dbp;
3384 while (dbp = etags_strchr (dbp, TEX_esc)) /* Look at each esc in line */ 3456 while (dbp = etags_strchr (dbp, TEX_esc)) /* Look at each esc in line */
3385 { 3457 {
3386 register int i; 3458 register int i;
3387 3459
@@ -3456,7 +3528,11 @@ TEX_decode_env (evarname, defenv)
3456 if (!env) 3528 if (!env)
3457 env = defenv; 3529 env = defenv;
3458 else 3530 else
3459 env = concat (env, defenv, ""); 3531 {
3532 char *oldenv = env;
3533 env = concat (oldenv, defenv, "");
3534 free (oldenv);
3535 }
3460 3536
3461 /* Allocate a token table */ 3537 /* Allocate a token table */
3462 for (size = 1, p = env; p;) 3538 for (size = 1, p = env; p;)
@@ -3976,29 +4052,64 @@ scan_separators (name)
3976 return name; 4052 return name;
3977} 4053}
3978 4054
3979/* Turn a name, which is an ed-style (but Emacs syntax) regular 4055/* Look at the argument of --regex or --no-regex and do the right
3980 expression, into a real regular expression by compiling it. */ 4056 thing. */
3981void 4057void
3982add_regex (regexp_pattern) 4058analyse_regex (regex_arg)
3983 char *regexp_pattern; 4059 char *regex_arg;
3984{ 4060{
3985 char *name; 4061 struct stat stat_buf;
3986 const char *err;
3987 struct re_pattern_buffer *patbuf;
3988 4062
3989 if (regexp_pattern == NULL) 4063 if (regex_arg == NULL)
3990 { 4064 {
3991 /* Remove existing regexps. */ 4065 /* Remove existing regexps. */
3992 num_patterns = 0; 4066 num_patterns = 0;
3993 patterns = NULL; 4067 patterns = NULL;
3994 return; 4068 return;
3995 } 4069 }
3996 4070 if (regex_arg[0] == '\0')
3997 if (regexp_pattern[0] == '\0')
3998 { 4071 {
3999 error ("missing regexp", (char *)NULL); 4072 error ("missing regexp", (char *)NULL);
4000 return; 4073 return;
4001 } 4074 }
4075 if (regex_arg[0] == '@'
4076 && stat (regex_arg + 1, &stat_buf) == 0
4077 && S_ISREG (stat_buf.st_mode))
4078 {
4079 FILE *regexfp;
4080 struct linebuffer regexbuf;
4081 char *regexfile = regex_arg + 1;
4082
4083 /* regexfile is a file containing regexps, one per line. */
4084 regexfp = fopen (regexfile, "r");
4085 if (regexfp == NULL)
4086 {
4087 perror (regexfile);
4088 return;
4089 }
4090 initbuffer (&regexbuf);
4091 while (readline_internal (&regexbuf, regexfp))
4092 add_regex (regexbuf.buffer);
4093 free (regexbuf.buffer);
4094 fclose (regexfp);
4095 }
4096 else
4097 {
4098 add_regex (regex_arg);
4099 }
4100}
4101
4102/* Turn a name, which is an ed-style (but Emacs syntax) regular
4103 expression, into a real regular expression by compiling it. */
4104void
4105add_regex (regexp_pattern)
4106 char *regexp_pattern;
4107{
4108 char *name;
4109 const char *err;
4110 struct re_pattern_buffer *patbuf;
4111
4112
4002 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0]) 4113 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
4003 { 4114 {
4004 error ("%s: unterminated regexp", regexp_pattern); 4115 error ("%s: unterminated regexp", regexp_pattern);
@@ -4238,7 +4349,7 @@ just_read_file (inf)
4238 { 4349 {
4239 ++lineno; 4350 ++lineno;
4240 linecharno = charno; 4351 linecharno = charno;
4241 charno += readline (&lb, inf) + 1; 4352 charno += readline (&lb, inf);
4242 } 4353 }
4243} 4354}
4244 4355
@@ -4377,6 +4488,7 @@ etags_getcwd ()
4377 if (errno != ERANGE) 4488 if (errno != ERANGE)
4378 pfatal ("getcwd"); 4489 pfatal ("getcwd");
4379 bufsize *= 2; 4490 bufsize *= 2;
4491 free (path);
4380 path = xnew (bufsize, char); 4492 path = xnew (bufsize, char);
4381 } 4493 }
4382 4494