From 2c656f7deb3b192a5063151368782c2715e81051 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 31 May 2015 23:52:09 -0700 Subject: [PATCH] Avoid grave accent quoting in stderr diagnostics A few Emacs diagnostics go directly to stderr, and so can't easily contain curved quotes (as non-UTF-8 locales might mishandle them). Instead of bothering to add support for this rarity, reword the diagnostics so that they don't use grave accent to quote. * src/alloc.c (mark_memory): Fix comment. * src/buffer.c (init_buffer): * src/dispnew.c (init_display): * src/emacs.c (main, sort_args): * src/lread.c (dir_warning): * src/term.c (init_tty): * src/unexmacosx.c (unexec): * src/xfns.c (select_visual): * src/xterm.c (cvt_string_to_pixel, x_io_error_quitter): Reword stderr diagnostics to avoid quoting `like this'. * src/unexmacosx.c: Include errno.h. * src/xfns.c (select_visual): Encode value for locale. --- src/alloc.c | 2 +- src/buffer.c | 4 ++-- src/dispnew.c | 4 ++-- src/emacs.c | 8 ++++---- src/lread.c | 5 +++-- src/term.c | 16 ++++++++-------- src/unexmacosx.c | 5 +++-- src/xfns.c | 3 ++- src/xterm.c | 4 ++-- 9 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 14baf291bd8..a956e95bf14 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4775,7 +4775,7 @@ mark_memory (void *start, void *end) Lisp_Object obj = build_string ("test"); struct Lisp_String *s = XSTRING (obj); Fgarbage_collect (); - fprintf (stderr, "test `%s'\n", s->data); + fprintf (stderr, "test '%s'\n", s->data); return Qnil; } diff --git a/src/buffer.c b/src/buffer.c index 13843a2ac4d..0b98431eb0e 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5285,7 +5285,7 @@ init_buffer (int initialized) pwd = get_current_dir_name (); if (!pwd) - fatal ("`get_current_dir_name' failed: %s\n", strerror (errno)); + fatal ("get_current_dir_name: %s\n", strerror (errno)); /* Maybe this should really use some standard subroutine whose definition is filename syntax dependent. */ @@ -5295,7 +5295,7 @@ init_buffer (int initialized) /* Grow buffer to add directory separator and '\0'. */ pwd = realloc (pwd, len + 2); if (!pwd) - fatal ("`get_current_dir_name' failed: %s\n", strerror (errno)); + fatal ("get_current_dir_name: %s\n", strerror (errno)); pwd[len] = DIRECTORY_SEP; pwd[len + 1] = '\0'; len++; diff --git a/src/dispnew.c b/src/dispnew.c index 7e7afa71d20..1fc3cfeef44 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -6036,10 +6036,10 @@ init_display (void) { #ifdef HAVE_WINDOW_SYSTEM if (! inhibit_window_system) - fprintf (stderr, "Please set the environment variable DISPLAY or TERM (see `tset').\n"); + fprintf (stderr, "Please set the environment variable DISPLAY or TERM (see 'tset').\n"); else #endif /* HAVE_WINDOW_SYSTEM */ - fprintf (stderr, "Please set the environment variable TERM; see `tset'.\n"); + fprintf (stderr, "Please set the environment variable TERM; see 'tset'.\n"); exit (1); } diff --git a/src/emacs.c b/src/emacs.c index bba68068a83..8396f5d4e45 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -776,12 +776,12 @@ main (int argc, char **argv) tem2 = Fsymbol_value (intern_c_string ("emacs-copyright")); if (!STRINGP (tem)) { - fprintf (stderr, "Invalid value of `emacs-version'\n"); + fprintf (stderr, "Invalid value of 'emacs-version'\n"); exit (1); } if (!STRINGP (tem2)) { - fprintf (stderr, "Invalid value of `emacs-copyright'\n"); + fprintf (stderr, "Invalid value of 'emacs-copyright'\n"); exit (1); } else @@ -1796,7 +1796,7 @@ sort_args (int argc, char **argv) options[from] = standard_args[i].nargs; priority[from] = standard_args[i].priority; if (from + standard_args[i].nargs >= argc) - fatal ("Option `%s' requires an argument\n", argv[from]); + fatal ("Option '%s' requires an argument\n", argv[from]); from += standard_args[i].nargs; goto done; } @@ -1833,7 +1833,7 @@ sort_args (int argc, char **argv) if (equals != 0) options[from] = 0; if (from + options[from] >= argc) - fatal ("Option `%s' requires an argument\n", argv[from]); + fatal ("Option '%s' requires an argument\n", argv[from]); from += options[from]; } /* FIXME When match < 0, shouldn't there be some error, diff --git a/src/lread.c b/src/lread.c index 26c19d8338b..11c8d0031c9 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4418,9 +4418,10 @@ init_lread (void) void dir_warning (char const *use, Lisp_Object dirname) { - static char const format[] = "Warning: %s `%s': %s\n"; + static char const format[] = "Warning: %s '%s': %s\n"; int access_errno = errno; - fprintf (stderr, format, use, SSDATA (dirname), strerror (access_errno)); + fprintf (stderr, format, use, SSDATA (ENCODE_SYSTEM (dirname)), + strerror (access_errno)); /* Don't log the warning before we've initialized!! */ if (initialized) diff --git a/src/term.c b/src/term.c index d2a9c3d1f30..8ebb620dd9b 100644 --- a/src/term.c +++ b/src/term.c @@ -4028,12 +4028,12 @@ init_tty (const char *name, const char *terminal_type, bool must_succeed) "Terminal type %s is not defined", "Terminal type %s is not defined.\n\ If that is not the actual type of terminal you have,\n\ -use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ -`setenv TERM ...') to specify the correct type. It may be necessary\n" +use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\ +'setenv TERM ...') to specify the correct type. It may be necessary\n" #ifdef TERMINFO -"to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", +"to do 'unset TERMINFO' (C-shell: 'unsetenv TERMINFO') as well.", #else -"to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", +"to do 'unset TERMCAP' (C-shell: 'unsetenv TERMCAP') as well.", #endif terminal_type); } @@ -4307,12 +4307,12 @@ use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ "Terminal type \"%s\" is not powerful enough to run Emacs.\n\ It lacks the ability to position the cursor.\n\ If that is not the actual type of terminal you have,\n\ -use the Bourne shell command `TERM=... export TERM' (C-shell:\n\ -`setenv TERM ...') to specify the correct type. It may be necessary\n" +use the Bourne shell command 'TERM=...; export TERM' (C-shell:\n\ +'setenv TERM ...') to specify the correct type. It may be necessary\n" # ifdef TERMINFO -"to do `unset TERMINFO' (C-shell: `unsetenv TERMINFO') as well.", +"to do 'unset TERMINFO' (C-shell: 'unsetenv TERMINFO') as well.", # else /* TERMCAP */ -"to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", +"to do 'unset TERMCAP' (C-shell: 'unsetenv TERMCAP') as well.", # endif /* TERMINFO */ terminal_type); } diff --git a/src/unexmacosx.c b/src/unexmacosx.c index fe6637e2ef5..319ec7956e5 100644 --- a/src/unexmacosx.c +++ b/src/unexmacosx.c @@ -99,6 +99,7 @@ along with GNU Emacs. If not, see . */ #include "unexec.h" #include "lisp.h" +#include #include #include #include @@ -1264,14 +1265,14 @@ unexec (const char *outfile, const char *infile) infd = emacs_open (infile, O_RDONLY, 0); if (infd < 0) { - unexec_error ("cannot open input file `%s'", infile); + unexec_error ("%s: %s", infile, strerror (errno)); } outfd = emacs_open (outfile, O_WRONLY | O_TRUNC | O_CREAT, 0777); if (outfd < 0) { emacs_close (infd); - unexec_error ("cannot open output file `%s'", outfile); + unexec_error ("%s: %s", outfile, strerror (errno)); } build_region_list (); diff --git a/src/xfns.c b/src/xfns.c index 16a568e9153..634881d0a66 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -4519,7 +4519,8 @@ select_visual (struct x_display_info *dpyinfo) if (class == -1 || !XMatchVisualInfo (dpy, XScreenNumberOfScreen (screen), dpyinfo->n_planes, class, &vinfo)) - fatal ("Invalid visual specification `%s'", SDATA (value)); + fatal ("Invalid visual specification '%s'", + SSDATA (ENCODE_SYSTEM (value))); dpyinfo->visual = vinfo.visual; } diff --git a/src/xterm.c b/src/xterm.c index 4f5dfed9ae8..17c1a645d98 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -2091,7 +2091,7 @@ cvt_string_to_pixel (Display *dpy, XrmValue *args, Cardinal *nargs, params[0] = color_name; XtAppWarningMsg (XtDisplayToApplicationContext (dpy), "badValue", "cvt_string_to_pixel", - "XtToolkitError", "Invalid color `%s'", + "XtToolkitError", "Invalid color '%s'", params, &nparams); return False; } @@ -9388,7 +9388,7 @@ x_io_error_quitter (Display *display) { char buf[256]; - snprintf (buf, sizeof buf, "Connection lost to X server `%s'", + snprintf (buf, sizeof buf, "Connection lost to X server '%s'", DisplayString (display)); x_connection_closed (display, buf, true); return 0; -- 2.11.4.GIT