GNU bug report logs - #17056
dfa.c patch for systems with no locale support

Previous Next

Package: grep;

Reported by: Aharon Robbins <arnold <at> skeeve.com>

Date: Fri, 21 Mar 2014 11:42:01 UTC

Severity: normal

Tags: patch

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Aharon Robbins <arnold <at> skeeve.com>
To: eggert <at> cs.ucla.edu, arnold <at> skeeve.com, 17056-done <at> debbugs.gnu.org
Subject: bug#17056: dfa.c patch for systems with no locale support
Date: Thu, 27 Mar 2014 20:48:38 +0200
Hi Paul.

> Date: Wed, 26 Mar 2014 21:39:48 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> To: Aharon Robbins <arnold <at> skeeve.com>, 17056-done <at> debbugs.gnu.org
>
> Aharon Robbins wrote:
> > we should be defining this as
> >
> > 	# define setlocale(category, locale) ("C")
>
> Thanks, that sounds right.  I installed the attached patch.

Actually, after a night's sleep, I think that was wrong. What if
the system's setlocale() actually returns NULL?  I suggest
the below change to master.

Thanks,

Arnold
----------------------------------------------------------------
diff --git a/src/dfa.c b/src/dfa.c
index f88ff2a..0fd8944 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -37,7 +37,7 @@
 /* Gawk doesn't use Gnulib, so don't assume that setlocale and
    static_assert are present.  */
 #ifndef LC_ALL
-# define setlocale(category, locale) "C"
+# define setlocale(category, locale) NULL
 #endif
 #ifndef static_assert
 # define static_assert(cond, diagnostic) \
@@ -784,8 +784,9 @@ using_simple_locale (void)
       if (unibyte_c < 0)
         {
           char const *locale = setlocale (LC_ALL, NULL);
-          unibyte_c = (locale && (STREQ (locale, "C")
-                                  || STREQ (locale, "POSIX")));
+          unibyte_c = (locale == NULL
+                          || STREQ (locale, "C")
+                          || STREQ (locale, "POSIX"));
         }
       return unibyte_c;
     }




This bug report was last modified 11 years and 112 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.