diff options
| author | Karl Heuer | 1994-09-16 21:16:20 +0000 |
|---|---|---|
| committer | Karl Heuer | 1994-09-16 21:16:20 +0000 |
| commit | 5e9c82960a05c492b144bd1c06931748ecf4e0f3 (patch) | |
| tree | 65efee5382afeed25ba15a27109abbe4e15f91c0 /lib-src | |
| parent | 11ec70418c00f9455dfa199441e85388f66e0d10 (diff) | |
| download | emacs-5e9c82960a05c492b144bd1c06931748ecf4e0f3.tar.gz emacs-5e9c82960a05c492b144bd1c06931748ecf4e0f3.zip | |
(etags_getcwd): Use getcwd if available.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/etags.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib-src/etags.c b/lib-src/etags.c index e640fcdfeee..f4fea9ff1dd 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -3148,13 +3148,21 @@ etags_getcwd () | |||
| 3148 | char * | 3148 | char * |
| 3149 | etags_getcwd () | 3149 | etags_getcwd () |
| 3150 | { | 3150 | { |
| 3151 | FILE *pipe; | ||
| 3152 | char *buf; | 3151 | char *buf; |
| 3153 | int bufsize = 256; | 3152 | int bufsize = 256; |
| 3154 | 3153 | ||
| 3154 | #ifdef HAVE_GETCWD | ||
| 3155 | do | 3155 | do |
| 3156 | { | 3156 | { |
| 3157 | buf = xnew (bufsize, char); | 3157 | buf = xnew (bufsize, char); |
| 3158 | bufsize *= 2; | ||
| 3159 | } | ||
| 3160 | while (getcwd (buf, bufsize / 2) == NULL); | ||
| 3161 | #else | ||
| 3162 | do | ||
| 3163 | { | ||
| 3164 | FILE *pipe; | ||
| 3165 | buf = xnew (bufsize, char); | ||
| 3158 | 3166 | ||
| 3159 | pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); | 3167 | pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); |
| 3160 | if (pipe == NULL) | 3168 | if (pipe == NULL) |
| @@ -3172,6 +3180,7 @@ etags_getcwd () | |||
| 3172 | bufsize *= 2; | 3180 | bufsize *= 2; |
| 3173 | 3181 | ||
| 3174 | } while (buf[strlen (buf) - 1] != '\n'); | 3182 | } while (buf[strlen (buf) - 1] != '\n'); |
| 3183 | #endif | ||
| 3175 | 3184 | ||
| 3176 | buf[strlen (buf) - 1] = '\0'; | 3185 | buf[strlen (buf) - 1] = '\0'; |
| 3177 | return buf; | 3186 | return buf; |