Commit 95bd6a79 authored by Linus Torvalds's avatar Linus Torvalds

revert to correct C99 behaviour

Cset exclude: bcrl@redhat.com|ChangeSet|20020429021546|12619
parent 82edfcdc
......@@ -172,41 +172,50 @@ static char * number(char * buf, char * end, long long num, int base, int size,
if (!(type&(ZEROPAD+LEFT))) {
while(size-->0) {
if (buf <= end)
*buf++ = ' ';
*buf = ' ';
++buf;
}
}
if (sign) {
if (buf <= end)
*buf++ = sign;
*buf = sign;
++buf;
}
if (type & SPECIAL) {
if (base==8) {
if (buf <= end)
*buf++ = '0';
*buf = '0';
++buf;
} else if (base==16) {
if (buf <= end)
*buf++ = '0';
*buf = '0';
++buf;
if (buf <= end)
*buf++ = digits[33];
*buf = digits[33];
++buf;
}
}
if (!(type & LEFT)) {
while (size-- > 0) {
if (buf <= end)
*buf++ = c;
*buf = c;
++buf;
}
}
while (i < precision--) {
if (buf <= end)
*buf++ = '0';
*buf = '0';
++buf;
}
while (i-- > 0) {
if (buf <= end)
*buf++ = tmp[i];
*buf = tmp[i];
++buf;
}
while (size-- > 0) {
if (buf <= end)
*buf++ = ' ';
*buf = ' ';
++buf;
}
return buf;
}
......@@ -238,10 +247,6 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
/* 'z' support added 23/7/1999 S.H. */
/* 'z' changed to 'Z' --davidm 1/25/99 */
/* Enforce absolute minimum size: one character + the trailing 0 */
if (size < 2)
return 0;
str = buf;
end = buf + size - 1;
......@@ -253,7 +258,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
for (; *fmt ; ++fmt) {
if (*fmt != '%') {
if (str <= end)
*str++ = *fmt;
*str = *fmt;
++str;
continue;
}
......@@ -317,15 +323,18 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
if (!(flags & LEFT)) {
while (--field_width > 0) {
if (str <= end)
*str++ = ' ';
*str = ' ';
++str;
}
}
c = (unsigned char) va_arg(args, int);
if (str <= end)
*str++ = c;
*str = c;
++str;
while (--field_width > 0) {
if (str <= end)
*str++ = ' ';
*str = ' ';
++str;
}
continue;
......@@ -339,16 +348,19 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
if (!(flags & LEFT)) {
while (len < field_width--) {
if (str <= end)
*str++ = ' ';
*str = ' ';
++str;
}
}
for (i = 0; i < len; ++i) {
if (str <= end)
*str++ = *s++;
*str = *s;
++str; ++s;
}
while (len < field_width--) {
if (str <= end)
*str++ = ' ';
*str = ' ';
++str;
}
continue;
......@@ -380,7 +392,8 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
case '%':
if (str <= end)
*str++ = '%';
*str = '%';
++str;
continue;
/* integer number formats - set up the flags and "break" */
......@@ -402,10 +415,12 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
default:
if (str <= end)
*str++ = '%';
*str = '%';
++str;
if (*fmt) {
if (str <= end)
*str++ = *fmt;
*str = *fmt;
++str;
} else {
--fmt;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment