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 /lib-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 'lib-src')
| -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 |
4 files changed, 22 insertions, 88 deletions
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 |