From: Piotr Caban piotr@codeweavers.com
--- dlls/msvcrt/exit.c | 2 +- dlls/msvcrt/file.c | 56 ++++++++++++++++++++++---------------------- dlls/msvcrt/msvcrt.h | 9 ++++--- dlls/msvcrt/scanf.c | 16 ++++++------- dlls/msvcrt/scanf.h | 4 ++-- 5 files changed, 43 insertions(+), 44 deletions(-)
diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c index cf1e7caeb06..c8db6c405da 100644 --- a/dlls/msvcrt/exit.c +++ b/dlls/msvcrt/exit.c @@ -302,7 +302,7 @@ void DECLSPEC_NORETURN CDECL _wassert(const wchar_t* str, const wchar_t* file, u DoMessageBoxW(L"Assertion failed!", text); } else - fwprintf(MSVCRT_stderr, L"Assertion failed: %ls, file %ls, line %d\n\n", str, file, line); + fwprintf(stderr, L"Assertion failed: %ls, file %ls, line %d\n\n", str, file, line);
raise(SIGABRT); _exit(3); diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 24cca6fb63e..2075d0b4288 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -3915,7 +3915,7 @@ int CDECL _fgetc_nolock(FILE* file) */ int CDECL _fgetchar(void) { - return fgetc(MSVCRT_stdin); + return fgetc(stdin); }
/********************************************************************* @@ -4047,7 +4047,7 @@ wint_t CDECL getwc(FILE* file) */ wint_t CDECL _fgetwchar(void) { - return fgetwc(MSVCRT_stdin); + return fgetwc(stdin); }
/********************************************************************* @@ -4266,7 +4266,7 @@ wint_t CDECL _fputwc_nolock(wint_t wc, FILE* file) */ wint_t CDECL _fputwchar(wint_t wc) { - return fputwc(wc, MSVCRT_stdout); + return fputwc(wc, stdout); }
/********************************************************************* @@ -4424,7 +4424,7 @@ int CDECL _fputc_nolock(int c, FILE* file) */ int CDECL _fputchar(int c) { - return fputc(c, MSVCRT_stdout); + return fputc(c, stdout); }
/********************************************************************* @@ -4839,7 +4839,7 @@ int CDECL fputws(const wchar_t *s, FILE* file) */ int CDECL getchar(void) { - return fgetc(MSVCRT_stdin); + return fgetc(stdin); }
/********************************************************************* @@ -4861,10 +4861,10 @@ char * CDECL gets_s(char *buf, size_t len) if (!MSVCRT_CHECK_PMT(buf != NULL)) return NULL; if (!MSVCRT_CHECK_PMT(len != 0)) return NULL;
- _lock_file(MSVCRT_stdin); - for(cc = _fgetc_nolock(MSVCRT_stdin); + _lock_file(stdin); + for(cc = _fgetc_nolock(stdin); len != 0 && cc != EOF && cc != '\n'; - cc = _fgetc_nolock(MSVCRT_stdin)) + cc = _fgetc_nolock(stdin)) { if (cc != '\r') { @@ -4872,7 +4872,7 @@ char * CDECL gets_s(char *buf, size_t len) len--; } } - _unlock_file(MSVCRT_stdin); + _unlock_file(stdin);
if (!len) { @@ -4908,14 +4908,14 @@ wchar_t* CDECL _getws(wchar_t* buf) wint_t cc; wchar_t* ws = buf;
- _lock_file(MSVCRT_stdin); - for (cc = _fgetwc_nolock(MSVCRT_stdin); cc != WEOF && cc != '\n'; - cc = _fgetwc_nolock(MSVCRT_stdin)) + _lock_file(stdin); + for (cc = _fgetwc_nolock(stdin); cc != WEOF && cc != '\n'; + cc = _fgetwc_nolock(stdin)) { if (cc != '\r') *buf++ = (wchar_t)cc; } - _unlock_file(MSVCRT_stdin); + _unlock_file(stdin);
if ((cc == WEOF) && (ws == buf)) { @@ -4941,7 +4941,7 @@ int CDECL putc(int c, FILE* file) */ int CDECL putchar(int c) { - return fputc(c, MSVCRT_stdout); + return fputc(c, stdout); }
/********************************************************************* @@ -4952,14 +4952,14 @@ int CDECL puts(const char *s) size_t len = strlen(s); int ret;
- _lock_file(MSVCRT_stdout); - if(_fwrite_nolock(s, sizeof(*s), len, MSVCRT_stdout) != len) { - _unlock_file(MSVCRT_stdout); + _lock_file(stdout); + if(_fwrite_nolock(s, sizeof(*s), len, stdout) != len) { + _unlock_file(stdout); return EOF; }
- ret = _fwrite_nolock("\n",1,1,MSVCRT_stdout) == 1 ? 0 : EOF; - _unlock_file(MSVCRT_stdout); + ret = _fwrite_nolock("\n",1,1,stdout) == 1 ? 0 : EOF; + _unlock_file(stdout); return ret; }
@@ -4970,11 +4970,11 @@ int CDECL _putws(const wchar_t *s) { int ret;
- _lock_file(MSVCRT_stdout); - ret = fputws(s, MSVCRT_stdout); + _lock_file(stdout); + ret = fputws(s, stdout); if(ret >= 0) - ret = _fputwc_nolock('\n', MSVCRT_stdout); - _unlock_file(MSVCRT_stdout); + ret = _fputwc_nolock('\n', stdout); + _unlock_file(stdout); return ret >= 0 ? 0 : WEOF; }
@@ -5546,7 +5546,7 @@ int CDECL _vfwprintf_p(FILE* file, const wchar_t *format, va_list valist) */ int CDECL vprintf(const char *format, va_list valist) { - return vfprintf(MSVCRT_stdout,format,valist); + return vfprintf(stdout,format,valist); }
/********************************************************************* @@ -5554,7 +5554,7 @@ int CDECL vprintf(const char *format, va_list valist) */ int CDECL vprintf_s(const char *format, va_list valist) { - return vfprintf_s(MSVCRT_stdout,format,valist); + return vfprintf_s(stdout,format,valist); }
/********************************************************************* @@ -5562,7 +5562,7 @@ int CDECL vprintf_s(const char *format, va_list valist) */ int CDECL vwprintf(const wchar_t *format, va_list valist) { - return vfwprintf(MSVCRT_stdout,format,valist); + return vfwprintf(stdout,format,valist); }
/********************************************************************* @@ -5570,7 +5570,7 @@ int CDECL vwprintf(const wchar_t *format, va_list valist) */ int CDECL vwprintf_s(const wchar_t *format, va_list valist) { - return vfwprintf_s(MSVCRT_stdout,format,valist); + return vfwprintf_s(stdout,format,valist); }
/********************************************************************* @@ -5738,7 +5738,7 @@ int WINAPIV printf(const char *format, ...) va_list valist; int res; va_start(valist, format); - res = vfprintf(MSVCRT_stdout, format, valist); + res = vfprintf(stdout, format, valist); va_end(valist); return res; } diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index d35412ee6b8..35e6e8233a1 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -301,14 +301,13 @@ extern BOOL msvcrt_create_io_inherit_block(WORD*, BYTE**); #define _RT_CRNL 252 #define _RT_BANNER 255
-extern FILE MSVCRT__iob[]; - #define MSVCRT_NO_CONSOLE_FD (-2) #define MSVCRT_NO_CONSOLE ((HANDLE)MSVCRT_NO_CONSOLE_FD)
-#define MSVCRT_stdin (MSVCRT__iob+STDIN_FILENO) -#define MSVCRT_stdout (MSVCRT__iob+STDOUT_FILENO) -#define MSVCRT_stderr (MSVCRT__iob+STDERR_FILENO) +#if _MSVCR_VER < 140 +extern FILE MSVCRT__iob[]; +#define __acrt_iob_func(idx) (MSVCRT__iob+(idx)) +#endif
/* internal file._flag flags */ #define MSVCRT__USERBUF 0x0100 diff --git a/dlls/msvcrt/scanf.c b/dlls/msvcrt/scanf.c index c8bbe15f373..c77649797ed 100644 --- a/dlls/msvcrt/scanf.c +++ b/dlls/msvcrt/scanf.c @@ -211,7 +211,7 @@ int WINAPIV scanf(const char *format, ...) int res;
va_start(valist, format); - res = vfscanf_l(MSVCRT_stdin, format, NULL, valist); + res = vfscanf_l(stdin, format, NULL, valist); va_end(valist); return res; } @@ -225,7 +225,7 @@ int WINAPIV _scanf_l(const char *format, _locale_t locale, ...) int res;
va_start(valist, locale); - res = vfscanf_l(MSVCRT_stdin, format, locale, valist); + res = vfscanf_l(stdin, format, locale, valist); va_end(valist); return res; } @@ -239,7 +239,7 @@ int WINAPIV scanf_s(const char *format, ...) int res;
va_start(valist, format); - res = vfscanf_s_l(MSVCRT_stdin, format, NULL, valist); + res = vfscanf_s_l(stdin, format, NULL, valist); va_end(valist); return res; } @@ -253,7 +253,7 @@ int WINAPIV _scanf_s_l(const char *format, _locale_t locale, ...) int res;
va_start(valist, locale); - res = vfscanf_s_l(MSVCRT_stdin, format, locale, valist); + res = vfscanf_s_l(stdin, format, locale, valist); va_end(valist); return res; } @@ -325,7 +325,7 @@ int WINAPIV wscanf(const wchar_t *format, ...) int res;
va_start(valist, format); - res = vfwscanf_l(MSVCRT_stdin, format, NULL, valist); + res = vfwscanf_l(stdin, format, NULL, valist); va_end(valist); return res; } @@ -340,7 +340,7 @@ int WINAPIV _wscanf_l(const wchar_t *format, int res;
va_start(valist, locale); - res = vfwscanf_l(MSVCRT_stdin, format, locale, valist); + res = vfwscanf_l(stdin, format, locale, valist); va_end(valist); return res; } @@ -354,7 +354,7 @@ int WINAPIV wscanf_s(const wchar_t *format, ...) int res;
va_start(valist, format); - res = vfwscanf_s_l(MSVCRT_stdin, format, NULL, valist); + res = vfwscanf_s_l(stdin, format, NULL, valist); va_end(valist); return res; } @@ -369,7 +369,7 @@ int WINAPIV _wscanf_s_l(const wchar_t *format, int res;
va_start(valist, locale); - res = vfwscanf_s_l(MSVCRT_stdin, format, locale, valist); + res = vfwscanf_s_l(stdin, format, locale, valist); va_end(valist); return res; } diff --git a/dlls/msvcrt/scanf.h b/dlls/msvcrt/scanf.h index 97ecc578760..1d7a92a9c1c 100644 --- a/dlls/msvcrt/scanf.h +++ b/dlls/msvcrt/scanf.h @@ -48,8 +48,8 @@ #define _STRTOD_NAME_(func) console_ ## func #define _GETC_(file) (consumed++, _getch()) #define _UNGETC_(nch, file) do { _ungetch(nch); consumed--; } while(0) -#define _LOCK_FILE_(file) _lock_file(MSVCRT_stdin) -#define _UNLOCK_FILE_(file) _unlock_file(MSVCRT_stdin) +#define _LOCK_FILE_(file) _lock_file(stdin) +#define _UNLOCK_FILE_(file) _unlock_file(stdin) #ifdef WIDE_SCANF #ifdef SECURE #define _FUNCTION_ static int vcwscanf_s_l(const wchar_t *format, _locale_t locale, va_list ap)