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

From: [email-masked] (GNU bug Tracking System)
Date: Sun, 23 Mar 2014 21:17:02 +0000

Your bug report

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

which was filed against the grep package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
17056: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17056
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#17056: dfa.c patch for systems with no locale support
From: Paul Eggert <[email-masked]>
To: Aharon Robbins <[email-masked]>, [email-masked]
Date: Sun, 23 Mar 2014 14:16:47 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

Aharon Robbins wrote:

> See the original report below

I downloaded the DJGPP sources.  LC_ALL is defined unless one compiles 
as a freestanding environment, in which case neither LC_ALL nor 
setlocale are declared.  So my guess is that your correspondent is using 
a freestanding environment somehow, and the patch that I suggested 
should work.  It's better to avoid #ifdefs inside functions so I 
installed this into the grep master (see attached) and am marking this 
as done; we can always resurrect it if my guess is wrong.

From c3a693e829ad9d9a3a7e74a8cfadb2e1f0dfa30d Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sun, 23 Mar 2014 14:10:18 -0700
Subject: [PATCH] dfa: port to freestanding DJGPP (Bug#17056)

* src/dfa.c (setlocale) [!LC_ALL]: Define a dummy.
---
 src/dfa.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/dfa.c b/src/dfa.c
index 5e60cd5..92ac1b9 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -34,7 +34,11 @@
 #include <locale.h>
 #include <stdbool.h>
 
-/* Gawk doesn't use Gnulib, so don't assume static_assert is present.  */
+/* Gawk doesn't use Gnulib, so don't assume that setlocale and
+   static_assert are present.  */
+#ifndef LC_ALL
+# define setlocale(category, locale) NULL
+#endif
 #ifndef static_assert
 # define static_assert(cond, diagnostic) \
     extern int (*foo (void)) [!!sizeof (struct { int foo: (cond) ? 8 : -1; })]
-- 
1.8.5.3

Subject: dfa.c patch for systems with no locale support
From: Aharon Robbins <[email-masked]>
To: [email-masked]
Date: Fri, 21 Mar 2014 13:40:17 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi.

This turned up in testing on DJGPP.  Thanks,

Arnold
--------------------------
diff --git a/dfa.c b/dfa.c
index 8771bbe..813c239 100644
--- a/dfa.c
+++ b/dfa.c
@@ -820,9 +820,13 @@ using_simple_locale (void)
       static int unibyte_c = -1;
       if (unibyte_c < 0)
         {
+#ifdef LC_ALL
           char *locale = setlocale (LC_ALL, NULL);
           unibyte_c = (locale && (STREQ (locale, "C")
                                   || STREQ (locale, "POSIX")));
+#else
+          unibyte_c = 1;
+#endif
         }
       return unibyte_c;
     }