Piotr Caban : msvcrt: Add support for locales in scanf helper functions.
Alexandre Julliard
julliard at winehq.org
Thu Apr 22 11:24:02 CDT 2010
Module: wine
Branch: master
Commit: 231fc1145772011aae5a73ebaf9b911756302393
URL: http://source.winehq.org/git/wine.git/?a=commit;h=231fc1145772011aae5a73ebaf9b911756302393
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Apr 22 13:48:49 2010 +0200
msvcrt: Add support for locales in scanf helper functions.
---
dlls/msvcrt/scanf.c | 24 ++++++++++++------------
dlls/msvcrt/scanf.h | 17 ++++++++++-------
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/dlls/msvcrt/scanf.c b/dlls/msvcrt/scanf.c
index 8959897..8cbe964 100644
--- a/dlls/msvcrt/scanf.c
+++ b/dlls/msvcrt/scanf.c
@@ -57,31 +57,31 @@ static int wchar2digit(MSVCRT_wchar_t c, int base) {
return -1;
}
-/* vfscanf */
+/* vfscanf_l */
#undef WIDE_SCANF
#undef CONSOLE
#undef STRING
#include "scanf.h"
-/* vfwscanf */
+/* vfwscanf_l */
#define WIDE_SCANF 1
#undef CONSOLE
#undef STRING
#include "scanf.h"
-/* vsscanf */
+/* vsscanf_l */
#undef WIDE_SCANF
#undef CONSOLE
#define STRING 1
#include "scanf.h"
-/* vswscanf */
+/* vswscanf_l */
#define WIDE_SCANF 1
#undef CONSOLE
#define STRING 1
#include "scanf.h"
-/* vcscanf */
+/* vcscanf_l */
#undef WIDE_SCANF
#define CONSOLE 1
#undef STRING
@@ -97,7 +97,7 @@ int CDECL MSVCRT_fscanf(MSVCRT_FILE *file, const char *format, ...)
int res;
__ms_va_start(valist, format);
- res = MSVCRT_vfscanf(file, format, valist);
+ res = MSVCRT_vfscanf_l(file, format, NULL, valist);
__ms_va_end(valist);
return res;
}
@@ -111,7 +111,7 @@ int CDECL MSVCRT_scanf(const char *format, ...)
int res;
__ms_va_start(valist, format);
- res = MSVCRT_vfscanf(MSVCRT_stdin, format, valist);
+ res = MSVCRT_vfscanf_l(MSVCRT_stdin, format, NULL, valist);
__ms_va_end(valist);
return res;
}
@@ -125,7 +125,7 @@ int CDECL MSVCRT_fwscanf(MSVCRT_FILE *file, const MSVCRT_wchar_t *format, ...)
int res;
__ms_va_start(valist, format);
- res = MSVCRT_vfwscanf(file, format, valist);
+ res = MSVCRT_vfwscanf_l(file, format, NULL, valist);
__ms_va_end(valist);
return res;
}
@@ -140,7 +140,7 @@ int CDECL MSVCRT_wscanf(const MSVCRT_wchar_t *format, ...)
int res;
__ms_va_start(valist, format);
- res = MSVCRT_vfwscanf(MSVCRT_stdin, format, valist);
+ res = MSVCRT_vfwscanf_l(MSVCRT_stdin, format, NULL, valist);
__ms_va_end(valist);
return res;
}
@@ -155,7 +155,7 @@ int CDECL MSVCRT_sscanf(const char *str, const char *format, ...)
int res;
__ms_va_start(valist, format);
- res = MSVCRT_vsscanf(str, format, valist);
+ res = MSVCRT_vsscanf_l(str, format, NULL, valist);
__ms_va_end(valist);
return res;
}
@@ -170,7 +170,7 @@ int CDECL MSVCRT_swscanf(const MSVCRT_wchar_t *str, const MSVCRT_wchar_t *format
int res;
__ms_va_start(valist, format);
- res = MSVCRT_vswscanf(str, format, valist);
+ res = MSVCRT_vswscanf_l(str, format, NULL, valist);
__ms_va_end(valist);
return res;
}
@@ -185,7 +185,7 @@ int CDECL _cscanf(const char *format, ...)
int res;
__ms_va_start(valist, format);
- res = MSVCRT_vcscanf(format, valist);
+ res = MSVCRT_vcscanf_l(format, NULL, valist);
__ms_va_end(valist);
return res;
}
diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h
index 953c133..086854f 100644
--- a/dlls/msvcrt/scanf.h
+++ b/dlls/msvcrt/scanf.h
@@ -48,7 +48,7 @@
#ifdef CONSOLE
#define _GETC_(file) (consumed++, _getch())
#define _UNGETC_(nch, file) do { _ungetch(nch); consumed--; } while(0)
-#define _FUNCTION_ static int MSVCRT_vcscanf(const char *format, __ms_va_list ap)
+#define _FUNCTION_ static int MSVCRT_vcscanf_l(const char *format, MSVCRT__locale_t locale, __ms_va_list ap)
#else
#ifdef STRING
#undef _EOF_
@@ -56,19 +56,19 @@
#define _GETC_(file) (consumed++, *file++)
#define _UNGETC_(nch, file) do { file--; consumed--; } while(0)
#ifdef WIDE_SCANF
-#define _FUNCTION_ static int MSVCRT_vswscanf(const MSVCRT_wchar_t *file, const MSVCRT_wchar_t *format, __ms_va_list ap)
+#define _FUNCTION_ static int MSVCRT_vswscanf_l(const MSVCRT_wchar_t *file, const MSVCRT_wchar_t *format, MSVCRT__locale_t locale, __ms_va_list ap)
#else /* WIDE_SCANF */
-#define _FUNCTION_ static int MSVCRT_vsscanf(const char *file, const char *format, __ms_va_list ap)
+#define _FUNCTION_ static int MSVCRT_vsscanf_l(const char *file, const char *format, MSVCRT__locale_t locale, __ms_va_list ap)
#endif /* WIDE_SCANF */
#else /* STRING */
#ifdef WIDE_SCANF
#define _GETC_(file) (consumed++, MSVCRT_fgetwc(file))
#define _UNGETC_(nch, file) do { MSVCRT_ungetwc(nch, file); consumed--; } while(0)
-#define _FUNCTION_ static int MSVCRT_vfwscanf(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, __ms_va_list ap)
+#define _FUNCTION_ static int MSVCRT_vfwscanf_l(MSVCRT_FILE* file, const MSVCRT_wchar_t *format, MSVCRT__locale_t locale, __ms_va_list ap)
#else /* WIDE_SCANF */
#define _GETC_(file) (consumed++, MSVCRT_fgetc(file))
#define _UNGETC_(nch, file) do { MSVCRT_ungetc(nch, file); consumed--; } while(0)
-#define _FUNCTION_ static int MSVCRT_vfscanf(MSVCRT_FILE* file, const char *format, __ms_va_list ap)
+#define _FUNCTION_ static int MSVCRT_vfscanf_l(MSVCRT_FILE* file, const char *format, MSVCRT__locale_t locale, __ms_va_list ap)
#endif /* WIDE_SCANF */
#endif /* STRING */
#endif /* CONSOLE */
@@ -91,6 +91,9 @@ _FUNCTION_ {
nch = _GETC_(file);
if (nch == _EOF_) return _EOF_RET;
+ if(!locale)
+ locale = get_locale();
+
while (*format) {
/* a whitespace character in the format string causes scanf to read,
* but not store, all consecutive white-space characters in the input
@@ -250,7 +253,7 @@ _FUNCTION_ {
nch = _GETC_(file);
}
/* get first digit. */
- if ('.' != nch) {
+ if (*locale->locinfo->lconv->decimal_point != nch) {
if (!_ISDIGIT_(nch)) break;
cur = (nch - '0');
nch = _GETC_(file);
@@ -265,7 +268,7 @@ _FUNCTION_ {
cur = 0; /* MaxPayneDemo Fix: .8 -> 0.8 */
}
/* handle decimals */
- if (width!=0 && nch == '.') {
+ if (width!=0 && nch == *locale->locinfo->lconv->decimal_point) {
long double dec = 1;
nch = _GETC_(file);
if (width>0) width--;
More information about the wine-cvs
mailing list