aboutsummaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-07-31 23:11:16 +0300
committerArnold D. Robbins <arnold@skeeve.com>2014-07-31 23:11:16 +0300
commit4425e6c5b88ecc03371b68926ebf89ebe03839ba (patch)
treea71c9c160edb05fc35ce530b78b69f43654f42e0 /builtin.c
parentd60fb05cc5db4f1ee1176a9ed7f053011f8521aa (diff)
parentd3bd5c88e7505063348d88604180d3e1e6e0f5a9 (diff)
downloadegawk-4425e6c5b88ecc03371b68926ebf89ebe03839ba.tar.gz
egawk-4425e6c5b88ecc03371b68926ebf89ebe03839ba.tar.bz2
egawk-4425e6c5b88ecc03371b68926ebf89ebe03839ba.zip
Merge branch 'master' into comment
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/builtin.c b/builtin.c
index 6f8aeb36..585d53f1 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;