diff --git a/dlls/api-ms-win-crt-convert-l1-1-0/api-ms-win-crt-convert-l1-1-0.spec b/dlls/api-ms-win-crt-convert-l1-1-0/api-ms-win-crt-convert-l1-1-0.spec index b38905b134d..e2b5ab9877b 100644 --- a/dlls/api-ms-win-crt-convert-l1-1-0/api-ms-win-crt-convert-l1-1-0.spec +++ b/dlls/api-ms-win-crt-convert-l1-1-0/api-ms-win-crt-convert-l1-1-0.spec @@ -88,7 +88,7 @@ @ stub mbrtoc32 @ cdecl mbrtowc(ptr str long ptr) ucrtbase.mbrtowc @ cdecl mbsrtowcs(ptr ptr long ptr) ucrtbase.mbsrtowcs -@ stub mbsrtowcs_s +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) ucrtbase.mbsrtowcs_s @ cdecl mbstowcs(ptr str long) ucrtbase.mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) ucrtbase.mbstowcs_s @ cdecl mbtowc(ptr str long) ucrtbase.mbtowc diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 6fde8dfe933..efbd6880bf5 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1745,7 +1745,7 @@ @ cdecl mbrlen(ptr long ptr) MSVCRT_mbrlen @ cdecl mbrtowc(ptr str long ptr) MSVCRT_mbrtowc @ cdecl mbsrtowcs(ptr ptr long ptr) MSVCRT_mbsrtowcs -@ stub mbsrtowcs_s +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) MSVCRT_mbsrtowcs_s @ cdecl mbstowcs(ptr str long) MSVCRT_mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) MSVCRT__mbstowcs_s @ cdecl mbtowc(ptr str long) MSVCRT_mbtowc diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index ddab904b809..7476995be4e 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -2103,7 +2103,7 @@ @ cdecl mbrlen(ptr long ptr) MSVCRT_mbrlen @ cdecl mbrtowc(ptr str long ptr) MSVCRT_mbrtowc @ cdecl mbsrtowcs(ptr ptr long ptr) MSVCRT_mbsrtowcs -@ stub mbsrtowcs_s +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) MSVCRT_mbsrtowcs_s @ cdecl mbstowcs(ptr str long) MSVCRT_mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) MSVCRT__mbstowcs_s @ cdecl mbtowc(ptr str long) MSVCRT_mbtowc diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index 7efcb209dae..7aa2d191827 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -2280,7 +2280,7 @@ @ cdecl mbrlen(ptr long ptr) MSVCRT_mbrlen @ cdecl mbrtowc(ptr str long ptr) MSVCRT_mbrtowc @ cdecl mbsrtowcs(ptr ptr long ptr) MSVCRT_mbsrtowcs -@ stub mbsrtowcs_s +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) MSVCRT_mbsrtowcs_s @ cdecl mbstowcs(ptr str long) MSVCRT_mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) MSVCRT__mbstowcs_s @ cdecl mbtowc(ptr str long) MSVCRT_mbtowc diff --git a/dlls/msvcr120_app/msvcr120_app.spec b/dlls/msvcr120_app/msvcr120_app.spec index 6bfc0b721a2..893c0997838 100644 --- a/dlls/msvcr120_app/msvcr120_app.spec +++ b/dlls/msvcr120_app/msvcr120_app.spec @@ -1943,7 +1943,7 @@ @ cdecl mbrlen(ptr long ptr) msvcr120.mbrlen @ cdecl mbrtowc(ptr str long ptr) msvcr120.mbrtowc @ cdecl mbsrtowcs(ptr ptr long ptr) msvcr120.mbsrtowcs -@ stub mbsrtowcs_s +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) msvcr120.mbsrtowcs_s @ cdecl mbstowcs(ptr str long) msvcr120.mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) msvcr120.mbstowcs_s @ cdecl mbtowc(ptr str long) msvcr120.mbtowc diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 97f50977d52..a6f0a90f0f7 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -1425,7 +1425,7 @@ @ cdecl mbrlen(ptr long ptr) MSVCRT_mbrlen @ cdecl mbrtowc(ptr str long ptr) MSVCRT_mbrtowc @ cdecl mbsrtowcs(ptr ptr long ptr) MSVCRT_mbsrtowcs -@ stub mbsrtowcs_s +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) MSVCRT_mbsrtowcs_s @ cdecl mbstowcs(ptr str long) MSVCRT_mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) MSVCRT__mbstowcs_s @ cdecl mbtowc(ptr str long) MSVCRT_mbtowc diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 4a29dedd20d..48aed2c3f72 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -1398,7 +1398,7 @@ @ cdecl mbrlen(ptr long ptr) MSVCRT_mbrlen @ cdecl mbrtowc(ptr str long ptr) MSVCRT_mbrtowc @ cdecl mbsrtowcs(ptr ptr long ptr) MSVCRT_mbsrtowcs -@ stub mbsrtowcs_s +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) MSVCRT_mbsrtowcs_s @ cdecl mbstowcs(ptr str long) MSVCRT_mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) MSVCRT__mbstowcs_s @ cdecl mbtowc(ptr str long) MSVCRT_mbtowc diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 47478a3d8a3..3e71c91efd9 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -2370,6 +2370,35 @@ MSVCRT_size_t CDECL MSVCRT_mbsrtowcs(MSVCRT_wchar_t *wcstr, return ret; } +/********************************************************************* + * mbsrtowcs_s(MSVCRT.@) + */ +int CDECL MSVCRT_mbsrtowcs_s(MSVCRT_size_t *ret, MSVCRT_wchar_t *wcstr, MSVCRT_size_t len, + const char **mbstr, MSVCRT_size_t count, MSVCRT_mbstate_t *state) +{ + MSVCRT_size_t tmp; + + if(!ret) ret = &tmp; + if(!MSVCRT_CHECK_PMT(!!wcstr == !!len)) { + *ret = -1; + return MSVCRT_EINVAL; + } + + *ret = MSVCRT_mbsrtowcs(wcstr, mbstr, count>len ? len : count, state); + if(*ret == -1) { + if(wcstr) *wcstr = 0; + return *MSVCRT__errno(); + } + (*ret)++; + if(*ret > len) { + /* no place for terminating '\0' */ + if(wcstr) *wcstr = 0; + return 0; + } + if(wcstr) wcstr[(*ret)-1] = 0; + return 0; +} + /********************************************************************* * _mbctohira (MSVCRT.@) * diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index d485a0ed742..37107d58cf7 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -1365,7 +1365,7 @@ @ cdecl mbrtowc(ptr str long ptr) MSVCRT_mbrtowc # stub mbsdup_dbg(wstr long ptr long) @ cdecl mbsrtowcs(ptr ptr long ptr) MSVCRT_mbsrtowcs -# stub mbsrtowcs_s(ptr ptr long ptr long ptr) +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) MSVCRT_mbsrtowcs_s @ cdecl mbstowcs(ptr str long) MSVCRT_mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) MSVCRT__mbstowcs_s @ cdecl mbtowc(ptr str long) MSVCRT_mbtowc diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index cfb2a0a1ab1..bda6d3df935 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -2415,7 +2415,7 @@ @ stub mbrtoc32 @ cdecl mbrtowc(ptr str long ptr) MSVCRT_mbrtowc @ cdecl mbsrtowcs(ptr ptr long ptr) MSVCRT_mbsrtowcs -@ stub mbsrtowcs_s +@ cdecl mbsrtowcs_s(ptr ptr long ptr long ptr) MSVCRT_mbsrtowcs_s @ cdecl mbstowcs(ptr str long) MSVCRT_mbstowcs @ cdecl mbstowcs_s(ptr ptr long str long) MSVCRT__mbstowcs_s @ cdecl mbtowc(ptr str long) MSVCRT_mbtowc