comparison lib-src/etags.c @ 71783:b442d7e84235

(absolute_filename): Free unused space (cosmetic change). (in_word_set): In C, also tag #undef symbols.
author Francesco Potortì <pot@gnu.org>
date Tue, 11 Jul 2006 11:00:44 +0000
parents f483d24dc1dd
children 15be100e5afb 8a8e69664178
comparison
equal deleted inserted replaced
71782:3a9abf492909 71783:b442d7e84235
39 * If you want to add support for a new language, start by looking at the LUA 39 * If you want to add support for a new language, start by looking at the LUA
40 * language, which is the simplest. Alternatively, consider shipping a 40 * language, which is the simplest. Alternatively, consider shipping a
41 * configuration file containing regexp definitions for etags. 41 * configuration file containing regexp definitions for etags.
42 */ 42 */
43 43
44 char pot_etags_version[] = "@(#) pot revision number is 17.17"; 44 char pot_etags_version[] = "@(#) pot revision number is 17.18";
45 45
46 #define TRUE 1 46 #define TRUE 1
47 #define FALSE 0 47 #define FALSE 0
48 48
49 #ifdef DEBUG 49 #ifdef DEBUG
2455 struct, 0, st_C_struct 2455 struct, 0, st_C_struct
2456 extern, 0, st_C_extern 2456 extern, 0, st_C_extern
2457 enum, 0, st_C_enum 2457 enum, 0, st_C_enum
2458 typedef, 0, st_C_typedef 2458 typedef, 0, st_C_typedef
2459 define, 0, st_C_define 2459 define, 0, st_C_define
2460 undef, 0, st_C_define
2460 operator, C_PLPL, st_C_operator 2461 operator, C_PLPL, st_C_operator
2461 template, 0, st_C_template 2462 template, 0, st_C_template
2462 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach). 2463 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
2463 DEFUN, 0, st_C_gnumacro 2464 DEFUN, 0, st_C_gnumacro
2464 SYSCALL, 0, st_C_gnumacro 2465 SYSCALL, 0, st_C_gnumacro
2473 - remove the #if characterset check 2474 - remove the #if characterset check
2474 - make in_word_set static and not inline. */ 2475 - make in_word_set static and not inline. */
2475 /*%<*/ 2476 /*%<*/
2476 /* C code produced by gperf version 3.0.1 */ 2477 /* C code produced by gperf version 3.0.1 */
2477 /* Command-line: gperf -m 5 */ 2478 /* Command-line: gperf -m 5 */
2478 /* Computed positions: -k'1-2' */ 2479 /* Computed positions: -k'2-3' */
2479 2480
2480 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }; 2481 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
2481 /* maximum key range = 31, duplicates = 0 */ 2482 /* maximum key range = 33, duplicates = 0 */
2482 2483
2483 #ifdef __GNUC__ 2484 #ifdef __GNUC__
2484 __inline 2485 __inline
2485 #else 2486 #else
2486 #ifdef __cplusplus 2487 #ifdef __cplusplus
2492 register const char *str; 2493 register const char *str;
2493 register unsigned int len; 2494 register unsigned int len;
2494 { 2495 {
2495 static unsigned char asso_values[] = 2496 static unsigned char asso_values[] =
2496 { 2497 {
2497 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2498 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2498 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2499 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2499 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2500 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2500 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2501 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2501 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2502 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2502 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2503 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2503 34, 34, 34, 34, 1, 34, 34, 34, 14, 14, 2504 35, 35, 35, 35, 35, 35, 35, 35, 35, 15,
2504 34, 34, 34, 34, 34, 34, 34, 34, 13, 34, 2505 14, 35, 35, 35, 35, 35, 35, 35, 14, 35,
2505 13, 34, 34, 12, 34, 34, 34, 34, 34, 11, 2506 35, 35, 35, 12, 13, 35, 35, 35, 35, 12,
2506 34, 34, 34, 34, 34, 8, 34, 11, 34, 12, 2507 35, 35, 35, 35, 35, 1, 35, 16, 35, 6,
2507 11, 0, 1, 34, 7, 0, 34, 34, 11, 9, 2508 23, 0, 0, 35, 22, 0, 35, 35, 5, 0,
2508 0, 4, 0, 34, 7, 4, 14, 21, 34, 15, 2509 0, 15, 1, 35, 6, 35, 8, 19, 35, 16,
2509 0, 2, 34, 34, 34, 34, 34, 34, 34, 34, 2510 4, 5, 35, 35, 35, 35, 35, 35, 35, 35,
2510 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2511 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2511 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2512 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2512 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2513 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2513 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2514 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2514 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2515 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2515 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2516 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2516 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2517 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2517 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2518 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2518 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2519 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2519 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2520 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2520 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2521 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2521 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 2522 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2522 34, 34, 34, 34, 34, 34 2523 35, 35, 35, 35, 35, 35
2523 }; 2524 };
2524 return len + asso_values[(unsigned char)str[1]] + asso_values[(unsigned char)str[0]]; 2525 register int hval = len;
2526
2527 switch (hval)
2528 {
2529 default:
2530 hval += asso_values[(unsigned char)str[2]];
2531 /*FALLTHROUGH*/
2532 case 2:
2533 hval += asso_values[(unsigned char)str[1]];
2534 break;
2535 }
2536 return hval;
2525 } 2537 }
2526 2538
2527 static struct C_stab_entry * 2539 static struct C_stab_entry *
2528 in_word_set (str, len) 2540 in_word_set (str, len)
2529 register const char *str; 2541 register const char *str;
2530 register unsigned int len; 2542 register unsigned int len;
2531 { 2543 {
2532 enum 2544 enum
2533 { 2545 {
2534 TOTAL_KEYWORDS = 31, 2546 TOTAL_KEYWORDS = 32,
2535 MIN_WORD_LENGTH = 2, 2547 MIN_WORD_LENGTH = 2,
2536 MAX_WORD_LENGTH = 15, 2548 MAX_WORD_LENGTH = 15,
2537 MIN_HASH_VALUE = 3, 2549 MIN_HASH_VALUE = 2,
2538 MAX_HASH_VALUE = 33 2550 MAX_HASH_VALUE = 34
2539 }; 2551 };
2540 2552
2541 static struct C_stab_entry wordlist[] = 2553 static struct C_stab_entry wordlist[] =
2542 { 2554 {
2543 {""}, {""}, {""}, 2555 {""}, {""},
2544 {"if", 0, st_C_ignore}, 2556 {"if", 0, st_C_ignore},
2545 {"enum", 0, st_C_enum}, 2557 {""},
2546 {"@end", 0, st_C_objend}, 2558 {"@end", 0, st_C_objend},
2559 {"union", 0, st_C_struct},
2560 {"define", 0, st_C_define},
2561 {"import", (C_JAVA & !C_PLPL), st_C_ignore},
2562 {"template", 0, st_C_template},
2563 {"operator", C_PLPL, st_C_operator},
2564 {"@interface", 0, st_C_objprot},
2565 {"implements", (C_JAVA & !C_PLPL), st_C_javastruct},
2566 {"friend", C_PLPL, st_C_ignore},
2567 {"typedef", 0, st_C_typedef},
2568 {"return", 0, st_C_ignore},
2569 {"@implementation",0, st_C_objimpl},
2570 {"@protocol", 0, st_C_objprot},
2571 {"interface", (C_JAVA & !C_PLPL), st_C_struct},
2547 {"extern", 0, st_C_extern}, 2572 {"extern", 0, st_C_extern},
2548 {"extends", (C_JAVA & !C_PLPL), st_C_javastruct}, 2573 {"extends", (C_JAVA & !C_PLPL), st_C_javastruct},
2574 {"struct", 0, st_C_struct},
2575 {"domain", C_STAR, st_C_struct},
2576 {"switch", 0, st_C_ignore},
2577 {"enum", 0, st_C_enum},
2549 {"for", 0, st_C_ignore}, 2578 {"for", 0, st_C_ignore},
2550 {"interface", (C_JAVA & !C_PLPL), st_C_struct}, 2579 {"namespace", C_PLPL, st_C_struct},
2551 {"@protocol", 0, st_C_objprot}, 2580 {"class", 0, st_C_class},
2552 {"@interface", 0, st_C_objprot}, 2581 {"while", 0, st_C_ignore},
2553 {"operator", C_PLPL, st_C_operator}, 2582 {"undef", 0, st_C_define},
2554 {"return", 0, st_C_ignore},
2555 {"friend", C_PLPL, st_C_ignore},
2556 {"import", (C_JAVA & !C_PLPL), st_C_ignore},
2557 {"@implementation",0, st_C_objimpl},
2558 {"define", 0, st_C_define},
2559 {"package", (C_JAVA & !C_PLPL), st_C_ignore}, 2583 {"package", (C_JAVA & !C_PLPL), st_C_ignore},
2560 {"implements", (C_JAVA & !C_PLPL), st_C_javastruct},
2561 {"namespace", C_PLPL, st_C_struct},
2562 {"domain", C_STAR, st_C_struct},
2563 {"template", 0, st_C_template},
2564 {"typedef", 0, st_C_typedef},
2565 {"struct", 0, st_C_struct},
2566 {"switch", 0, st_C_ignore},
2567 {"union", 0, st_C_struct},
2568 {"while", 0, st_C_ignore},
2569 {"class", 0, st_C_class},
2570 {"__attribute__", 0, st_C_attribute}, 2584 {"__attribute__", 0, st_C_attribute},
2571 {"SYSCALL", 0, st_C_gnumacro}, 2585 {"SYSCALL", 0, st_C_gnumacro},
2586 {"ENTRY", 0, st_C_gnumacro},
2572 {"PSEUDO", 0, st_C_gnumacro}, 2587 {"PSEUDO", 0, st_C_gnumacro},
2573 {"ENTRY", 0, st_C_gnumacro},
2574 {"DEFUN", 0, st_C_gnumacro} 2588 {"DEFUN", 0, st_C_gnumacro}
2575 }; 2589 };
2576 2590
2577 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) 2591 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
2578 { 2592 {
6784 } 6798 }
6785 6799
6786 slashp = etags_strchr (slashp + 1, '/'); 6800 slashp = etags_strchr (slashp + 1, '/');
6787 } 6801 }
6788 6802
6789 if (res[0] == '\0') 6803 if (res[0] == '\0') /* just a safety net: should never happen */
6790 return savestr ("/"); 6804 {
6805 free (res);
6806 return savestr ("/");
6807 }
6791 else 6808 else
6792 return res; 6809 return res;
6793 } 6810 }
6794 6811
6795 /* Return a newly allocated string containing the absolute 6812 /* Return a newly allocated string containing the absolute