Commit 9b63daca authored by Alexandre Julliard's avatar Alexandre Julliard

include: Default to the standards-compliant version of swprintf().

parent e79b0fd7
......@@ -246,14 +246,12 @@ wchar_t* __cdecl getws(wchar_t*);
wint_t __cdecl putwc(wint_t,FILE*);
wint_t __cdecl putwchar(wint_t);
int __cdecl putws(const wchar_t*);
int WINAPIV swprintf(wchar_t*,const wchar_t*,...);
int WINAPIV swprintf_s(wchar_t*,size_t,const wchar_t*,...);
int WINAPIV swscanf(const wchar_t*,const wchar_t*,...);
int WINAPIV swscanf_s(const wchar_t*,const wchar_t*,...);
wint_t __cdecl ungetwc(wint_t,FILE*);
int __cdecl vfwprintf(FILE*,const wchar_t*,__ms_va_list);
int __cdecl vfwprintf_s(FILE*,const wchar_t*,__ms_va_list);
int __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list);
int __cdecl vswprintf_s(wchar_t*,size_t,const wchar_t*,__ms_va_list);
int __cdecl vwprintf(const wchar_t*,__ms_va_list);
int __cdecl vwprintf_s(const wchar_t*,__ms_va_list);
......@@ -261,6 +259,24 @@ int WINAPIV wprintf(const wchar_t*,...);
int WINAPIV wprintf_s(const wchar_t*,...);
int WINAPIV wscanf(const wchar_t*,...);
int WINAPIV wscanf_s(const wchar_t*,...);
#ifdef _CRT_NON_CONFORMING_SWPRINTFS
int WINAPIV swprintf(wchar_t*,const wchar_t*,...);
int __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list);
#else /* _CRT_NON_CONFORMING_SWPRINTFS */
static inline int vswprintf(wchar_t *buffer, size_t size, const wchar_t *format, __ms_va_list args) { return _vsnwprintf(buffer,size,format,args); }
static inline int WINAPIV swprintf(wchar_t *buffer, size_t size, const wchar_t *format, ...)
{
int ret;
__ms_va_list args;
__ms_va_start(args, format);
ret = _vsnwprintf(buffer, size, format, args);
__ms_va_end(args);
return ret;
}
#endif /* _CRT_NON_CONFORMING_SWPRINTFS */
#endif /* _WSTDIO_DEFINED */
#endif /* _STDIO_DEFINED */
......
......@@ -357,14 +357,12 @@ wchar_t* __cdecl getws(wchar_t*);
wint_t __cdecl putwc(wint_t,FILE*);
wint_t __cdecl putwchar(wint_t);
int __cdecl putws(const wchar_t*);
int WINAPIV swprintf(wchar_t*,const wchar_t*,...);
int WINAPIV swprintf_s(wchar_t*,size_t,const wchar_t*,...);
int WINAPIV swscanf(const wchar_t*,const wchar_t*,...);
int WINAPIV swscanf_s(const wchar_t*,const wchar_t*,...);
wint_t __cdecl ungetwc(wint_t,FILE*);
int __cdecl vfwprintf(FILE*,const wchar_t*,__ms_va_list);
int __cdecl vfwprintf_s(FILE*,const wchar_t*,__ms_va_list);
int __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list);
int __cdecl vswprintf_s(wchar_t*,size_t,const wchar_t*,__ms_va_list);
int __cdecl vwprintf(const wchar_t*,__ms_va_list);
int __cdecl vwprintf_s(const wchar_t*,__ms_va_list);
......@@ -372,6 +370,23 @@ int WINAPIV wprintf(const wchar_t*,...);
int WINAPIV wprintf_s(const wchar_t*,...);
int WINAPIV wscanf(const wchar_t*,...);
int WINAPIV wscanf_s(const wchar_t*,...);
#ifdef _CRT_NON_CONFORMING_SWPRINTFS
int WINAPIV swprintf(wchar_t*,const wchar_t*,...);
int __cdecl vswprintf(wchar_t*,const wchar_t*,__ms_va_list);
#else /* _CRT_NON_CONFORMING_SWPRINTFS */
static inline int vswprintf(wchar_t *buffer, size_t size, const wchar_t *format, __ms_va_list args) { return _vsnwprintf(buffer,size,format,args); }
static inline int WINAPIV swprintf(wchar_t *buffer, size_t size, const wchar_t *format, ...)
{
int ret;
__ms_va_list args;
__ms_va_start(args, format);
ret = _vsnwprintf(buffer, size, format, args);
__ms_va_end(args);
return ret;
}
#endif /* _CRT_NON_CONFORMING_SWPRINTFS */
#endif /* _WSTDIO_DEFINED */
#ifndef _WSTDLIB_DEFINED
......
......@@ -92,7 +92,7 @@ static size_t export_value_name(HANDLE hFile, WCHAR *name, size_t len)
{
WCHAR *str = escape_string(name, len, &line_len);
WCHAR *buf = heap_xalloc((line_len + 4) * sizeof(WCHAR));
line_len = swprintf(buf, quoted_fmt, str);
line_len = swprintf(buf, line_len + 4, quoted_fmt, str);
write_file(hFile, buf);
heap_free(buf);
heap_free(str);
......@@ -116,7 +116,7 @@ static void export_string_data(WCHAR **buf, WCHAR *data, size_t size)
len = size / sizeof(WCHAR) - 1;
str = escape_string(data, len, &line_len);
*buf = heap_xalloc((line_len + 3) * sizeof(WCHAR));
swprintf(*buf, fmt, str);
swprintf(*buf, line_len + 3, fmt, str);
heap_free(str);
}
......@@ -125,7 +125,7 @@ static void export_dword_data(WCHAR **buf, DWORD *data)
static const WCHAR fmt[] = {'d','w','o','r','d',':','%','0','8','x',0};
*buf = heap_xalloc(15 * sizeof(WCHAR));
swprintf(*buf, fmt, *data);
swprintf(*buf, 15, fmt, *data);
}
static size_t export_hex_data_type(HANDLE hFile, DWORD type)
......@@ -142,7 +142,7 @@ static size_t export_hex_data_type(HANDLE hFile, DWORD type)
else
{
WCHAR *buf = heap_xalloc(15 * sizeof(WCHAR));
line_len = swprintf(buf, hexp_fmt, type);
line_len = swprintf(buf, 15, hexp_fmt, type);
write_file(hFile, buf);
heap_free(buf);
}
......@@ -168,7 +168,7 @@ static void export_hex_data(HANDLE hFile, WCHAR **buf, DWORD type,
for (i = 0, pos = 0; i < size; i++)
{
pos += swprintf(*buf + pos, fmt, ((BYTE *)data)[i]);
pos += swprintf(*buf + pos, 3, fmt, ((BYTE *)data)[i]);
if (i == num_commas) break;
(*buf)[pos++] = ',';
(*buf)[pos] = 0;
......@@ -233,7 +233,7 @@ static void export_key_name(HANDLE hFile, WCHAR *name)
WCHAR *buf;
buf = heap_xalloc((lstrlenW(name) + 7) * sizeof(WCHAR));
swprintf(buf, fmt, name);
swprintf(buf, lstrlenW(name) + 7, fmt, name);
write_file(hFile, buf);
heap_free(buf);
}
......
......@@ -539,7 +539,7 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes)
buffer = heap_xalloc((size_bytes * 2 + 1) * sizeof(WCHAR));
ptr = buffer;
for (i = 0; i < size_bytes; i++)
ptr += swprintf(ptr, fmt, src[i]);
ptr += swprintf(ptr, 3, fmt, src[i]);
break;
}
case REG_DWORD:
......@@ -550,7 +550,7 @@ static WCHAR *reg_data_to_wchar(DWORD type, const BYTE *src, DWORD size_bytes)
static const WCHAR fmt[] = {'0','x','%','x',0};
buffer = heap_xalloc((zero_x_dword + 1) * sizeof(WCHAR));
swprintf(buffer, fmt, *(DWORD *)src);
swprintf(buffer, zero_x_dword + 1, fmt, *(DWORD *)src);
break;
}
case REG_MULTI_SZ:
......@@ -635,7 +635,7 @@ WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name, DWORD
static const WCHAR fmt[] = {'%','s','\\','%','s',0};
subkey_path = heap_xalloc((path_len + subkey_len + 2) * sizeof(WCHAR));
swprintf(subkey_path, fmt, path, subkey_name);
swprintf(subkey_path, path_len + subkey_len + 2, fmt, path, subkey_name);
return subkey_path;
}
......@@ -856,7 +856,7 @@ static WCHAR *get_long_key(HKEY root, WCHAR *path)
len += lstrlenW(path) + 1; /* add one for the backslash */
long_key = heap_xalloc((len + 1) * sizeof(WCHAR));
swprintf(long_key, fmt, root_rels[i].long_name, path);
swprintf(long_key, len + 1, fmt, root_rels[i].long_name, path);
return long_key;
}
......
......@@ -426,7 +426,8 @@ static BOOL InitOpenFileName(HWND hWnd, OPENFILENAMEW *pofn)
LoadStringW(hInst, IDS_FILEDIALOG_FILTER_REG, filter_reg, MAX_PATH);
LoadStringW(hInst, IDS_FILEDIALOG_FILTER_REG4, filter_reg4, MAX_PATH);
LoadStringW(hInst, IDS_FILEDIALOG_FILTER_ALL, filter_all, MAX_PATH);
swprintf( FilterBuffer, filterW, filter_reg, 0, 0, filter_reg4, 0, 0, filter_all, 0, 0 );
swprintf( FilterBuffer, ARRAY_SIZE(FilterBuffer), filterW,
filter_reg, 0, 0, filter_reg4, 0, 0, filter_all, 0, 0 );
}
pofn->lpstrFilter = FilterBuffer;
pofn->nFilterIndex = 1;
......
......@@ -1216,7 +1216,7 @@ static size_t export_value_name(FILE *fp, WCHAR *name, size_t len, BOOL unicode)
{
WCHAR *str = REGPROC_escape_string(name, len, &line_len);
WCHAR *buf = heap_xalloc((line_len + 4) * sizeof(WCHAR));
line_len = swprintf(buf, quoted_fmt, str);
line_len = swprintf(buf, line_len + 4, quoted_fmt, str);
REGPROC_write_line(fp, buf, unicode);
heap_free(buf);
heap_free(str);
......@@ -1240,7 +1240,7 @@ static void export_string_data(WCHAR **buf, WCHAR *data, size_t size)
len = size / sizeof(WCHAR) - 1;
str = REGPROC_escape_string(data, len, &line_len);
*buf = heap_xalloc((line_len + 3) * sizeof(WCHAR));
swprintf(*buf, fmt, str);
swprintf(*buf, line_len + 3, fmt, str);
heap_free(str);
}
......@@ -1249,7 +1249,7 @@ static void export_dword_data(WCHAR **buf, DWORD *data)
static const WCHAR fmt[] = {'d','w','o','r','d',':','%','0','8','x',0};
*buf = heap_xalloc(15 * sizeof(WCHAR));
swprintf(*buf, fmt, *data);
swprintf(*buf, 15, fmt, *data);
}
static size_t export_hex_data_type(FILE *fp, DWORD type, BOOL unicode)
......@@ -1266,7 +1266,7 @@ static size_t export_hex_data_type(FILE *fp, DWORD type, BOOL unicode)
else
{
WCHAR *buf = heap_xalloc(15 * sizeof(WCHAR));
line_len = swprintf(buf, hexp_fmt, type);
line_len = swprintf(buf, 15, hexp_fmt, type);
REGPROC_write_line(fp, buf, unicode);
heap_free(buf);
}
......@@ -1295,7 +1295,7 @@ static void export_hex_data(FILE *fp, WCHAR **buf, DWORD type, DWORD line_len,
for (i = 0, pos = 0; i < size; i++)
{
pos += swprintf(*buf + pos, fmt, ((BYTE *)data)[i]);
pos += swprintf(*buf + pos, 3, fmt, ((BYTE *)data)[i]);
if (i == num_commas) break;
(*buf)[pos++] = ',';
(*buf)[pos] = 0;
......@@ -1360,7 +1360,7 @@ static WCHAR *build_subkey_path(WCHAR *path, DWORD path_len, WCHAR *subkey_name,
static const WCHAR fmt[] = {'%','s','\\','%','s',0};
subkey_path = heap_xalloc((path_len + subkey_len + 2) * sizeof(WCHAR));
swprintf(subkey_path, fmt, path, subkey_name);
swprintf(subkey_path, path_len + subkey_len + 2, fmt, path, subkey_name);
return subkey_path;
}
......@@ -1371,7 +1371,7 @@ static void export_key_name(FILE *fp, WCHAR *name, BOOL unicode)
WCHAR *buf;
buf = heap_xalloc((lstrlenW(name) + 7) * sizeof(WCHAR));
swprintf(buf, fmt, name);
swprintf(buf, lstrlenW(name) + 7, fmt, name);
REGPROC_write_line(fp, buf, unicode);
heap_free(buf);
}
......
......@@ -83,15 +83,15 @@ static void Graph_DrawCpuUsageGraph(HDC hDC, HWND hWnd)
*/
if (CpuUsage == 100)
{
swprintf(Text, wszFormatI, (int)CpuUsage);
swprintf(Text, ARRAY_SIZE(Text), wszFormatI, (int)CpuUsage);
}
else if (CpuUsage < 10)
{
swprintf(Text, wszFormatII, (int)CpuUsage);
swprintf(Text, ARRAY_SIZE(Text), wszFormatII, (int)CpuUsage);
}
else
{
swprintf(Text, wszFormatIII, (int)CpuUsage);
swprintf(Text, ARRAY_SIZE(Text), wszFormatIII, (int)CpuUsage);
}
/*
......
......@@ -698,7 +698,7 @@ LPWSTR GetLastErrorText(LPWSTR lpwszBuf, DWORD dwSize)
lpwszBuf[0] = '\0';
} else {
lpwszTemp[lstrlenW(lpwszTemp)-2] = '\0'; /* remove cr and newline character */
swprintf(lpwszBuf, wszFormat, lpwszTemp, GetLastError());
swprintf(lpwszBuf, dwSize, wszFormat, lpwszTemp, GetLastError());
}
if (lpwszTemp) {
LocalFree(lpwszTemp);
......
......@@ -1382,7 +1382,7 @@ static void number_with_units(LPWSTR buffer, int number)
static const WCHAR fmt[] = {'%','.','2','f',' ','%','s','\0'};
float converted = (float)number / (float)TWIPS_PER_INCH *(float)CENTMM_PER_INCH / 1000.0;
swprintf(buffer, fmt, converted, units_cmW);
swprintf(buffer, MAX_STRING_LEN, fmt, converted, units_cmW);
}
static BOOL get_comboexlist_selection(HWND hComboEx, LPWSTR wszBuffer, UINT bufferLength)
......
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