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 | |
| 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
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | admin/CPP-DEFINES | 5 | ||||
| -rw-r--r-- | admin/ChangeLog | 6 | ||||
| -rw-r--r-- | configure.ac | 10 | ||||
| -rw-r--r-- | lib-src/ChangeLog | 12 | ||||
| -rw-r--r-- | lib-src/emacsclient.c | 23 | ||||
| -rw-r--r-- | lib-src/etags.c | 68 | ||||
| -rw-r--r-- | lib-src/movemail.c | 7 | ||||
| -rw-r--r-- | nt/ChangeLog | 5 | ||||
| -rw-r--r-- | nt/config.nt | 6 | ||||
| -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 |
16 files changed, 67 insertions, 193 deletions
| @@ -1,3 +1,8 @@ | |||
| 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 | * configure.ac: Do not check for getcwd or getwd. | ||
| 5 | |||
| 1 | 2012-11-21 Glenn Morris <rgm@gnu.org> | 6 | 2012-11-21 Glenn Morris <rgm@gnu.org> |
| 2 | 7 | ||
| 3 | * configure.ac (--enable-profiling): Doc fix. | 8 | * configure.ac (--enable-profiling): Doc fix. |
diff --git a/admin/CPP-DEFINES b/admin/CPP-DEFINES index ae8673452a3..5c291944766 100644 --- a/admin/CPP-DEFINES +++ b/admin/CPP-DEFINES | |||
| @@ -86,7 +86,6 @@ anymore, so they can be removed. | |||
| 86 | AMPERSAND_FULL_NAME | 86 | AMPERSAND_FULL_NAME |
| 87 | BROKEN_DATAGRAM_SOCKETS | 87 | BROKEN_DATAGRAM_SOCKETS |
| 88 | BROKEN_FIONREAD | 88 | BROKEN_FIONREAD |
| 89 | BROKEN_GETWD | ||
| 90 | BROKEN_GET_CURRENT_DIR_NAME | 89 | BROKEN_GET_CURRENT_DIR_NAME |
| 91 | BROKEN_NON_BLOCKING_CONNECT | 90 | BROKEN_NON_BLOCKING_CONNECT |
| 92 | BROKEN_PTY_READ_AFTER_EAGAIN | 91 | BROKEN_PTY_READ_AFTER_EAGAIN |
| @@ -161,7 +160,6 @@ HAVE_FUTIMESAT | |||
| 161 | HAVE_GAI_STRERROR | 160 | HAVE_GAI_STRERROR |
| 162 | HAVE_GCONF | 161 | HAVE_GCONF |
| 163 | HAVE_GETADDRINFO | 162 | HAVE_GETADDRINFO |
| 164 | HAVE_GETCWD | ||
| 165 | HAVE_GETDELIM | 163 | HAVE_GETDELIM |
| 166 | HAVE_GETGRENT | 164 | HAVE_GETGRENT |
| 167 | HAVE_GETHOSTNAME | 165 | HAVE_GETHOSTNAME |
| @@ -178,7 +176,6 @@ HAVE_GETRLIMIT | |||
| 178 | HAVE_GETRUSAGE | 176 | HAVE_GETRUSAGE |
| 179 | HAVE_GETSOCKNAME | 177 | HAVE_GETSOCKNAME |
| 180 | HAVE_GETTIMEOFDAY | 178 | HAVE_GETTIMEOFDAY |
| 181 | HAVE_GETWD | ||
| 182 | HAVE_GET_CURRENT_DIR_NAME | 179 | HAVE_GET_CURRENT_DIR_NAME |
| 183 | HAVE_GHOSTSCRIPT | 180 | HAVE_GHOSTSCRIPT |
| 184 | HAVE_GIF | 181 | HAVE_GIF |
| @@ -304,7 +301,6 @@ HAVE_SIGNED_SIG_ATOMIC_T | |||
| 304 | HAVE_SIGNED_WCHAR_T | 301 | HAVE_SIGNED_WCHAR_T |
| 305 | HAVE_SIGNED_WINT_T | 302 | HAVE_SIGNED_WINT_T |
| 306 | HAVE_SIGSET_T | 303 | HAVE_SIGSET_T |
| 307 | HAVE_SIZE_T | ||
| 308 | HAVE_SNPRINTF | 304 | HAVE_SNPRINTF |
| 309 | HAVE_SOCKETS | 305 | HAVE_SOCKETS |
| 310 | HAVE_SOUND | 306 | HAVE_SOUND |
| @@ -369,7 +365,6 @@ HAVE_TM_ZONE | |||
| 369 | HAVE_TOUCHLOCK | 365 | HAVE_TOUCHLOCK |
| 370 | HAVE_TZNAME | 366 | HAVE_TZNAME |
| 371 | HAVE_TZSET | 367 | HAVE_TZSET |
| 372 | HAVE_UNISTD_H | ||
| 373 | HAVE_UNSIGNED_LONG_LONG_INT | 368 | HAVE_UNSIGNED_LONG_LONG_INT |
| 374 | HAVE_UTIL_H | 369 | HAVE_UTIL_H |
| 375 | HAVE_UTIMENSAT | 370 | HAVE_UTIMENSAT |
diff --git a/admin/ChangeLog b/admin/ChangeLog index 3d76f9dd2ba..b256a0f5dc4 100644 --- a/admin/ChangeLog +++ b/admin/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 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 | * CPP-DEFINES (BROKEN_GETWD, HAVE_GETCWD, HAVE_GETWD, HAVE_SIZE_T) | ||
| 5 | (HAVE_UNISTD_H): Remove. | ||
| 6 | |||
| 1 | 2012-11-17 Paul Eggert <eggert@cs.ucla.edu> | 7 | 2012-11-17 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 8 | ||
| 3 | Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881). | 9 | Assume POSIX 1003.1-1988 or later for fcntl.h (Bug#12881). |
diff --git a/configure.ac b/configure.ac index 343a9e7cfb5..25bf2b47cc9 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -2894,7 +2894,7 @@ AC_CHECK_FUNCS(gethostname \ | |||
| 2894 | closedir getrusage get_current_dir_name \ | 2894 | closedir getrusage get_current_dir_name \ |
| 2895 | lrand48 \ | 2895 | lrand48 \ |
| 2896 | select getpagesize setlocale \ | 2896 | select getpagesize setlocale \ |
| 2897 | utimes getrlimit setrlimit getcwd shutdown getaddrinfo \ | 2897 | utimes getrlimit setrlimit shutdown getaddrinfo \ |
| 2898 | strsignal setitimer \ | 2898 | strsignal setitimer \ |
| 2899 | sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ | 2899 | sendto recvfrom getsockname getpeername getifaddrs freeifaddrs \ |
| 2900 | gai_strerror mkstemp getline getdelim fsync sync \ | 2900 | gai_strerror mkstemp getline getdelim fsync sync \ |
| @@ -2903,14 +2903,6 @@ getpwent endpwent getgrent endgrent \ | |||
| 2903 | touchlock \ | 2903 | touchlock \ |
| 2904 | cfmakeraw cfsetspeed copysign __executable_start) | 2904 | cfmakeraw cfsetspeed copysign __executable_start) |
| 2905 | 2905 | ||
| 2906 | dnl getwd appears to be buggy on SVR4.2, so we don't use it. | ||
| 2907 | if test $opsys = unixware; then | ||
| 2908 | dnl In case some other test ends up checking for getwd. | ||
| 2909 | AC_DEFINE(BROKEN_GETWD, 1, [Define if getwd should not be used.]) | ||
| 2910 | else | ||
| 2911 | AC_CHECK_FUNCS(getwd) | ||
| 2912 | fi | ||
| 2913 | |||
| 2914 | ## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines | 2906 | ## Eric Backus <ericb@lsid.hp.com> says, HP-UX 9.x on HP 700 machines |
| 2915 | ## has a broken `rint' in some library versions including math library | 2907 | ## has a broken `rint' in some library versions including math library |
| 2916 | ## version number A.09.05. | 2908 | ## version number A.09.05. |
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 67035773977..8e835795e6a 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog | |||
| @@ -1,3 +1,15 @@ | |||
| 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 | * emacsclient.c (getcwd): Remove decl. | ||
| 5 | (get_current_dir_name): Assume getcwd exists. | ||
| 6 | * etags.c (HAVE_GETCWD): Remove. | ||
| 7 | (getcwd): Remove decl. | ||
| 8 | (NO_LONG_OPTIONS): Remove this. All uses removed. | ||
| 9 | Emacs always has GNU getopt. | ||
| 10 | (etags_getcwd): Assume getcwd exists. | ||
| 11 | * movemail.c (F_OK, X_OK, W_OK, R_OK): Remove. | ||
| 12 | |||
| 1 | 2012-11-20 Paul Eggert <eggert@cs.ucla.edu> | 13 | 2012-11-20 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 14 | ||
| 3 | * emacsclient.c (handle_sigcont, handle_sigtstp): Use raise (sig) | 15 | * emacsclient.c (handle_sigcont, handle_sigtstp): Use raise (sig) |
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 78079b5cf69..021ac6eb247 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c | |||
| @@ -88,10 +88,7 @@ char *w32_getenv (char *); | |||
| 88 | 88 | ||
| 89 | 89 | ||
| 90 | 90 | ||
| 91 | char *getenv (const char *), *getwd (char *); | 91 | char *getenv (const char *); |
| 92 | #ifdef HAVE_GETCWD | ||
| 93 | char *(getcwd) (char *, size_t); | ||
| 94 | #endif | ||
| 95 | 92 | ||
| 96 | #ifndef VERSION | 93 | #ifndef VERSION |
| 97 | #define VERSION "unspecified" | 94 | #define VERSION "unspecified" |
| @@ -223,7 +220,7 @@ get_current_dir_name (void) | |||
| 223 | char *buf; | 220 | char *buf; |
| 224 | const char *pwd; | 221 | const char *pwd; |
| 225 | struct stat dotstat, pwdstat; | 222 | struct stat dotstat, pwdstat; |
| 226 | /* If PWD is accurate, use it instead of calling getwd. PWD is | 223 | /* If PWD is accurate, use it instead of calling getcwd. PWD is |
| 227 | sometimes a nicer name, and using it may avoid a fatal error if a | 224 | sometimes a nicer name, and using it may avoid a fatal error if a |
| 228 | parent directory is searchable but not readable. */ | 225 | parent directory is searchable but not readable. */ |
| 229 | if ((pwd = egetenv ("PWD")) != 0 | 226 | if ((pwd = egetenv ("PWD")) != 0 |
| @@ -240,7 +237,6 @@ get_current_dir_name (void) | |||
| 240 | buf = (char *) xmalloc (strlen (pwd) + 1); | 237 | buf = (char *) xmalloc (strlen (pwd) + 1); |
| 241 | strcpy (buf, pwd); | 238 | strcpy (buf, pwd); |
| 242 | } | 239 | } |
| 243 | #ifdef HAVE_GETCWD | ||
| 244 | else | 240 | else |
| 245 | { | 241 | { |
| 246 | size_t buf_size = 1024; | 242 | size_t buf_size = 1024; |
| @@ -267,20 +263,6 @@ get_current_dir_name (void) | |||
| 267 | } | 263 | } |
| 268 | } | 264 | } |
| 269 | } | 265 | } |
| 270 | #else | ||
| 271 | else | ||
| 272 | { | ||
| 273 | /* We need MAXPATHLEN here. */ | ||
| 274 | buf = (char *) xmalloc (MAXPATHLEN + 1); | ||
| 275 | if (getwd (buf) == NULL) | ||
| 276 | { | ||
| 277 | int tmp_errno = errno; | ||
| 278 | free (buf); | ||
| 279 | errno = tmp_errno; | ||
| 280 | return NULL; | ||
| 281 | } | ||
| 282 | } | ||
| 283 | #endif | ||
| 284 | return buf; | 266 | return buf; |
| 285 | } | 267 | } |
| 286 | #endif | 268 | #endif |
| @@ -1592,7 +1574,6 @@ main (int argc, char **argv) | |||
| 1592 | cwd = get_current_dir_name (); | 1574 | cwd = get_current_dir_name (); |
| 1593 | if (cwd == 0) | 1575 | if (cwd == 0) |
| 1594 | { | 1576 | { |
| 1595 | /* getwd puts message in STRING if it fails. */ | ||
| 1596 | message (TRUE, "%s: %s\n", progname, | 1577 | message (TRUE, "%s: %s\n", progname, |
| 1597 | "Cannot get current working directory"); | 1578 | "Cannot get current working directory"); |
| 1598 | fail (); | 1579 | fail (); |
diff --git a/lib-src/etags.c b/lib-src/etags.c index ec415e9905f..b6af17b8edf 100644 --- a/lib-src/etags.c +++ b/lib-src/etags.c | |||
| @@ -123,19 +123,9 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; | |||
| 123 | # undef HAVE_NTGUI | 123 | # undef HAVE_NTGUI |
| 124 | # undef DOS_NT | 124 | # undef DOS_NT |
| 125 | # define DOS_NT | 125 | # define DOS_NT |
| 126 | # ifndef HAVE_GETCWD | 126 | #endif /* WINDOWSNT */ |
| 127 | # define HAVE_GETCWD | ||
| 128 | # endif /* undef HAVE_GETCWD */ | ||
| 129 | #else /* not WINDOWSNT */ | ||
| 130 | #endif /* !WINDOWSNT */ | ||
| 131 | 127 | ||
| 132 | #include <unistd.h> | 128 | #include <unistd.h> |
| 133 | #ifndef HAVE_UNISTD_H | ||
| 134 | # if defined (HAVE_GETCWD) && !defined (WINDOWSNT) | ||
| 135 | extern char *getcwd (char *buf, size_t size); | ||
| 136 | # endif | ||
| 137 | #endif /* HAVE_UNISTD_H */ | ||
| 138 | |||
| 139 | #include <stdarg.h> | 129 | #include <stdarg.h> |
| 140 | #include <stdlib.h> | 130 | #include <stdlib.h> |
| 141 | #include <string.h> | 131 | #include <string.h> |
| @@ -152,16 +142,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; | |||
| 152 | # define assert(x) ((void) 0) | 142 | # define assert(x) ((void) 0) |
| 153 | #endif | 143 | #endif |
| 154 | 144 | ||
| 155 | #ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */ | 145 | #include <getopt.h> |
| 156 | # define NO_LONG_OPTIONS TRUE | ||
| 157 | # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) | ||
| 158 | extern char *optarg; | ||
| 159 | extern int optind, opterr; | ||
| 160 | #else | ||
| 161 | # define NO_LONG_OPTIONS FALSE | ||
| 162 | # include <getopt.h> | ||
| 163 | #endif /* NO_LONG_OPTIONS */ | ||
| 164 | |||
| 165 | #include <regex.h> | 146 | #include <regex.h> |
| 166 | 147 | ||
| 167 | /* Define CTAGS to make the program "ctags" compatible with the usual one. | 148 | /* Define CTAGS to make the program "ctags" compatible with the usual one. |
| @@ -869,11 +850,7 @@ print_help (argument *argbuffer) | |||
| 869 | printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\ | 850 | printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\ |
| 870 | \n\ | 851 | \n\ |
| 871 | These are the options accepted by %s.\n", progname, progname); | 852 | These are the options accepted by %s.\n", progname, progname); |
| 872 | if (NO_LONG_OPTIONS) | 853 | puts ("You may use unambiguous abbreviations for the long option names."); |
| 873 | puts ("WARNING: long option names do not work with this executable,\n\ | ||
| 874 | as it is not linked with GNU getopt."); | ||
| 875 | else | ||
| 876 | puts ("You may use unambiguous abbreviations for the long option names."); | ||
| 877 | puts (" A - as file name means read names from stdin (one per line).\n\ | 854 | puts (" A - as file name means read names from stdin (one per line).\n\ |
| 878 | Absolute names are stored in the output file as they are.\n\ | 855 | Absolute names are stored in the output file as they are.\n\ |
| 879 | Relative ones are stored relative to the output file's directory.\n"); | 856 | Relative ones are stored relative to the output file's directory.\n"); |
| @@ -1065,9 +1042,9 @@ main (int argc, char **argv) | |||
| 1065 | 1042 | ||
| 1066 | /* When the optstring begins with a '-' getopt_long does not rearrange the | 1043 | /* When the optstring begins with a '-' getopt_long does not rearrange the |
| 1067 | non-options arguments to be at the end, but leaves them alone. */ | 1044 | non-options arguments to be at the end, but leaves them alone. */ |
| 1068 | optstring = concat (NO_LONG_OPTIONS ? "" : "-", | 1045 | optstring = concat ("-ac:Cf:Il:o:r:RSVhH", |
| 1069 | "ac:Cf:Il:o:r:RSVhH", | 1046 | (CTAGS) ? "BxdtTuvw" : "Di:", |
| 1070 | (CTAGS) ? "BxdtTuvw" : "Di:"); | 1047 | ""); |
| 1071 | 1048 | ||
| 1072 | while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) | 1049 | while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) |
| 1073 | switch (opt) | 1050 | switch (opt) |
| @@ -6333,8 +6310,8 @@ pfatal (const char *s1) | |||
| 6333 | static void | 6310 | static void |
| 6334 | suggest_asking_for_help (void) | 6311 | suggest_asking_for_help (void) |
| 6335 | { | 6312 | { |
| 6336 | fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n", | 6313 | fprintf (stderr, "\tTry `%s --help' for a complete list of options.\n", |
| 6337 | progname, NO_LONG_OPTIONS ? "-h" : "--help"); | 6314 | progname); |
| 6338 | exit (EXIT_FAILURE); | 6315 | exit (EXIT_FAILURE); |
| 6339 | } | 6316 | } |
| 6340 | 6317 | ||
| @@ -6372,7 +6349,6 @@ concat (const char *s1, const char *s2, const char *s3) | |||
| 6372 | static char * | 6349 | static char * |
| 6373 | etags_getcwd (void) | 6350 | etags_getcwd (void) |
| 6374 | { | 6351 | { |
| 6375 | #ifdef HAVE_GETCWD | ||
| 6376 | int bufsize = 200; | 6352 | int bufsize = 200; |
| 6377 | char *path = xnew (bufsize, char); | 6353 | char *path = xnew (bufsize, char); |
| 6378 | 6354 | ||
| @@ -6387,34 +6363,6 @@ etags_getcwd (void) | |||
| 6387 | 6363 | ||
| 6388 | canonicalize_filename (path); | 6364 | canonicalize_filename (path); |
| 6389 | return path; | 6365 | return path; |
| 6390 | |||
| 6391 | #else /* not HAVE_GETCWD */ | ||
| 6392 | #if MSDOS | ||
| 6393 | |||
| 6394 | char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ | ||
| 6395 | |||
| 6396 | getwd (path); | ||
| 6397 | |||
| 6398 | for (p = path; *p != '\0'; p++) | ||
| 6399 | if (*p == '\\') | ||
| 6400 | *p = '/'; | ||
| 6401 | else | ||
| 6402 | *p = lowcase (*p); | ||
| 6403 | |||
| 6404 | return strdup (path); | ||
| 6405 | #else /* not MSDOS */ | ||
| 6406 | linebuffer path; | ||
| 6407 | FILE *pipe; | ||
| 6408 | |||
| 6409 | linebuffer_init (&path); | ||
| 6410 | pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); | ||
| 6411 | if (pipe == NULL || readline_internal (&path, pipe) == 0) | ||
| 6412 | pfatal ("pwd"); | ||
| 6413 | pclose (pipe); | ||
| 6414 | |||
| 6415 | return path.buffer; | ||
| 6416 | #endif /* not MSDOS */ | ||
| 6417 | #endif /* not HAVE_GETCWD */ | ||
| 6418 | } | 6366 | } |
| 6419 | 6367 | ||
| 6420 | /* Return a newly allocated string containing the file name of FILE | 6368 | /* Return a newly allocated string containing the file name of FILE |
diff --git a/lib-src/movemail.c b/lib-src/movemail.c index cd329a110a8..adc5dd96409 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c | |||
| @@ -96,13 +96,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 96 | #include <fcntl.h> | 96 | #include <fcntl.h> |
| 97 | #endif /* WINDOWSNT */ | 97 | #endif /* WINDOWSNT */ |
| 98 | 98 | ||
| 99 | #ifndef F_OK | ||
| 100 | #define F_OK 0 | ||
| 101 | #define X_OK 1 | ||
| 102 | #define W_OK 2 | ||
| 103 | #define R_OK 4 | ||
| 104 | #endif | ||
| 105 | |||
| 106 | #ifdef WINDOWSNT | 99 | #ifdef WINDOWSNT |
| 107 | #include <sys/locking.h> | 100 | #include <sys/locking.h> |
| 108 | #endif | 101 | #endif |
diff --git a/nt/ChangeLog b/nt/ChangeLog index 0eda3a699d6..4fa3d04513c 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 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 | * config.nt (HAVE_GETCWD): Remove. | ||
| 5 | |||
| 1 | 2012-11-21 Eli Zaretskii <eliz@gnu.org> | 6 | 2012-11-21 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | * nmake.defs: Use !if, not !ifdef. For the details, see | 8 | * nmake.defs: Use !if, not !ifdef. For the details, see |
diff --git a/nt/config.nt b/nt/config.nt index 57c18ad2789..1adcbca89be 100644 --- a/nt/config.nt +++ b/nt/config.nt | |||
| @@ -411,12 +411,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 411 | /* Define to 1 if you have the `getaddrinfo' function. */ | 411 | /* Define to 1 if you have the `getaddrinfo' function. */ |
| 412 | #undef HAVE_GETADDRINFO | 412 | #undef HAVE_GETADDRINFO |
| 413 | 413 | ||
| 414 | /* Define to 1 if you have the `getcwd' function. | ||
| 415 | If you think about defining HAVE_GETCWD, don't: the alternative | ||
| 416 | getwd is redefined on w32.c, and does not really return the current | ||
| 417 | directory, to get the desired results elsewhere in Emacs. */ | ||
| 418 | #undef HAVE_GETCWD | ||
| 419 | |||
| 420 | /* Define to 1 if you have the `getdelim' function. */ | 414 | /* Define to 1 if you have the `getdelim' function. */ |
| 421 | #undef HAVE_GETDELIM | 415 | #undef HAVE_GETDELIM |
| 422 | 416 | ||
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 | |||