diff options
| author | Francesco Potortì | 1994-11-16 10:29:33 +0000 |
|---|---|---|
| committer | Francesco Potortì | 1994-11-16 10:29:33 +0000 |
| commit | dcc89e637efb228219082f200788d9c36270f66b (patch) | |
| tree | a677e2bfcf05e26b60ca7580df501b0bfdd158b3 /lib-src | |
| parent | da2792e0e8661ef0c211a000c837222e08af0444 (diff) | |
| download | emacs-dcc89e637efb228219082f200788d9c36270f66b.tar.gz emacs-dcc89e637efb228219082f200788d9c36270f66b.zip | |
* etags.c (<errno.h>): #include added.
(etags_getcwd): Check return value from getcwd.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index 8a87f4a2f4d..58ad4ee373f 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -52,6 +52,10 @@ char pot_etags_version[] = "@(#) pot revision number is 10.32"; | |||
| 52 | 52 | ||
| 53 | #include <stdio.h> | 53 | #include <stdio.h> |
| 54 | #include <ctype.h> | 54 | #include <ctype.h> |
| 55 | #include <errno.h> | ||
| 56 | #ifndef errno | ||
| 57 | extern int errno; | ||
| 58 | #endif | ||
| 55 | #include <sys/types.h> | 59 | #include <sys/types.h> |
| 56 | #include <sys/stat.h> | 60 | #include <sys/stat.h> |
| 57 | 61 | ||
| @@ -430,7 +434,7 @@ main (argc, argv) | |||
| 430 | if (!CTAGS) | 434 | if (!CTAGS) |
| 431 | typedefs = typedefs_and_cplusplus = constantypedefs = 1; | 435 | typedefs = typedefs_and_cplusplus = constantypedefs = 1; |
| 432 | 436 | ||
| 433 | for (;;) | 437 | while (1) |
| 434 | { | 438 | { |
| 435 | int opt; | 439 | int opt; |
| 436 | opt = getopt_long (argc, argv, "aCdDf:o:StTi:BuvxwVH", longopts, 0); | 440 | opt = getopt_long (argc, argv, "aCdDf:o:StTi:BuvxwVH", longopts, 0); |
| @@ -3194,25 +3198,28 @@ etags_getcwd () | |||
| 3194 | } | 3198 | } |
| 3195 | #else /* not DOS_NT */ | 3199 | #else /* not DOS_NT */ |
| 3196 | /* Does the same work as the system V getcwd, but does not need to | 3200 | /* Does the same work as the system V getcwd, but does not need to |
| 3197 | guess buffer size in advance. Included mostly for compatibility. */ | 3201 | guess buffer size in advance. */ |
| 3198 | char * | 3202 | char * |
| 3199 | etags_getcwd () | 3203 | etags_getcwd () |
| 3200 | { | 3204 | { |
| 3201 | char *buf; | ||
| 3202 | int bufsize = 256; | 3205 | int bufsize = 256; |
| 3206 | char *buf = xnew (bufsize, char); | ||
| 3203 | 3207 | ||
| 3204 | #ifdef HAVE_GETCWD | 3208 | #ifdef HAVE_GETCWD |
| 3205 | do | 3209 | while (getcwd (buf, bufsize / 2) == NULL) |
| 3206 | { | 3210 | { |
| 3207 | buf = xnew (bufsize, char); | 3211 | if (errno != ERANGE) |
| 3212 | { | ||
| 3213 | perror ("pwd"); | ||
| 3214 | exit (BAD); | ||
| 3215 | } | ||
| 3208 | bufsize *= 2; | 3216 | bufsize *= 2; |
| 3217 | buf = xnew (bufsize, char); | ||
| 3209 | } | 3218 | } |
| 3210 | while (getcwd (buf, bufsize / 2) == NULL); | ||
| 3211 | #else | 3219 | #else |
| 3212 | do | 3220 | do |
| 3213 | { | 3221 | { |
| 3214 | FILE *pipe; | 3222 | FILE *pipe; |
| 3215 | buf = xnew (bufsize, char); | ||
| 3216 | 3223 | ||
| 3217 | pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); | 3224 | pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); |
| 3218 | if (pipe == NULL) | 3225 | if (pipe == NULL) |
| @@ -3228,6 +3235,7 @@ etags_getcwd () | |||
| 3228 | pclose (pipe); | 3235 | pclose (pipe); |
| 3229 | 3236 | ||
| 3230 | bufsize *= 2; | 3237 | bufsize *= 2; |
| 3238 | buf = xnew (bufsize, char); | ||
| 3231 | 3239 | ||
| 3232 | } while (buf[strlen (buf) - 1] != '\n'); | 3240 | } while (buf[strlen (buf) - 1] != '\n'); |
| 3233 | #endif | 3241 | #endif |