aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--builtin.c23
2 files changed, 23 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a616f47..0072c804 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2014-07-31 Arnold D. Robbins <arnold@skeeve.com>
+ * builtin.c (format_tree): Make %c handling more sane on Windows.
+ Rework the lint messages.
+
+ Unrelated:
+
* dfa.c: Sync with GNU grep. Mainly white space differences.
Unrelated:
diff --git a/builtin.c b/builtin.c
index 7523d6c9..7d314dc5 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1066,13 +1066,30 @@ check_pos:
size_t count;
memset(& mbs, 0, sizeof(mbs));
+
+ /* handle systems with too small wchar_t */
+ if (sizeof(wchar_t) < 4 && uval > 0xffff) {
+ if (do_lint)
+ lintwarn(
+ _("[s]printf: value %g is too big for %%c format"),
+ arg->numbr);
+
+ goto out0;
+ }
+
wc = uval;
count = wcrtomb(buf, wc, & mbs);
if (count == 0
|| count == (size_t)-1
- || count == (size_t)-2)
+ || count == (size_t)-2) {
+ if (do_lint)
+ lintwarn(
+ _("[s]printf: value %g is not a valid wide character"),
+ arg->numbr);
+
goto out0;
+ }
memcpy(cpbuf, buf, count);
prec = count;
@@ -1084,10 +1101,6 @@ out0:
/* else,
fall through */
#endif
- if (do_lint && uval > 255) {
- lintwarn("[s]printf: value %g is too big for %%c format",
- arg->numbr);
- }
cpbuf[0] = uval;
prec = 1;
cp = cpbuf;