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

From: Paul Eggert <[email-masked]>
Date: Wed, 26 Mar 2014 21:39:48 -0700

Aharon Robbins wrote:
> we should be defining this as
>
> 	# define setlocale(category, locale) ("C")

Thanks, that sounds right.  I installed the attached patch.

From 36e21aa6913abeda12062d8294924afbd6313939 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 26 Mar 2014 21:37:54 -0700
Subject: [PATCH] dfa: improve port to freestanding DJGPP

* src/dfa.c (setlocale) [!LC_ALL]: Return "C", not NULL (Bug#17056).
(using_simple_locale): Store setlocale result in a ptr-to-const.
---
 src/dfa.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 0a2b8b8..f88ff2a 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) NULL
+# define setlocale(category, locale) "C"
 #endif
 #ifndef static_assert
 # define static_assert(cond, diagnostic) \
@@ -783,7 +783,7 @@ using_simple_locale (void)
       static int unibyte_c = -1;
       if (unibyte_c < 0)
         {
-          char *locale = setlocale (LC_ALL, NULL);
+          char const *locale = setlocale (LC_ALL, NULL);
           unibyte_c = (locale && (STREQ (locale, "C")
                                   || STREQ (locale, "POSIX")));
         }
-- 
1.8.5.3