Mercurial > emacs
comparison lib-src/etags.c @ 15243:c024dca549c5
* etags.c (CNL_SAVE_DEFINEDEF): Set linecharno for use by readline.
(Pascal_functions): Increase linecharno by the correct number of
chars, inline the GET_NEW_LINE macro and delete its definition.
author | Francesco Potortì <pot@gnu.org> |
---|---|
date | Fri, 17 May 1996 16:48:02 +0000 |
parents | b470e33ce4a9 |
children | 32ab7b623b9b |
comparison
equal
deleted
inserted
replaced
15242:56c035c36875 | 15243:c024dca549c5 |
---|---|
29 * Regexp tags by Tom Tromey. | 29 * Regexp tags by Tom Tromey. |
30 * | 30 * |
31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer. | 31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer. |
32 */ | 32 */ |
33 | 33 |
34 char pot_etags_version[] = "@(#) pot revision number is 11.59"; | 34 char pot_etags_version[] = "@(#) pot revision number is 11.63"; |
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 |
214 | 214 |
215 char searchar = '/'; /* use /.../ searches */ | 215 char searchar = '/'; /* use /.../ searches */ |
216 | 216 |
217 int lineno; /* line number of current line */ | 217 int lineno; /* line number of current line */ |
218 long charno; /* current character number */ | 218 long charno; /* current character number */ |
219 | 219 long linecharno; /* charno of start of line */ |
220 long linecharno; /* charno of start of line; not used by C, | |
221 but by every other language. */ | |
222 | 220 |
223 char *curfile; /* current input file name */ | 221 char *curfile; /* current input file name */ |
224 char *tagfile; /* output file */ | 222 char *tagfile; /* output file */ |
225 char *progname; /* name this program was invoked with */ | 223 char *progname; /* name this program was invoked with */ |
226 char *cwd; /* current working directory */ | 224 char *cwd; /* current working directory */ |
878 if (streq (tagfile, "-")) | 876 if (streq (tagfile, "-")) |
879 { | 877 { |
880 tagf = stdout; | 878 tagf = stdout; |
881 #ifdef DOS_NT | 879 #ifdef DOS_NT |
882 /* Switch redirected `stdout' to binary mode (setting `_fmode' | 880 /* Switch redirected `stdout' to binary mode (setting `_fmode' |
883 doesn't take effect until after `stdout' is already open), */ | 881 doesn't take effect until after `stdout' is already open). */ |
884 if (!isatty (fileno (stdout))) | 882 if (!isatty (fileno (stdout))) |
885 setmode (fileno (stdout), O_BINARY); | 883 setmode (fileno (stdout), O_BINARY); |
886 #endif /* DOS_NT */ | 884 #endif /* DOS_NT */ |
887 } | 885 } |
888 else | 886 else |
1069 char *file; | 1067 char *file; |
1070 { | 1068 { |
1071 struct stat stat_buf; | 1069 struct stat stat_buf; |
1072 FILE *inf; | 1070 FILE *inf; |
1073 #ifdef DOS_NT | 1071 #ifdef DOS_NT |
1074 /* The rest of the program can't grok `\\'-style slashes. */ | 1072 char *p; |
1075 char *p = file; | 1073 |
1076 | 1074 for (p = file; *p != '\0'; p++) |
1077 while (*p) | 1075 if (*p == '\\') |
1078 { | 1076 *p = '/'; |
1079 if (*p == '\\') | |
1080 *p = '/'; | |
1081 ++p; | |
1082 } | |
1083 #endif | 1077 #endif |
1084 | 1078 |
1085 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode)) | 1079 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode)) |
1086 { | 1080 { |
1087 fprintf (stderr, "Skipping %s: it is not a regular file.\n", file); | 1081 fprintf (stderr, "Skipping %s: it is not a regular file.\n", file); |
2054 | 2048 |
2055 #define CNL_SAVE_DEFINEDEF \ | 2049 #define CNL_SAVE_DEFINEDEF \ |
2056 do { \ | 2050 do { \ |
2057 curlinepos = charno; \ | 2051 curlinepos = charno; \ |
2058 lineno++; \ | 2052 lineno++; \ |
2053 linecharno = charno; \ | |
2059 charno += readline (&curlb, inf); \ | 2054 charno += readline (&curlb, inf); \ |
2060 lp = curlb.buffer; \ | 2055 lp = curlb.buffer; \ |
2061 quotednl = FALSE; \ | 2056 quotednl = FALSE; \ |
2062 newndx = curndx; \ | 2057 newndx = curndx; \ |
2063 } while (0) | 2058 } while (0) |
2921 } | 2916 } |
2922 | 2917 |
2923 /* Added by Mosur Mohan, 4/22/88 */ | 2918 /* Added by Mosur Mohan, 4/22/88 */ |
2924 /* Pascal parsing */ | 2919 /* Pascal parsing */ |
2925 | 2920 |
2926 #define GET_NEW_LINE \ | |
2927 { \ | |
2928 linecharno = charno; lineno++; \ | |
2929 charno += 1 + readline (&lb, inf); \ | |
2930 dbp = lb.buffer; \ | |
2931 } | |
2932 | |
2933 /* | 2921 /* |
2934 * Locates tags for procedures & functions. Doesn't do any type- or | 2922 * Locates tags for procedures & functions. Doesn't do any type- or |
2935 * var-definitions. It does look for the keyword "extern" or | 2923 * var-definitions. It does look for the keyword "extern" or |
2936 * "forward" immediately following the procedure statement; if found, | 2924 * "forward" immediately following the procedure statement; if found, |
2937 * the tag is skipped. | 2925 * the tag is skipped. |
2974 while (!feof (inf)) | 2962 while (!feof (inf)) |
2975 { | 2963 { |
2976 c = *dbp++; | 2964 c = *dbp++; |
2977 if (c == '\0') /* if end of line */ | 2965 if (c == '\0') /* if end of line */ |
2978 { | 2966 { |
2979 GET_NEW_LINE; | 2967 lineno++; |
2968 linecharno = charno; | |
2969 charno += readline (&lb, inf); | |
2970 dbp = lb.buffer; | |
2980 if (*dbp == '\0') | 2971 if (*dbp == '\0') |
2981 continue; | 2972 continue; |
2982 if (!((found_tag && verify_tag) || | 2973 if (!((found_tag && verify_tag) || |
2983 get_tagname)) | 2974 get_tagname)) |
2984 c = *dbp++; /* only if don't need *dbp pointing | 2975 c = *dbp++; /* only if don't need *dbp pointing |
4316 { | 4307 { |
4317 #ifdef DOS_NT | 4308 #ifdef DOS_NT |
4318 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ | 4309 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ |
4319 | 4310 |
4320 getwd (path); | 4311 getwd (path); |
4321 p = path; | 4312 for (p = path; *p != '\0'; p++) |
4322 while (*p) | 4313 if (*p == '\\') |
4323 { | 4314 *p = '/'; |
4324 if (*p == '\\') | 4315 else |
4325 *p++ = '/'; | 4316 *p = lowcase (*p); |
4326 else | |
4327 *p++ = lowcase (*p); | |
4328 } | |
4329 | 4317 |
4330 return strdup (path); | 4318 return strdup (path); |
4331 #else /* not DOS_NT */ | 4319 #else /* not DOS_NT */ |
4332 #if HAVE_GETCWD | 4320 #if HAVE_GETCWD |
4333 int bufsize = 200; | 4321 int bufsize = 200; |
4469 char *file, *cwd; | 4457 char *file, *cwd; |
4470 { | 4458 { |
4471 char *slashp, *res; | 4459 char *slashp, *res; |
4472 char save; | 4460 char save; |
4473 #ifdef DOS_NT | 4461 #ifdef DOS_NT |
4474 char *p = file; | 4462 char *p; |
4475 | 4463 |
4476 while (*p) | 4464 for (p = file; *p != '\0'; p++) |
4477 { | 4465 if (*p == '\\') |
4478 if (*p == '\\') | 4466 *p = '/'; |
4479 *p = '/'; | |
4480 ++p; | |
4481 } | |
4482 #endif | 4467 #endif |
4483 | 4468 |
4484 slashp = etags_strrchr (file, '/'); | 4469 slashp = etags_strrchr (file, '/'); |
4485 if (slashp == NULL) | 4470 if (slashp == NULL) |
4486 return cwd; | 4471 return cwd; |