Piotr Caban : msvcrt: Added _set_output_format implementation.
Alexandre Julliard
julliard at winehq.org
Wed Mar 27 15:40:05 CDT 2013
Module: wine
Branch: master
Commit: 9c4be83a78c5a105d4e3305d9977c213a4503a84
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9c4be83a78c5a105d4e3305d9977c213a4503a84
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Mar 27 10:39:30 2013 +0100
msvcrt: Added _set_output_format implementation.
---
dlls/msvcr100/msvcr100.spec | 2 +-
dlls/msvcr110/msvcr110.spec | 2 +-
dlls/msvcr80/msvcr80.spec | 2 +-
dlls/msvcr90/msvcr90.spec | 2 +-
dlls/msvcrt/misc.c | 17 ++++++++++++++++-
dlls/msvcrt/msvcrt.h | 1 +
dlls/msvcrt/msvcrt.spec | 2 +-
dlls/msvcrt/printf.h | 23 +++++++++++++----------
include/msvcrt/stdio.h | 1 +
9 files changed, 36 insertions(+), 16 deletions(-)
diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 5938d54..93bddbf 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1270,7 +1270,7 @@
@ cdecl _set_fmode(long) msvcrt._set_fmode
@ cdecl _set_invalid_parameter_handler(ptr) msvcrt._set_invalid_parameter_handler
@ stub _set_malloc_crt_max_wait
-@ stub _set_output_format
+@ cdecl _set_output_format(long) msvcrt._set_output_format
@ cdecl _set_printf_count_output(long) msvcrt._set_printf_count_output
@ cdecl _set_purecall_handler(ptr) msvcrt._set_purecall_handler
@ cdecl _seterrormode(long) msvcrt._seterrormode
diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec
index 81b3fc2..7f6b0d9 100644
--- a/dlls/msvcr110/msvcr110.spec
+++ b/dlls/msvcr110/msvcr110.spec
@@ -1632,7 +1632,7 @@
@ cdecl _set_fmode(long) msvcrt._set_fmode
@ cdecl _set_invalid_parameter_handler(ptr) msvcrt._set_invalid_parameter_handler
@ stub _set_malloc_crt_max_wait
-@ stub _set_output_format
+@ cdecl _set_output_format(long) msvcrt._set_output_format
@ cdecl _set_printf_count_output(long) msvcrt._set_printf_count_output
@ cdecl _set_purecall_handler(ptr) msvcrt._set_purecall_handler
@ cdecl _seterrormode(long) msvcrt._seterrormode
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 6b7a318..a2e2929 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -931,7 +931,7 @@
@ cdecl _set_fmode(long) msvcrt._set_fmode
@ cdecl _set_invalid_parameter_handler(ptr) msvcrt._set_invalid_parameter_handler
@ stub _set_malloc_crt_max_wait
-@ stub _set_output_format
+@ cdecl _set_output_format(long) msvcrt._set_output_format
@ cdecl _set_printf_count_output(long) msvcrt._set_printf_count_output
@ cdecl _set_purecall_handler(ptr) msvcrt._set_purecall_handler
@ cdecl _set_sbh_threshold(long) msvcrt._set_sbh_threshold
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 81a265d..998349f 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -924,7 +924,7 @@
@ cdecl _set_fmode(long) msvcrt._set_fmode
@ cdecl _set_invalid_parameter_handler(ptr) msvcrt._set_invalid_parameter_handler
@ stub _set_malloc_crt_max_wait
-@ stub _set_output_format
+@ cdecl _set_output_format(long) msvcrt._set_output_format
@ cdecl _set_printf_count_output(long) msvcrt._set_printf_count_output
@ cdecl _set_purecall_handler(ptr) msvcrt._set_purecall_handler
@ cdecl _set_sbh_threshold(long) msvcrt._set_sbh_threshold
diff --git a/dlls/msvcrt/misc.c b/dlls/msvcrt/misc.c
index 2da2429..75e75e6 100644
--- a/dlls/msvcrt/misc.c
+++ b/dlls/msvcrt/misc.c
@@ -29,6 +29,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(msvcrt);
+static unsigned int output_format;
/*********************************************************************
* _beep (MSVCRT.@)
@@ -283,7 +284,21 @@ void CDECL MSVCRT_qsort_s(void *base, MSVCRT_size_t nmemb, MSVCRT_size_t size,
*/
unsigned int CDECL _get_output_format(void)
{
- return 0;
+ return output_format;
+}
+
+/*********************************************************************
+ * _set_output_format (MSVCRT.@)
+ */
+unsigned int CDECL _set_output_format(unsigned int new_output_format)
+{
+ unsigned int ret = output_format;
+
+ if(!MSVCRT_CHECK_PMT(new_output_format==0 || new_output_format==MSVCRT__TWO_DIGIT_EXPONENT))
+ return ret;
+
+ output_format = new_output_format;
+ return ret;
}
/*********************************************************************
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 3bbbe93..07e2984 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -982,6 +982,7 @@ int __cdecl MSVCRT__toupper_l(int,MSVCRT__locale_t);
int __cdecl MSVCRT__tolower_l(int,MSVCRT__locale_t);
int __cdecl MSVCRT__strnicoll_l(const char*, const char*, MSVCRT_size_t, MSVCRT__locale_t);
int __cdecl MSVCRT_strncoll_l(const char*, const char*, MSVCRT_size_t, MSVCRT__locale_t);
+unsigned int __cdecl _get_output_format(void);
/* Maybe one day we'll enable the invalid parameter handlers with the full set of information (msvcrXXd)
* #define MSVCRT_INVALID_PMT(x) MSVCRT_call_invalid_parameter_handler(x, __FUNCTION__, __FILE__, __LINE__, 0)
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index b6ae261..99072aa 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -894,7 +894,7 @@
@ cdecl _set_error_mode(long)
# stub _set_fileinfo(long)
@ cdecl _set_fmode(long)
-# stub _set_output_format(long)
+@ cdecl _set_output_format(long)
@ cdecl _set_sbh_threshold(long)
@ cdecl _seterrormode(long)
@ cdecl -arch=i386,x86_64,arm -norelay _setjmp(ptr) MSVCRT__setjmp
diff --git a/dlls/msvcrt/printf.h b/dlls/msvcrt/printf.h
index d02115e..3ccb1c4 100644
--- a/dlls/msvcrt/printf.h
+++ b/dlls/msvcrt/printf.h
@@ -307,22 +307,25 @@ static inline void FUNC_NAME(pf_fixup_exponent)(char *buf)
if(tmp[0] && (tmp[1]=='+' || tmp[1]=='-') &&
isdigit(tmp[2]) && isdigit(tmp[3])) {
- char final;
+ BOOL two_digit_exp = (_get_output_format() == MSVCRT__TWO_DIGIT_EXPONENT);
+
+ tmp += 2;
+ if(isdigit(tmp[2])) {
+ if(two_digit_exp && tmp[0]=='0') {
+ tmp[0] = tmp[1];
+ tmp[1] = tmp[2];
+ tmp[2] = tmp[3];
+ }
- if (isdigit(tmp[4]))
return; /* Exponent already 3 digits */
+ }else if(two_digit_exp) {
+ return;
+ }
- tmp += 2;
- final = tmp[2];
+ tmp[3] = tmp[2];
tmp[2] = tmp[1];
tmp[1] = tmp[0];
tmp[0] = '0';
-
- if(final == '\0') {
- tmp[3] = '\0';
- if(buf[0] == ' ')
- memmove(buf, buf + 1, (tmp - buf) + 3);
- }
}
}
diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h
index f6bf3b5..a01859e 100644
--- a/include/msvcrt/stdio.h
+++ b/include/msvcrt/stdio.h
@@ -182,6 +182,7 @@ int __cdecl vprintf_s(const char*,__ms_va_list);
int __cdecl vsprintf(char*,const char*,__ms_va_list);
int __cdecl vsprintf_s(char*,size_t,const char*,__ms_va_list);
unsigned int __cdecl _get_output_format(void);
+unsigned int __cdecl _set_output_format(void);
#ifndef _WSTDIO_DEFINED
#define _WSTDIO_DEFINED
More information about the wine-cvs
mailing list