diff options
| author | Francesco Potortì | 1995-11-06 17:21:24 +0000 |
|---|---|---|
| committer | Francesco Potortì | 1995-11-06 17:21:24 +0000 |
| commit | 1f6382492815fd94710ecbe2ed78d59e2ea015a5 (patch) | |
| tree | 00dc62e92d90fed2c468a84605a421b0b15856fc /lib-src | |
| parent | 89d56c1a5267744e7feec4d93919c90475304432 (diff) | |
| download | emacs-1f6382492815fd94710ecbe2ed78d59e2ea015a5.tar.gz emacs-1f6382492815fd94710ecbe2ed78d59e2ea015a5.zip | |
* etags.c (get_lang_from_name, get_lang_from_interpreter,
get_lang_from_suffix): New functions.
(get_language): Function deleted.
(lang_entry): Two members added to struct.
(lang_names): Reflect the new layout of lang_entry.
(print_language_names, main, find_entries): Use the new functions.
(find_entries): Look at the first line for #! if no language.
(C_entries): Invalidate the token when funcdef is reset.
(Perl_functions): New function.
(lang_suffixes): .pl and .pm are Perl suffixes.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 393 |
1 files changed, 251 insertions, 142 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index d53bf286aa6..61218c90f1d 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -32,7 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 32 | * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer. | 32 | * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer. |
| 33 | */ | 33 | */ |
| 34 | 34 | ||
| 35 | char pot_etags_version[] = "@(#) pot revision number is 11.42"; | 35 | char pot_etags_version[] = "@(#) pot revision number is 11.45"; |
| 36 | 36 | ||
| 37 | #define TRUE 1 | 37 | #define TRUE 1 |
| 38 | #define FALSE 0 | 38 | #define FALSE 0 |
| @@ -160,6 +160,7 @@ Lang_function Fortran_functions; | |||
| 160 | Lang_function Yacc_entries; | 160 | Lang_function Yacc_entries; |
| 161 | Lang_function Lisp_functions; | 161 | Lang_function Lisp_functions; |
| 162 | Lang_function Pascal_functions; | 162 | Lang_function Pascal_functions; |
| 163 | Lang_function Perl_functions; | ||
| 163 | Lang_function Prolog_functions; | 164 | Lang_function Prolog_functions; |
| 164 | Lang_function Scheme_functions; | 165 | Lang_function Scheme_functions; |
| 165 | Lang_function TeX_functions; | 166 | Lang_function TeX_functions; |
| @@ -175,13 +176,16 @@ void Fortran_functions (); | |||
| 175 | void Yacc_entries (); | 176 | void Yacc_entries (); |
| 176 | void Lisp_functions (); | 177 | void Lisp_functions (); |
| 177 | void Pascal_functions (); | 178 | void Pascal_functions (); |
| 179 | void Perl_functions (); | ||
| 178 | void Prolog_functions (); | 180 | void Prolog_functions (); |
| 179 | void Scheme_functions (); | 181 | void Scheme_functions (); |
| 180 | void TeX_functions (); | 182 | void TeX_functions (); |
| 181 | void just_read_file (); | 183 | void just_read_file (); |
| 182 | #endif | 184 | #endif |
| 183 | 185 | ||
| 184 | logical get_language (); | 186 | Lang_function *get_language_from_name (); |
| 187 | Lang_function *get_language_from_interpreter (); | ||
| 188 | Lang_function *get_language_from_suffix (); | ||
| 185 | int total_size_of_entries (); | 189 | int total_size_of_entries (); |
| 186 | long readline (); | 190 | long readline (); |
| 187 | long readline_internal (); | 191 | long readline_internal (); |
| @@ -307,140 +311,130 @@ int num_patterns = 0; | |||
| 307 | struct pattern *patterns = NULL; | 311 | struct pattern *patterns = NULL; |
| 308 | #endif /* ETAGS_REGEXPS */ | 312 | #endif /* ETAGS_REGEXPS */ |
| 309 | 313 | ||
| 310 | /* Language stuff. */ | 314 | /* |
| 315 | * Language stuff. | ||
| 316 | */ | ||
| 317 | |||
| 318 | /* Non-NULL if language fixed. */ | ||
| 319 | Lang_function *lang_func = NULL; | ||
| 320 | |||
| 321 | /* Assembly code */ | ||
| 322 | char *Asm_suffixes [] = { "a", /* Unix assembler */ | ||
| 323 | "asm", /* Microcontroller assembly */ | ||
| 324 | "def", /* BSO/Tasking definition includes */ | ||
| 325 | "inc", /* Microcontroller include files */ | ||
| 326 | "ins", /* Microcontroller include files */ | ||
| 327 | "s", "sa", /* Unix assembler */ | ||
| 328 | "src", /* BSO/Tasking C compiler output */ | ||
| 329 | NULL | ||
| 330 | }; | ||
| 331 | |||
| 332 | /* Note that .c and .h can be considered C++, if the --c++ flag was | ||
| 333 | given. That is why default_C_entries is called here. */ | ||
| 334 | char *default_C_suffixes [] = | ||
| 335 | { "c", "h", NULL }; | ||
| 336 | |||
| 337 | /* C++ file */ | ||
| 338 | char *Cplusplus_suffixes [] = | ||
| 339 | { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx", NULL }; | ||
| 340 | |||
| 341 | /* C* file */ | ||
| 342 | char *Cstar_suffixes [] = | ||
| 343 | { "cs", "hs", NULL }; | ||
| 344 | |||
| 345 | /* Fortran */ | ||
| 346 | char *Fortran_suffixes [] = | ||
| 347 | { "F", "f", "f90", "for", NULL }; | ||
| 348 | |||
| 349 | /* Lisp source code */ | ||
| 350 | char *Lisp_suffixes [] = | ||
| 351 | { "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL }; | ||
| 352 | |||
| 353 | /* Pascal file */ | ||
| 354 | char *Pascal_suffixes [] = | ||
| 355 | { "p", "pas", NULL }; | ||
| 356 | |||
| 357 | /* Perl file */ | ||
| 358 | char *Perl_suffixes [] = | ||
| 359 | { "pl", "pm", NULL }; | ||
| 360 | char *Perl_interpreters [] = | ||
| 361 | { "perl", NULL }; | ||
| 362 | |||
| 363 | /* Pro*C file. */ | ||
| 364 | char *plain_C_suffixes [] = | ||
| 365 | { "pc", NULL }; | ||
| 366 | |||
| 367 | /* Prolog source code */ | ||
| 368 | char *Prolog_suffixes [] = | ||
| 369 | { "prolog", NULL }; | ||
| 370 | |||
| 371 | /* Scheme source code */ | ||
| 372 | /* FIXME Can't do the `SCM' or `scm' prefix with a version number */ | ||
| 373 | char *Scheme_suffixes [] = | ||
| 374 | { "SCM", "SM", "oak", "sch", "scheme", "scm", "sm", "t", NULL }; | ||
| 375 | |||
| 376 | /* TeX/LaTeX source code */ | ||
| 377 | char *TeX_suffixes [] = | ||
| 378 | { "bib", "clo", "cls", "ltx", "sty", "TeX", "tex", NULL }; | ||
| 379 | |||
| 380 | /* Yacc file */ | ||
| 381 | char *Yacc_suffixes [] = | ||
| 382 | { "y", NULL }; | ||
| 383 | |||
| 384 | /* Table of language names and corresponding functions, file suffixes | ||
| 385 | and interpreter names. | ||
| 386 | It is ok for a given function to be listed under more than one | ||
| 387 | name. I just didn't. */ | ||
| 311 | struct lang_entry | 388 | struct lang_entry |
| 312 | { | 389 | { |
| 313 | char *suffix; | 390 | char *name; |
| 314 | Lang_function *function; | 391 | Lang_function *function; |
| 392 | char **suffixes; | ||
| 393 | char **interpreters; | ||
| 315 | }; | 394 | }; |
| 316 | 395 | ||
| 317 | /* Table of language names and corresponding functions. */ | 396 | struct lang_entry lang_names [] = |
| 318 | /* It is ok for a given function to be listed under more than one | 397 | { |
| 319 | name. I just didn't. */ | 398 | { "asm", Asm_labels, Asm_suffixes }, |
| 320 | /* "auto" language reverts to default behavior. */ | 399 | { "c", default_C_entries, default_C_suffixes }, |
| 321 | struct lang_entry lang_names[] = | 400 | { "c++", Cplusplus_entries, Cplusplus_suffixes }, |
| 322 | { | 401 | { "c*", Cstar_entries, Cstar_suffixes }, |
| 323 | { "asm", Asm_labels }, | 402 | { "fortran", Fortran_functions, Fortran_suffixes }, |
| 324 | { "c", default_C_entries }, | 403 | { "lisp", Lisp_functions, Lisp_suffixes }, |
| 325 | { "c++", Cplusplus_entries }, | 404 | { "pascal", Pascal_functions, Pascal_suffixes }, |
| 326 | { "c*", Cstar_entries }, | 405 | { "perl", Perl_functions, Perl_suffixes, Perl_interpreters }, |
| 327 | { "fortran", Fortran_functions }, | 406 | { "proc", plain_C_entries, plain_C_suffixes }, |
| 328 | { "lisp", Lisp_functions }, | 407 | { "prolog", Prolog_functions, Prolog_suffixes }, |
| 329 | { "none", just_read_file }, | 408 | { "scheme" , Scheme_functions, Scheme_suffixes }, |
| 330 | { "pascal", Pascal_functions }, | 409 | { "tex", TeX_functions, TeX_suffixes }, |
| 331 | { "scheme" , Scheme_functions }, | 410 | { "yacc", Yacc_entries, Yacc_suffixes }, |
| 332 | { "tex", TeX_functions }, | 411 | { "auto", NULL }, /* default guessing scheme */ |
| 333 | { "auto", NULL }, | 412 | { "none", just_read_file }, /* regexp matching only */ |
| 334 | { NULL, NULL } | 413 | { NULL, NULL } /* end of list */ |
| 335 | }; | ||
| 336 | |||
| 337 | /* Table of file name suffixes and corresponding language functions. */ | ||
| 338 | struct lang_entry lang_suffixes[] = | ||
| 339 | { | ||
| 340 | /* Assembly code */ | ||
| 341 | { "a", Asm_labels }, /* Unix assembler */ | ||
| 342 | { "asm", Asm_labels }, /* Microcontroller assembly */ | ||
| 343 | { "def", Asm_labels }, /* BSO/Tasking definition includes */ | ||
| 344 | { "inc", Asm_labels }, /* Microcontroller include files */ | ||
| 345 | { "ins", Asm_labels }, /* Microcontroller include files */ | ||
| 346 | { "s", Asm_labels }, | ||
| 347 | { "sa", Asm_labels }, /* Unix assembler */ | ||
| 348 | { "src", Asm_labels }, /* BSO/Tasking C compiler output */ | ||
| 349 | |||
| 350 | /* LaTeX source code */ | ||
| 351 | { "bib", TeX_functions }, | ||
| 352 | { "clo", TeX_functions }, | ||
| 353 | { "cls", TeX_functions }, | ||
| 354 | { "ltx", TeX_functions }, | ||
| 355 | { "sty", TeX_functions }, | ||
| 356 | { "TeX", TeX_functions }, | ||
| 357 | { "tex", TeX_functions }, | ||
| 358 | |||
| 359 | /* Lisp source code */ | ||
| 360 | { "cl", Lisp_functions }, | ||
| 361 | { "clisp", Lisp_functions }, | ||
| 362 | { "el", Lisp_functions }, | ||
| 363 | { "l", Lisp_functions }, | ||
| 364 | { "lisp", Lisp_functions }, | ||
| 365 | { "lsp", Lisp_functions }, | ||
| 366 | { "ml", Lisp_functions }, | ||
| 367 | |||
| 368 | /* Scheme source code */ | ||
| 369 | { "SCM", Scheme_functions }, | ||
| 370 | { "SM", Scheme_functions }, | ||
| 371 | { "oak", Scheme_functions }, | ||
| 372 | { "sch", Scheme_functions }, | ||
| 373 | { "scheme", Scheme_functions }, | ||
| 374 | { "scm", Scheme_functions }, | ||
| 375 | { "sm", Scheme_functions }, | ||
| 376 | { "t", Scheme_functions }, | ||
| 377 | /* FIXME Can't do the `SCM' or `scm' prefix with a version number */ | ||
| 378 | |||
| 379 | /* Note that .c and .h can be considered C++, if the --c++ flag was | ||
| 380 | given. That is why default_C_entries is called here. */ | ||
| 381 | { "c", default_C_entries }, | ||
| 382 | { "h", default_C_entries }, | ||
| 383 | |||
| 384 | /* Pro*C file. */ | ||
| 385 | { "pc", plain_C_entries }, | ||
| 386 | |||
| 387 | /* C++ file */ | ||
| 388 | { "C", Cplusplus_entries }, | ||
| 389 | { "H", Cplusplus_entries }, | ||
| 390 | { "c++", Cplusplus_entries }, | ||
| 391 | { "cc", Cplusplus_entries }, | ||
| 392 | { "cpp", Cplusplus_entries }, | ||
| 393 | { "cxx", Cplusplus_entries }, | ||
| 394 | { "h++", Cplusplus_entries }, | ||
| 395 | { "hh", Cplusplus_entries }, | ||
| 396 | { "hpp", Cplusplus_entries }, | ||
| 397 | { "hxx", Cplusplus_entries }, | ||
| 398 | |||
| 399 | /* Yacc file */ | ||
| 400 | { "y", Yacc_entries }, | ||
| 401 | |||
| 402 | /* C* file */ | ||
| 403 | { "cs", Cstar_entries }, | ||
| 404 | { "hs", Cstar_entries }, | ||
| 405 | |||
| 406 | /* Fortran */ | ||
| 407 | { "F", Fortran_functions }, | ||
| 408 | { "f", Fortran_functions }, | ||
| 409 | { "f90", Fortran_functions }, | ||
| 410 | { "for", Fortran_functions }, | ||
| 411 | |||
| 412 | /* Prolog source code */ | ||
| 413 | { "prolog", Prolog_functions }, | ||
| 414 | |||
| 415 | /* Pascal file */ | ||
| 416 | { "p", Pascal_functions }, | ||
| 417 | { "pas", Pascal_functions }, | ||
| 418 | |||
| 419 | { NULL, NULL } | ||
| 420 | }; | 414 | }; |
| 421 | 415 | ||
| 422 | /* Non-NULL if language fixed. */ | ||
| 423 | Lang_function *lang_func = NULL; | ||
| 424 | |||
| 425 | 416 | ||
| 426 | void | 417 | void |
| 427 | print_language_names () | 418 | print_language_names () |
| 428 | { | 419 | { |
| 429 | struct lang_entry *name, *ext; | 420 | struct lang_entry *lang; |
| 421 | char **ext; | ||
| 430 | 422 | ||
| 431 | puts ("\nThese are the currently supported languages, along with the\n\ | 423 | puts ("\nThese are the currently supported languages, along with the\n\ |
| 432 | default file name suffixes:"); | 424 | default file name suffixes:"); |
| 433 | for (name = lang_names; name->suffix; ++name) | 425 | for (lang = lang_names; lang->name != NULL; lang++) |
| 434 | { | 426 | { |
| 435 | printf ("\t%s\t", name->suffix); | 427 | printf ("\t%s\t", lang->name); |
| 436 | for (ext = lang_suffixes; ext->suffix; ++ext) | 428 | if (lang->suffixes != NULL) |
| 437 | if (name->function == ext->function) | 429 | for (ext = lang->suffixes; *ext != NULL; ext++) |
| 438 | printf (" .%s", ext->suffix); | 430 | printf (" .%s", *ext); |
| 439 | puts (""); | 431 | puts (""); |
| 440 | } | 432 | } |
| 441 | puts ("Where `auto' means use default language for files based on file\n\ | 433 | puts ("Where `auto' means use default language for files based on file\n\ |
| 442 | name suffix, and `none' means only do regexp processing on files.\n\ | 434 | name suffix, and `none' means only do regexp processing on files.\n\ |
| 443 | If no language is specified and no matching suffix is found,\n\ | 435 | If no language is specified and no matching suffix is found,\n\ |
| 436 | the first line of the file is read for a sharp-bang (#!) sequence\n\ | ||
| 437 | followed by the name of an interpreter. If no such sequence is found,\n\ | ||
| 444 | Fortran is tried first; if no tags are found, C is tried next."); | 438 | Fortran is tried first; if no tags are found, C is tried next."); |
| 445 | } | 439 | } |
| 446 | 440 | ||
| @@ -562,7 +556,7 @@ typedef struct | |||
| 562 | enum argument_type arg_type; | 556 | enum argument_type arg_type; |
| 563 | char *what; | 557 | char *what; |
| 564 | Lang_function *function; | 558 | Lang_function *function; |
| 565 | } ARGUMENT; | 559 | } argument; |
| 566 | 560 | ||
| 567 | #ifdef VMS /* VMS specific functions */ | 561 | #ifdef VMS /* VMS specific functions */ |
| 568 | 562 | ||
| @@ -698,7 +692,7 @@ main (argc, argv) | |||
| 698 | unsigned int nincluded_files = 0; | 692 | unsigned int nincluded_files = 0; |
| 699 | char **included_files = xnew (argc, char *); | 693 | char **included_files = xnew (argc, char *); |
| 700 | char *this_file; | 694 | char *this_file; |
| 701 | ARGUMENT *argbuffer; | 695 | argument *argbuffer; |
| 702 | int current_arg = 0, file_count = 0; | 696 | int current_arg = 0, file_count = 0; |
| 703 | struct linebuffer filename_lb; | 697 | struct linebuffer filename_lb; |
| 704 | #ifdef VMS | 698 | #ifdef VMS |
| @@ -713,7 +707,7 @@ main (argc, argv) | |||
| 713 | 707 | ||
| 714 | /* Allocate enough no matter what happens. Overkill, but each one | 708 | /* Allocate enough no matter what happens. Overkill, but each one |
| 715 | is small. */ | 709 | is small. */ |
| 716 | argbuffer = xnew (argc, ARGUMENT); | 710 | argbuffer = xnew (argc, argument); |
| 717 | 711 | ||
| 718 | #ifdef ETAGS_REGEXPS | 712 | #ifdef ETAGS_REGEXPS |
| 719 | /* Set syntax for regular expression routines. */ | 713 | /* Set syntax for regular expression routines. */ |
| @@ -778,7 +772,8 @@ main (argc, argv) | |||
| 778 | noindentypedefs = TRUE; | 772 | noindentypedefs = TRUE; |
| 779 | break; | 773 | break; |
| 780 | case 'l': | 774 | case 'l': |
| 781 | if (!get_language (optarg, &argbuffer[current_arg].function)) | 775 | argbuffer[current_arg].function = get_language_from_name (optarg); |
| 776 | if (argbuffer[current_arg].function == NULL) | ||
| 782 | { | 777 | { |
| 783 | fprintf (stderr, "%s: language \"%s\" not recognized.\n", | 778 | fprintf (stderr, "%s: language \"%s\" not recognized.\n", |
| 784 | progname, optarg); | 779 | progname, optarg); |
| @@ -989,25 +984,68 @@ main (argc, argv) | |||
| 989 | 984 | ||
| 990 | 985 | ||
| 991 | /* | 986 | /* |
| 992 | * Set the language, given the name. | 987 | * Return a Lang_function given the name. |
| 993 | */ | 988 | */ |
| 994 | logical | 989 | Lang_function * |
| 995 | get_language (language, func) | 990 | get_language_from_name (name) |
| 996 | char *language; | 991 | char *name; |
| 997 | Lang_function **func; | ||
| 998 | { | 992 | { |
| 999 | struct lang_entry *lang; | 993 | struct lang_entry *lang; |
| 1000 | 994 | ||
| 1001 | for (lang = lang_names; lang->suffix; ++lang) | 995 | if (name == NULL) |
| 996 | return NULL; | ||
| 997 | for (lang = lang_names; lang->name != NULL; lang++) | ||
| 1002 | { | 998 | { |
| 1003 | if (streq (language, lang->suffix)) | 999 | if (streq (name, lang->name)) |
| 1004 | { | 1000 | return lang->function; |
| 1005 | *func = lang->function; | ||
| 1006 | return TRUE; | ||
| 1007 | } | ||
| 1008 | } | 1001 | } |
| 1009 | 1002 | ||
| 1010 | return FALSE; | 1003 | return NULL; |
| 1004 | } | ||
| 1005 | |||
| 1006 | |||
| 1007 | /* | ||
| 1008 | * Return a Lang_function given the interpreter name. | ||
| 1009 | */ | ||
| 1010 | Lang_function * | ||
| 1011 | get_language_from_interpreter (interpreter) | ||
| 1012 | char *interpreter; | ||
| 1013 | { | ||
| 1014 | struct lang_entry *lang; | ||
| 1015 | char **iname; | ||
| 1016 | |||
| 1017 | if (interpreter == NULL) | ||
| 1018 | return NULL; | ||
| 1019 | for (lang = lang_names; lang->name != NULL; lang++) | ||
| 1020 | if (lang->interpreters != NULL) | ||
| 1021 | for (iname = lang->interpreters; *iname != NULL; iname++) | ||
| 1022 | if (streq (*iname, interpreter)) | ||
| 1023 | return lang->function; | ||
| 1024 | |||
| 1025 | return NULL; | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | |||
| 1029 | |||
| 1030 | /* | ||
| 1031 | * Return a Lang_function given the file suffix. | ||
| 1032 | */ | ||
| 1033 | Lang_function * | ||
| 1034 | get_language_from_suffix (suffix) | ||
| 1035 | char *suffix; | ||
| 1036 | { | ||
| 1037 | struct lang_entry *lang; | ||
| 1038 | char **ext; | ||
| 1039 | |||
| 1040 | if (suffix == NULL) | ||
| 1041 | return NULL; | ||
| 1042 | for (lang = lang_names; lang->name != NULL; lang++) | ||
| 1043 | if (lang->suffixes != NULL) | ||
| 1044 | for (ext = lang->suffixes; *ext != NULL; ext++) | ||
| 1045 | if (streq (*ext, suffix)) | ||
| 1046 | return lang->function; | ||
| 1047 | |||
| 1048 | return NULL; | ||
| 1011 | } | 1049 | } |
| 1012 | 1050 | ||
| 1013 | 1051 | ||
| @@ -1103,7 +1141,7 @@ find_entries (file, inf) | |||
| 1103 | FILE *inf; | 1141 | FILE *inf; |
| 1104 | { | 1142 | { |
| 1105 | char *cp; | 1143 | char *cp; |
| 1106 | struct lang_entry *lang; | 1144 | Lang_function *function; |
| 1107 | NODE *old_last_node; | 1145 | NODE *old_last_node; |
| 1108 | extern NODE *last_node; | 1146 | extern NODE *last_node; |
| 1109 | 1147 | ||
| @@ -1111,29 +1149,61 @@ find_entries (file, inf) | |||
| 1111 | released. The amount of memory leaked here is the sum of the | 1149 | released. The amount of memory leaked here is the sum of the |
| 1112 | lengths of the input file names. */ | 1150 | lengths of the input file names. */ |
| 1113 | curfile = savestr (file); | 1151 | curfile = savestr (file); |
| 1114 | cp = etags_strrchr (file, '.'); | ||
| 1115 | 1152 | ||
| 1116 | /* If user specified a language, use it. */ | 1153 | /* If user specified a language, use it. */ |
| 1117 | if (lang_func != NULL) | 1154 | function = lang_func; |
| 1155 | if (function != NULL) | ||
| 1118 | { | 1156 | { |
| 1119 | lang_func (inf); | 1157 | function (inf); |
| 1120 | fclose (inf); | 1158 | fclose (inf); |
| 1121 | return; | 1159 | return; |
| 1122 | } | 1160 | } |
| 1123 | 1161 | ||
| 1124 | if (cp) | 1162 | cp = etags_strrchr (file, '.'); |
| 1163 | if (cp != NULL) | ||
| 1125 | { | 1164 | { |
| 1126 | ++cp; | 1165 | cp += 1; |
| 1127 | for (lang = lang_suffixes; lang->suffix; ++lang) | 1166 | function = get_language_from_suffix (cp); |
| 1167 | if (function != NULL) | ||
| 1128 | { | 1168 | { |
| 1129 | if (streq (cp, lang->suffix)) | 1169 | function (inf); |
| 1170 | fclose (inf); | ||
| 1171 | return; | ||
| 1172 | } | ||
| 1173 | } | ||
| 1174 | |||
| 1175 | /* Look for sharp-bang as the first two characters. */ | ||
| 1176 | if (readline_internal (&lb, inf) > 2 | ||
| 1177 | && lb.buffer[0] == '#' | ||
| 1178 | && lb.buffer[1] == '!') | ||
| 1179 | { | ||
| 1180 | char *lp; | ||
| 1181 | |||
| 1182 | /* Set lp to point at the first char after the last slash in the | ||
| 1183 | line or, if no slashes, at the first nonblank. Then set cp to | ||
| 1184 | the first successive blank and terminate the string. */ | ||
| 1185 | lp = etags_strrchr (lb.buffer+2, '/'); | ||
| 1186 | if (lp != NULL) | ||
| 1187 | lp += 1; | ||
| 1188 | else | ||
| 1189 | for (lp = lb.buffer+2; *lp != '\0' && isspace (*lp); lp++) | ||
| 1190 | continue; | ||
| 1191 | for (cp = lp; *cp != '\0' && !isspace (*cp); cp++) | ||
| 1192 | continue; | ||
| 1193 | *cp = '\0'; | ||
| 1194 | |||
| 1195 | if (strlen (lp) > 0) | ||
| 1196 | { | ||
| 1197 | function = get_language_from_interpreter (lp); | ||
| 1198 | if (function != NULL) | ||
| 1130 | { | 1199 | { |
| 1131 | lang->function (inf); | 1200 | function (inf); |
| 1132 | fclose (inf); | 1201 | fclose (inf); |
| 1133 | return; | 1202 | return; |
| 1134 | } | 1203 | } |
| 1135 | } | 1204 | } |
| 1136 | } | 1205 | } |
| 1206 | rewind (inf); | ||
| 1137 | 1207 | ||
| 1138 | /* Try Fortran. */ | 1208 | /* Try Fortran. */ |
| 1139 | old_last_node = last_node; | 1209 | old_last_node = last_node; |
| @@ -1146,6 +1216,7 @@ find_entries (file, inf) | |||
| 1146 | default_C_entries (inf); | 1216 | default_C_entries (inf); |
| 1147 | } | 1217 | } |
| 1148 | fclose (inf); | 1218 | fclose (inf); |
| 1219 | return; | ||
| 1149 | } | 1220 | } |
| 1150 | 1221 | ||
| 1151 | /* Record a tag. */ | 1222 | /* Record a tag. */ |
| @@ -2197,7 +2268,13 @@ C_entries (c_ext, inf) | |||
| 2197 | typdef = tnone; | 2268 | typdef = tnone; |
| 2198 | } | 2269 | } |
| 2199 | if (funcdef != fignore) | 2270 | if (funcdef != fignore) |
| 2200 | funcdef = fnone; | 2271 | { |
| 2272 | funcdef = fnone; | ||
| 2273 | /* The following instruction invalidates the token. | ||
| 2274 | Probably the token should be invalidated in all | ||
| 2275 | other cases where some state machine is reset. */ | ||
| 2276 | tok.valid = FALSE; | ||
| 2277 | } | ||
| 2201 | if (structdef == stagseen) | 2278 | if (structdef == stagseen) |
| 2202 | structdef = snone; | 2279 | structdef = snone; |
| 2203 | break; | 2280 | break; |
| @@ -2599,6 +2676,38 @@ Asm_labels (inf) | |||
| 2599 | } | 2676 | } |
| 2600 | } | 2677 | } |
| 2601 | 2678 | ||
| 2679 | /* | ||
| 2680 | * Perl support by Bart Robinson <lomew@cs.utah.edu> | ||
| 2681 | * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/ | ||
| 2682 | */ | ||
| 2683 | void | ||
| 2684 | Perl_functions (inf) | ||
| 2685 | FILE *inf; | ||
| 2686 | { | ||
| 2687 | register char *cp; | ||
| 2688 | |||
| 2689 | lineno = 0; | ||
| 2690 | charno = 0; | ||
| 2691 | |||
| 2692 | while (!feof (inf)) | ||
| 2693 | { | ||
| 2694 | lineno++; | ||
| 2695 | linecharno = charno; | ||
| 2696 | charno += readline (&lb, inf); | ||
| 2697 | cp = lb.buffer; | ||
| 2698 | |||
| 2699 | if (*cp++ == 's' && *cp++ == 'u' && *cp++ == 'b' && isspace(*cp++)) | ||
| 2700 | { | ||
| 2701 | while (*cp && isspace(*cp)) | ||
| 2702 | cp++; | ||
| 2703 | while (*cp && ! isspace(*cp) && *cp != '{') | ||
| 2704 | cp++; | ||
| 2705 | pfnote (NULL, TRUE, | ||
| 2706 | lb.buffer, cp - lb.buffer + 1, lineno, linecharno); | ||
| 2707 | } | ||
| 2708 | } | ||
| 2709 | } | ||
| 2710 | |||
| 2602 | /* Added by Mosur Mohan, 4/22/88 */ | 2711 | /* Added by Mosur Mohan, 4/22/88 */ |
| 2603 | /* Pascal parsing */ | 2712 | /* Pascal parsing */ |
| 2604 | 2713 | ||