# HG changeset patch # User Francesco Potort # Date 784981773 0 # Node ID e21b0674f37c198e200bfd53972ca1ababaafa15 # Parent 5cda62e4222a25c3c422ed09dcb57a3362d57626 * etags.c (): #include added. (etags_getcwd): Check return value from getcwd. diff -r 5cda62e4222a -r e21b0674f37c lib-src/etags.c --- a/lib-src/etags.c Wed Nov 16 06:17:13 1994 +0000 +++ b/lib-src/etags.c Wed Nov 16 10:29:33 1994 +0000 @@ -52,6 +52,10 @@ #include #include +#include +#ifndef errno +extern int errno; +#endif #include #include @@ -430,7 +434,7 @@ if (!CTAGS) typedefs = typedefs_and_cplusplus = constantypedefs = 1; - for (;;) + while (1) { int opt; opt = getopt_long (argc, argv, "aCdDf:o:StTi:BuvxwVH", longopts, 0); @@ -3194,25 +3198,28 @@ } #else /* not DOS_NT */ /* Does the same work as the system V getcwd, but does not need to - guess buffer size in advance. Included mostly for compatibility. */ + guess buffer size in advance. */ char * etags_getcwd () { - char *buf; int bufsize = 256; + char *buf = xnew (bufsize, char); #ifdef HAVE_GETCWD - do + while (getcwd (buf, bufsize / 2) == NULL) { + if (errno != ERANGE) + { + perror ("pwd"); + exit (BAD); + } + bufsize *= 2; buf = xnew (bufsize, char); - bufsize *= 2; } - while (getcwd (buf, bufsize / 2) == NULL); #else do { FILE *pipe; - buf = xnew (bufsize, char); pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); if (pipe == NULL) @@ -3228,6 +3235,7 @@ pclose (pipe); bufsize *= 2; + buf = xnew (bufsize, char); } while (buf[strlen (buf) - 1] != '\n'); #endif