fixing some bugs for %c in the string version of printf

svn path=/trunk/; revision=22257
This commit is contained in:
Magnus Olsen 2006-06-06 23:01:44 +00:00
parent dd221de709
commit 9c696e1c9e
2 changed files with 24 additions and 37 deletions

View file

@ -477,27 +477,20 @@ int _vsnprintf(char *buf, size_t cnt, const char *fmt, va_list args)
switch (*fmt) {
case 'c': /* finished */
if (!(flags & LEFT))
while (--field_width > 0) {
if (str <= end)
*str = ' ';
++str;
}
if (qualifier == 'l' || qualifier == 'w') {
if (str <= end)
*str = (unsigned char)(wchar_t) va_arg(args, int);
++str;
if (qualifier == 'l' || qualifier == 'w') {
wchar_t sw1[2];
/* print unicode string */
sw1[0] = (wchar_t) va_arg(args, int);
sw1[1] = 0;
str = stringw(str, end, (wchar_t *)&sw1, -1, field_width, precision, flags);
} else {
if (str <= end)
*str = (unsigned char) va_arg(args, int);
++str;
char s1[2];
/* print ascii string */
s1[0] = ( unsigned char) va_arg(args, int);
s1[1] = 0;
str = string(str, end, (char *)&s1, -1, field_width, precision, flags);
}
while (--field_width > 0) {
if (str <= end)
*str = ' ';
++str;
}
continue;
continue;
case 'C': /* finished */
if (!(flags & LEFT))

View file

@ -475,26 +475,20 @@ int _vsnwprintf(wchar_t *buf, size_t cnt, const wchar_t *fmt, va_list args)
switch (*fmt) {
case L'c':
if (!(flags & LEFT))
while (--field_width > 0) {
if (str <= end)
*str = L' ';
++str;
}
if (qualifier == 'h') {
if (str <= end)
*str = (wchar_t) va_arg(args, int);
++str;
if (qualifier == 'h' || qualifier == 'w') {
wchar_t sw1[2];
/* print unicode string */
sw1[0] = (wchar_t) va_arg(args, int);
sw1[1] = 0;
str = stringw(str, end, (wchar_t *)&sw1, -1, field_width, precision, flags);
} else {
if (str <= end)
*str = (wchar_t) va_arg(args, int);
++str;
}
while (--field_width > 0) {
if (str <= end)
*str = L' ';
++str;
char s1[2];
/* print ascii string */
s1[0] = ( unsigned char) va_arg(args, int);
s1[1] = 0;
str = string(str, end, (char *)&s1, -1, field_width, precision, flags);
}
continue;
case L'C':