msvcr80: Add gets_s implementation.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=45393
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2018-07-16 19:29:04 +02:00 committed by Alexandre Julliard
parent 13f9461e99
commit 6b268e77bb
9 changed files with 52 additions and 30 deletions

View File

@ -140,7 +140,7 @@
@ cdecl getc(ptr) ucrtbase.getc
@ cdecl getchar() ucrtbase.getchar
@ cdecl gets(str) ucrtbase.gets
@ stub gets_s
@ cdecl gets_s(ptr long) ucrtbase.gets_s
@ cdecl getwc(ptr) ucrtbase.getwc
@ cdecl getwchar() ucrtbase.getwchar
@ cdecl putc(long ptr) ucrtbase.putc

View File

@ -1700,7 +1700,7 @@
@ cdecl getenv(str) MSVCRT_getenv
@ cdecl getenv_s(ptr ptr long str)
@ cdecl gets(str) MSVCRT_gets
@ stub gets_s
@ cdecl gets_s(ptr long) MSVCRT_gets_s
@ cdecl getwc(ptr) MSVCRT_getwc
@ cdecl getwchar() MSVCRT_getwchar
@ cdecl is_wctype(long long) ntdll.iswctype

View File

@ -2058,7 +2058,7 @@
@ cdecl getenv(str) MSVCRT_getenv
@ cdecl getenv_s(ptr ptr long str)
@ cdecl gets(str) MSVCRT_gets
@ stub gets_s
@ cdecl gets_s(ptr long) MSVCRT_gets_s
@ cdecl getwc(ptr) MSVCRT_getwc
@ cdecl getwchar() MSVCRT_getwchar
@ cdecl is_wctype(long long) ntdll.iswctype

View File

@ -2204,7 +2204,7 @@
@ cdecl getenv(str) MSVCRT_getenv
@ cdecl getenv_s(ptr ptr long str)
@ cdecl gets(str) MSVCRT_gets
@ stub gets_s
@ cdecl gets_s(ptr long) MSVCRT_gets_s
@ cdecl getwc(ptr) MSVCRT_getwc
@ cdecl getwchar() MSVCRT_getwchar
@ stub ilogb

View File

@ -1868,7 +1868,7 @@
@ cdecl getc(ptr) msvcr120.getc
@ cdecl getchar() msvcr120.getchar
@ cdecl gets(str) msvcr120.gets
@ stub gets_s
@ cdecl gets_s(ptr long) msvcr120.gets_s
@ cdecl getwc(ptr) msvcr120.getwc
@ cdecl getwchar() msvcr120.getwchar
@ stub ilogb

View File

@ -1382,7 +1382,7 @@
@ cdecl getenv(str) MSVCRT_getenv
@ cdecl getenv_s(ptr ptr long str)
@ cdecl gets(str) MSVCRT_gets
@ stub gets_s
@ cdecl gets_s(ptr long) MSVCRT_gets_s
@ cdecl getwc(ptr) MSVCRT_getwc
@ cdecl getwchar() MSVCRT_getwchar
@ cdecl is_wctype(long long) ntdll.iswctype

View File

@ -1355,7 +1355,7 @@
@ cdecl getenv(str) MSVCRT_getenv
@ cdecl getenv_s(ptr ptr long str)
@ cdecl gets(str) MSVCRT_gets
@ stub gets_s
@ cdecl gets_s(ptr long) MSVCRT_gets_s
@ cdecl getwc(ptr) MSVCRT_getwc
@ cdecl getwchar() MSVCRT_getwchar
@ cdecl is_wctype(long long) ntdll.iswctype

View File

@ -4719,31 +4719,53 @@ int CDECL MSVCRT_getc(MSVCRT_FILE* file)
}
/*********************************************************************
* gets (MSVCRT.@)
* gets_s (MSVCR80.@)
*/
char * CDECL MSVCRT_gets_s(char *buf, MSVCRT_size_t len)
{
char *buf_start = buf;
int cc;
if (!MSVCRT_CHECK_PMT(buf != NULL)) return NULL;
if (!MSVCRT_CHECK_PMT(len != 0)) return NULL;
MSVCRT__lock_file(MSVCRT_stdin);
for(cc = MSVCRT__fgetc_nolock(MSVCRT_stdin);
len != 0 && cc != MSVCRT_EOF && cc != '\n';
cc = MSVCRT__fgetc_nolock(MSVCRT_stdin))
{
if (cc != '\r')
{
*buf++ = (char)cc;
len--;
}
}
MSVCRT__unlock_file(MSVCRT_stdin);
if (!len)
{
*buf_start = 0;
MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0);
return NULL;
}
if ((cc == MSVCRT_EOF) && (buf_start == buf))
{
TRACE(":nothing read\n");
return NULL;
}
*buf = '\0';
TRACE("got '%s'\n", buf_start);
return buf_start;
}
/*********************************************************************
* gets (MSVCRT.@)
*/
char * CDECL MSVCRT_gets(char *buf)
{
int cc;
char * buf_start = buf;
MSVCRT__lock_file(MSVCRT_stdin);
for(cc = MSVCRT__fgetc_nolock(MSVCRT_stdin); cc != MSVCRT_EOF && cc != '\n';
cc = MSVCRT__fgetc_nolock(MSVCRT_stdin))
{
if(cc != '\r')
*buf++ = (char)cc;
}
MSVCRT__unlock_file(MSVCRT_stdin);
if ((cc == MSVCRT_EOF) && (buf_start == buf))
{
TRACE(":nothing read\n");
return NULL;
}
*buf = '\0';
TRACE("got '%s'\n", buf_start);
return buf_start;
return MSVCRT_gets_s(buf, -1);
}
/*********************************************************************

View File

@ -2337,7 +2337,7 @@
@ cdecl getenv(str) MSVCRT_getenv
@ cdecl getenv_s(ptr ptr long str)
@ cdecl gets(str) MSVCRT_gets
@ stub gets_s
@ cdecl gets_s(ptr long) MSVCRT_gets_s
@ cdecl getwc(ptr) MSVCRT_getwc
@ cdecl getwchar() MSVCRT_getwchar
@ cdecl hypot(double double) _hypot