bug-grep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: two minor bug fixes for dfa.c


From: Jim Meyering
Subject: Re: two minor bug fixes for dfa.c
Date: Tue, 29 Nov 2011 19:08:20 +0100

Aharon Robbins wrote:
> 1. The setbit_wc() function for not MBS_SUPPORT has return type bool
>    but does not return a value
> 2. A test for `defined MBS_SUPPORT' should just be `MBS_SUPPORT' since
>    MBS_SUPPORT is now always defined.
>
> Diff below.
>
> Thanks,
>
> Arnold
> ------------------------------
> --- /usr/local/src/Gnu/grep/src/dfa.c 2011-11-22 23:32:58.501681998 +0200
> +++ dfa.c     2011-11-27 21:09:35.195545161 +0200
> @@ -585,7 +608,12 @@
>  }
>  #else
>  # define setbit_c setbit
> -static inline bool setbit_wc (wint_t wc, charclass c) { abort (); }
> +static inline bool setbit_wc (wint_t wc, charclass c)
> +{
> +  abort ();
> +  /*NOTREACHED*/
> +  return false;
> +}
>  #endif
>
>  /* Like setbit_c, but if case is folded, set both cases of a letter.  For
> @@ -622,7 +650,7 @@
>    static int utf8 = -1;
>    if (utf8 == -1)
>      {
> -#if defined HAVE_LANGINFO_CODESET && defined MBS_SUPPORT
> +#if defined HAVE_LANGINFO_CODESET && MBS_SUPPORT
>        utf8 = (STREQ (nl_langinfo (CODESET), "UTF-8"));
>  #else
>        utf8 = 0;

Thanks.
However, it would have been even better if you had written commit logs.
Please make an effort next time.  I've written them for you:

>From 3054c6850e0d3d1578f5e87c23e595ed528fbf6e Mon Sep 17 00:00:00 2001
From: Arnold Robbins <address@hidden>
Date: Tue, 29 Nov 2011 18:58:18 +0100
Subject: [PATCH 1/2] dfa: avoid warning from deficient compiler in
 !MBS_SUPPORT mode

* src/dfa.c (setbit_wc) [!MBS_SUPPORT]: Add explicit "return false;"
after "abort ();", to avoid a warning from deficient compilers.
---
 src/dfa.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 3214f29..969a72e 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -585,7 +585,13 @@ setbit_c (int b, charclass c)
 }
 #else
 # define setbit_c setbit
-static inline bool setbit_wc (wint_t wc, charclass c) { abort (); }
+static inline bool
+setbit_wc (wint_t wc, charclass c)
+{
+  abort ();
+  /*NOTREACHED*/
+  return false;
+}
 #endif

 /* Like setbit_c, but if case is folded, set both cases of a letter.  For
--
1.7.8.rc4


>From 9d68b23adfe963387525a5a3e8eb84957ee17212 Mon Sep 17 00:00:00 2001
From: Arnold Robbins <address@hidden>
Date: Tue, 29 Nov 2011 19:06:32 +0100
Subject: [PATCH 2/2] dfa: do not call nl_langinfo in !MBS_SUPPORT mode

* src/dfa.c (using_utf8) [!MBS_SUPPORT]: Remove erroneous "defined"
in cpp test for MBS_SUPPORT.  Since commit a163349d, MBS_SUPPORT is 0/1.
This error caused trouble only in the !MBS_SUPPORT case.
---
 src/dfa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/dfa.c b/src/dfa.c
index 969a72e..26ea4b5 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -628,7 +628,7 @@ using_utf8 (void)
   static int utf8 = -1;
   if (utf8 == -1)
     {
-#if defined HAVE_LANGINFO_CODESET && defined MBS_SUPPORT
+#if defined HAVE_LANGINFO_CODESET && MBS_SUPPORT
       utf8 = (STREQ (nl_langinfo (CODESET), "UTF-8"));
 #else
       utf8 = 0;
--
1.7.8.rc4



reply via email to

[Prev in Thread] Current Thread [Next in Thread]