Subject: bug#17056: dfa.c patch for systems with no locale support

From: Aharon Robbins <[email-masked]>
Date: Thu, 27 Mar 2014 20:48:38 +0200

Hi Paul.

> Date: Wed, 26 Mar 2014 21:39:48 -0700
> From: Paul Eggert <[email-masked]>
> To: Aharon Robbins <[email-masked]>, [email-masked]
>
> 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;
     }