Discussion:
grep/util.c type mismatch
enh
2014-07-14 18:06:27 UTC
Permalink
building NetBSD's grep for Android/x86, i get:

grep/util.c:332:9: error: format '%lc' expects argument of type
'wchar_t *', but argument 3 has type 'wint_t *' [-Werror=format=]
"%lc", &wbegin) != 1)
^
grep/util.c:336:9: error: format '%lc' expects argument of type
'wchar_t *', but argument 3 has type 'wint_t *' [-Werror=format=]
"%lc", &wend) != 1)
^


cvs diff: Diffing .
Index: util.c
===================================================================
RCS file: /cvsroot/src/usr.bin/grep/util.c,v
retrieving revision 1.17
diff -u -r1.17 util.c
--- util.c 21 Jan 2013 03:24:43 -0000 1.17
+++ util.c 14 Jul 2014 18:05:23 -0000
@@ -324,7 +324,7 @@
continue;
/* Check for whole word match */
if (fg_pattern[i].word && pmatch.rm_so != 0) {
- wint_t wbegin, wend;
+ wchar_t wbegin, wend;

wbegin = wend = L' ';
if (pmatch.rm_so != 0 &&
cvs diff: Diffing nls
Taylor R Campbell
2014-07-14 18:42:11 UTC
Permalink
Date: Mon, 14 Jul 2014 11:06:27 -0700
From: enh <***@google.com>

building NetBSD's grep for Android/x86, i get:

grep/util.c:332:9: error: format '%lc' expects argument of type
'wchar_t *', but argument 3 has type 'wint_t *' [-Werror=format=]
"%lc", &wbegin) != 1)
^
--- util.c 21 Jan 2013 03:24:43 -0000 1.17
+++ util.c 14 Jul 2014 18:05:23 -0000
@@ -324,7 +324,7 @@
continue;
/* Check for whole word match */
if (fg_pattern[i].word && pmatch.rm_so != 0) {
- wint_t wbegin, wend;
+ wchar_t wbegin, wend;

I don't think this change is sufficient, because passing a wchar_t to
iswalnum via iswword a few lines below is not kosher. You need to
convert to wint_t via the unsigned version of wchar_t, except I don't
know that we have a correct portable way to do that.

...unless I am much mistaken and there is no analogue to the issue for
isalnum &c. documented in the CAVEATS section of the ctype(3) man
page.
Christos Zoulas
2014-07-14 21:56:31 UTC
Permalink
Post by enh
grep/util.c:332:9: error: format '%lc' expects argument of type
'wchar_t *', but argument 3 has type 'wint_t *' [-Werror=format=]
"%lc", &wbegin) != 1)
^
grep/util.c:336:9: error: format '%lc' expects argument of type
'wchar_t *', but argument 3 has type 'wint_t *' [-Werror=format=]
"%lc", &wend) != 1)
^
fixed, thanks!

christos

Loading...