diff options
| author | Francesco Potortì | 1995-06-27 14:21:23 +0000 |
|---|---|---|
| committer | Francesco Potortì | 1995-06-27 14:21:23 +0000 |
| commit | 79263656b0ed544811a57b97ff419dd039a5ba0a (patch) | |
| tree | 3e3b06401f7e87bbd167b5580fb5fbb511f091b9 /lib-src | |
| parent | d3bea05f1f14fd9b4425307ade7bf65ea1df65be (diff) | |
| download | emacs-79263656b0ed544811a57b97ff419dd039a5ba0a.tar.gz emacs-79263656b0ed544811a57b97ff419dd039a5ba0a.zip | |
* etags.c (plain_C_entries): new function.
(lowcase): new macro.
(tail, Fortran_functions, Pascal_functions): use new macro lowcase.
(lang_suffixes): new suffix ".pc" for Pro*C files.
(consider_token): don't tag all tokens beginning with DEFUN & Co..
(tail): look for the end of the token when comparing.
(takeprec): since now tail behaves differently, use strneq.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 79 |
1 files changed, 48 insertions, 31 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index 9a17863c457..92a07c675bd 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -105,6 +105,8 @@ extern int errno; | |||
| 105 | #define streq(s,t) (strcmp (s, t) == 0) | 105 | #define streq(s,t) (strcmp (s, t) == 0) |
| 106 | #define strneq(s,t,n) (strncmp (s, t, n) == 0) | 106 | #define strneq(s,t,n) (strncmp (s, t, n) == 0) |
| 107 | 107 | ||
| 108 | #define lowcase(c) ((c) | ' ') | ||
| 109 | |||
| 108 | #define iswhite(arg) (_wht[arg]) /* T if char is white */ | 110 | #define iswhite(arg) (_wht[arg]) /* T if char is white */ |
| 109 | #define begtoken(arg) (_btk[arg]) /* T if char can start token */ | 111 | #define begtoken(arg) (_btk[arg]) /* T if char can start token */ |
| 110 | #define intoken(arg) (_itk[arg]) /* T if char can be in token */ | 112 | #define intoken(arg) (_itk[arg]) /* T if char can be in token */ |
| @@ -165,8 +167,9 @@ Lang_function TeX_functions; | |||
| 165 | Lang_function just_read_file; | 167 | Lang_function just_read_file; |
| 166 | #else /* so let's write it this way */ | 168 | #else /* so let's write it this way */ |
| 167 | void Asm_labels (); | 169 | void Asm_labels (); |
| 168 | void default_C_entries (); | ||
| 169 | void C_entries (); | 170 | void C_entries (); |
| 171 | void default_C_entries (); | ||
| 172 | void plain_C_entries (); | ||
| 170 | void Cplusplus_entries (); | 173 | void Cplusplus_entries (); |
| 171 | void Cstar_entries (); | 174 | void Cstar_entries (); |
| 172 | void Fortran_functions (); | 175 | void Fortran_functions (); |
| @@ -309,7 +312,7 @@ struct pattern *patterns = NULL; | |||
| 309 | /* Language stuff. */ | 312 | /* Language stuff. */ |
| 310 | struct lang_entry | 313 | struct lang_entry |
| 311 | { | 314 | { |
| 312 | char *extension; | 315 | char *suffix; |
| 313 | Lang_function *function; | 316 | Lang_function *function; |
| 314 | }; | 317 | }; |
| 315 | 318 | ||
| @@ -333,8 +336,8 @@ struct lang_entry lang_names[] = | |||
| 333 | { NULL, NULL } | 336 | { NULL, NULL } |
| 334 | }; | 337 | }; |
| 335 | 338 | ||
| 336 | /* Table of file extensions and corresponding language functions. */ | 339 | /* Table of file name suffixes and corresponding language functions. */ |
| 337 | struct lang_entry lang_extensions[] = | 340 | struct lang_entry lang_suffixes[] = |
| 338 | { | 341 | { |
| 339 | /* Assume that ".s" or ".a" is assembly code. -wolfgang. | 342 | /* Assume that ".s" or ".a" is assembly code. -wolfgang. |
| 340 | Or even ".sa". */ | 343 | Or even ".sa". */ |
| @@ -375,11 +378,14 @@ struct lang_entry lang_extensions[] = | |||
| 375 | { "t", Scheme_functions }, | 378 | { "t", Scheme_functions }, |
| 376 | /* FIXME Can't do the `SCM' or `scm' prefix with a version number */ | 379 | /* FIXME Can't do the `SCM' or `scm' prefix with a version number */ |
| 377 | 380 | ||
| 378 | /* Note that ".c" and ".h" can be considered C++, if the --c++ | 381 | /* Note that .c and .h can be considered C++, if the --c++ flag was |
| 379 | flag was given. That is why default_C_entries is called here. */ | 382 | given. That is why default_C_entries is called here. */ |
| 380 | { "c", default_C_entries }, | 383 | { "c", default_C_entries }, |
| 381 | { "h", default_C_entries }, | 384 | { "h", default_C_entries }, |
| 382 | 385 | ||
| 386 | /* .pc is a Pro*C file. */ | ||
| 387 | { "pc", plain_C_entries }, | ||
| 388 | |||
| 383 | /* .C or .H or .c++ or .cc or .cpp or .cxx or .h++ or .hh or .hxx: | 389 | /* .C or .H or .c++ or .cc or .cpp or .cxx or .h++ or .hh or .hxx: |
| 384 | a C++ file */ | 390 | a C++ file */ |
| 385 | { "C", Cplusplus_entries }, | 391 | { "C", Cplusplus_entries }, |
| @@ -424,18 +430,18 @@ print_language_names () | |||
| 424 | struct lang_entry *name, *ext; | 430 | struct lang_entry *name, *ext; |
| 425 | 431 | ||
| 426 | puts ("\nThese are the currently supported languages, along with the\n\ | 432 | puts ("\nThese are the currently supported languages, along with the\n\ |
| 427 | default extensions for files:"); | 433 | default file name suffixes:"); |
| 428 | for (name = lang_names; name->extension; ++name) | 434 | for (name = lang_names; name->suffix; ++name) |
| 429 | { | 435 | { |
| 430 | printf ("\t%s\t", name->extension); | 436 | printf ("\t%s\t", name->suffix); |
| 431 | for (ext = lang_extensions; ext->extension; ++ext) | 437 | for (ext = lang_suffixes; ext->suffix; ++ext) |
| 432 | if (name->function == ext->function) | 438 | if (name->function == ext->function) |
| 433 | printf (" .%s", ext->extension); | 439 | printf (" .%s", ext->suffix); |
| 434 | puts (""); | 440 | puts (""); |
| 435 | } | 441 | } |
| 436 | puts ("Where `auto' means use default language for files based on filename\n\ | 442 | puts ("Where `auto' means use default language for files based on file\n\ |
| 437 | extension, and `none' means only do regexp processing on files.\n\ | 443 | name suffix, and `none' means only do regexp processing on files.\n\ |
| 438 | If no language is specified and no extension is found for some file,\n\ | 444 | If no language is specified and no matching suffix is found,\n\ |
| 439 | Fortran is tried first; if no tags are found, C is tried next."); | 445 | Fortran is tried first; if no tags are found, C is tried next."); |
| 440 | } | 446 | } |
| 441 | 447 | ||
| @@ -467,7 +473,7 @@ names from stdin.\n\n", progname); | |||
| 467 | backward-search command instead of '/', the forward-search command."); | 473 | backward-search command instead of '/', the forward-search command."); |
| 468 | 474 | ||
| 469 | puts ("-C, --c++\n\ | 475 | puts ("-C, --c++\n\ |
| 470 | Treat files whose extension defaults to C language as C++ files."); | 476 | Treat files whose name suffix defaults to C language as C++ files."); |
| 471 | 477 | ||
| 472 | if (CTAGS) | 478 | if (CTAGS) |
| 473 | puts ("-d, --defines\n\ | 479 | puts ("-d, --defines\n\ |
| @@ -994,9 +1000,9 @@ get_language (language, func) | |||
| 994 | { | 1000 | { |
| 995 | struct lang_entry *lang; | 1001 | struct lang_entry *lang; |
| 996 | 1002 | ||
| 997 | for (lang = lang_names; lang->extension; ++lang) | 1003 | for (lang = lang_names; lang->suffix; ++lang) |
| 998 | { | 1004 | { |
| 999 | if (streq (language, lang->extension)) | 1005 | if (streq (language, lang->suffix)) |
| 1000 | { | 1006 | { |
| 1001 | *func = lang->function; | 1007 | *func = lang->function; |
| 1002 | return TRUE; | 1008 | return TRUE; |
| @@ -1117,9 +1123,9 @@ find_entries (file, inf) | |||
| 1117 | if (cp) | 1123 | if (cp) |
| 1118 | { | 1124 | { |
| 1119 | ++cp; | 1125 | ++cp; |
| 1120 | for (lang = lang_extensions; lang->extension; ++lang) | 1126 | for (lang = lang_suffixes; lang->suffix; ++lang) |
| 1121 | { | 1127 | { |
| 1122 | if (streq (cp, lang->extension)) | 1128 | if (streq (cp, lang->suffix)) |
| 1123 | { | 1129 | { |
| 1124 | lang->function (inf); | 1130 | lang->function (inf); |
| 1125 | fclose (inf); | 1131 | fclose (inf); |
| @@ -1774,16 +1780,16 @@ consider_token (str, len, c, c_ext, cblev, is_func) | |||
| 1774 | 1780 | ||
| 1775 | /* Detect GNU macros. */ | 1781 | /* Detect GNU macros. */ |
| 1776 | if (definedef == dnone) | 1782 | if (definedef == dnone) |
| 1777 | if (strneq (str, "DEFUN", 5) /* Used in emacs */ | 1783 | if (strneq (str, "DEFUN", len) /* Used in emacs */ |
| 1778 | #if FALSE | 1784 | #if FALSE |
| 1779 | These are defined inside C functions, so currently they | 1785 | These are defined inside C functions, so currently they |
| 1780 | are not met anyway. | 1786 | are not met anyway. |
| 1781 | || strneq (str, "EXFUN", 5) /* Used in glibc */ | 1787 | || strneq (str, "EXFUN", len) /* Used in glibc */ |
| 1782 | || strneq (str, "DEFVAR_", 7) /* Used in emacs */ | 1788 | || strneq (str, "DEFVAR_", 7) /* Used in emacs */ |
| 1783 | #endif | 1789 | #endif |
| 1784 | || strneq (str, "SYSCALL", 7) /* Used in glibc (mach) */ | 1790 | || strneq (str, "SYSCALL", len) /* Used in glibc (mach) */ |
| 1785 | || strneq (str, "ENTRY", 5) /* Used in glibc */ | 1791 | || strneq (str, "ENTRY", len) /* Used in glibc */ |
| 1786 | || strneq (str, "PSEUDO", 6)) /* Used in glibc */ | 1792 | || strneq (str, "PSEUDO", len)) /* Used in glibc */ |
| 1787 | 1793 | ||
| 1788 | { | 1794 | { |
| 1789 | next_token_is_func = TRUE; | 1795 | next_token_is_func = TRUE; |
| @@ -2376,6 +2382,14 @@ default_C_entries (inf) | |||
| 2376 | C_entries (cplusplus ? C_PLPL : 0, inf); | 2382 | C_entries (cplusplus ? C_PLPL : 0, inf); |
| 2377 | } | 2383 | } |
| 2378 | 2384 | ||
| 2385 | /* Always do plain ANSI C. */ | ||
| 2386 | void | ||
| 2387 | plain_C_entries (inf) | ||
| 2388 | FILE *inf; | ||
| 2389 | { | ||
| 2390 | C_entries (0, inf); | ||
| 2391 | } | ||
| 2392 | |||
| 2379 | /* Always do C++. */ | 2393 | /* Always do C++. */ |
| 2380 | void | 2394 | void |
| 2381 | Cplusplus_entries (inf) | 2395 | Cplusplus_entries (inf) |
| @@ -2410,9 +2424,9 @@ tail (cp) | |||
| 2410 | { | 2424 | { |
| 2411 | register int len = 0; | 2425 | register int len = 0; |
| 2412 | 2426 | ||
| 2413 | while (*cp && (*cp | ' ') == (dbp[len] | ' ')) | 2427 | while (*cp && lowcase(*cp) == lowcase(dbp[len])) |
| 2414 | cp++, len++; | 2428 | cp++, len++; |
| 2415 | if (*cp == 0) | 2429 | if (*cp == 0 && !intoken(dbp[len])) |
| 2416 | { | 2430 | { |
| 2417 | dbp += len; | 2431 | dbp += len; |
| 2418 | return TRUE; | 2432 | return TRUE; |
| @@ -2430,8 +2444,11 @@ takeprec () | |||
| 2430 | dbp++; | 2444 | dbp++; |
| 2431 | while (isspace (*dbp)) | 2445 | while (isspace (*dbp)) |
| 2432 | dbp++; | 2446 | dbp++; |
| 2433 | if (tail ("(*)")) | 2447 | if (strneq (dbp, "(*)", 3)) |
| 2434 | return; | 2448 | { |
| 2449 | dbp += 3; | ||
| 2450 | return; | ||
| 2451 | } | ||
| 2435 | if (!isdigit (*dbp)) | 2452 | if (!isdigit (*dbp)) |
| 2436 | { | 2453 | { |
| 2437 | --dbp; /* force failure */ | 2454 | --dbp; /* force failure */ |
| @@ -2494,7 +2511,7 @@ Fortran_functions (inf) | |||
| 2494 | dbp++; | 2511 | dbp++; |
| 2495 | if (*dbp == 0) | 2512 | if (*dbp == 0) |
| 2496 | continue; | 2513 | continue; |
| 2497 | switch (*dbp | ' ') | 2514 | switch (lowcase (*dbp)) |
| 2498 | { | 2515 | { |
| 2499 | case 'i': | 2516 | case 'i': |
| 2500 | if (tail ("integer")) | 2517 | if (tail ("integer")) |
| @@ -2529,7 +2546,7 @@ Fortran_functions (inf) | |||
| 2529 | dbp++; | 2546 | dbp++; |
| 2530 | if (*dbp == 0) | 2547 | if (*dbp == 0) |
| 2531 | continue; | 2548 | continue; |
| 2532 | switch (*dbp | ' ') | 2549 | switch (lowcase (*dbp)) |
| 2533 | { | 2550 | { |
| 2534 | case 'f': | 2551 | case 'f': |
| 2535 | if (tail ("function")) | 2552 | if (tail ("function")) |
| @@ -2762,7 +2779,7 @@ Pascal_functions (inf) | |||
| 2762 | else if (!incomment && !inquote && !found_tag) | 2779 | else if (!incomment && !inquote && !found_tag) |
| 2763 | { | 2780 | { |
| 2764 | /* check for proc/fn keywords */ | 2781 | /* check for proc/fn keywords */ |
| 2765 | switch (c | ' ') | 2782 | switch (lowcase (c)) |
| 2766 | { | 2783 | { |
| 2767 | case 'p': | 2784 | case 'p': |
| 2768 | if (tail ("rocedure")) /* c = 'p', dbp has advanced */ | 2785 | if (tail ("rocedure")) /* c = 'p', dbp has advanced */ |