diff options
| -rw-r--r-- | lib-src/etags.c | 615 |
1 files changed, 297 insertions, 318 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index 510648f95a9..950389545ac 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -1,5 +1,5 @@ | |||
| 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, 87, 88, 89, 93, 94, 95, 98, 99, 2000, 2001 | 2 | Copyright (C) 1984, 1987-1989, 1993-1995, 1998-2001 |
| 3 | Free Software Foundation, Inc. and Ken Arnold | 3 | Free Software Foundation, Inc. and Ken Arnold |
| 4 | 4 | ||
| 5 | This file is not considered part of GNU Emacs. | 5 | This file is not considered part of GNU Emacs. |
| @@ -25,14 +25,15 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ | |||
| 25 | * Ed Pelegri-Llopart added C typedefs. | 25 | * Ed Pelegri-Llopart added C typedefs. |
| 26 | * Gnu Emacs TAGS format and modifications by RMS? | 26 | * Gnu Emacs TAGS format and modifications by RMS? |
| 27 | * 1989 Sam Kendall added C++. | 27 | * 1989 Sam Kendall added C++. |
| 28 | * 1993 Francesco Potort́ reorganised C and C++ based on work by Joe Wells. | 28 | * 1992 Joseph B. Wells improved C and C++ parsing. |
| 29 | * 1993 Francesco Potort́ reorganised C and C++. | ||
| 29 | * 1994 Regexp tags by Tom Tromey. | 30 | * 1994 Regexp tags by Tom Tromey. |
| 30 | * 2001 Nested classes by Francesco Potort́ based on work by Mykola Dzyuba. | 31 | * 2001 Nested classes by Francesco Potort́ (ideas by Mykola Dzyuba). |
| 31 | * | 32 | * |
| 32 | * Francesco Potort́ <pot@gnu.org> has maintained it since 1993. | 33 | * Francesco Potort́ <pot@gnu.org> has maintained it since 1993. |
| 33 | */ | 34 | */ |
| 34 | 35 | ||
| 35 | char pot_etags_version[] = "@(#) pot revision number is 14.26"; | 36 | char pot_etags_version[] = "@(#) pot revision number is 14.35"; |
| 36 | 37 | ||
| 37 | #define TRUE 1 | 38 | #define TRUE 1 |
| 38 | #define FALSE 0 | 39 | #define FALSE 0 |
| @@ -45,12 +46,6 @@ char pot_etags_version[] = "@(#) pot revision number is 14.26"; | |||
| 45 | # define NDEBUG /* disable assert */ | 46 | # define NDEBUG /* disable assert */ |
| 46 | #endif | 47 | #endif |
| 47 | 48 | ||
| 48 | #if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C)) | ||
| 49 | # define P_(proto) proto | ||
| 50 | #else | ||
| 51 | # define P_(proto) () | ||
| 52 | #endif | ||
| 53 | |||
| 54 | #ifdef HAVE_CONFIG_H | 49 | #ifdef HAVE_CONFIG_H |
| 55 | # include <config.h> | 50 | # include <config.h> |
| 56 | /* On some systems, Emacs defines static as nothing for the sake | 51 | /* On some systems, Emacs defines static as nothing for the sake |
| @@ -58,10 +53,20 @@ char pot_etags_version[] = "@(#) pot revision number is 14.26"; | |||
| 58 | # undef static | 53 | # undef static |
| 59 | # define ETAGS_REGEXPS /* use the regexp features */ | 54 | # define ETAGS_REGEXPS /* use the regexp features */ |
| 60 | # define LONG_OPTIONS /* accept long options */ | 55 | # define LONG_OPTIONS /* accept long options */ |
| 56 | # ifndef PTR /* for Xemacs */ | ||
| 57 | # define PTR void * | ||
| 58 | # endif | ||
| 59 | # ifndef __P /* for Xemacs */ | ||
| 60 | # define __P(args) args | ||
| 61 | # endif | ||
| 61 | #else | 62 | #else |
| 62 | # ifndef __STDC__ | 63 | # if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C)) |
| 63 | # define static /* remove static for old compilers' sake */ | 64 | # define __P(args) args /* use prototypes */ |
| 64 | # define const /* same for const */ | 65 | # define PTR void * /* for generic pointers */ |
| 66 | # else | ||
| 67 | # define __P(args) () /* no prototypes */ | ||
| 68 | # define const /* remove const for old compilers' sake */ | ||
| 69 | # define PTR long * /* don't use void* */ | ||
| 65 | # endif | 70 | # endif |
| 66 | #endif /* !HAVE_CONFIG_H */ | 71 | #endif /* !HAVE_CONFIG_H */ |
| 67 | 72 | ||
| @@ -217,9 +222,9 @@ If you want regular expression support, you should delete this notice and | |||
| 217 | (char *) (op), (n) * sizeof (Type))) | 222 | (char *) (op), (n) * sizeof (Type))) |
| 218 | #endif | 223 | #endif |
| 219 | 224 | ||
| 220 | typedef int bool; | 225 | #define bool int |
| 221 | 226 | ||
| 222 | typedef void Lang_function P_((FILE *)); | 227 | typedef void Lang_function __P((FILE *)); |
| 223 | 228 | ||
| 224 | typedef struct | 229 | typedef struct |
| 225 | { | 230 | { |
| @@ -265,83 +270,83 @@ typedef struct | |||
| 265 | /* Many compilers barf on this: | 270 | /* Many compilers barf on this: |
| 266 | Lang_function Ada_funcs; | 271 | Lang_function Ada_funcs; |
| 267 | so let's write it this way */ | 272 | so let's write it this way */ |
| 268 | static void Ada_funcs P_((FILE *)); | 273 | static void Ada_funcs __P((FILE *)); |
| 269 | static void Asm_labels P_((FILE *)); | 274 | static void Asm_labels __P((FILE *)); |
| 270 | static void C_entries P_((int c_ext, FILE *)); | 275 | static void C_entries __P((int c_ext, FILE *)); |
| 271 | static void default_C_entries P_((FILE *)); | 276 | static void default_C_entries __P((FILE *)); |
| 272 | static void plain_C_entries P_((FILE *)); | 277 | static void plain_C_entries __P((FILE *)); |
| 273 | static void Cjava_entries P_((FILE *)); | 278 | static void Cjava_entries __P((FILE *)); |
| 274 | static void Cobol_paragraphs P_((FILE *)); | 279 | static void Cobol_paragraphs __P((FILE *)); |
| 275 | static void Cplusplus_entries P_((FILE *)); | 280 | static void Cplusplus_entries __P((FILE *)); |
| 276 | static void Cstar_entries P_((FILE *)); | 281 | static void Cstar_entries __P((FILE *)); |
| 277 | static void Erlang_functions P_((FILE *)); | 282 | static void Erlang_functions __P((FILE *)); |
| 278 | static void Fortran_functions P_((FILE *)); | 283 | static void Fortran_functions __P((FILE *)); |
| 279 | static void Yacc_entries P_((FILE *)); | 284 | static void Yacc_entries __P((FILE *)); |
| 280 | static void Lisp_functions P_((FILE *)); | 285 | static void Lisp_functions __P((FILE *)); |
| 281 | static void Makefile_targets P_((FILE *)); | 286 | static void Makefile_targets __P((FILE *)); |
| 282 | static void Pascal_functions P_((FILE *)); | 287 | static void Pascal_functions __P((FILE *)); |
| 283 | static void Perl_functions P_((FILE *)); | 288 | static void Perl_functions __P((FILE *)); |
| 284 | static void PHP_functions P_((FILE *)); | 289 | static void PHP_functions __P((FILE *)); |
| 285 | static void Postscript_functions P_((FILE *)); | 290 | static void Postscript_functions __P((FILE *)); |
| 286 | static void Prolog_functions P_((FILE *)); | 291 | static void Prolog_functions __P((FILE *)); |
| 287 | static void Python_functions P_((FILE *)); | 292 | static void Python_functions __P((FILE *)); |
| 288 | static void Scheme_functions P_((FILE *)); | 293 | static void Scheme_functions __P((FILE *)); |
| 289 | static void TeX_commands P_((FILE *)); | 294 | static void TeX_commands __P((FILE *)); |
| 290 | static void Texinfo_nodes P_((FILE *)); | 295 | static void Texinfo_nodes __P((FILE *)); |
| 291 | static void just_read_file P_((FILE *)); | 296 | static void just_read_file __P((FILE *)); |
| 292 | 297 | ||
| 293 | static void print_language_names P_((void)); | 298 | static void print_language_names __P((void)); |
| 294 | static void print_version P_((void)); | 299 | static void print_version __P((void)); |
| 295 | static void print_help P_((void)); | 300 | static void print_help __P((void)); |
| 296 | int main P_((int, char **)); | 301 | int main __P((int, char **)); |
| 297 | static int number_len P_((long)); | 302 | static int number_len __P((long)); |
| 298 | 303 | ||
| 299 | static compressor *get_compressor_from_suffix P_((char *, char **)); | 304 | static compressor *get_compressor_from_suffix __P((char *, char **)); |
| 300 | static language *get_language_from_langname P_((char *)); | 305 | static language *get_language_from_langname __P((const char *)); |
| 301 | static language *get_language_from_interpreter P_((char *)); | 306 | static language *get_language_from_interpreter __P((char *)); |
| 302 | static language *get_language_from_filename P_((char *)); | 307 | static language *get_language_from_filename __P((char *)); |
| 303 | static int total_size_of_entries P_((node *)); | 308 | static int total_size_of_entries __P((node *)); |
| 304 | static long readline P_((linebuffer *, FILE *)); | 309 | static long readline __P((linebuffer *, FILE *)); |
| 305 | static long readline_internal P_((linebuffer *, FILE *)); | 310 | static long readline_internal __P((linebuffer *, FILE *)); |
| 306 | static void get_tag P_((char *)); | 311 | static bool nocase_tail __P((char *)); |
| 312 | static char *get_tag __P((char *)); | ||
| 307 | 313 | ||
| 308 | #ifdef ETAGS_REGEXPS | 314 | #ifdef ETAGS_REGEXPS |
| 309 | static void analyse_regex P_((char *, bool)); | 315 | static void analyse_regex __P((char *, bool)); |
| 310 | static void add_regex P_((char *, bool, language *)); | 316 | static void add_regex __P((char *, bool, language *)); |
| 311 | static void free_patterns P_((void)); | 317 | static void free_patterns __P((void)); |
| 312 | #endif /* ETAGS_REGEXPS */ | 318 | #endif /* ETAGS_REGEXPS */ |
| 313 | static void error P_((const char *, const char *)); | 319 | static void error __P((const char *, const char *)); |
| 314 | static void suggest_asking_for_help P_((void)); | 320 | static void suggest_asking_for_help __P((void)); |
| 315 | void fatal P_((char *, char *)); | 321 | void fatal __P((char *, char *)); |
| 316 | static void pfatal P_((char *)); | 322 | static void pfatal __P((char *)); |
| 317 | static void add_node P_((node *, node **)); | 323 | static void add_node __P((node *, node **)); |
| 318 | 324 | ||
| 319 | static void init P_((void)); | 325 | static void init __P((void)); |
| 320 | static void initbuffer P_((linebuffer *)); | 326 | static void initbuffer __P((linebuffer *)); |
| 321 | static void find_entries P_((char *, FILE *)); | 327 | static void find_entries __P((char *, FILE *)); |
| 322 | static void free_tree P_((node *)); | 328 | static void free_tree __P((node *)); |
| 323 | static void pfnote P_((char *, bool, char *, int, int, long)); | 329 | static void pfnote __P((char *, bool, char *, int, int, long)); |
| 324 | static void new_pfnote P_((char *, int, bool, char *, int, int, long)); | 330 | static void new_pfnote __P((char *, int, bool, char *, int, int, long)); |
| 325 | static void process_file P_((char *)); | 331 | static void process_file __P((char *)); |
| 326 | static void put_entries P_((node *)); | 332 | static void put_entries __P((node *)); |
| 327 | static void takeprec P_((void)); | 333 | |
| 328 | 334 | static char *concat __P((char *, char *, char *)); | |
| 329 | static char *concat P_((char *, char *, char *)); | 335 | static char *skip_spaces __P((char *)); |
| 330 | static char *skip_spaces P_((char *)); | 336 | static char *skip_non_spaces __P((char *)); |
| 331 | static char *skip_non_spaces P_((char *)); | 337 | static char *savenstr __P((char *, int)); |
| 332 | static char *savenstr P_((char *, int)); | 338 | static char *savestr __P((char *)); |
| 333 | static char *savestr P_((char *)); | 339 | static char *etags_strchr __P((const char *, int)); |
| 334 | static char *etags_strchr P_((const char *, int)); | 340 | static char *etags_strrchr __P((const char *, int)); |
| 335 | static char *etags_strrchr P_((const char *, int)); | 341 | static char *etags_getcwd __P((void)); |
| 336 | static char *etags_getcwd P_((void)); | 342 | static char *relative_filename __P((char *, char *)); |
| 337 | static char *relative_filename P_((char *, char *)); | 343 | static char *absolute_filename __P((char *, char *)); |
| 338 | static char *absolute_filename P_((char *, char *)); | 344 | static char *absolute_dirname __P((char *, char *)); |
| 339 | static char *absolute_dirname P_((char *, char *)); | 345 | static bool filename_is_absolute __P((char *f)); |
| 340 | static bool filename_is_absolute P_((char *f)); | 346 | static void canonicalize_filename __P((char *)); |
| 341 | static void canonicalize_filename P_((char *)); | 347 | static void linebuffer_setlen __P((linebuffer *, int)); |
| 342 | static void linebuffer_setlen P_((linebuffer *, int)); | 348 | PTR xmalloc __P((unsigned int)); |
| 343 | long *xmalloc P_((unsigned int)); | 349 | PTR xrealloc __P((char *, unsigned int)); |
| 344 | long *xrealloc P_((char *, unsigned int)); | ||
| 345 | 350 | ||
| 346 | 351 | ||
| 347 | char searchar = '/'; /* use /.../ searches */ | 352 | char searchar = '/'; /* use /.../ searches */ |
| @@ -370,7 +375,7 @@ char | |||
| 370 | /* white chars */ | 375 | /* white chars */ |
| 371 | *white = " \f\t\n\r\v", | 376 | *white = " \f\t\n\r\v", |
| 372 | /* not in a name */ | 377 | /* not in a name */ |
| 373 | *nonam = " \f\t\n\r(=,[;", | 378 | *nonam = " \f\t\n\r()=,;", |
| 374 | /* token ending chars */ | 379 | /* token ending chars */ |
| 375 | *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?", | 380 | *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?", |
| 376 | /* token starting chars */ | 381 | /* token starting chars */ |
| @@ -440,9 +445,9 @@ struct option longopts[] = | |||
| 440 | typedef struct pattern | 445 | typedef struct pattern |
| 441 | { | 446 | { |
| 442 | struct pattern *p_next; | 447 | struct pattern *p_next; |
| 443 | language *language; | 448 | language *lang; |
| 444 | char *regex; | 449 | char *regex; |
| 445 | struct re_pattern_buffer *pattern; | 450 | struct re_pattern_buffer *pat; |
| 446 | struct re_registers regs; | 451 | struct re_registers regs; |
| 447 | char *name_pattern; | 452 | char *name_pattern; |
| 448 | bool error_signaled; | 453 | bool error_signaled; |
| @@ -1289,7 +1294,7 @@ get_compressor_from_suffix (file, extptr) | |||
| 1289 | */ | 1294 | */ |
| 1290 | static language * | 1295 | static language * |
| 1291 | get_language_from_langname (name) | 1296 | get_language_from_langname (name) |
| 1292 | char *name; | 1297 | const char *name; |
| 1293 | { | 1298 | { |
| 1294 | language *lang; | 1299 | language *lang; |
| 1295 | 1300 | ||
| @@ -1702,7 +1707,7 @@ pfnote (name, is_func, linestart, linelen, lno, cno) | |||
| 1702 | * also be one of the characters " \t(),;". | 1707 | * also be one of the characters " \t(),;". |
| 1703 | * | 1708 | * |
| 1704 | * The real implementation uses the notinname() macro, which recognises | 1709 | * The real implementation uses the notinname() macro, which recognises |
| 1705 | * characters slightly different form " \t\r\n(),;". See the variable | 1710 | * characters slightly different from " \t\r\n(),;". See the variable |
| 1706 | * `nonam'. | 1711 | * `nonam'. |
| 1707 | */ | 1712 | */ |
| 1708 | #define traditional_tag_style TRUE | 1713 | #define traditional_tag_style TRUE |
| @@ -1965,9 +1970,9 @@ enum sym_type | |||
| 1965 | st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec | 1970 | st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec |
| 1966 | }; | 1971 | }; |
| 1967 | 1972 | ||
| 1968 | static unsigned int hash P_((const char *, unsigned int)); | 1973 | static unsigned int hash __P((const char *, unsigned int)); |
| 1969 | static struct C_stab_entry * in_word_set P_((const char *, unsigned int)); | 1974 | static struct C_stab_entry * in_word_set __P((const char *, unsigned int)); |
| 1970 | static enum sym_type C_symtype P_((char *, int, int)); | 1975 | static enum sym_type C_symtype __P((char *, int, int)); |
| 1971 | 1976 | ||
| 1972 | /* Feed stuff between (but not including) %[ and %] lines to: | 1977 | /* Feed stuff between (but not including) %[ and %] lines to: |
| 1973 | gperf -c -k 1,3 -o -p -r -t | 1978 | gperf -c -k 1,3 -o -p -r -t |
| @@ -2315,9 +2320,9 @@ linebuffer token_name; /* its name */ | |||
| 2315 | * Variables and functions for dealing with nested structures. | 2320 | * Variables and functions for dealing with nested structures. |
| 2316 | * Idea by Mykola Dzyuba <mdzyuba@yahoo.com> (2001) | 2321 | * Idea by Mykola Dzyuba <mdzyuba@yahoo.com> (2001) |
| 2317 | */ | 2322 | */ |
| 2318 | static void pushclass_above P_((int, char *, int)); | 2323 | static void pushclass_above __P((int, char *, int)); |
| 2319 | static void popclass_above P_((int)); | 2324 | static void popclass_above __P((int)); |
| 2320 | static void write_classname P_((linebuffer *, char *qualifier)); | 2325 | static void write_classname __P((linebuffer *, char *qualifier)); |
| 2321 | 2326 | ||
| 2322 | struct { | 2327 | struct { |
| 2323 | char **cname; /* nested class names */ | 2328 | char **cname; /* nested class names */ |
| @@ -2406,8 +2411,8 @@ write_classname (cn, qualifier) | |||
| 2406 | } | 2411 | } |
| 2407 | 2412 | ||
| 2408 | 2413 | ||
| 2409 | static bool consider_token P_((char *, int, int, int *, int, int, bool *)); | 2414 | static bool consider_token __P((char *, int, int, int *, int, int, bool *)); |
| 2410 | static void make_C_tag P_((bool)); | 2415 | static void make_C_tag __P((bool)); |
| 2411 | 2416 | ||
| 2412 | /* | 2417 | /* |
| 2413 | * consider_token () | 2418 | * consider_token () |
| @@ -3607,9 +3612,9 @@ Yacc_entries (inf) | |||
| 3607 | TRUE); \ | 3612 | TRUE); \ |
| 3608 | ) | 3613 | ) |
| 3609 | #define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \ | 3614 | #define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \ |
| 3610 | (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at kyword */ \ | 3615 | (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at keyword */ \ |
| 3611 | && iswhite((cp)[sizeof(keyword)-1]) /* followed by a blank */ \ | 3616 | && notinname ((cp)[sizeof(keyword)-1]) /* end of keyword */ \ |
| 3612 | && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip blanks */ | 3617 | && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip spaces */ |
| 3613 | 3618 | ||
| 3614 | /* | 3619 | /* |
| 3615 | * Read a file, but do no processing. This is used to do regexp | 3620 | * Read a file, but do no processing. This is used to do regexp |
| @@ -3628,28 +3633,11 @@ just_read_file (inf) | |||
| 3628 | 3633 | ||
| 3629 | /* Fortran parsing */ | 3634 | /* Fortran parsing */ |
| 3630 | 3635 | ||
| 3631 | static bool tail P_((char *)); | 3636 | static void F_takeprec __P((void)); |
| 3632 | static void takeprec P_((void)); | 3637 | static void F_getit __P((FILE *)); |
| 3633 | static void getit P_((FILE *)); | ||
| 3634 | |||
| 3635 | static bool | ||
| 3636 | tail (cp) | ||
| 3637 | char *cp; | ||
| 3638 | { | ||
| 3639 | register int len = 0; | ||
| 3640 | |||
| 3641 | while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len])) | ||
| 3642 | cp++, len++; | ||
| 3643 | if (*cp == '\0' && !intoken (dbp[len])) | ||
| 3644 | { | ||
| 3645 | dbp += len; | ||
| 3646 | return TRUE; | ||
| 3647 | } | ||
| 3648 | return FALSE; | ||
| 3649 | } | ||
| 3650 | 3638 | ||
| 3651 | static void | 3639 | static void |
| 3652 | takeprec () | 3640 | F_takeprec () |
| 3653 | { | 3641 | { |
| 3654 | dbp = skip_spaces (dbp); | 3642 | dbp = skip_spaces (dbp); |
| 3655 | if (*dbp != '*') | 3643 | if (*dbp != '*') |
| @@ -3672,7 +3660,7 @@ takeprec () | |||
| 3672 | } | 3660 | } |
| 3673 | 3661 | ||
| 3674 | static void | 3662 | static void |
| 3675 | getit (inf) | 3663 | F_getit (inf) |
| 3676 | FILE *inf; | 3664 | FILE *inf; |
| 3677 | { | 3665 | { |
| 3678 | register char *cp; | 3666 | register char *cp; |
| @@ -3712,28 +3700,28 @@ Fortran_functions (inf) | |||
| 3712 | switch (lowcase (*dbp)) | 3700 | switch (lowcase (*dbp)) |
| 3713 | { | 3701 | { |
| 3714 | case 'i': | 3702 | case 'i': |
| 3715 | if (tail ("integer")) | 3703 | if (nocase_tail ("integer")) |
| 3716 | takeprec (); | 3704 | F_takeprec (); |
| 3717 | break; | 3705 | break; |
| 3718 | case 'r': | 3706 | case 'r': |
| 3719 | if (tail ("real")) | 3707 | if (nocase_tail ("real")) |
| 3720 | takeprec (); | 3708 | F_takeprec (); |
| 3721 | break; | 3709 | break; |
| 3722 | case 'l': | 3710 | case 'l': |
| 3723 | if (tail ("logical")) | 3711 | if (nocase_tail ("logical")) |
| 3724 | takeprec (); | 3712 | F_takeprec (); |
| 3725 | break; | 3713 | break; |
| 3726 | case 'c': | 3714 | case 'c': |
| 3727 | if (tail ("complex") || tail ("character")) | 3715 | if (nocase_tail ("complex") || nocase_tail ("character")) |
| 3728 | takeprec (); | 3716 | F_takeprec (); |
| 3729 | break; | 3717 | break; |
| 3730 | case 'd': | 3718 | case 'd': |
| 3731 | if (tail ("double")) | 3719 | if (nocase_tail ("double")) |
| 3732 | { | 3720 | { |
| 3733 | dbp = skip_spaces (dbp); | 3721 | dbp = skip_spaces (dbp); |
| 3734 | if (*dbp == '\0') | 3722 | if (*dbp == '\0') |
| 3735 | continue; | 3723 | continue; |
| 3736 | if (tail ("precision")) | 3724 | if (nocase_tail ("precision")) |
| 3737 | break; | 3725 | break; |
| 3738 | continue; | 3726 | continue; |
| 3739 | } | 3727 | } |
| @@ -3745,26 +3733,26 @@ Fortran_functions (inf) | |||
| 3745 | switch (lowcase (*dbp)) | 3733 | switch (lowcase (*dbp)) |
| 3746 | { | 3734 | { |
| 3747 | case 'f': | 3735 | case 'f': |
| 3748 | if (tail ("function")) | 3736 | if (nocase_tail ("function")) |
| 3749 | getit (inf); | 3737 | F_getit (inf); |
| 3750 | continue; | 3738 | continue; |
| 3751 | case 's': | 3739 | case 's': |
| 3752 | if (tail ("subroutine")) | 3740 | if (nocase_tail ("subroutine")) |
| 3753 | getit (inf); | 3741 | F_getit (inf); |
| 3754 | continue; | 3742 | continue; |
| 3755 | case 'e': | 3743 | case 'e': |
| 3756 | if (tail ("entry")) | 3744 | if (nocase_tail ("entry")) |
| 3757 | getit (inf); | 3745 | F_getit (inf); |
| 3758 | continue; | 3746 | continue; |
| 3759 | case 'b': | 3747 | case 'b': |
| 3760 | if (tail ("blockdata") || tail ("block data")) | 3748 | if (nocase_tail ("blockdata") || nocase_tail ("block data")) |
| 3761 | { | 3749 | { |
| 3762 | dbp = skip_spaces (dbp); | 3750 | dbp = skip_spaces (dbp); |
| 3763 | if (*dbp == '\0') /* assume un-named */ | 3751 | if (*dbp == '\0') /* assume un-named */ |
| 3764 | pfnote (savestr ("blockdata"), TRUE, | 3752 | pfnote (savestr ("blockdata"), TRUE, |
| 3765 | lb.buffer, dbp - lb.buffer, lineno, linecharno); | 3753 | lb.buffer, dbp - lb.buffer, lineno, linecharno); |
| 3766 | else | 3754 | else |
| 3767 | getit (inf); /* look for name */ | 3755 | F_getit (inf); /* look for name */ |
| 3768 | } | 3756 | } |
| 3769 | continue; | 3757 | continue; |
| 3770 | } | 3758 | } |
| @@ -3774,15 +3762,16 @@ Fortran_functions (inf) | |||
| 3774 | 3762 | ||
| 3775 | /* | 3763 | /* |
| 3776 | * Ada parsing | 3764 | * Ada parsing |
| 3765 | * Original code by | ||
| 3777 | * Philippe Waroquiers <philippe.waroquiers@eurocontrol.be> (1998) | 3766 | * Philippe Waroquiers <philippe.waroquiers@eurocontrol.be> (1998) |
| 3778 | */ | 3767 | */ |
| 3779 | 3768 | ||
| 3780 | static void adagetit P_((FILE *, char *)); | 3769 | static void Ada_getit __P((FILE *, char *)); |
| 3781 | 3770 | ||
| 3782 | /* Once we are positioned after an "interesting" keyword, let's get | 3771 | /* Once we are positioned after an "interesting" keyword, let's get |
| 3783 | the real tag value necessary. */ | 3772 | the real tag value necessary. */ |
| 3784 | static void | 3773 | static void |
| 3785 | adagetit (inf, name_qualifier) | 3774 | Ada_getit (inf, name_qualifier) |
| 3786 | FILE *inf; | 3775 | FILE *inf; |
| 3787 | char *name_qualifier; | 3776 | char *name_qualifier; |
| 3788 | { | 3777 | { |
| @@ -3801,11 +3790,10 @@ adagetit (inf, name_qualifier) | |||
| 3801 | charno += readline (&lb, inf); | 3790 | charno += readline (&lb, inf); |
| 3802 | dbp = lb.buffer; | 3791 | dbp = lb.buffer; |
| 3803 | } | 3792 | } |
| 3804 | switch (*dbp) | 3793 | switch (lowcase(*dbp)) |
| 3805 | { | 3794 | { |
| 3806 | case 'b': | 3795 | case 'b': |
| 3807 | case 'B': | 3796 | if (nocase_tail ("body")) |
| 3808 | if (tail ("body")) | ||
| 3809 | { | 3797 | { |
| 3810 | /* Skipping body of procedure body or package body or .... | 3798 | /* Skipping body of procedure body or package body or .... |
| 3811 | resetting qualifier to body instead of spec. */ | 3799 | resetting qualifier to body instead of spec. */ |
| @@ -3814,9 +3802,8 @@ adagetit (inf, name_qualifier) | |||
| 3814 | } | 3802 | } |
| 3815 | break; | 3803 | break; |
| 3816 | case 't': | 3804 | case 't': |
| 3817 | case 'T': | ||
| 3818 | /* Skipping type of task type or protected type ... */ | 3805 | /* Skipping type of task type or protected type ... */ |
| 3819 | if (tail ("type")) | 3806 | if (nocase_tail ("type")) |
| 3820 | continue; | 3807 | continue; |
| 3821 | break; | 3808 | break; |
| 3822 | } | 3809 | } |
| @@ -3897,33 +3884,30 @@ Ada_funcs (inf) | |||
| 3897 | } | 3884 | } |
| 3898 | 3885 | ||
| 3899 | /* We are at the beginning of a token. */ | 3886 | /* We are at the beginning of a token. */ |
| 3900 | switch (*dbp) | 3887 | switch (lowcase(*dbp)) |
| 3901 | { | 3888 | { |
| 3902 | case 'f': | 3889 | case 'f': |
| 3903 | case 'F': | 3890 | if (!packages_only && nocase_tail ("function")) |
| 3904 | if (!packages_only && tail ("function")) | 3891 | Ada_getit (inf, "/f"); |
| 3905 | adagetit (inf, "/f"); | ||
| 3906 | else | 3892 | else |
| 3907 | break; /* from switch */ | 3893 | break; /* from switch */ |
| 3908 | continue; /* advance char */ | 3894 | continue; /* advance char */ |
| 3909 | case 'p': | 3895 | case 'p': |
| 3910 | case 'P': | 3896 | if (!packages_only && nocase_tail ("procedure")) |
| 3911 | if (!packages_only && tail ("procedure")) | 3897 | Ada_getit (inf, "/p"); |
| 3912 | adagetit (inf, "/p"); | 3898 | else if (nocase_tail ("package")) |
| 3913 | else if (tail ("package")) | 3899 | Ada_getit (inf, "/s"); |
| 3914 | adagetit (inf, "/s"); | 3900 | else if (nocase_tail ("protected")) /* protected type */ |
| 3915 | else if (tail ("protected")) /* protected type */ | 3901 | Ada_getit (inf, "/t"); |
| 3916 | adagetit (inf, "/t"); | ||
| 3917 | else | 3902 | else |
| 3918 | break; /* from switch */ | 3903 | break; /* from switch */ |
| 3919 | continue; /* advance char */ | 3904 | continue; /* advance char */ |
| 3920 | case 't': | 3905 | case 't': |
| 3921 | case 'T': | 3906 | if (!packages_only && nocase_tail ("task")) |
| 3922 | if (!packages_only && tail ("task")) | 3907 | Ada_getit (inf, "/k"); |
| 3923 | adagetit (inf, "/k"); | 3908 | else if (typedefs && !packages_only && nocase_tail ("type")) |
| 3924 | else if (typedefs && !packages_only && tail ("type")) | ||
| 3925 | { | 3909 | { |
| 3926 | adagetit (inf, "/t"); | 3910 | Ada_getit (inf, "/t"); |
| 3927 | while (*dbp != '\0') | 3911 | while (*dbp != '\0') |
| 3928 | dbp += 1; | 3912 | dbp += 1; |
| 3929 | } | 3913 | } |
| @@ -3942,9 +3926,9 @@ Ada_funcs (inf) | |||
| 3942 | 3926 | ||
| 3943 | 3927 | ||
| 3944 | /* | 3928 | /* |
| 3945 | * Bob Weiner, Motorola Inc., 4/3/94 | ||
| 3946 | * Unix and microcontroller assembly tag handling | 3929 | * Unix and microcontroller assembly tag handling |
| 3947 | * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]' | 3930 | * Labels: /^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]/ |
| 3931 | * Idea by Bob Weiner, Motorola Inc. (1994) | ||
| 3948 | */ | 3932 | */ |
| 3949 | static void | 3933 | static void |
| 3950 | Asm_labels (inf) | 3934 | Asm_labels (inf) |
| @@ -3975,40 +3959,57 @@ Asm_labels (inf) | |||
| 3975 | 3959 | ||
| 3976 | /* | 3960 | /* |
| 3977 | * Perl support | 3961 | * Perl support |
| 3978 | * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/ | 3962 | * Perl sub names: /^sub[ \t\n]+[^ \t\n{]+/ |
| 3979 | * Perl variable names: /^(my|local).../ | 3963 | * Perl variable names: /^(my|local).../ |
| 3980 | * Bart Robinson <lomew@cs.utah.edu> (1995) | 3964 | * Original code by Bart Robinson <lomew@cs.utah.edu> (1995) |
| 3981 | * Michael Ernst <mernst@alum.mit.edu> (1997) | 3965 | * Additions by Michael Ernst <mernst@alum.mit.edu> (1997) |
| 3966 | * Ideas by Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> (2001) | ||
| 3982 | */ | 3967 | */ |
| 3983 | static void | 3968 | static void |
| 3984 | Perl_functions (inf) | 3969 | Perl_functions (inf) |
| 3985 | FILE *inf; | 3970 | FILE *inf; |
| 3986 | { | 3971 | { |
| 3972 | char *package = savestr ("main"); /* current package name */ | ||
| 3987 | register char *cp; | 3973 | register char *cp; |
| 3988 | 3974 | ||
| 3989 | LOOP_ON_INPUT_LINES (inf, lb, cp) | 3975 | LOOP_ON_INPUT_LINES (inf, lb, cp) |
| 3990 | { | 3976 | { |
| 3991 | if (LOOKING_AT (cp, "sub")) | 3977 | skip_spaces(cp); |
| 3978 | |||
| 3979 | if (LOOKING_AT (cp, "package")) | ||
| 3992 | { | 3980 | { |
| 3993 | if (*cp != '\0') | 3981 | free (package); |
| 3994 | { | 3982 | package = get_tag (cp); |
| 3995 | char *sp = cp; | 3983 | if (package == NULL) /* can't parse package name */ |
| 3996 | while (*cp != '\0' | 3984 | package = savestr (""); |
| 3997 | && !iswhite (*cp) && *cp != '{' && *cp != '(') | 3985 | else |
| 3998 | cp++; | 3986 | package = savestr(package); /* make a copy */ |
| 3999 | pfnote (savenstr (sp, cp-sp), TRUE, | 3987 | } |
| 4000 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 3988 | else if (LOOKING_AT (cp, "sub")) |
| 4001 | } | 3989 | { |
| 3990 | char *name, *fullname, *pos; | ||
| 3991 | char *sp = cp; | ||
| 3992 | |||
| 3993 | while (!notinname (*cp)) | ||
| 3994 | cp++; | ||
| 3995 | if (cp == sp) | ||
| 3996 | continue; | ||
| 3997 | name = savenstr (sp, cp-sp); | ||
| 3998 | if ((pos = etags_strchr (name, ':')) != NULL && pos[1] == ':') | ||
| 3999 | fullname = name; | ||
| 4000 | else | ||
| 4001 | fullname = concat (package, "::", name); | ||
| 4002 | pfnote (fullname, TRUE, | ||
| 4003 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | ||
| 4004 | if (name != fullname) | ||
| 4005 | free (name); | ||
| 4002 | } | 4006 | } |
| 4003 | else if (globals /* only if tagging global vars is enabled */ | 4007 | else if (globals /* only if tagging global vars is enabled */ |
| 4004 | && ((strneq (cp, "my", 2) && (cp+=2)) | 4008 | && (LOOKING_AT (cp, "my") || LOOKING_AT (cp, "local"))) |
| 4005 | || (strneq (cp, "local", 5) && (cp+=5))) | ||
| 4006 | && (*cp == '(' || iswhite (*cp))) | ||
| 4007 | { | 4009 | { |
| 4008 | /* After "my" or "local", but before any following paren or space. */ | 4010 | /* After "my" or "local", but before any following paren or space. */ |
| 4009 | char *varname = NULL; | 4011 | char *varname = NULL; |
| 4010 | 4012 | ||
| 4011 | cp = skip_spaces (cp); | ||
| 4012 | if (*cp == '$' || *cp == '@' || *cp == '%') | 4013 | if (*cp == '$' || *cp == '@' || *cp == '%') |
| 4013 | { | 4014 | { |
| 4014 | char* varstart = ++cp; | 4015 | char* varstart = ++cp; |
| @@ -4036,7 +4037,7 @@ Perl_functions (inf) | |||
| 4036 | /* | 4037 | /* |
| 4037 | * Python support | 4038 | * Python support |
| 4038 | * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/ | 4039 | * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/ |
| 4039 | * Eric S. Raymond <esr@thyrsus.com> (1997) | 4040 | * Idea by Eric S. Raymond <esr@thyrsus.com> (1997) |
| 4040 | */ | 4041 | */ |
| 4041 | static void | 4042 | static void |
| 4042 | Python_functions (inf) | 4043 | Python_functions (inf) |
| @@ -4047,7 +4048,7 @@ Python_functions (inf) | |||
| 4047 | LOOP_ON_INPUT_LINES (inf, lb, cp) | 4048 | LOOP_ON_INPUT_LINES (inf, lb, cp) |
| 4048 | if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class")) | 4049 | if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class")) |
| 4049 | { | 4050 | { |
| 4050 | while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':') | 4051 | while (!notinname (*cp) && *cp != ':') |
| 4051 | cp++; | 4052 | cp++; |
| 4052 | pfnote (NULL, TRUE, | 4053 | pfnote (NULL, TRUE, |
| 4053 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 4054 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
| @@ -4063,7 +4064,7 @@ Python_functions (inf) | |||
| 4063 | * - /^[ \t]*define\(\"[^\"]+/ | 4064 | * - /^[ \t]*define\(\"[^\"]+/ |
| 4064 | * Only with --members: | 4065 | * Only with --members: |
| 4065 | * - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/ | 4066 | * - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/ |
| 4066 | * originally by Diez B. Roggisch 2001-06-06 | 4067 | * Idea by Diez B. Roggisch (2001) |
| 4067 | */ | 4068 | */ |
| 4068 | static void | 4069 | static void |
| 4069 | PHP_functions (inf) | 4070 | PHP_functions (inf) |
| @@ -4078,7 +4079,7 @@ PHP_functions (inf) | |||
| 4078 | if (search_identifier | 4079 | if (search_identifier |
| 4079 | && *cp != '\0') | 4080 | && *cp != '\0') |
| 4080 | { | 4081 | { |
| 4081 | while (*cp != '\0' && !iswhite (*cp) && *cp != '(') | 4082 | while (!notinname (*cp)) |
| 4082 | cp++; | 4083 | cp++; |
| 4083 | pfnote (NULL, TRUE, | 4084 | pfnote (NULL, TRUE, |
| 4084 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 4085 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
| @@ -4090,7 +4091,7 @@ PHP_functions (inf) | |||
| 4090 | cp = skip_spaces (cp+1); | 4091 | cp = skip_spaces (cp+1); |
| 4091 | if(*cp != '\0') | 4092 | if(*cp != '\0') |
| 4092 | { | 4093 | { |
| 4093 | while (*cp != '\0' && !iswhite (*cp) && *cp != '(') | 4094 | while (!notinname (*cp)) |
| 4094 | cp++; | 4095 | cp++; |
| 4095 | pfnote (NULL, TRUE, | 4096 | pfnote (NULL, TRUE, |
| 4096 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 4097 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
| @@ -4125,7 +4126,7 @@ PHP_functions (inf) | |||
| 4125 | && LOOKING_AT (cp, "var") | 4126 | && LOOKING_AT (cp, "var") |
| 4126 | && *cp == '$') | 4127 | && *cp == '$') |
| 4127 | { | 4128 | { |
| 4128 | while (*cp != '=' && *cp != ';' && *cp != '\0' && !iswhite(*cp)) | 4129 | while (!notinname(*cp)) |
| 4129 | cp++; | 4130 | cp++; |
| 4130 | pfnote (NULL, FALSE, | 4131 | pfnote (NULL, FALSE, |
| 4131 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 4132 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
| @@ -4134,10 +4135,11 @@ PHP_functions (inf) | |||
| 4134 | } | 4135 | } |
| 4135 | 4136 | ||
| 4136 | 4137 | ||
| 4137 | /* Idea by Corny de Souza | 4138 | /* |
| 4138 | * Cobol tag functions | 4139 | * Cobol tag functions |
| 4139 | * We could look for anything that could be a paragraph name. | 4140 | * We could look for anything that could be a paragraph name. |
| 4140 | * i.e. anything that starts in column 8 is one word and ends in a full stop. | 4141 | * i.e. anything that starts in column 8 is one word and ends in a full stop. |
| 4142 | * Idea by Corny de Souza (1993) | ||
| 4141 | */ | 4143 | */ |
| 4142 | static void | 4144 | static void |
| 4143 | Cobol_paragraphs (inf) | 4145 | Cobol_paragraphs (inf) |
| @@ -4187,10 +4189,10 @@ Makefile_targets (inf) | |||
| 4187 | } | 4189 | } |
| 4188 | 4190 | ||
| 4189 | 4191 | ||
| 4190 | /* Added by Mosur Mohan, 4/22/88 */ | ||
| 4191 | /* Pascal parsing */ | ||
| 4192 | |||
| 4193 | /* | 4192 | /* |
| 4193 | * Pascal parsing | ||
| 4194 | * Original code by Mosur K. Mohan (1989) | ||
| 4195 | * | ||
| 4194 | * Locates tags for procedures & functions. Doesn't do any type- or | 4196 | * Locates tags for procedures & functions. Doesn't do any type- or |
| 4195 | * var-definitions. It does look for the keyword "extern" or | 4197 | * var-definitions. It does look for the keyword "extern" or |
| 4196 | * "forward" immediately following the procedure statement; if found, | 4198 | * "forward" immediately following the procedure statement; if found, |
| @@ -4303,7 +4305,7 @@ Pascal_functions (inf) | |||
| 4303 | continue; | 4305 | continue; |
| 4304 | if (lowcase (*dbp == 'e')) | 4306 | if (lowcase (*dbp == 'e')) |
| 4305 | { | 4307 | { |
| 4306 | if (tail ("extern")) /* superfluous, really! */ | 4308 | if (nocase_tail ("extern")) /* superfluous, really! */ |
| 4307 | { | 4309 | { |
| 4308 | found_tag = FALSE; | 4310 | found_tag = FALSE; |
| 4309 | verify_tag = FALSE; | 4311 | verify_tag = FALSE; |
| @@ -4311,7 +4313,7 @@ Pascal_functions (inf) | |||
| 4311 | } | 4313 | } |
| 4312 | else if (lowcase (*dbp) == 'f') | 4314 | else if (lowcase (*dbp) == 'f') |
| 4313 | { | 4315 | { |
| 4314 | if (tail ("forward")) /* check for forward reference */ | 4316 | if (nocase_tail ("forward")) /* check for forward reference */ |
| 4315 | { | 4317 | { |
| 4316 | found_tag = FALSE; | 4318 | found_tag = FALSE; |
| 4317 | verify_tag = FALSE; | 4319 | verify_tag = FALSE; |
| @@ -4355,11 +4357,11 @@ Pascal_functions (inf) | |||
| 4355 | switch (lowcase (c)) | 4357 | switch (lowcase (c)) |
| 4356 | { | 4358 | { |
| 4357 | case 'p': | 4359 | case 'p': |
| 4358 | if (tail ("rocedure")) /* c = 'p', dbp has advanced */ | 4360 | if (nocase_tail ("rocedure")) /* c = 'p', dbp has advanced */ |
| 4359 | get_tagname = TRUE; | 4361 | get_tagname = TRUE; |
| 4360 | continue; | 4362 | continue; |
| 4361 | case 'f': | 4363 | case 'f': |
| 4362 | if (tail ("unction")) | 4364 | if (nocase_tail ("unction")) |
| 4363 | get_tagname = TRUE; | 4365 | get_tagname = TRUE; |
| 4364 | continue; | 4366 | continue; |
| 4365 | } | 4367 | } |
| @@ -4375,56 +4377,22 @@ Pascal_functions (inf) | |||
| 4375 | * look for (def or (DEF, quote or QUOTE | 4377 | * look for (def or (DEF, quote or QUOTE |
| 4376 | */ | 4378 | */ |
| 4377 | 4379 | ||
| 4378 | static int L_isdef P_((char *)); | 4380 | static void L_getit __P((void)); |
| 4379 | static int L_isquote P_((char *)); | ||
| 4380 | static void L_getit P_((void)); | ||
| 4381 | |||
| 4382 | static int | ||
| 4383 | L_isdef (strp) | ||
| 4384 | register char *strp; | ||
| 4385 | { | ||
| 4386 | return ((strp[1] == 'd' || strp[1] == 'D') | ||
| 4387 | && (strp[2] == 'e' || strp[2] == 'E') | ||
| 4388 | && (strp[3] == 'f' || strp[3] == 'F')); | ||
| 4389 | } | ||
| 4390 | |||
| 4391 | static int | ||
| 4392 | L_isquote (strp) | ||
| 4393 | register char *strp; | ||
| 4394 | { | ||
| 4395 | return ((*++strp == 'q' || *strp == 'Q') | ||
| 4396 | && (*++strp == 'u' || *strp == 'U') | ||
| 4397 | && (*++strp == 'o' || *strp == 'O') | ||
| 4398 | && (*++strp == 't' || *strp == 'T') | ||
| 4399 | && (*++strp == 'e' || *strp == 'E') | ||
| 4400 | && iswhite (*++strp)); | ||
| 4401 | } | ||
| 4402 | 4381 | ||
| 4403 | static void | 4382 | static void |
| 4404 | L_getit () | 4383 | L_getit () |
| 4405 | { | 4384 | { |
| 4406 | register char *cp; | ||
| 4407 | |||
| 4408 | if (*dbp == '\'') /* Skip prefix quote */ | 4385 | if (*dbp == '\'') /* Skip prefix quote */ |
| 4409 | dbp++; | 4386 | dbp++; |
| 4410 | else if (*dbp == '(') | 4387 | else if (*dbp == '(') |
| 4411 | { | 4388 | { |
| 4412 | if (L_isquote (dbp)) | 4389 | dbp++; |
| 4413 | dbp += 7; /* Skip "(quote " */ | 4390 | /* Try to skip "(quote " */ |
| 4414 | else | 4391 | if (!LOOKING_AT (dbp, "quote") && !LOOKING_AT (dbp, "QUOTE")) |
| 4415 | dbp += 1; /* Skip "(" before name in (defstruct (foo)) */ | 4392 | /* Ok, then skip "(" before name in (defstruct (foo)) */ |
| 4416 | dbp = skip_spaces (dbp); | 4393 | dbp = skip_spaces (dbp); |
| 4417 | } | 4394 | } |
| 4418 | 4395 | get_tag (dbp); | |
| 4419 | for (cp = dbp /*+1*/; | ||
| 4420 | *cp != '\0' && *cp != '(' && !iswhite(*cp) && *cp != ')'; | ||
| 4421 | cp++) | ||
| 4422 | continue; | ||
| 4423 | if (cp == dbp) | ||
| 4424 | return; | ||
| 4425 | |||
| 4426 | pfnote (savenstr (dbp, cp-dbp), TRUE, | ||
| 4427 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | ||
| 4428 | } | 4396 | } |
| 4429 | 4397 | ||
| 4430 | static void | 4398 | static void |
| @@ -4433,33 +4401,32 @@ Lisp_functions (inf) | |||
| 4433 | { | 4401 | { |
| 4434 | LOOP_ON_INPUT_LINES (inf, lb, dbp) | 4402 | LOOP_ON_INPUT_LINES (inf, lb, dbp) |
| 4435 | { | 4403 | { |
| 4436 | if (dbp[0] == '(') | 4404 | if (dbp[0] != '(') |
| 4405 | continue; | ||
| 4406 | |||
| 4407 | if (strneq (dbp+1, "def", 3) || strneq (dbp+1, "DEF", 3)) | ||
| 4437 | { | 4408 | { |
| 4438 | if (L_isdef (dbp)) | 4409 | dbp = skip_non_spaces (dbp); |
| 4439 | { | 4410 | dbp = skip_spaces (dbp); |
| 4440 | dbp = skip_non_spaces (dbp); | 4411 | L_getit (); |
| 4441 | dbp = skip_spaces (dbp); | 4412 | } |
| 4442 | L_getit (); | 4413 | else |
| 4443 | } | 4414 | { |
| 4444 | else | 4415 | /* Check for (foo::defmumble name-defined ... */ |
| 4416 | do | ||
| 4417 | dbp++; | ||
| 4418 | while (!notinname (*dbp) && *dbp != ':'); | ||
| 4419 | if (*dbp == ':') | ||
| 4445 | { | 4420 | { |
| 4446 | /* Check for (foo::defmumble name-defined ... */ | ||
| 4447 | do | 4421 | do |
| 4448 | dbp++; | 4422 | dbp++; |
| 4449 | while (*dbp != '\0' && !iswhite (*dbp) | 4423 | while (*dbp == ':'); |
| 4450 | && *dbp != ':' && *dbp != '(' && *dbp != ')'); | ||
| 4451 | if (*dbp == ':') | ||
| 4452 | { | ||
| 4453 | do | ||
| 4454 | dbp++; | ||
| 4455 | while (*dbp == ':'); | ||
| 4456 | 4424 | ||
| 4457 | if (L_isdef (dbp - 1)) | 4425 | if (strneq (dbp, "def", 3) || strneq (dbp, "DEF", 3)) |
| 4458 | { | 4426 | { |
| 4459 | dbp = skip_non_spaces (dbp); | 4427 | dbp = skip_non_spaces (dbp); |
| 4460 | dbp = skip_spaces (dbp); | 4428 | dbp = skip_spaces (dbp); |
| 4461 | L_getit (); | 4429 | L_getit (); |
| 4462 | } | ||
| 4463 | } | 4430 | } |
| 4464 | } | 4431 | } |
| 4465 | } | 4432 | } |
| @@ -4471,8 +4438,9 @@ Lisp_functions (inf) | |||
| 4471 | * Postscript tag functions | 4438 | * Postscript tag functions |
| 4472 | * Just look for lines where the first character is '/' | 4439 | * Just look for lines where the first character is '/' |
| 4473 | * Also look at "defineps" for PSWrap | 4440 | * Also look at "defineps" for PSWrap |
| 4474 | * Richard Mlynarik <mly@adoc.xerox.com> (1997) | 4441 | * Ideas by: |
| 4475 | * Ideas by Masatake Yamato <masata-y@is.aist-nara.ac.jp> (1999) | 4442 | * Richard Mlynarik <mly@adoc.xerox.com> (1997) |
| 4443 | * Masatake Yamato <masata-y@is.aist-nara.ac.jp> (1999) | ||
| 4476 | */ | 4444 | */ |
| 4477 | static void | 4445 | static void |
| 4478 | Postscript_functions (inf) | 4446 | Postscript_functions (inf) |
| @@ -4491,12 +4459,8 @@ Postscript_functions (inf) | |||
| 4491 | pfnote (savenstr (bp, ep-bp), TRUE, | 4459 | pfnote (savenstr (bp, ep-bp), TRUE, |
| 4492 | lb.buffer, ep - lb.buffer + 1, lineno, linecharno); | 4460 | lb.buffer, ep - lb.buffer + 1, lineno, linecharno); |
| 4493 | } | 4461 | } |
| 4494 | else if (strneq (bp, "defineps", 8)) | 4462 | else if (LOOKING_AT (bp, "defineps")) |
| 4495 | { | 4463 | get_tag (bp); |
| 4496 | bp = skip_non_spaces (bp); | ||
| 4497 | bp = skip_spaces (bp); | ||
| 4498 | get_tag (bp); | ||
| 4499 | } | ||
| 4500 | } | 4464 | } |
| 4501 | } | 4465 | } |
| 4502 | 4466 | ||
| @@ -4504,9 +4468,10 @@ Postscript_functions (inf) | |||
| 4504 | /* | 4468 | /* |
| 4505 | * Scheme tag functions | 4469 | * Scheme tag functions |
| 4506 | * look for (def... xyzzy | 4470 | * look for (def... xyzzy |
| 4507 | * look for (def... (xyzzy | 4471 | * (def... (xyzzy |
| 4508 | * look for (def ... ((...(xyzzy .... | 4472 | * (def ... ((...(xyzzy .... |
| 4509 | * look for (set! xyzzy | 4473 | * (set! xyzzy |
| 4474 | * Original code by Ken Haase (1985?) | ||
| 4510 | */ | 4475 | */ |
| 4511 | 4476 | ||
| 4512 | static void | 4477 | static void |
| @@ -4517,14 +4482,11 @@ Scheme_functions (inf) | |||
| 4517 | 4482 | ||
| 4518 | LOOP_ON_INPUT_LINES (inf, lb, bp) | 4483 | LOOP_ON_INPUT_LINES (inf, lb, bp) |
| 4519 | { | 4484 | { |
| 4520 | if (bp[0] == '(' | 4485 | if (strneq (bp, "(def", 4) || strneq (bp, "(DEF", 4)) |
| 4521 | && (bp[1] == 'D' || bp[1] == 'd') | ||
| 4522 | && (bp[2] == 'E' || bp[2] == 'e') | ||
| 4523 | && (bp[3] == 'F' || bp[3] == 'f')) | ||
| 4524 | { | 4486 | { |
| 4525 | bp = skip_non_spaces (bp); | 4487 | bp = skip_non_spaces (bp+4); |
| 4526 | /* Skip over open parens and white space */ | 4488 | /* Skip over open parens and white space */ |
| 4527 | while (iswhite (*bp) || *bp == '(') | 4489 | while (notinname (*bp)) |
| 4528 | bp++; | 4490 | bp++; |
| 4529 | get_tag (bp); | 4491 | get_tag (bp); |
| 4530 | } | 4492 | } |
| @@ -4554,9 +4516,9 @@ char *TEX_defenv = "\ | |||
| 4554 | :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\ | 4516 | :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\ |
| 4555 | :part:appendix:entry:index"; | 4517 | :part:appendix:entry:index"; |
| 4556 | 4518 | ||
| 4557 | static void TEX_mode P_((FILE *)); | 4519 | static void TEX_mode __P((FILE *)); |
| 4558 | static struct TEX_tabent *TEX_decode_env P_((char *, char *)); | 4520 | static struct TEX_tabent *TEX_decode_env __P((char *, char *)); |
| 4559 | static int TEX_Token P_((char *)); | 4521 | static int TEX_Token __P((char *)); |
| 4560 | 4522 | ||
| 4561 | char TEX_esc = '\\'; | 4523 | char TEX_esc = '\\'; |
| 4562 | char TEX_opgrp = '{'; | 4524 | char TEX_opgrp = '{'; |
| @@ -4736,14 +4698,16 @@ Texinfo_nodes (inf) | |||
| 4736 | 4698 | ||
| 4737 | 4699 | ||
| 4738 | /* | 4700 | /* |
| 4739 | * Prolog support (rewritten) by Anders Lindgren, Mar. 96 | 4701 | * Prolog support |
| 4740 | * | 4702 | * |
| 4741 | * Assumes that the predicate starts at column 0. | 4703 | * Assumes that the predicate or rule starts at column 0. |
| 4742 | * Only the first clause of a predicate is added. | 4704 | * Only the first clause of a predicate or rule is added. |
| 4705 | * Original code by Sunichirou Sugou (1989) | ||
| 4706 | * Rewritten by Anders Lindgren (1996) | ||
| 4743 | */ | 4707 | */ |
| 4744 | static int prolog_pr P_((char *, char *)); | 4708 | static int prolog_pr __P((char *, char *)); |
| 4745 | static void prolog_skip_comment P_((linebuffer *, FILE *)); | 4709 | static void prolog_skip_comment __P((linebuffer *, FILE *)); |
| 4746 | static int prolog_atom P_((char *, int)); | 4710 | static int prolog_atom __P((char *, int)); |
| 4747 | 4711 | ||
| 4748 | static void | 4712 | static void |
| 4749 | Prolog_functions (inf) | 4713 | Prolog_functions (inf) |
| @@ -4767,8 +4731,8 @@ Prolog_functions (inf) | |||
| 4767 | prolog_skip_comment (&lb, inf); | 4731 | prolog_skip_comment (&lb, inf); |
| 4768 | else if ((len = prolog_pr (cp, last)) > 0) | 4732 | else if ((len = prolog_pr (cp, last)) > 0) |
| 4769 | { | 4733 | { |
| 4770 | /* Predicate. Store the function name so that we only | 4734 | /* Predicate or rule. Store the function name so that we |
| 4771 | generate a tag for the first clause. */ | 4735 | only generate a tag for the first clause. */ |
| 4772 | if (last == NULL) | 4736 | if (last == NULL) |
| 4773 | last = xnew(len + 1, char); | 4737 | last = xnew(len + 1, char); |
| 4774 | else if (len + 1 > allocated) | 4738 | else if (len + 1 > allocated) |
| @@ -4900,15 +4864,15 @@ prolog_atom (s, pos) | |||
| 4900 | 4864 | ||
| 4901 | 4865 | ||
| 4902 | /* | 4866 | /* |
| 4903 | * Support for Erlang -- Anders Lindgren, Feb 1996. | 4867 | * Support for Erlang |
| 4904 | * | 4868 | * |
| 4905 | * Generates tags for functions, defines, and records. | 4869 | * Generates tags for functions, defines, and records. |
| 4906 | * | ||
| 4907 | * Assumes that Erlang functions start at column 0. | 4870 | * Assumes that Erlang functions start at column 0. |
| 4871 | * Original code by Anders Lindgren (1996) | ||
| 4908 | */ | 4872 | */ |
| 4909 | static int erlang_func P_((char *, char *)); | 4873 | static int erlang_func __P((char *, char *)); |
| 4910 | static void erlang_attribute P_((char *)); | 4874 | static void erlang_attribute __P((char *)); |
| 4911 | static int erlang_atom P_((char *, int)); | 4875 | static int erlang_atom __P((char *, int)); |
| 4912 | 4876 | ||
| 4913 | static void | 4877 | static void |
| 4914 | Erlang_functions (inf) | 4878 | Erlang_functions (inf) |
| @@ -5010,9 +4974,8 @@ erlang_attribute (s) | |||
| 5010 | int pos; | 4974 | int pos; |
| 5011 | int len; | 4975 | int len; |
| 5012 | 4976 | ||
| 5013 | if (strneq (s, "-define", 7) || strneq (s, "-record", 7)) | 4977 | if (LOOKING_AT (s, "-define") || LOOKING_AT (s, "-record")) |
| 5014 | { | 4978 | { |
| 5015 | pos = skip_spaces (s + 7) - s; | ||
| 5016 | if (s[pos++] == '(') | 4979 | if (s[pos++] == '(') |
| 5017 | { | 4980 | { |
| 5018 | pos = skip_spaces (s + pos) - s; | 4981 | pos = skip_spaces (s + pos) - s; |
| @@ -5079,10 +5042,10 @@ erlang_atom (s, pos) | |||
| 5079 | 5042 | ||
| 5080 | #ifdef ETAGS_REGEXPS | 5043 | #ifdef ETAGS_REGEXPS |
| 5081 | 5044 | ||
| 5082 | static char *scan_separators P_((char *)); | 5045 | static char *scan_separators __P((char *)); |
| 5083 | static void analyse_regex P_((char *, bool)); | 5046 | static void analyse_regex __P((char *, bool)); |
| 5084 | static void add_regex P_((char *, bool, language *)); | 5047 | static void add_regex __P((char *, bool, language *)); |
| 5085 | static char *substitute P_((char *, char *, struct re_registers *)); | 5048 | static char *substitute __P((char *, char *, struct re_registers *)); |
| 5086 | 5049 | ||
| 5087 | /* Take a string like "/blah/" and turn it into "blah", making sure | 5050 | /* Take a string like "/blah/" and turn it into "blah", making sure |
| 5088 | that the first and last characters are the same, and handling | 5051 | that the first and last characters are the same, and handling |
| @@ -5244,8 +5207,8 @@ add_regex (regexp_pattern, ignore_case, lang) | |||
| 5244 | p_head = xnew (1, pattern); | 5207 | p_head = xnew (1, pattern); |
| 5245 | p_head->regex = savestr (regexp_pattern); | 5208 | p_head->regex = savestr (regexp_pattern); |
| 5246 | p_head->p_next = pp; | 5209 | p_head->p_next = pp; |
| 5247 | p_head->language = lang; | 5210 | p_head->lang = lang; |
| 5248 | p_head->pattern = patbuf; | 5211 | p_head->pat = patbuf; |
| 5249 | p_head->name_pattern = savestr (name); | 5212 | p_head->name_pattern = savestr (name); |
| 5250 | p_head->error_signaled = FALSE; | 5213 | p_head->error_signaled = FALSE; |
| 5251 | } | 5214 | } |
| @@ -5318,21 +5281,37 @@ free_patterns () | |||
| 5318 | #endif /* ETAGS_REGEXPS */ | 5281 | #endif /* ETAGS_REGEXPS */ |
| 5319 | 5282 | ||
| 5320 | 5283 | ||
| 5321 | static void | 5284 | static bool |
| 5285 | nocase_tail (cp) | ||
| 5286 | char *cp; | ||
| 5287 | { | ||
| 5288 | register int len = 0; | ||
| 5289 | |||
| 5290 | while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len])) | ||
| 5291 | cp++, len++; | ||
| 5292 | if (*cp == '\0' && !intoken (dbp[len])) | ||
| 5293 | { | ||
| 5294 | dbp += len; | ||
| 5295 | return TRUE; | ||
| 5296 | } | ||
| 5297 | return FALSE; | ||
| 5298 | } | ||
| 5299 | |||
| 5300 | static char * | ||
| 5322 | get_tag (bp) | 5301 | get_tag (bp) |
| 5323 | register char *bp; | 5302 | register char *bp; |
| 5324 | { | 5303 | { |
| 5325 | register char *cp; | 5304 | register char *cp, *name; |
| 5326 | 5305 | ||
| 5327 | if (*bp == '\0') | 5306 | if (*bp == '\0') |
| 5328 | return; | 5307 | return NULL; |
| 5329 | /* Go till you get to white space or a syntactic break */ | 5308 | /* Go till you get to white space or a syntactic break */ |
| 5330 | for (cp = bp + 1; | 5309 | for (cp = bp + 1; !notinname (*cp); cp++) |
| 5331 | *cp != '\0' && *cp != '(' && *cp != ')' && !iswhite (*cp); | ||
| 5332 | cp++) | ||
| 5333 | continue; | 5310 | continue; |
| 5334 | pfnote (savenstr (bp, cp-bp), TRUE, | 5311 | name = savenstr (bp, cp-bp); |
| 5312 | pfnote (name, TRUE, | ||
| 5335 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | 5313 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); |
| 5314 | return name; | ||
| 5336 | } | 5315 | } |
| 5337 | 5316 | ||
| 5338 | /* Initialize a linebuffer for use */ | 5317 | /* Initialize a linebuffer for use */ |
| @@ -5436,10 +5415,10 @@ readline (lbp, stream) | |||
| 5436 | for (pp = p_head; pp != NULL; pp = pp->p_next) | 5415 | for (pp = p_head; pp != NULL; pp = pp->p_next) |
| 5437 | { | 5416 | { |
| 5438 | /* Only use generic regexps or those for the current language. */ | 5417 | /* Only use generic regexps or those for the current language. */ |
| 5439 | if (pp->language != NULL && pp->language != curlang) | 5418 | if (pp->lang != NULL && pp->lang != curlang) |
| 5440 | continue; | 5419 | continue; |
| 5441 | 5420 | ||
| 5442 | match = re_match (pp->pattern, lbp->buffer, lbp->len, 0, &pp->regs); | 5421 | match = re_match (pp->pat, lbp->buffer, lbp->len, 0, &pp->regs); |
| 5443 | switch (match) | 5422 | switch (match) |
| 5444 | { | 5423 | { |
| 5445 | case -2: | 5424 | case -2: |
| @@ -5847,22 +5826,22 @@ linebuffer_setlen (lbp, toksize) | |||
| 5847 | } | 5826 | } |
| 5848 | 5827 | ||
| 5849 | /* Like malloc but get fatal error if memory is exhausted. */ | 5828 | /* Like malloc but get fatal error if memory is exhausted. */ |
| 5850 | long * | 5829 | PTR |
| 5851 | xmalloc (size) | 5830 | xmalloc (size) |
| 5852 | unsigned int size; | 5831 | unsigned int size; |
| 5853 | { | 5832 | { |
| 5854 | long *result = (long *) malloc (size); | 5833 | PTR result = (PTR) malloc (size); |
| 5855 | if (result == NULL) | 5834 | if (result == NULL) |
| 5856 | fatal ("virtual memory exhausted", (char *)NULL); | 5835 | fatal ("virtual memory exhausted", (char *)NULL); |
| 5857 | return result; | 5836 | return result; |
| 5858 | } | 5837 | } |
| 5859 | 5838 | ||
| 5860 | long * | 5839 | PTR |
| 5861 | xrealloc (ptr, size) | 5840 | xrealloc (ptr, size) |
| 5862 | char *ptr; | 5841 | char *ptr; |
| 5863 | unsigned int size; | 5842 | unsigned int size; |
| 5864 | { | 5843 | { |
| 5865 | long *result = (long *) realloc (ptr, size); | 5844 | PTR result = (PTR) realloc (ptr, size); |
| 5866 | if (result == NULL) | 5845 | if (result == NULL) |
| 5867 | fatal ("virtual memory exhausted", (char *)NULL); | 5846 | fatal ("virtual memory exhausted", (char *)NULL); |
| 5868 | return result; | 5847 | return result; |
| @@ -5873,6 +5852,6 @@ xrealloc (ptr, size) | |||
| 5873 | * c-indentation-style: gnu | 5852 | * c-indentation-style: gnu |
| 5874 | * indent-tabs-mode: t | 5853 | * indent-tabs-mode: t |
| 5875 | * tab-width: 8 | 5854 | * tab-width: 8 |
| 5876 | * c-font-lock-extra-types: ("FILE" "bool" "linebuffer") | 5855 | * c-font-lock-extra-types: ("FILE" "bool" "language" "linebuffer") |
| 5877 | * End: | 5856 | * End: |
| 5878 | */ | 5857 | */ |