summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-09-05 10:01:00 -0700
committerThiago Macieira <thiago.macieira@intel.com>2018-09-10 04:17:03 +0000
commitb66357e3ebf3e3dbda04f880e87184e247882843 (patch)
treede16a035badedcd747d41ddfb82916f80133264c /src/tools
parentc0e94fa0cd2a2e6216dae5da0dde289fb689d22d (diff)
moc: Fix compilation of text strings containing non-ASCII
On platforms where char is signed, like x86, the following is an error (narrowing conversion): unsigned char x[] = { '\xc3' }; Change-Id: I495bc19409f348069f5bfffd15518f9ef4e43faf Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/moc/cbordevice.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/tools/moc/cbordevice.h b/src/tools/moc/cbordevice.h
index 25b75b79eb..dbfc537dd2 100644
--- a/src/tools/moc/cbordevice.h
+++ b/src/tools/moc/cbordevice.h
@@ -82,8 +82,10 @@ private:
void putChar(char c)
{
putNewline();
- if (c < 0x20 || c >= 0x7f)
+ if (uchar(c) < 0x20)
fprintf(out, " '\\x%x',", uint8_t(c));
+ else if (uchar(c) >= 0x7f)
+ fprintf(out, " uchar('\\x%x'),", uint8_t(c));
else if (c == '\'' || c == '\\')
fprintf(out, " '\\%c',", c);
else