* sysdep.c (str_collate) [__STDC_ISO_10646__]: Move up setting errno.
authorMichael Albinus <michael.albinus@gmx.de>
Fri, 29 Aug 2014 21:19:45 +0000 (23:19 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Fri, 29 Aug 2014 21:19:45 +0000 (23:19 +0200)
src/ChangeLog
src/sysdep.c

index 81381168c0c09594208ad701032f612627b93450..19e9985b082454c4ce5123c75ce1410efcab2203 100644 (file)
@@ -1,9 +1,13 @@
+2014-08-29  Michael Albinus  <michael.albinus@gmx.de>
+
+       * sysdep.c (str_collate) [__STDC_ISO_10646__]: Move up setting errno.
+
 2014-08-29  Paul Eggert  <eggert@cs.ucla.edu>
 
-       * sysdep.c (str_collate): Do not look at errno after towlower_l.
-       errno's value is not specified after towlower_l.  Instead, assume
-       that towlower_l returns its argument on failure, which is portable
-       in practice.
+       * sysdep.c (str_collate) [__STDC_ISO_10646__]: Do not look at
+       errno after towlower_l.  errno's value is not specified after
+       towlower_l.  Instead, assume that towlower_l returns its argument
+       on failure, which is portable in practice.
 
 2014-08-29  Eli Zaretskii  <eliz@gnu.org>
 
index d36f5b29b08d86983761fb5bb6a132839b58a9cc..e1da2f87eb2ab2e53455f24f7f56fcd407ce47bc 100644 (file)
@@ -3740,6 +3740,8 @@ str_collate (Lisp_Object s1, Lisp_Object s2,
     FETCH_STRING_CHAR_ADVANCE (*(p2+i-1), s2, i, i_byte);
   *(p2+len) = 0;
 
+  errno = 0;
+
   if (STRINGP (locale))
     {
       locale_t loc = newlocale (LC_COLLATE_MASK | LC_CTYPE_MASK,
@@ -3761,7 +3763,6 @@ str_collate (Lisp_Object s1, Lisp_Object s2,
     }
   else
     {
-      errno = 0;
       if (! NILP (ignore_case))
        for (int i = 1; i < 3; i++)
          {
@@ -3769,6 +3770,7 @@ str_collate (Lisp_Object s1, Lisp_Object s2,
            for (; *p; p++)
              *p = towlower (*p);
          }
+
       res = wcscoll (p1, p2);
       err = errno;
     }