From a7db35b378d960071823a319bb781dc96b8eed7c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 20 Nov 2012 00:31:19 -0800 Subject: * emacsclient.c (handle_sigcont, handle_sigtstp): Use raise (sig) rather than kill (getpid (), sig), as it's simpler and safer. --- lib-src/ChangeLog | 5 +++++ lib-src/emacsclient.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'lib-src') diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 926297b6dd3..67035773977 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,8 @@ +2012-11-20 Paul Eggert + + * emacsclient.c (handle_sigcont, handle_sigtstp): Use raise (sig) + rather than kill (getpid (), sig), as it's simpler and safer. + 2012-11-17 Juanma Barranquero * makefile.w32-in (SYSWAIT_H): New macro. diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 8d60d7961da..78079b5cf69 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -1138,7 +1138,7 @@ handle_sigcont (int signalnum) else { /* We are in the background; cancel the continue. */ - kill (getpid (), SIGSTOP); + raise (SIGSTOP); } signal (signalnum, handle_sigcont); @@ -1165,7 +1165,7 @@ handle_sigtstp (int signalnum) sigprocmask (SIG_BLOCK, NULL, &set); sigdelset (&set, signalnum); signal (signalnum, SIG_DFL); - kill (getpid (), signalnum); + raise (signalnum); sigprocmask (SIG_SETMASK, &set, NULL); /* Let's the above signal through. */ signal (signalnum, handle_sigtstp); -- cgit v1.2.1 From 9239d970523919dfcf7437f728f4976b3a9467f3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 21 Nov 2012 13:06:52 -0800 Subject: 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 --- lib-src/ChangeLog | 12 +++++++++ lib-src/emacsclient.c | 23 ++--------------- lib-src/etags.c | 68 ++++++--------------------------------------------- lib-src/movemail.c | 7 ------ 4 files changed, 22 insertions(+), 88 deletions(-) (limited to 'lib-src') 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 @@ +2012-11-21 Paul Eggert + + Assume POSIX 1003.1-1988 or later for unistd.h (Bug#12945). + * emacsclient.c (getcwd): Remove decl. + (get_current_dir_name): Assume getcwd exists. + * 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. + * movemail.c (F_OK, X_OK, W_OK, R_OK): Remove. + 2012-11-20 Paul Eggert * 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 *); -char *getenv (const char *), *getwd (char *); -#ifdef HAVE_GETCWD -char *(getcwd) (char *, size_t); -#endif +char *getenv (const char *); #ifndef VERSION #define VERSION "unspecified" @@ -223,7 +220,7 @@ get_current_dir_name (void) char *buf; const char *pwd; struct stat dotstat, pwdstat; - /* If PWD is accurate, use it instead of calling getwd. PWD is + /* If PWD is accurate, use it instead of calling getcwd. PWD is sometimes a nicer name, and using it may avoid a fatal error if a parent directory is searchable but not readable. */ if ((pwd = egetenv ("PWD")) != 0 @@ -240,7 +237,6 @@ get_current_dir_name (void) buf = (char *) xmalloc (strlen (pwd) + 1); strcpy (buf, pwd); } -#ifdef HAVE_GETCWD else { size_t buf_size = 1024; @@ -267,20 +263,6 @@ get_current_dir_name (void) } } } -#else - else - { - /* We need MAXPATHLEN here. */ - buf = (char *) xmalloc (MAXPATHLEN + 1); - if (getwd (buf) == NULL) - { - int tmp_errno = errno; - free (buf); - errno = tmp_errno; - return NULL; - } - } -#endif return buf; } #endif @@ -1592,7 +1574,6 @@ main (int argc, char **argv) cwd = get_current_dir_name (); if (cwd == 0) { - /* getwd puts message in STRING if it fails. */ message (TRUE, "%s: %s\n", progname, "Cannot get current working directory"); 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"; # undef HAVE_NTGUI # undef DOS_NT # define DOS_NT -# ifndef HAVE_GETCWD -# define HAVE_GETCWD -# endif /* undef HAVE_GETCWD */ -#else /* not WINDOWSNT */ -#endif /* !WINDOWSNT */ +#endif /* WINDOWSNT */ #include -#ifndef HAVE_UNISTD_H -# if defined (HAVE_GETCWD) && !defined (WINDOWSNT) - extern char *getcwd (char *buf, size_t size); -# endif -#endif /* HAVE_UNISTD_H */ - #include #include #include @@ -152,16 +142,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4"; # define assert(x) ((void) 0) #endif -#ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */ -# define NO_LONG_OPTIONS TRUE -# define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr) - extern char *optarg; - extern int optind, opterr; -#else -# define NO_LONG_OPTIONS FALSE -# include -#endif /* NO_LONG_OPTIONS */ - +#include #include /* Define CTAGS to make the program "ctags" compatible with the usual one. @@ -869,11 +850,7 @@ print_help (argument *argbuffer) printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\ \n\ These are the options accepted by %s.\n", progname, progname); - if (NO_LONG_OPTIONS) - puts ("WARNING: long option names do not work with this executable,\n\ -as it is not linked with GNU getopt."); - else - puts ("You may use unambiguous abbreviations for the long option names."); + puts ("You may use unambiguous abbreviations for the long option names."); puts (" A - as file name means read names from stdin (one per line).\n\ Absolute names are stored in the output file as they are.\n\ Relative ones are stored relative to the output file's directory.\n"); @@ -1065,9 +1042,9 @@ main (int argc, char **argv) /* When the optstring begins with a '-' getopt_long does not rearrange the non-options arguments to be at the end, but leaves them alone. */ - optstring = concat (NO_LONG_OPTIONS ? "" : "-", - "ac:Cf:Il:o:r:RSVhH", - (CTAGS) ? "BxdtTuvw" : "Di:"); + optstring = concat ("-ac:Cf:Il:o:r:RSVhH", + (CTAGS) ? "BxdtTuvw" : "Di:", + ""); while ((opt = getopt_long (argc, argv, optstring, longopts, NULL)) != EOF) switch (opt) @@ -6333,8 +6310,8 @@ pfatal (const char *s1) static void suggest_asking_for_help (void) { - fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n", - progname, NO_LONG_OPTIONS ? "-h" : "--help"); + fprintf (stderr, "\tTry `%s --help' for a complete list of options.\n", + progname); exit (EXIT_FAILURE); } @@ -6372,7 +6349,6 @@ concat (const char *s1, const char *s2, const char *s3) static char * etags_getcwd (void) { -#ifdef HAVE_GETCWD int bufsize = 200; char *path = xnew (bufsize, char); @@ -6387,34 +6363,6 @@ etags_getcwd (void) canonicalize_filename (path); return path; - -#else /* not HAVE_GETCWD */ -#if MSDOS - - char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */ - - getwd (path); - - for (p = path; *p != '\0'; p++) - if (*p == '\\') - *p = '/'; - else - *p = lowcase (*p); - - return strdup (path); -#else /* not MSDOS */ - linebuffer path; - FILE *pipe; - - linebuffer_init (&path); - pipe = (FILE *) popen ("pwd 2>/dev/null", "r"); - if (pipe == NULL || readline_internal (&path, pipe) == 0) - pfatal ("pwd"); - pclose (pipe); - - return path.buffer; -#endif /* not MSDOS */ -#endif /* not HAVE_GETCWD */ } /* 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 . */ #include #endif /* WINDOWSNT */ -#ifndef F_OK -#define F_OK 0 -#define X_OK 1 -#define W_OK 2 -#define R_OK 4 -#endif - #ifdef WINDOWSNT #include #endif -- cgit v1.2.1 From e6bac8768bfff6756ccf9b595e403821ff539036 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 23 Nov 2012 00:28:06 -0800 Subject: movemail: treat EACCES etc. failures as permanent * movemail.c (main): Treat any link failure other than EEXIST as a permanent failure, not just EPERM. EACCES, for example. --- lib-src/ChangeLog | 6 ++++++ lib-src/movemail.c | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib-src') diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 8e835795e6a..b85ba12a5b2 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,9 @@ +2012-11-23 Paul Eggert + + movemail: treat EACCES etc. failures as permanent + * movemail.c (main): Treat any link failure other than EEXIST as a + permanent failure, not just EPERM. EACCES, for example. + 2012-11-21 Paul Eggert Assume POSIX 1003.1-1988 or later for unistd.h (Bug#12945). diff --git a/lib-src/movemail.c b/lib-src/movemail.c index adc5dd96409..264b3d292c6 100644 --- a/lib-src/movemail.c +++ b/lib-src/movemail.c @@ -328,11 +328,8 @@ main (int argc, char **argv) tem = link (tempname, lockname); -#ifdef EPERM - if (tem < 0 && errno == EPERM) - fatal ("Unable to create hard link between %s and %s", - tempname, lockname); -#endif + if (tem < 0 && errno != EEXIST) + pfatal_with_name (lockname); unlink (tempname); if (tem >= 0) -- cgit v1.2.1