CVS: winex/dlls/ntdll wcstring.c,1.7,1.8
[email protected] 14 Dec 2007 20:19:25 -0000
| Newsgroups | gmane.comp.emulators.winex.cvs |
|---|---|
| Message-ID | <[email protected]> |
Subject: winex/dlls/ntdll wcstring.c,1.7,1.8Update of /var/lib/cvsd/cvsroot/winex/dlls/ntdll
In directory agravaine:/tmp/cvs-serv15429/dlls/ntdll
Modified Files:
wcstring.c
Log Message:
Moved the wide-character sprintf implementations in ntdll and msvcrt into
libwine_unicode.
Index: wcstring.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/dlls/ntdll/wcstring.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- wcstring.c 2 Mar 2007 18:25:17 -0000 1.7
+++ wcstring.c 14 Dec 2007 20:19:23 -0000 1.8
@@ -410,131 +410,11 @@
* _vsnwprintf (NTDLL.@)
*
* Wide char snprintf
- * If you fix a bug in this function, fix it in msvcrt/wcs.c also!
*/
INT __cdecl NTDLL_vsnwprintf(WCHAR *str, unsigned int len,
const WCHAR *format, va_list valist)
{
- unsigned int written = 0;
- const WCHAR *iter = format;
- char bufa[256], fmtbufa[64], *fmta;
-
- TRACE("(%d,%s)\n",len,debugstr_w(format));
-
- while (*iter)
- {
- while (*iter && *iter != (WCHAR)L'%')
- {
- if (written++ >= len)
- return -1;
- *str++ = *iter++;
- }
- if (*iter == (WCHAR)L'%')
- {
- fmta = fmtbufa;
- *fmta++ = *iter++;
- while (*iter == (WCHAR)L'0' ||
- *iter == (WCHAR)L'+' ||
- *iter == (WCHAR)L'-' ||
- *iter == (WCHAR)L' ' ||
- *iter == (WCHAR)L'0' ||
- *iter == (WCHAR)L'*' ||
- *iter == (WCHAR)L'#')
- {
- if (*iter == (WCHAR)L'*')
- {
- char *buffiter = bufa;
- int fieldlen = va_arg(valist, int);
- sprintf(buffiter, "%d", fieldlen);
- while (*buffiter)
- *fmta++ = *buffiter++;
- }
- else
- *fmta++ = *iter;
- iter++;
- }
-
- while (isdigit(*iter))
- *fmta++ = *iter++;
-
- if (*iter == (WCHAR)L'.')
- {
- *fmta++ = *iter++;
- if (*iter == (WCHAR)L'*')
- {
- char *buffiter = bufa;
- int fieldlen = va_arg(valist, int);
- sprintf(buffiter, "%d", fieldlen);
- while (*buffiter)
- *fmta++ = *buffiter++;
- }
- else
- while (isdigit(*iter))
- *fmta++ = *iter++;
- }
- if (*iter == (WCHAR)L'h' ||
- *iter == (WCHAR)L'l')
- {
- *fmta++ = *iter++;
- *fmta++ = *iter++;
- }
-
- switch (*iter)
- {
- case (WCHAR)L's':
- {
- static const WCHAR none[] = { '(', 'n', 'u', 'l', 'l', ')', 0 };
- const WCHAR *wstr = va_arg(valist, const WCHAR *);
- const WCHAR *striter = wstr ? wstr : none;
- while (*striter)
- {
- if (written++ >= len)
- return -1;
- *str++ = *striter++;
- }
- iter++;
- break;
- }
-
- case (WCHAR)L'c':
- if (written++ >= len)
- return -1;
- *str++ = (WCHAR)va_arg(valist, int);
- iter++;
- break;
-
- default:
- {
- /* For non wc types, use system sprintf and append to wide char output */
- /* FIXME: for unrecognised types, should ignore % when printing */
- char *bufaiter = bufa;
- if (*iter == (WCHAR)L'p')
- sprintf(bufaiter, "%08lX", va_arg(valist, long));
- else
- {
- *fmta++ = *iter;
- *fmta = '\0';
- if (*iter == (WCHAR)L'f')
- sprintf(bufaiter, fmtbufa, va_arg(valist, double));
- else
- sprintf(bufaiter, fmtbufa, va_arg(valist, void *));
- }
- while (*bufaiter)
- {
- if (written++ >= len)
- return -1;
- *str++ = *bufaiter++;
- }
- iter++;
- break;
- }
- }
- }
- }
- if (written >= len)
- return -1;
- *str++ = (WCHAR)L'\0';
- return (int)written;
+ return vsnprintfW(str, len, format, valist);
}
/***********************************************************************