Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/smallprint.cc')
-rw-r--r--winsup/cygwin/smallprint.cc35
1 files changed, 26 insertions, 9 deletions
diff --git a/winsup/cygwin/smallprint.cc b/winsup/cygwin/smallprint.cc
index fa7706b47..1ca7ca817 100644
--- a/winsup/cygwin/smallprint.cc
+++ b/winsup/cygwin/smallprint.cc
@@ -147,15 +147,15 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
continue;
case 'c':
{
- unsigned char c = (va_arg (ap, int) & 0xff);
- if (isprint (c) || pad != '0')
+ int c = va_arg (ap, int);
+ if (c > ' ' && c <= 127)
*dst++ = c;
else
- {
- *dst++ = '0';
- *dst++ = 'x';
- dst = __rn (dst, 16, 0, c, len, pad, LMASK);
- }
+ {
+ *dst++ = '0';
+ *dst++ = 'x';
+ dst = __rn (dst, 16, 0, c, len, pad, LMASK);
+ }
}
break;
case 'C':
@@ -164,7 +164,14 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
char buf[4], *c;
sys_wcstombs (buf, 4, &wc, 1);
for (c = buf; *c; ++c)
- *dst++ = *c;
+ if (isprint (*c))
+ *dst++ = *c;
+ else
+ {
+ *dst++ = '0';
+ *dst++ = 'x';
+ dst = __rn (dst, 16, 0, *c, len, pad, LMASK);
+ }
}
case 'E':
strcpy (dst, "Win32 error ");
@@ -438,7 +445,17 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
continue;
case L'c':
case L'C':
- *dst++ = va_arg (ap, unsigned);
+ {
+ unsigned int c = va_arg (ap, unsigned int);
+ if (c > L' ' && c <= 127)
+ *dst++ = c;
+ else
+ {
+ *dst++ = L'0';
+ *dst++ = L'x';
+ dst = __wrn (dst, 16, 0, c, len, pad, LMASK);
+ }
+ }
break;
case L'E':
wcscpy (dst, L"Win32 error ");