diff options
| author | Richard M. Stallman | 1992-08-20 05:09:30 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1992-08-20 05:09:30 +0000 |
| commit | 8a6c8bcf0bca0c7ec28dadaa05ae82b2b2365114 (patch) | |
| tree | bb5db1d11563544d4da0b68e4fe5559c358233cb /lib-src | |
| parent | 547075d4a051f472300b843daadfa90bffb3bc66 (diff) | |
| download | emacs-8a6c8bcf0bca0c7ec28dadaa05ae82b2b2365114.tar.gz emacs-8a6c8bcf0bca0c7ec28dadaa05ae82b2b2365114.zip | |
*** empty log message ***
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 77 |
1 files changed, 34 insertions, 43 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index 6cab322bf87..4921e3114cf 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -45,14 +45,11 @@ extern char *alloca (); | |||
| 45 | 45 | ||
| 46 | extern char *malloc (), *realloc (); | 46 | extern char *malloc (), *realloc (); |
| 47 | extern char *getenv (); | 47 | extern char *getenv (); |
| 48 | extern char *index (), *rindex (); | ||
| 49 | extern char *strcpy (), *strncpy (); | 48 | extern char *strcpy (), *strncpy (); |
| 50 | extern int strcmp (); | 49 | extern int strcmp (); |
| 51 | 50 | ||
| 52 | #ifdef hpux | 51 | char *etags_index (), *etags_rindex (); |
| 53 | #define NEED_INDEX 1 | 52 | char *savenstr (); |
| 54 | #define NEED_RINDEX 1 | ||
| 55 | #endif | ||
| 56 | 53 | ||
| 57 | /* Define the symbol ETAGS to make the program "etags", | 54 | /* Define the symbol ETAGS to make the program "etags", |
| 58 | which makes emacs-style tag tables by default. | 55 | which makes emacs-style tag tables by default. |
| @@ -873,7 +870,11 @@ process_file (file) | |||
| 873 | struct stat stat_buf; | 870 | struct stat stat_buf; |
| 874 | 871 | ||
| 875 | stat (file, &stat_buf); | 872 | stat (file, &stat_buf); |
| 876 | if (!(stat_buf.st_mode & S_IFREG) || !(stat_buf.st_mode & S_IFLNK)) | 873 | if (!(stat_buf.st_mode & S_IFREG) |
| 874 | #ifdef S_IFLNK | ||
| 875 | || !(stat_buf.st_mode & S_IFLNK) | ||
| 876 | #endif | ||
| 877 | ) | ||
| 877 | { | 878 | { |
| 878 | fprintf (stderr, "Skipping %s: it is not a regular file.\n", file); | 879 | fprintf (stderr, "Skipping %s: it is not a regular file.\n", file); |
| 879 | return; | 880 | return; |
| @@ -886,7 +887,7 @@ process_file (file) | |||
| 886 | } | 887 | } |
| 887 | if (emacs_tags_format) | 888 | if (emacs_tags_format) |
| 888 | { | 889 | { |
| 889 | char *cp = rindex (file, '/'); | 890 | char *cp = etags_rindex (file, '/'); |
| 890 | if (cp) | 891 | if (cp) |
| 891 | ++cp; | 892 | ++cp; |
| 892 | else | 893 | else |
| @@ -957,7 +958,7 @@ find_entries (file) | |||
| 957 | return; | 958 | return; |
| 958 | } | 959 | } |
| 959 | curfile = savestr (file); | 960 | curfile = savestr (file); |
| 960 | cp = rindex (file, '.'); | 961 | cp = etags_rindex (file, '.'); |
| 961 | 962 | ||
| 962 | header_file = (cp && (streq (cp + 1, "h"))); | 963 | header_file = (cp && (streq (cp + 1, "h"))); |
| 963 | 964 | ||
| @@ -1100,9 +1101,9 @@ pfnote (name, is_func, rewritten, linestart, linelen, lno, cno) | |||
| 1100 | /* If ctags mode, change name "main" to M<thisfilename>. */ | 1101 | /* If ctags mode, change name "main" to M<thisfilename>. */ |
| 1101 | if (!emacs_tags_format && !cxref_style && streq (name, "main")) | 1102 | if (!emacs_tags_format && !cxref_style && streq (name, "main")) |
| 1102 | { | 1103 | { |
| 1103 | fp = rindex (curfile, '/'); | 1104 | fp = etags_rindex (curfile, '/'); |
| 1104 | name = concat ("M", fp == 0 ? curfile : fp + 1, ""); | 1105 | name = concat ("M", fp == 0 ? curfile : fp + 1, ""); |
| 1105 | fp = rindex (name, '.'); | 1106 | fp = etags_rindex (name, '.'); |
| 1106 | if (fp && fp[1] != '\0' && fp[2] == '\0') | 1107 | if (fp && fp[1] != '\0' && fp[2] == '\0') |
| 1107 | *fp = 0; | 1108 | *fp = 0; |
| 1108 | rewritten = TRUE; | 1109 | rewritten = TRUE; |
| @@ -2031,6 +2032,10 @@ PF_funcs (fi) | |||
| 2031 | if (tail ("subroutine")) | 2032 | if (tail ("subroutine")) |
| 2032 | getit (); | 2033 | getit (); |
| 2033 | continue; | 2034 | continue; |
| 2035 | case 'e': | ||
| 2036 | if (tail ("entry")) | ||
| 2037 | getit (); | ||
| 2038 | continue; | ||
| 2034 | case 'p': | 2039 | case 'p': |
| 2035 | if (tail ("program")) | 2040 | if (tail ("program")) |
| 2036 | { | 2041 | { |
| @@ -2541,34 +2546,25 @@ TEX_funcs (fi) | |||
| 2541 | TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv); | 2546 | TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv); |
| 2542 | 2547 | ||
| 2543 | while (!feof (fi)) | 2548 | while (!feof (fi)) |
| 2544 | { | 2549 | { /* Scan each line in file */ |
| 2545 | lineno++; | 2550 | lineno++; |
| 2546 | linecharno = charno; | 2551 | linecharno = charno; |
| 2547 | charno += readline (&lb, fi); | 2552 | charno += readline (&lb, fi); |
| 2548 | dbp = lb.buffer; | 2553 | dbp = lb.buffer; |
| 2549 | lasthit = dbp; | 2554 | lasthit = dbp; |
| 2555 | while (dbp = etags_index (dbp, TEX_esc)) /* Look at each escape in line */ | ||
| 2556 | { | ||
| 2557 | register int i; | ||
| 2550 | 2558 | ||
| 2551 | while (!feof (fi)) | 2559 | if (!*(++dbp)) |
| 2552 | { /* Scan each line in file */ | 2560 | break; |
| 2553 | lineno++; | 2561 | linecharno += dbp - lasthit; |
| 2554 | linecharno = charno; | ||
| 2555 | charno += readline (&lb, fi); | ||
| 2556 | dbp = lb.buffer; | ||
| 2557 | lasthit = dbp; | 2562 | lasthit = dbp; |
| 2558 | while (dbp = index (dbp, TEX_esc)) /* Look at each escape in line */ | 2563 | i = TEX_Token (lasthit); |
| 2564 | if (0 <= i) | ||
| 2559 | { | 2565 | { |
| 2560 | register int i; | 2566 | TEX_getit (lasthit, TEX_toktab[i].len); |
| 2561 | 2567 | break; /* We only save a line once */ | |
| 2562 | if (!*(++dbp)) | ||
| 2563 | break; | ||
| 2564 | linecharno += dbp - lasthit; | ||
| 2565 | lasthit = dbp; | ||
| 2566 | i = TEX_Token (lasthit); | ||
| 2567 | if (0 <= i) | ||
| 2568 | { | ||
| 2569 | TEX_getit (lasthit, TEX_toktab[i].len); | ||
| 2570 | break; /* We only save a line once */ | ||
| 2571 | } | ||
| 2572 | } | 2568 | } |
| 2573 | } | 2569 | } |
| 2574 | } | 2570 | } |
| @@ -2621,7 +2617,6 @@ TEX_decode_env (evarname, defenv) | |||
| 2621 | char *defenv; | 2617 | char *defenv; |
| 2622 | { | 2618 | { |
| 2623 | register char *env, *p; | 2619 | register char *env, *p; |
| 2624 | extern char *savenstr (), *index (); | ||
| 2625 | 2620 | ||
| 2626 | struct TEX_tabent *tab; | 2621 | struct TEX_tabent *tab; |
| 2627 | int size, i; | 2622 | int size, i; |
| @@ -2635,15 +2630,16 @@ TEX_decode_env (evarname, defenv) | |||
| 2635 | 2630 | ||
| 2636 | /* Allocate a token table */ | 2631 | /* Allocate a token table */ |
| 2637 | for (size = 1, p = env; p;) | 2632 | for (size = 1, p = env; p;) |
| 2638 | if ((p = index (p, ':')) && *(++p)) | 2633 | if ((p = etags_index (p, ':')) && *(++p)) |
| 2639 | size++; | 2634 | size++; |
| 2640 | tab = xnew (size, struct TEX_tabent); | 2635 | /* Add 1 to leave room for null terminator. */ |
| 2636 | tab = xnew (size + 1, struct TEX_tabent); | ||
| 2641 | 2637 | ||
| 2642 | /* Unpack environment string into token table. Be careful about */ | 2638 | /* Unpack environment string into token table. Be careful about */ |
| 2643 | /* zero-length strings (leading ':', "::" and trailing ':') */ | 2639 | /* zero-length strings (leading ':', "::" and trailing ':') */ |
| 2644 | for (i = 0; *env;) | 2640 | for (i = 0; *env;) |
| 2645 | { | 2641 | { |
| 2646 | p = index (env, ':'); | 2642 | p = etags_index (env, ':'); |
| 2647 | if (!p) /* End of environment string. */ | 2643 | if (!p) /* End of environment string. */ |
| 2648 | p = env + strlen (env); | 2644 | p = env + strlen (env); |
| 2649 | if (p - env > 0) | 2645 | if (p - env > 0) |
| @@ -2690,7 +2686,7 @@ TEX_getit (name, len) | |||
| 2690 | } | 2686 | } |
| 2691 | 2687 | ||
| 2692 | /* If the text at CP matches one of the tag-defining TeX command names, | 2688 | /* If the text at CP matches one of the tag-defining TeX command names, |
| 2693 | return the index of that command in TEX_toktab. | 2689 | return the etags_index of that command in TEX_toktab. |
| 2694 | Otherwise return -1. */ | 2690 | Otherwise return -1. */ |
| 2695 | 2691 | ||
| 2696 | /* Keep the capital `T' in `Token' for dumb truncating compilers | 2692 | /* Keep the capital `T' in `Token' for dumb truncating compilers |
| @@ -2813,7 +2809,7 @@ substr (sub, s) | |||
| 2813 | char *sub; | 2809 | char *sub; |
| 2814 | char *s; | 2810 | char *s; |
| 2815 | { | 2811 | { |
| 2816 | while (*s && (s = index (s, *sub))) | 2812 | while (*s && (s = etags_index (s, *sub))) |
| 2817 | if (prestr (sub, s)) | 2813 | if (prestr (sub, s)) |
| 2818 | return (TRUE); | 2814 | return (TRUE); |
| 2819 | else | 2815 | else |
| @@ -2906,7 +2902,6 @@ savenstr (cp, len) | |||
| 2906 | return dp; | 2902 | return dp; |
| 2907 | } | 2903 | } |
| 2908 | 2904 | ||
| 2909 | #ifdef NEED_RINDEX | ||
| 2910 | /* | 2905 | /* |
| 2911 | * Return the ptr in sp at which the character c last | 2906 | * Return the ptr in sp at which the character c last |
| 2912 | * appears; NULL if not found | 2907 | * appears; NULL if not found |
| @@ -2915,7 +2910,7 @@ savenstr (cp, len) | |||
| 2915 | */ | 2910 | */ |
| 2916 | 2911 | ||
| 2917 | char * | 2912 | char * |
| 2918 | rindex (sp, c) | 2913 | etags_rindex (sp, c) |
| 2919 | register char *sp, c; | 2914 | register char *sp, c; |
| 2920 | { | 2915 | { |
| 2921 | register char *r; | 2916 | register char *r; |
| @@ -2928,10 +2923,8 @@ rindex (sp, c) | |||
| 2928 | } while (*sp++); | 2923 | } while (*sp++); |
| 2929 | return (r); | 2924 | return (r); |
| 2930 | } | 2925 | } |
| 2931 | #endif /* not NEED_RINDEX */ | ||
| 2932 | 2926 | ||
| 2933 | 2927 | ||
| 2934 | #ifdef NEED_INDEX | ||
| 2935 | /* | 2928 | /* |
| 2936 | * Return the ptr in sp at which the character c first | 2929 | * Return the ptr in sp at which the character c first |
| 2937 | * appears; NULL if not found | 2930 | * appears; NULL if not found |
| @@ -2940,7 +2933,7 @@ rindex (sp, c) | |||
| 2940 | */ | 2933 | */ |
| 2941 | 2934 | ||
| 2942 | char * | 2935 | char * |
| 2943 | index (sp, c) | 2936 | etags_index (sp, c) |
| 2944 | register char *sp, c; | 2937 | register char *sp, c; |
| 2945 | { | 2938 | { |
| 2946 | do | 2939 | do |
| @@ -2951,8 +2944,6 @@ index (sp, c) | |||
| 2951 | return (NULL); | 2944 | return (NULL); |
| 2952 | } | 2945 | } |
| 2953 | 2946 | ||
| 2954 | #endif /* not NEED_INDEX */ | ||
| 2955 | |||
| 2956 | /* Print error message and exit. */ | 2947 | /* Print error message and exit. */ |
| 2957 | 2948 | ||
| 2958 | /* VARARGS1 */ | 2949 | /* VARARGS1 */ |