summaryrefslogtreecommitdiff
path: root/src/sysdep.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2014-08-30 11:19:24 +0300
committerEli Zaretskii <eliz@gnu.org>2014-08-30 11:19:24 +0300
commite7027eab55d9b3b63ddc1c26f3e222692c8c9499 (patch)
tree62f5b2569c009499c0c5ff5c896a0df9b4b49f30 /src/sysdep.c
parente1a9bbbd4f719a2256bd180ae9e9fffb64db63e4 (diff)
downloademacs-e7027eab55d9b3b63ddc1c26f3e222692c8c9499.tar.gz
Improve error checking and error messages in string-collation functions.
src/sysdep.c (str_collate) [__STDC_ISO_10646__]: Improve the wording of the error messages. (str_collate) [WINDOWSNT]: Signal an error if w32_compare_strings sets errno. src/w32proc.c (get_lcid_callback): Accept locale specifications without the country part, as in "enu" vs "enu_USA". (w32_compare_strings): Signal an error if a locale was specified, but couldn't be translated into a valid LCID.
Diffstat (limited to 'src/sysdep.c')
-rw-r--r--src/sysdep.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/sysdep.c b/src/sysdep.c
index e1da2f87eb2..8b62c8c4f62 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -3747,7 +3747,7 @@ str_collate (Lisp_Object s1, Lisp_Object s2,
locale_t loc = newlocale (LC_COLLATE_MASK | LC_CTYPE_MASK,
SSDATA (locale), 0);
if (!loc)
- error ("Wrong locale: %s", strerror (errno));
+ error ("Invalid locale %s: %s", SSDATA (locale), strerror (errno));
if (! NILP (ignore_case))
for (int i = 1; i < 3; i++)
@@ -3774,8 +3774,13 @@ str_collate (Lisp_Object s1, Lisp_Object s2,
res = wcscoll (p1, p2);
err = errno;
}
+# ifndef HAVE_NEWLOCALE
if (err)
- error ("Wrong argument: %s", strerror (err));
+ error ("Invalid locale or string for collation: %s", strerror (err));
+# else
+ if (err)
+ error ("Invalid string for collation: %s", strerror (err));
+# endif
SAFE_FREE ();
return res;
@@ -3789,7 +3794,14 @@ str_collate (Lisp_Object s1, Lisp_Object s2,
{
char *loc = STRINGP (locale) ? SSDATA (locale) : NULL;
+ int res, err = errno;
- return w32_compare_strings (SDATA (s1), SDATA (s2), loc, !NILP (ignore_case));
+ errno = 0;
+ res = w32_compare_strings (SDATA (s1), SDATA (s2), loc, !NILP (ignore_case));
+ if (errno)
+ error ("Invalid string for collation: %s", strerror (errno));
+
+ errno = err;
+ return res;
}
#endif /* WINDOWSNT */