summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorFrancesco Potortì <pot@gnu.org>1994-11-16 10:29:33 +0000
committerFrancesco Potortì <pot@gnu.org>1994-11-16 10:29:33 +0000
commit7c08d70aa29abd4fed90dd676b1eb2a8a6031e5b (patch)
treeec83ed3710a0ac08843cd4cbf41d4c77de1ad3e5 /lib-src
parent899b847c4a52a572b5222725a6e5d648ff87536f (diff)
downloademacs-7c08d70aa29abd4fed90dd676b1eb2a8a6031e5b.tar.gz
* etags.c (<errno.h>): #include added.
(etags_getcwd): Check return value from getcwd.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/etags.c22
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";
#include <stdio.h>
#include <ctype.h>
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
#include <sys/types.h>
#include <sys/stat.h>
@@ -430,7 +434,7 @@ main (argc, argv)
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 @@ etags_getcwd ()
}
#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)
{
- buf = xnew (bufsize, char);
+ if (errno != ERANGE)
+ {
+ perror ("pwd");
+ exit (BAD);
+ }
bufsize *= 2;
+ buf = xnew (bufsize, char);
}
- 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 @@ etags_getcwd ()
pclose (pipe);
bufsize *= 2;
+ buf = xnew (bufsize, char);
} while (buf[strlen (buf) - 1] != '\n');
#endif