diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2016-06-11 23:48:13 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2016-06-11 23:49:00 -0700 |
commit | 5932ffcd028af9fc70c9f8e731f2776a9753d81d (patch) | |
tree | 4d9ab8f89fdc526146e5571f028147afde568e3d /src/lread.c | |
parent | eacdc9eb6c89346fb72535632a1c65f6483b639f (diff) | |
download | emacs-5932ffcd028af9fc70c9f8e731f2776a9753d81d.tar.gz |
emacs_strerror cleanups
* src/buffer.c, src/emacs.c, src/lread.c: Don’t include coding.h;
no longer needed, now that emacs_strerror is declared by lisp.h.
* src/coding.c (emacs_strerror): Remove; moved to emacs.c.
* src/coding.h (emacs_strerror) [emacs]: Remove decl; moved
to lisp.h.
* src/emacs.c (emacs_strerror): Move here from coding.c. Do not
convert result string; this is now the caller’s responsibility,
as some need conversion and others don’t.
* src/fileio.c (report_file_errno, report_file_notify_error):
Use emacs_strerror rather than rolling it ourselves.
* src/lisp.h (emacs_strerror): Move decl here from coding.h.
* src/lread.c (dir_warning): Just call emacs_strerror rather than
both strerror and emacs_strerror. Convert its result from
locale-coding-system, since it no longer does that conversion.
* src/sound.c (sound_perror):
* src/sysdep.c (emacs_perror, str_collate):
Use emacs_strerror, not strerror.
Diffstat (limited to 'src/lread.c')
-rw-r--r-- | src/lread.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/lread.c b/src/lread.c index b08ce17fd9c..9f804ac3194 100644 --- a/src/lread.c +++ b/src/lread.c @@ -36,7 +36,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include "character.h" #include "buffer.h" #include "charset.h" -#include "coding.h" #include <epaths.h> #include "commands.h" #include "keyboard.h" @@ -4484,18 +4483,24 @@ void dir_warning (char const *use, Lisp_Object dirname) { static char const format[] = "Warning: %s '%s': %s\n"; - int access_errno = errno; - fprintf (stderr, format, use, SSDATA (ENCODE_SYSTEM (dirname)), - strerror (access_errno)); + char *diagnostic = emacs_strerror (errno); + fprintf (stderr, format, use, SSDATA (ENCODE_SYSTEM (dirname)), diagnostic); /* Don't log the warning before we've initialized!! */ if (initialized) { - char const *diagnostic = emacs_strerror (access_errno); + ptrdiff_t diaglen = strlen (diagnostic); + AUTO_STRING_WITH_LEN (diag, diagnostic, diaglen); + if (! NILP (Vlocale_coding_system)) + { + Lisp_Object s + = code_convert_string_norecord (diag, Vlocale_coding_system, false); + diagnostic = SSDATA (s); + diaglen = SBYTES (s); + } USE_SAFE_ALLOCA; char *buffer = SAFE_ALLOCA (sizeof format - 3 * (sizeof "%s" - 1) - + strlen (use) + SBYTES (dirname) - + strlen (diagnostic)); + + strlen (use) + SBYTES (dirname) + diaglen); ptrdiff_t message_len = esprintf (buffer, format, use, SSDATA (dirname), diagnostic); message_dolog (buffer, message_len, 0, STRING_MULTIBYTE (dirname)); |