diff options
| author | Paul Eggert | 2012-11-21 13:06:52 -0800 |
|---|---|---|
| committer | Paul Eggert | 2012-11-21 13:06:52 -0800 |
| commit | 9239d970523919dfcf7437f728f4976b3a9467f3 (patch) | |
| tree | b9fd9fb6de02ad291a462a8387cb04d3972114e5 /src | |
| parent | 954bba56c62e4e0637a933cf21626a55b873e144 (diff) | |
| download | emacs-9239d970523919dfcf7437f728f4976b3a9467f3.tar.gz emacs-9239d970523919dfcf7437f728f4976b3a9467f3.zip | |
Assume POSIX 1003.1-1988 or later for unistd.h.
* admin/CPP-DEFINES (BROKEN_GETWD, HAVE_GETCWD, HAVE_GETWD, HAVE_SIZE_T)
(HAVE_UNISTD_H): Remove.
* configure.ac: Do not check for getcwd or getwd.
* lib-src/emacsclient.c (getcwd): Remove decl.
(get_current_dir_name): Assume getcwd exists.
* lib-src/etags.c (HAVE_GETCWD): Remove.
(getcwd): Remove decl.
(NO_LONG_OPTIONS): Remove this. All uses removed.
Emacs always has GNU getopt.
(etags_getcwd): Assume getcwd exists.
* lib-src/movemail.c (F_OK, X_OK, W_OK, R_OK): Remove.
* nt/config.nt (HAVE_GETCWD): Remove.
* src/alloc.c: Assume unistd.h exists.
* src/fileio.c (Fexpand_file_name) [DOS_NT]: Use getcwd, not getwd.
* src/sysdep.c (get_current_dir_name): Assume getcwd exists.
(getwd) [USG]: Remove; no longer needed.
(sys_subshell) [DOS_NT]: Use getcwd, not getwd.
* src/w32.c (getcwd): Rename from getwd, and switch to getcwd's API.
* src/w32.h (getcwd): Remove decl.
Fixes: debbugs:12945
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/alloc.c | 4 | ||||
| -rw-r--r-- | src/fileio.c | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 80 | ||||
| -rw-r--r-- | src/w32.c | 14 | ||||
| -rw-r--r-- | src/w32.h | 2 |
6 files changed, 28 insertions, 85 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b1a76bfdae0..9e9ae468044 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,14 @@ | |||
| 1 | 2012-11-21 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Assume POSIX 1003.1-1988 or later for unistd.h (Bug#12945). | ||
| 4 | * alloc.c: Assume unistd.h exists. | ||
| 5 | * fileio.c (Fexpand_file_name) [DOS_NT]: Use getcwd, not getwd. | ||
| 6 | * sysdep.c (get_current_dir_name): Assume getcwd exists. | ||
| 7 | (getwd) [USG]: Remove; no longer needed. | ||
| 8 | (sys_subshell) [DOS_NT]: Use getcwd, not getwd. | ||
| 9 | * w32.c (getcwd): Rename from getwd, and switch to getcwd's API. | ||
| 10 | * w32.h (getcwd): Remove decl. | ||
| 11 | |||
| 1 | 2012-11-21 Stefan Monnier <monnier@iro.umontreal.ca> | 12 | 2012-11-21 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 13 | ||
| 3 | * xdisp.c (fast_set_selected_frame): Rename from update_tool_bar_unwind. | 14 | * xdisp.c (fast_set_selected_frame): Rename from update_tool_bar_unwind. |
diff --git a/src/alloc.c b/src/alloc.c index 22e3db3cc77..46b2dde93a3 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -63,10 +63,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 63 | #endif | 63 | #endif |
| 64 | 64 | ||
| 65 | #include <unistd.h> | 65 | #include <unistd.h> |
| 66 | #ifndef HAVE_UNISTD_H | ||
| 67 | extern void *sbrk (); | ||
| 68 | #endif | ||
| 69 | |||
| 70 | #include <fcntl.h> | 66 | #include <fcntl.h> |
| 71 | 67 | ||
| 72 | #ifdef USE_GTK | 68 | #ifdef USE_GTK |
diff --git a/src/fileio.c b/src/fileio.c index e1a7cf55e28..442c66550d3 100644 --- a/src/fileio.c +++ b/src/fileio.c | |||
| @@ -1148,7 +1148,7 @@ filesystem tree, not (expand-file-name ".." dirname). */) | |||
| 1148 | newdir = "/"; | 1148 | newdir = "/"; |
| 1149 | } | 1149 | } |
| 1150 | else | 1150 | else |
| 1151 | getwd (adir); | 1151 | getcwd (adir, MAXPATHLEN + 1); |
| 1152 | newdir = adir; | 1152 | newdir = adir; |
| 1153 | } | 1153 | } |
| 1154 | 1154 | ||
diff --git a/src/sysdep.c b/src/sysdep.c index 7c5c144fa8c..3dd19685540 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -101,7 +101,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 101 | #define _P_WAIT 0 | 101 | #define _P_WAIT 0 |
| 102 | int _cdecl _spawnlp (int, const char *, const char *, ...); | 102 | int _cdecl _spawnlp (int, const char *, const char *, ...); |
| 103 | int _cdecl _getpid (void); | 103 | int _cdecl _getpid (void); |
| 104 | extern char *getwd (char *); | ||
| 105 | #endif | 104 | #endif |
| 106 | 105 | ||
| 107 | #include "syssignal.h" | 106 | #include "syssignal.h" |
| @@ -134,12 +133,12 @@ char* | |||
| 134 | get_current_dir_name (void) | 133 | get_current_dir_name (void) |
| 135 | { | 134 | { |
| 136 | char *buf; | 135 | char *buf; |
| 137 | char *pwd; | 136 | char *pwd = getenv ("PWD"); |
| 138 | struct stat dotstat, pwdstat; | 137 | struct stat dotstat, pwdstat; |
| 139 | /* If PWD is accurate, use it instead of calling getwd. PWD is | 138 | /* If PWD is accurate, use it instead of calling getcwd. PWD is |
| 140 | sometimes a nicer name, and using it may avoid a fatal error if a | 139 | sometimes a nicer name, and using it may avoid a fatal error if a |
| 141 | parent directory is searchable but not readable. */ | 140 | parent directory is searchable but not readable. */ |
| 142 | if ((pwd = getenv ("PWD")) != 0 | 141 | if (pwd |
| 143 | && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1]))) | 142 | && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1]))) |
| 144 | && stat (pwd, &pwdstat) == 0 | 143 | && stat (pwd, &pwdstat) == 0 |
| 145 | && stat (".", &dotstat) == 0 | 144 | && stat (".", &dotstat) == 0 |
| @@ -155,7 +154,6 @@ get_current_dir_name (void) | |||
| 155 | return NULL; | 154 | return NULL; |
| 156 | strcpy (buf, pwd); | 155 | strcpy (buf, pwd); |
| 157 | } | 156 | } |
| 158 | #ifdef HAVE_GETCWD | ||
| 159 | else | 157 | else |
| 160 | { | 158 | { |
| 161 | size_t buf_size = 1024; | 159 | size_t buf_size = 1024; |
| @@ -179,22 +177,6 @@ get_current_dir_name (void) | |||
| 179 | return NULL; | 177 | return NULL; |
| 180 | } | 178 | } |
| 181 | } | 179 | } |
| 182 | #else | ||
| 183 | else | ||
| 184 | { | ||
| 185 | /* We need MAXPATHLEN here. */ | ||
| 186 | buf = malloc (MAXPATHLEN + 1); | ||
| 187 | if (!buf) | ||
| 188 | return NULL; | ||
| 189 | if (getwd (buf) == NULL) | ||
| 190 | { | ||
| 191 | int tmp_errno = errno; | ||
| 192 | free (buf); | ||
| 193 | errno = tmp_errno; | ||
| 194 | return NULL; | ||
| 195 | } | ||
| 196 | } | ||
| 197 | #endif | ||
| 198 | return buf; | 180 | return buf; |
| 199 | } | 181 | } |
| 200 | #endif | 182 | #endif |
| @@ -521,7 +503,7 @@ sys_subshell (void) | |||
| 521 | const char *sh = 0; | 503 | const char *sh = 0; |
| 522 | 504 | ||
| 523 | #ifdef DOS_NT /* MW, Aug 1993 */ | 505 | #ifdef DOS_NT /* MW, Aug 1993 */ |
| 524 | getwd (oldwd); | 506 | getcwd (oldwd, sizeof oldwd); |
| 525 | if (sh == 0) | 507 | if (sh == 0) |
| 526 | sh = (char *) egetenv ("SUSPEND"); /* KFS, 1994-12-14 */ | 508 | sh = (char *) egetenv ("SUSPEND"); /* KFS, 1994-12-14 */ |
| 527 | #endif | 509 | #endif |
| @@ -2238,60 +2220,6 @@ emacs_readlink (char const *filename, char initial_buf[READLINK_BUFSIZE]) | |||
| 2238 | &emacs_norealloc_allocator, careadlinkatcwd); | 2220 | &emacs_norealloc_allocator, careadlinkatcwd); |
| 2239 | } | 2221 | } |
| 2240 | 2222 | ||
| 2241 | #ifdef USG | ||
| 2242 | /* | ||
| 2243 | * All of the following are for USG. | ||
| 2244 | * | ||
| 2245 | * On USG systems the system calls are INTERRUPTIBLE by signals | ||
| 2246 | * that the user program has elected to catch. Thus the system call | ||
| 2247 | * must be retried in these cases. To handle this without massive | ||
| 2248 | * changes in the source code, we remap the standard system call names | ||
| 2249 | * to names for our own functions in sysdep.c that do the system call | ||
| 2250 | * with retries. Actually, for portability reasons, it is good | ||
| 2251 | * programming practice, as this example shows, to limit all actual | ||
| 2252 | * system calls to a single occurrence in the source. Sure, this | ||
| 2253 | * adds an extra level of function call overhead but it is almost | ||
| 2254 | * always negligible. Fred Fish, Unisoft Systems Inc. | ||
| 2255 | */ | ||
| 2256 | |||
| 2257 | /* | ||
| 2258 | * Warning, this function may not duplicate 4.2 action properly | ||
| 2259 | * under error conditions. | ||
| 2260 | */ | ||
| 2261 | |||
| 2262 | #if !defined (HAVE_GETWD) || defined (BROKEN_GETWD) | ||
| 2263 | |||
| 2264 | #ifndef MAXPATHLEN | ||
| 2265 | /* In 4.1, param.h fails to define this. */ | ||
| 2266 | #define MAXPATHLEN 1024 | ||
| 2267 | #endif | ||
| 2268 | |||
| 2269 | char * | ||
| 2270 | getwd (char *pathname) | ||
| 2271 | { | ||
| 2272 | char *npath, *spath; | ||
| 2273 | extern char *getcwd (char *, size_t); | ||
| 2274 | |||
| 2275 | block_input (); /* getcwd uses malloc */ | ||
| 2276 | spath = npath = getcwd ((char *) 0, MAXPATHLEN); | ||
| 2277 | if (spath == 0) | ||
| 2278 | { | ||
| 2279 | unblock_input (); | ||
| 2280 | return spath; | ||
| 2281 | } | ||
| 2282 | /* On Altos 3068, getcwd can return @hostname/dir, so discard | ||
| 2283 | up to first slash. Should be harmless on other systems. */ | ||
| 2284 | while (*npath && *npath != '/') | ||
| 2285 | npath++; | ||
| 2286 | strcpy (pathname, npath); | ||
| 2287 | free (spath); /* getcwd uses malloc */ | ||
| 2288 | unblock_input (); | ||
| 2289 | return pathname; | ||
| 2290 | } | ||
| 2291 | |||
| 2292 | #endif /* !defined (HAVE_GETWD) || defined (BROKEN_GETWD) */ | ||
| 2293 | #endif /* USG */ | ||
| 2294 | |||
| 2295 | /* Directory routines for systems that don't have them. */ | 2223 | /* Directory routines for systems that don't have them. */ |
| 2296 | 2224 | ||
| 2297 | #ifdef HAVE_DIRENT_H | 2225 | #ifdef HAVE_DIRENT_H |
| @@ -908,8 +908,18 @@ static char startup_dir[MAXPATHLEN]; | |||
| 908 | 908 | ||
| 909 | /* Get the current working directory. */ | 909 | /* Get the current working directory. */ |
| 910 | char * | 910 | char * |
| 911 | getwd (char *dir) | 911 | getcwd (char *dir, size_t dirsize) |
| 912 | { | 912 | { |
| 913 | if (!dirsize) | ||
| 914 | { | ||
| 915 | errno = EINVAL; | ||
| 916 | return NULL; | ||
| 917 | } | ||
| 918 | if (dirsize <= strlen (startup_dir)) | ||
| 919 | { | ||
| 920 | errno = ERANGE; | ||
| 921 | return NULL; | ||
| 922 | } | ||
| 913 | #if 0 | 923 | #if 0 |
| 914 | if (GetCurrentDirectory (MAXPATHLEN, dir) > 0) | 924 | if (GetCurrentDirectory (MAXPATHLEN, dir) > 0) |
| 915 | return dir; | 925 | return dir; |
| @@ -1825,7 +1835,7 @@ init_environment (char ** argv) | |||
| 1825 | memcpy (*envp, "COMSPEC=", 8); | 1835 | memcpy (*envp, "COMSPEC=", 8); |
| 1826 | } | 1836 | } |
| 1827 | 1837 | ||
| 1828 | /* Remember the initial working directory for getwd. */ | 1838 | /* Remember the initial working directory for getcwd. */ |
| 1829 | /* FIXME: Do we need to resolve possible symlinks in startup_dir? | 1839 | /* FIXME: Do we need to resolve possible symlinks in startup_dir? |
| 1830 | Does it matter anywhere in Emacs? */ | 1840 | Does it matter anywhere in Emacs? */ |
| 1831 | if (!GetCurrentDirectory (MAXPATHLEN, startup_dir)) | 1841 | if (!GetCurrentDirectory (MAXPATHLEN, startup_dir)) |
| @@ -163,7 +163,6 @@ extern int sys_spawnve (int, char *, char **, char **); | |||
| 163 | extern void register_child (int, int); | 163 | extern void register_child (int, int); |
| 164 | 164 | ||
| 165 | extern void sys_sleep (int); | 165 | extern void sys_sleep (int); |
| 166 | extern char *getwd (char *); | ||
| 167 | extern int sys_link (const char *, const char *); | 166 | extern int sys_link (const char *, const char *); |
| 168 | 167 | ||
| 169 | 168 | ||
| @@ -181,4 +180,3 @@ extern ssize_t emacs_gnutls_push (gnutls_transport_ptr_t p, | |||
| 181 | #endif /* HAVE_GNUTLS */ | 180 | #endif /* HAVE_GNUTLS */ |
| 182 | 181 | ||
| 183 | #endif /* EMACS_W32_H */ | 182 | #endif /* EMACS_W32_H */ |
| 184 | |||