#include <verify.h>
#include "lisp.h"
-#include "coding.h"
#include "intervals.h"
#include "systime.h"
#include "window.h"
#endif
staticpro (&system_eol_type);
}
-
-char *
-emacs_strerror (int error_number)
-{
- char *str;
-
- synchronize_system_messages_locale ();
- str = strerror (error_number);
-
- if (! NILP (Vlocale_coding_system))
- {
- Lisp_Object dec = code_convert_string_norecord (build_string (str),
- Vlocale_coding_system,
- 0);
- str = SSDATA (dec);
- }
-
- return str;
-}
-
#endif /* emacs */
#ifdef emacs
-extern char *emacs_strerror (int);
-
/* Coding system to be used to encode text for terminal display when
terminal coding system is nil. */
extern struct coding_system safe_terminal_coding;
#include TERM_HEADER
#endif /* HAVE_WINDOW_SYSTEM */
-#include "coding.h"
#include "intervals.h"
#include "character.h"
#include "buffer.h"
#endif
}
#endif /* HAVE_SETLOCALE */
+
+/* Return a diagnostic string for ERROR_NUMBER, in the wording
+ and encoding appropriate for the current locale. */
+char *
+emacs_strerror (int error_number)
+{
+ synchronize_system_messages_locale ();
+ return strerror (error_number);
+}
\f
Lisp_Object
report_file_errno (char const *string, Lisp_Object name, int errorno)
{
Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
- synchronize_system_messages_locale ();
- char *str = strerror (errorno);
+ char *str = emacs_strerror (errorno);
AUTO_STRING (unibyte_str, str);
Lisp_Object errstring
= code_convert_string_norecord (unibyte_str, Vlocale_coding_system, 0);
void
report_file_notify_error (const char *string, Lisp_Object name)
{
- Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
- synchronize_system_messages_locale ();
- char *str = strerror (errno);
+ char *str = emacs_strerror (errno);
AUTO_STRING (unibyte_str, str);
Lisp_Object errstring
= code_convert_string_norecord (unibyte_str, Vlocale_coding_system, 0);
+ Lisp_Object data = CONSP (name) || NILP (name) ? name : list1 (name);
Lisp_Object errdata = Fcons (errstring, data);
xsignal (Qfile_notify_error, Fcons (build_string (string), errdata));
INLINE void synchronize_system_messages_locale (void) {}
INLINE void synchronize_system_time_locale (void) {}
#endif
+extern char *emacs_strerror (int);
extern void shut_down_emacs (int, Lisp_Object);
/* True means don't do interactive redisplay and don't change tty modes. */
#include "character.h"
#include "buffer.h"
#include "charset.h"
-#include "coding.h"
#include <epaths.h>
#include "commands.h"
#include "keyboard.h"
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));
}
#endif
if (saved_errno != 0)
- error ("%s: %s", msg, strerror (saved_errno));
+ error ("%s: %s", msg, emacs_strerror (saved_errno));
else
error ("%s", msg);
}
emacs_perror (char const *message)
{
int err = errno;
- char const *error_string = strerror (err);
+ char const *error_string = emacs_strerror (err);
char const *command = (initial_argv && initial_argv[0]
? initial_argv[0] : "emacs");
/* Write it out all at once, if it's short; this is less likely to
locale_t loc = newlocale (LC_COLLATE_MASK | LC_CTYPE_MASK,
SSDATA (locale), 0);
if (!loc)
- error ("Invalid locale %s: %s", SSDATA (locale), strerror (errno));
+ error ("Invalid locale %s: %s", SSDATA (locale), emacs_strerror (errno));
if (! NILP (ignore_case))
for (int i = 1; i < 3; i++)
}
# ifndef HAVE_NEWLOCALE
if (err)
- error ("Invalid locale or string for collation: %s", strerror (err));
+ error ("Invalid locale or string for collation: %s", emacs_strerror (err));
# else
if (err)
- error ("Invalid string for collation: %s", strerror (err));
+ error ("Invalid string for collation: %s", emacs_strerror (err));
# endif
SAFE_FREE ();