comparison lib-src/etags.c @ 27661:c8b3e7e83e09

2000-02-10 Francesco Potorti` <pot@gnu.org> * etags.c (iswhite): Redefined not to consider '\0' as white space, and use it throughout in place of isspace, thus preventing a potential signed char to int conversion problem. (MSDOS): #undefine befere redefining 2000-02-04 Francesco Potorti` <F.Potorti@cnuce.cnr.it> * etags.c (many functions): Add prototypes.
author Francesco Potortì <pot@gnu.org>
date Thu, 10 Feb 2000 21:27:01 +0000
parents 5980f19581dc
children 994203eb3753
comparison
equal deleted inserted replaced
27660:c3cdb8d6d50d 27661:c8b3e7e83e09
29 * Regexp tags by Tom Tromey. 29 * Regexp tags by Tom Tromey.
30 * 30 *
31 * Francesco Potorti` (pot@gnu.org) is the current maintainer. 31 * Francesco Potorti` (pot@gnu.org) is the current maintainer.
32 */ 32 */
33 33
34 char pot_etags_version[] = "@(#) pot revision number is 13.38"; 34 char pot_etags_version[] = "@(#) pot revision number is 13.44";
35 35
36 #define TRUE 1 36 #define TRUE 1
37 #define FALSE 0 37 #define FALSE 0
38 38
39 #ifndef DEBUG 39 #ifndef DEBUG
40 # define DEBUG FALSE 40 # define DEBUG FALSE
41 #endif 41 #endif
42 42
43 #if defined (__STDC__) && __STDC__ 43 #if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C))
44 # define P_(proto) proto 44 # define P_(proto) proto
45 #else 45 #else
46 # define P_(proto) () 46 # define P_(proto) ()
47 #endif 47 #endif
48 48
58 #ifndef _GNU_SOURCE 58 #ifndef _GNU_SOURCE
59 # define _GNU_SOURCE 1 /* enables some compiler checks on GNU */ 59 # define _GNU_SOURCE 1 /* enables some compiler checks on GNU */
60 #endif 60 #endif
61 61
62 #ifdef MSDOS 62 #ifdef MSDOS
63 # undef MSDOS
63 # define MSDOS TRUE 64 # define MSDOS TRUE
64 # include <fcntl.h> 65 # include <fcntl.h>
65 # include <sys/param.h> 66 # include <sys/param.h>
66 # include <io.h> 67 # include <io.h>
67 # ifndef HAVE_CONFIG_H 68 # ifndef HAVE_CONFIG_H
98 99
99 #ifdef HAVE_UNISTD_H 100 #ifdef HAVE_UNISTD_H
100 # include <unistd.h> 101 # include <unistd.h>
101 #else 102 #else
102 # if defined (HAVE_GETCWD) && !WINDOWSNT 103 # if defined (HAVE_GETCWD) && !WINDOWSNT
103 extern char *getcwd (); 104 extern char *getcwd (char *buf, size_t size);
104 # endif 105 # endif
105 #endif /* HAVE_UNISTD_H */ 106 #endif /* HAVE_UNISTD_H */
106 107
107 #include <stdio.h> 108 #include <stdio.h>
108 #include <ctype.h> 109 #include <ctype.h>
187 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type))) 188 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
188 #endif 189 #endif
189 190
190 typedef int bool; 191 typedef int bool;
191 192
192 typedef void Lang_function (); 193 typedef void Lang_function P_((FILE *));
193 194
194 typedef struct 195 typedef struct
195 { 196 {
196 char *suffix; 197 char *suffix;
197 char *command; /* Takes one arg and decompresses to stdout */ 198 char *command; /* Takes one arg and decompresses to stdout */
232 } linebuffer; 233 } linebuffer;
233 234
234 /* Many compilers barf on this: 235 /* Many compilers barf on this:
235 Lang_function Ada_funcs; 236 Lang_function Ada_funcs;
236 so let's write it this way */ 237 so let's write it this way */
237 static void Ada_funcs P_((FILE *inf)); 238 static void Ada_funcs P_((FILE *));
238 static void Asm_labels P_((FILE *inf)); 239 static void Asm_labels P_((FILE *));
239 static void C_entries P_((int c_ext, FILE *inf)); 240 static void C_entries P_((int c_ext, FILE *));
240 static void default_C_entries P_((FILE *inf)); 241 static void default_C_entries P_((FILE *));
241 static void plain_C_entries P_((FILE *inf)); 242 static void plain_C_entries P_((FILE *));
242 static void Cjava_entries P_((FILE *inf)); 243 static void Cjava_entries P_((FILE *));
243 static void Cobol_paragraphs P_((FILE *inf)); 244 static void Cobol_paragraphs P_((FILE *));
244 static void Cplusplus_entries P_((FILE *inf)); 245 static void Cplusplus_entries P_((FILE *));
245 static void Cstar_entries P_((FILE *inf)); 246 static void Cstar_entries P_((FILE *));
246 static void Erlang_functions P_((FILE *inf)); 247 static void Erlang_functions P_((FILE *));
247 static void Fortran_functions P_((FILE *inf)); 248 static void Fortran_functions P_((FILE *));
248 static void Yacc_entries P_((FILE *inf)); 249 static void Yacc_entries P_((FILE *));
249 static void Lisp_functions P_((FILE *inf)); 250 static void Lisp_functions P_((FILE *));
250 static void Pascal_functions P_((FILE *inf)); 251 static void Pascal_functions P_((FILE *));
251 static void Perl_functions P_((FILE *inf)); 252 static void Perl_functions P_((FILE *));
252 static void Postscript_functions P_((FILE *inf)); 253 static void Postscript_functions P_((FILE *));
253 static void Prolog_functions P_((FILE *inf)); 254 static void Prolog_functions P_((FILE *));
254 static void Python_functions P_((FILE *inf)); 255 static void Python_functions P_((FILE *));
255 static void Scheme_functions P_((FILE *inf)); 256 static void Scheme_functions P_((FILE *));
256 static void TeX_functions P_((FILE *inf)); 257 static void TeX_functions P_((FILE *));
257 static void just_read_file P_((FILE *inf)); 258 static void just_read_file P_((FILE *));
258 259
259 static compressor *get_compressor_from_suffix P_((char *file, char **extptr)); 260 static void print_language_names P_((void));
260 static language *get_language_from_name P_((char *name)); 261 static void print_version P_((void));
261 static language *get_language_from_interpreter P_((char *interpreter)); 262 static void print_help P_((void));
262 static language *get_language_from_suffix P_((char *file)); 263 int main P_((int, char **));
263 static int total_size_of_entries P_((register node *np)); 264 static int number_len P_((long));
264 static long readline P_((linebuffer *lbp, FILE *stream)); 265
265 static long readline_internal P_((linebuffer *lbp, register FILE *stream)); 266 static compressor *get_compressor_from_suffix P_((char *, char **));
266 static void get_tag P_((register char *bp)); 267 static language *get_language_from_name P_((char *));
268 static language *get_language_from_interpreter P_((char *));
269 static language *get_language_from_suffix P_((char *));
270 static int total_size_of_entries P_((node *));
271 static long readline P_((linebuffer *, FILE *));
272 static long readline_internal P_((linebuffer *, FILE *));
273 static void get_tag P_((char *));
267 274
268 #ifdef ETAGS_REGEXPS 275 #ifdef ETAGS_REGEXPS
269 static void analyse_regex P_((char *regex_arg, bool ignore_case)); 276 static void analyse_regex P_((char *, bool));
270 static void add_regex P_((char *regexp_pattern, bool ignore_case, language *lan)); 277 static void add_regex P_((char *, bool, language *));
271 static void free_patterns P_((void)); 278 static void free_patterns P_((void));
272 #endif /* ETAGS_REGEXPS */ 279 #endif /* ETAGS_REGEXPS */
273 static void error P_((const char *s1, const char *s2)); 280 static void error P_((const char *, const char *));
274 static void suggest_asking_for_help P_((void)); 281 static void suggest_asking_for_help P_((void));
275 static void fatal P_((char *s1, char *s2)); 282 static void fatal P_((char *, char *));
276 static void pfatal P_((char *s1)); 283 static void pfatal P_((char *));
277 static void add_node P_((node *np, node **cur_node_p)); 284 static void add_node P_((node *, node **));
278 285
279 static void init P_((void)); 286 static void init P_((void));
280 static void initbuffer P_((linebuffer *lbp)); 287 static void initbuffer P_((linebuffer *));
281 static void find_entries P_((char *file, FILE *inf)); 288 static void find_entries P_((char *, FILE *));
282 static void free_tree P_((register node *np)); 289 static void free_tree P_((node *));
283 static void pfnote P_((char *name, bool is_func, char *linestart, 290 static void pfnote P_((char *, bool, char *, int, int, long));
284 int linelen, int lno, long int cno)); 291 static void new_pfnote P_((char *, int, bool, char *, int, int, long));
285 static void new_pfnote P_((char *name, int namelen, bool is_func, 292 static void process_file P_((char *));
286 char *linestart, int linelen, int lno, long int cno)); 293 static void put_entries P_((node *));
287 static void process_file P_((char *file));
288 static void put_entries P_((register node *np));
289 static void takeprec P_((void)); 294 static void takeprec P_((void));
290 295
291 static char *concat P_((char *s1, char *s2, char *s3)); 296 static char *concat P_((char *, char *, char *));
292 static char *skip_spaces P_((char *cp)); 297 static char *skip_spaces P_((char *));
293 static char *skip_non_spaces P_((char *cp)); 298 static char *skip_non_spaces P_((char *));
294 static char *savenstr P_((char *cp, int len)); 299 static char *savenstr P_((char *, int));
295 static char *savestr P_((char *cp)); 300 static char *savestr P_((char *));
296 static char *etags_strchr P_((const char *sp, int c)); 301 static char *etags_strchr P_((const char *, int));
297 static char *etags_strrchr P_((const char *sp, int c)); 302 static char *etags_strrchr P_((const char *, int));
298 static char *etags_getcwd P_((void)); 303 static char *etags_getcwd P_((void));
299 static char *relative_filename P_((char *file, char *dir)); 304 static char *relative_filename P_((char *, char *));
300 static char *absolute_filename P_((char *file, char *dir)); 305 static char *absolute_filename P_((char *, char *));
301 static char *absolute_dirname P_((char *file, char *dir)); 306 static char *absolute_dirname P_((char *, char *));
302 static bool filename_is_absolute P_((char *fn)); 307 static bool filename_is_absolute P_((char *f));
303 static void canonicalize_filename P_((register char *fn)); 308 static void canonicalize_filename P_((char *));
304 static void grow_linebuffer P_((linebuffer *lbp, int toksize)); 309 static void grow_linebuffer P_((linebuffer *, int));
305 static long *xmalloc P_((unsigned int size)); 310 static long *xmalloc P_((unsigned int));
306 static long *xrealloc P_((char *ptr, unsigned int size)); 311 static long *xrealloc P_((char *, unsigned int));
307 312
308 313
309 char searchar = '/'; /* use /.../ searches */ 314 char searchar = '/'; /* use /.../ searches */
310 315
311 char *tagfile; /* output file */ 316 char *tagfile; /* output file */
334 339
335 /* boolean "functions" (see init) */ 340 /* boolean "functions" (see init) */
336 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS]; 341 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
337 char 342 char
338 /* white chars */ 343 /* white chars */
339 *white = " \f\t\n\r", 344 *white = " \f\t\n\r\v",
340 /* not in a name */ 345 /* not in a name */
341 *nonam = " \f\t\n\r(=,[;", 346 *nonam = " \f\t\n\r(=,[;",
342 /* token ending chars */ 347 /* token ending chars */
343 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?", 348 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
344 /* token starting chars */ 349 /* token starting chars */
1471 1476
1472 for (i = 0; i < CHARS; i++) 1477 for (i = 0; i < CHARS; i++)
1473 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE; 1478 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
1474 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE; 1479 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
1475 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE; 1480 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
1481 notinname('\0') = notinname('\n');
1476 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE; 1482 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
1483 begtoken('\0') = begtoken('\n');
1477 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE; 1484 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
1485 intoken('\0') = intoken('\n');
1478 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE; 1486 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
1479 iswhite('\0') = iswhite('\n');
1480 notinname('\0') = notinname('\n');
1481 begtoken('\0') = begtoken('\n');
1482 intoken('\0') = intoken('\n');
1483 endtoken('\0') = endtoken('\n'); 1487 endtoken('\0') = endtoken('\n');
1484 } 1488 }
1485 1489
1486 /* 1490 /*
1487 * This routine opens the specified file and calls the function 1491 * This routine opens the specified file and calls the function
1890 st_C_ignore, 1894 st_C_ignore,
1891 st_C_javastruct, 1895 st_C_javastruct,
1892 st_C_operator, 1896 st_C_operator,
1893 st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec 1897 st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
1894 }; 1898 };
1899
1900 static unsigned int hash P_((const char *, unsigned int));
1901 static struct C_stab_entry * in_word_set P_((const char *, unsigned int));
1902 static enum sym_type C_symtype P_((char *, int, int));
1895 1903
1896 /* Feed stuff between (but not including) %[ and %] lines to: 1904 /* Feed stuff between (but not including) %[ and %] lines to:
1897 gperf -c -k 1,3 -o -p -r -t 1905 gperf -c -k 1,3 -o -p -r -t
1898 %[ 1906 %[
1899 struct C_stab_entry { char *name; int c_ext; enum sym_type type; } 1907 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
2252 /* 2260 /*
2253 * methodlen is the length of the method name stored in token_name. 2261 * methodlen is the length of the method name stored in token_name.
2254 */ 2262 */
2255 int methodlen; 2263 int methodlen;
2256 2264
2265 static bool consider_token P_((char *, int, int, int, int, int, bool *));
2266 static void make_C_tag P_((bool));
2267
2257 /* 2268 /*
2258 * consider_token () 2269 * consider_token ()
2259 * checks to see if the current token is at the start of a 2270 * checks to see if the current token is at the start of a
2260 * function or variable, or corresponds to a typedef, or 2271 * function or variable, or corresponds to a typedef, or
2261 * is a struct/union/enum tag, or #define, or an enum constant. 2272 * is a struct/union/enum tag, or #define, or an enum constant.
2274 2285
2275 static bool 2286 static bool
2276 consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var) 2287 consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var)
2277 register char *str; /* IN: token pointer */ 2288 register char *str; /* IN: token pointer */
2278 register int len; /* IN: token length */ 2289 register int len; /* IN: token length */
2279 register char c; /* IN: first char after the token */ 2290 register int c; /* IN: first char after the token */
2280 int c_ext; /* IN: C extensions mask */ 2291 int c_ext; /* IN: C extensions mask */
2281 int cblev; /* IN: curly brace level */ 2292 int cblev; /* IN: curly brace level */
2282 int parlev; /* IN: parenthesis level */ 2293 int parlev; /* IN: parenthesis level */
2283 bool *is_func_or_var; /* OUT: function or variable found */ 2294 bool *is_func_or_var; /* OUT: function or variable found */
2284 { 2295 {
2826 char *oldlp = lp; 2837 char *oldlp = lp;
2827 lp = skip_spaces (lp-1); 2838 lp = skip_spaces (lp-1);
2828 if (*lp != '\0') 2839 if (*lp != '\0')
2829 lp += 1; 2840 lp += 1;
2830 while (*lp != '\0' 2841 while (*lp != '\0'
2831 && !isspace (*lp) && *lp != '(') 2842 && !iswhite (*lp) && *lp != '(')
2832 lp += 1; 2843 lp += 1;
2833 c = *lp++; 2844 c = *lp++;
2834 toklen += lp - oldlp; 2845 toklen += lp - oldlp;
2835 } 2846 }
2836 tok.named = FALSE; 2847 tok.named = FALSE;
3352 continue; 3363 continue;
3353 } 3364 }
3354 3365
3355 /* Fortran parsing */ 3366 /* Fortran parsing */
3356 3367
3368 static bool tail P_((char *));
3369 static void takeprec P_((void));
3370 static void getit P_((FILE *));
3371
3357 static bool 3372 static bool
3358 tail (cp) 3373 tail (cp)
3359 char *cp; 3374 char *cp;
3360 { 3375 {
3361 register int len = 0; 3376 register int len = 0;
3495 3510
3496 /* 3511 /*
3497 * Philippe Waroquiers <philippe.waroquiers@eurocontrol.be>, 1998-04-24 3512 * Philippe Waroquiers <philippe.waroquiers@eurocontrol.be>, 1998-04-24
3498 * Ada parsing 3513 * Ada parsing
3499 */ 3514 */
3515
3516 static void adagetit P_((FILE *, char *));
3517
3500 /* Once we are positioned after an "interesting" keyword, let's get 3518 /* Once we are positioned after an "interesting" keyword, let's get
3501 the real tag value necessary. */ 3519 the real tag value necessary. */
3502 static void 3520 static void
3503 adagetit (inf, name_qualifier) 3521 adagetit (inf, name_qualifier)
3504 FILE *inf; 3522 FILE *inf;
3677 { 3695 {
3678 /* Read past label. */ 3696 /* Read past label. */
3679 cp++; 3697 cp++;
3680 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$') 3698 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
3681 cp++; 3699 cp++;
3682 if (*cp == ':' || isspace (*cp)) 3700 if (*cp == ':' || iswhite (*cp))
3683 { 3701 {
3684 /* Found end of label, so copy it and add it to the table. */ 3702 /* Found end of label, so copy it and add it to the table. */
3685 pfnote (savenstr(lb.buffer, cp-lb.buffer), TRUE, 3703 pfnote (savenstr(lb.buffer, cp-lb.buffer), TRUE,
3686 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 3704 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3687 } 3705 }
3703 3721
3704 LOOP_ON_INPUT_LINES (inf, lb, cp) 3722 LOOP_ON_INPUT_LINES (inf, lb, cp)
3705 { 3723 {
3706 if (*cp++ == 's' 3724 if (*cp++ == 's'
3707 && *cp++ == 'u' 3725 && *cp++ == 'u'
3708 && *cp++ == 'b' && isspace (*cp++)) 3726 && *cp++ == 'b' && iswhite (*cp++))
3709 { 3727 {
3710 cp = skip_spaces (cp); 3728 cp = skip_spaces (cp);
3711 if (*cp != '\0') 3729 if (*cp != '\0')
3712 { 3730 {
3713 char *sp = cp; 3731 char *sp = cp;
3714 while (*cp != '\0' 3732 while (*cp != '\0'
3715 && !isspace (*cp) && *cp != '{' && *cp != '(') 3733 && !iswhite (*cp) && *cp != '{' && *cp != '(')
3716 cp++; 3734 cp++;
3717 pfnote (savenstr (sp, cp-sp), TRUE, 3735 pfnote (savenstr (sp, cp-sp), TRUE,
3718 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 3736 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3719 } 3737 }
3720 } 3738 }
3726 *cp++ == 'l' 3744 *cp++ == 'l'
3727 && *cp++ == 'o' 3745 && *cp++ == 'o'
3728 && *cp++ == 'c' 3746 && *cp++ == 'c'
3729 && *cp++ == 'a' 3747 && *cp++ == 'a'
3730 && *cp++ == 'l')) 3748 && *cp++ == 'l'))
3731 && (*cp == '(' || isspace (*cp))) 3749 && (*cp == '(' || iswhite (*cp)))
3732 { 3750 {
3733 /* After "my" or "local", but before any following paren or space. */ 3751 /* After "my" or "local", but before any following paren or space. */
3734 char *varname = NULL; 3752 char *varname = NULL;
3735 3753
3736 cp = skip_spaces (cp); 3754 cp = skip_spaces (cp);
3769 3787
3770 LOOP_ON_INPUT_LINES (inf, lb, cp) 3788 LOOP_ON_INPUT_LINES (inf, lb, cp)
3771 { 3789 {
3772 if (*cp++ == 'd' 3790 if (*cp++ == 'd'
3773 && *cp++ == 'e' 3791 && *cp++ == 'e'
3774 && *cp++ == 'f' && isspace (*cp++)) 3792 && *cp++ == 'f' && iswhite (*cp++))
3775 { 3793 {
3776 cp = skip_spaces (cp); 3794 cp = skip_spaces (cp);
3777 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':') 3795 while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
3778 cp++; 3796 cp++;
3779 pfnote (NULL, TRUE, 3797 pfnote (NULL, TRUE,
3780 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 3798 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3781 } 3799 }
3782 3800
3783 cp = lb.buffer; 3801 cp = lb.buffer;
3784 if (*cp++ == 'c' 3802 if (*cp++ == 'c'
3785 && *cp++ == 'l' 3803 && *cp++ == 'l'
3786 && *cp++ == 'a' 3804 && *cp++ == 'a'
3787 && *cp++ == 's' 3805 && *cp++ == 's'
3788 && *cp++ == 's' && isspace (*cp++)) 3806 && *cp++ == 's' && iswhite (*cp++))
3789 { 3807 {
3790 cp = skip_spaces (cp); 3808 cp = skip_spaces (cp);
3791 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':') 3809 while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
3792 cp++; 3810 cp++;
3793 pfnote (NULL, TRUE, 3811 pfnote (NULL, TRUE,
3794 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 3812 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3795 } 3813 }
3796 } 3814 }
4009 4027
4010 /* 4028 /*
4011 * lisp tag functions 4029 * lisp tag functions
4012 * look for (def or (DEF, quote or QUOTE 4030 * look for (def or (DEF, quote or QUOTE
4013 */ 4031 */
4032
4033 static int L_isdef P_((char *));
4034 static int L_isquote P_((char *));
4035 static void L_getit P_((void));
4036
4014 static int 4037 static int
4015 L_isdef (strp) 4038 L_isdef (strp)
4016 register char *strp; 4039 register char *strp;
4017 { 4040 {
4018 return ((strp[1] == 'd' || strp[1] == 'D') 4041 return ((strp[1] == 'd' || strp[1] == 'D')
4027 return ((*++strp == 'q' || *strp == 'Q') 4050 return ((*++strp == 'q' || *strp == 'Q')
4028 && (*++strp == 'u' || *strp == 'U') 4051 && (*++strp == 'u' || *strp == 'U')
4029 && (*++strp == 'o' || *strp == 'O') 4052 && (*++strp == 'o' || *strp == 'O')
4030 && (*++strp == 't' || *strp == 'T') 4053 && (*++strp == 't' || *strp == 'T')
4031 && (*++strp == 'e' || *strp == 'E') 4054 && (*++strp == 'e' || *strp == 'E')
4032 && isspace (*++strp)); 4055 && iswhite (*++strp));
4033 } 4056 }
4034 4057
4035 static void 4058 static void
4036 L_getit () 4059 L_getit ()
4037 { 4060 {
4047 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */ 4070 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */
4048 dbp = skip_spaces (dbp); 4071 dbp = skip_spaces (dbp);
4049 } 4072 }
4050 4073
4051 for (cp = dbp /*+1*/; 4074 for (cp = dbp /*+1*/;
4052 *cp != '\0' && *cp != '(' && !isspace(*cp) && *cp != ')'; 4075 *cp != '\0' && *cp != '(' && !iswhite(*cp) && *cp != ')';
4053 cp++) 4076 cp++)
4054 continue; 4077 continue;
4055 if (cp == dbp) 4078 if (cp == dbp)
4056 return; 4079 return;
4057 4080
4076 else 4099 else
4077 { 4100 {
4078 /* Check for (foo::defmumble name-defined ... */ 4101 /* Check for (foo::defmumble name-defined ... */
4079 do 4102 do
4080 dbp++; 4103 dbp++;
4081 while (*dbp != '\0' && !isspace (*dbp) 4104 while (*dbp != '\0' && !iswhite (*dbp)
4082 && *dbp != ':' && *dbp != '(' && *dbp != ')'); 4105 && *dbp != ':' && *dbp != '(' && *dbp != ')');
4083 if (*dbp == ':') 4106 if (*dbp == ':')
4084 { 4107 {
4085 do 4108 do
4086 dbp++; 4109 dbp++;
4153 && (bp[2] == 'E' || bp[2] == 'e') 4176 && (bp[2] == 'E' || bp[2] == 'e')
4154 && (bp[3] == 'F' || bp[3] == 'f')) 4177 && (bp[3] == 'F' || bp[3] == 'f'))
4155 { 4178 {
4156 bp = skip_non_spaces (bp); 4179 bp = skip_non_spaces (bp);
4157 /* Skip over open parens and white space */ 4180 /* Skip over open parens and white space */
4158 while (isspace (*bp) || *bp == '(') 4181 while (iswhite (*bp) || *bp == '(')
4159 bp++; 4182 bp++;
4160 get_tag (bp); 4183 get_tag (bp);
4161 } 4184 }
4162 if (bp[0] == '(' 4185 if (bp[0] == '('
4163 && (bp[1] == 'S' || bp[1] == 's') 4186 && (bp[1] == 'S' || bp[1] == 's')
4164 && (bp[2] == 'E' || bp[2] == 'e') 4187 && (bp[2] == 'E' || bp[2] == 'e')
4165 && (bp[3] == 'T' || bp[3] == 't') 4188 && (bp[3] == 'T' || bp[3] == 't')
4166 && (bp[4] == '!' || bp[4] == '!') 4189 && (bp[4] == '!' || bp[4] == '!')
4167 && (isspace (bp[5]))) 4190 && (iswhite (bp[5])))
4168 { 4191 {
4169 bp = skip_non_spaces (bp); 4192 bp = skip_non_spaces (bp);
4170 bp = skip_spaces (bp); 4193 bp = skip_spaces (bp);
4171 get_tag (bp); 4194 get_tag (bp);
4172 } 4195 }
4191 4214
4192 char *TEX_defenv = "\ 4215 char *TEX_defenv = "\
4193 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\ 4216 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
4194 :part:appendix:entry:index"; 4217 :part:appendix:entry:index";
4195 4218
4196 static void TEX_mode P_((FILE *inf)); 4219 static void TEX_mode P_((FILE *));
4197 static struct TEX_tabent *TEX_decode_env P_((char *evarname, char *defenv)); 4220 static struct TEX_tabent *TEX_decode_env P_((char *, char *));
4198 static int TEX_Token P_((char *cp)); 4221 static int TEX_Token P_((char *));
4199 4222
4200 char TEX_esc = '\\'; 4223 char TEX_esc = '\\';
4201 char TEX_opgrp = '{'; 4224 char TEX_opgrp = '{';
4202 char TEX_clgrp = '}'; 4225 char TEX_clgrp = '}';
4203 4226
4359 * Prolog support (rewritten) by Anders Lindgren, Mar. 96 4382 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
4360 * 4383 *
4361 * Assumes that the predicate starts at column 0. 4384 * Assumes that the predicate starts at column 0.
4362 * Only the first clause of a predicate is added. 4385 * Only the first clause of a predicate is added.
4363 */ 4386 */
4364 static int prolog_pred P_((char *s, char *last)); 4387 static int prolog_pred P_((char *, char *));
4365 static void prolog_skip_comment P_((linebuffer *plb, FILE *inf)); 4388 static void prolog_skip_comment P_((linebuffer *, FILE *));
4366 static int prolog_atom P_((char *s, int pos)); 4389 static int prolog_atom P_((char *, int));
4367 4390
4368 static void 4391 static void
4369 Prolog_functions (inf) 4392 Prolog_functions (inf)
4370 FILE *inf; 4393 FILE *inf;
4371 { 4394 {
4379 4402
4380 LOOP_ON_INPUT_LINES (inf, lb, cp) 4403 LOOP_ON_INPUT_LINES (inf, lb, cp)
4381 { 4404 {
4382 if (cp[0] == '\0') /* Empty line */ 4405 if (cp[0] == '\0') /* Empty line */
4383 continue; 4406 continue;
4384 else if (isspace (cp[0])) /* Not a predicate */ 4407 else if (iswhite (cp[0])) /* Not a predicate */
4385 continue; 4408 continue;
4386 else if (cp[0] == '/' && cp[1] == '*') /* comment. */ 4409 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
4387 prolog_skip_comment (&lb, inf); 4410 prolog_skip_comment (&lb, inf);
4388 else if ((len = prolog_pred (cp, last)) > 0) 4411 else if ((len = prolog_pred (cp, last)) > 0)
4389 { 4412 {
4525 * 4548 *
4526 * Generates tags for functions, defines, and records. 4549 * Generates tags for functions, defines, and records.
4527 * 4550 *
4528 * Assumes that Erlang functions start at column 0. 4551 * Assumes that Erlang functions start at column 0.
4529 */ 4552 */
4530 static int erlang_func P_((char *s, char *last)); 4553 static int erlang_func P_((char *, char *));
4531 static void erlang_attribute P_((char *s)); 4554 static void erlang_attribute P_((char *));
4532 static int erlang_atom P_((char *s, int pos)); 4555 static int erlang_atom P_((char *, int));
4533 4556
4534 static void 4557 static void
4535 Erlang_functions (inf) 4558 Erlang_functions (inf)
4536 FILE *inf; 4559 FILE *inf;
4537 { 4560 {
4545 4568
4546 LOOP_ON_INPUT_LINES (inf, lb, cp) 4569 LOOP_ON_INPUT_LINES (inf, lb, cp)
4547 { 4570 {
4548 if (cp[0] == '\0') /* Empty line */ 4571 if (cp[0] == '\0') /* Empty line */
4549 continue; 4572 continue;
4550 else if (isspace (cp[0])) /* Not function nor attribute */ 4573 else if (iswhite (cp[0])) /* Not function nor attribute */
4551 continue; 4574 continue;
4552 else if (cp[0] == '%') /* comment */ 4575 else if (cp[0] == '%') /* comment */
4553 continue; 4576 continue;
4554 else if (cp[0] == '"') /* Sometimes, strings start in column one */ 4577 else if (cp[0] == '"') /* Sometimes, strings start in column one */
4555 continue; 4578 continue;
4697 return -1; 4720 return -1;
4698 } 4721 }
4699 4722
4700 #ifdef ETAGS_REGEXPS 4723 #ifdef ETAGS_REGEXPS
4701 4724
4725 static char *scan_separators P_((char *));
4726 static void analyse_regex P_((char *, bool));
4727 static void add_regex P_((char *, bool, language *));
4728 static char *substitute P_((char *, char *, struct re_registers *));
4729
4702 /* Take a string like "/blah/" and turn it into "blah", making sure 4730 /* Take a string like "/blah/" and turn it into "blah", making sure
4703 that the first and last characters are the same, and handling 4731 that the first and last characters are the same, and handling
4704 quoted separator characters. Actually, stops on the occurrence of 4732 quoted separator characters. Actually, stops on the occurrence of
4705 an unquoted separator. Also turns "\t" into a Tab character. 4733 an unquoted separator. Also turns "\t" into a Tab character.
4706 Returns pointer to terminating separator. Works in place. Null 4734 Returns pointer to terminating separator. Works in place. Null
4939 4967
4940 if (*bp == '\0') 4968 if (*bp == '\0')
4941 return; 4969 return;
4942 /* Go till you get to white space or a syntactic break */ 4970 /* Go till you get to white space or a syntactic break */
4943 for (cp = bp + 1; 4971 for (cp = bp + 1;
4944 *cp != '\0' && *cp != '(' && *cp != ')' && !isspace (*cp); 4972 *cp != '\0' && *cp != '(' && *cp != ')' && !iswhite (*cp);
4945 cp++) 4973 cp++)
4946 continue; 4974 continue;
4947 pfnote (savenstr (bp, cp-bp), TRUE, 4975 pfnote (savenstr (bp, cp-bp), TRUE,
4948 lb.buffer, cp - lb.buffer + 1, lineno, linecharno); 4976 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
4949 } 4977 }
5162 /* Skip spaces, return new pointer. */ 5190 /* Skip spaces, return new pointer. */
5163 static char * 5191 static char *
5164 skip_spaces (cp) 5192 skip_spaces (cp)
5165 char *cp; 5193 char *cp;
5166 { 5194 {
5167 while (isspace (*cp)) /* isspace('\0')==FALSE */ 5195 while (iswhite (*cp))
5168 cp++; 5196 cp++;
5169 return cp; 5197 return cp;
5170 } 5198 }
5171 5199
5172 /* Skip non spaces, return new pointer. */ 5200 /* Skip non spaces, return new pointer. */
5173 static char * 5201 static char *
5174 skip_non_spaces (cp) 5202 skip_non_spaces (cp)
5175 char *cp; 5203 char *cp;
5176 { 5204 {
5177 while (!iswhite (*cp)) /* iswhite('\0')==TRUE */ 5205 while (*cp != '\0' && !iswhite (*cp))
5178 cp++; 5206 cp++;
5179 return cp; 5207 return cp;
5180 } 5208 }
5181 5209
5182 /* Print error message and exit. */ 5210 /* Print error message and exit. */