[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dfa.c problem on MinGW
From: |
Jim Meyering |
Subject: |
Re: dfa.c problem on MinGW |
Date: |
Fri, 17 Jun 2011 13:49:29 +0200 |
[Cc'ing bug-grep]
Aharon Robbins wrote:
> Hi.
>
> FYI:
>
>> Date: Fri, 17 Jun 2011 12:54:52 +0300
>> From: Eli Zaretskii <address@hidden>
>> Subject: Re: [gawk-devel] final beta test tar ball
>> To: Aharon Robbins <address@hidden>
>> Cc: address@hidden
>>
>> [...]
>>
>> In addition, the last changes introduced these warnings in the MinGW
>> build:
>>
>> gcc -c -O2 -gdwarf-2 -g3 -DGAWK -I. -DHAVE_CONFIG_H dfa.c
>> dfa.c: In function `setbit_c':
>> dfa.c:585: warning: comparison is always false due to limited range of
>> data type
>> dfa.c: In function `setbit_case_fold_c':
>> dfa.c:604: warning: comparison is always false due to limited range of
>> data type
>>
>> This happens because wint_t is an unsigned data type in the MinGW
>> build, so comparisons like
>>
>> wint_t wc = btowc (b);
>> if (wc == EOF)
>>
>> where EOF is "(-1)", are always false.
>>
>> My reading of the docs for btowc indicates that we should test against
>> WEOF, not EOF.
>
> The warnings are in code I pulled from grep's dfa.c.
Thanks for the heads-up.
Here's a proposed patch:
>From 02c405395fe9da677b4b84feca638993255d3a0d Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 17 Jun 2011 13:46:56 +0200
Subject: [PATCH] dfa: correct two uses of btowc
* src/dfa.c (setbit_c, setbit_case_fold_c): Compare the btowc
return value against WEOF, not EOF. Suggested by Eli Zaretskii.
On a system like MinGW with unsigned wint_t, comparing a btowc
return value against EOF (-1) would always be false.
---
src/dfa.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/dfa.c b/src/dfa.c
index c32d679..0fcb2f0 100644
--- a/src/dfa.c
+++ b/src/dfa.c
@@ -559,7 +559,7 @@ static void
setbit_c (int b, charclass c)
{
/* Do nothing if b is invalid in this character set. */
- if (MB_CUR_MAX > 1 && btowc (b) == EOF)
+ if (MB_CUR_MAX > 1 && btowc (b) == WEOF)
return;
setbit (b, c);
}
@@ -578,7 +578,7 @@ setbit_case_fold_c (int b, charclass c)
if (MB_CUR_MAX > 1)
{
wint_t wc = btowc (b);
- if (wc == EOF)
+ if (wc == WEOF)
return;
setbit (b, c);
if (case_fold && iswalpha (wc))
--
1.7.6.rc0.293.g40857
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: dfa.c problem on MinGW,
Jim Meyering <=