vsnprintfW: %% should output a literal % sign.

This commit is contained in:
Jon Griffiths 2003-07-19 03:05:28 +00:00 committed by Alexandre Julliard
parent d7eea36441
commit 0aefd857b7
1 changed files with 11 additions and 2 deletions

View File

@ -160,7 +160,7 @@ long int strtolW( const WCHAR *nptr, WCHAR **endptr, int base )
noconv: noconv:
/* We must handle a special case here: the base is 0 or 16 and the /* We must handle a special case here: the base is 0 or 16 and the
first two characters are '0' and 'x', but the rest are no first two characters are '0' and 'x', but the rest are not
hexadecimal digits. This is no error case. We return 0 and hexadecimal digits. This is no error case. We return 0 and
ENDPTR points to the `x`. */ ENDPTR points to the `x`. */
if (endptr != NULL) if (endptr != NULL)
@ -272,7 +272,7 @@ unsigned long int strtoulW( const WCHAR *nptr, WCHAR **endptr, int base )
noconv: noconv:
/* We must handle a special case here: the base is 0 or 16 and the /* We must handle a special case here: the base is 0 or 16 and the
first two characters are '0' and 'x', but the rest are no first two characters are '0' and 'x', but the rest are not
hexadecimal digits. This is no error case. We return 0 and hexadecimal digits. This is no error case. We return 0 and
ENDPTR points to the `x`. */ ENDPTR points to the `x`. */
if (endptr != NULL) if (endptr != NULL)
@ -305,6 +305,15 @@ int vsnprintfW(WCHAR *str, size_t len, const WCHAR *format, va_list valist)
} }
if (*iter == '%') if (*iter == '%')
{ {
if (iter[1] == '%')
{
if (written++ >= len)
return -1;
*str++ = '%'; /* "%%"->'%' */
iter += 2;
continue;
}
fmta = fmtbufa; fmta = fmtbufa;
*fmta++ = *iter++; *fmta++ = *iter++;
while (*iter == '0' || while (*iter == '0' ||