From 536be09b8449537925ad4635a06ae45283075c2e Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 21 Jul 2020 12:21:59 +0200 Subject: [PATCH] msvcrt: Don't use wine/unicode.h header. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/console.c | 2 +- dlls/msvcrt/ctype.c | 1 - dlls/msvcrt/data.c | 16 +++++++-------- dlls/msvcrt/dir.c | 33 +++++++++++++++---------------- dlls/msvcrt/environ.c | 15 +++++++-------- dlls/msvcrt/errno.c | 4 ++-- dlls/msvcrt/file.c | 9 ++++----- dlls/msvcrt/locale.c | 17 ++++++++-------- dlls/msvcrt/mbcs.c | 2 +- dlls/msvcrt/msvcrt.h | 3 +++ dlls/msvcrt/printf.h | 2 +- dlls/msvcrt/process.c | 45 ++++++++++++++++++++++--------------------- dlls/msvcrt/time.c | 1 - dlls/msvcrt/wcs.c | 19 +++++++++--------- 14 files changed, 83 insertions(+), 86 deletions(-) diff --git a/dlls/msvcrt/console.c b/dlls/msvcrt/console.c index 3a2301ef186..3ad79eec3a5 100644 --- a/dlls/msvcrt/console.c +++ b/dlls/msvcrt/console.c @@ -92,7 +92,7 @@ int CDECL _cputws(const MSVCRT_wchar_t* str) int len, retval = -1; if (!MSVCRT_CHECK_PMT(str != NULL)) return -1; - len = lstrlenW(str); + len = MSVCRT_wcslen(str); LOCK_CONSOLE; if (WriteConsoleW(MSVCRT_console_out, str, len, &count, NULL) diff --git a/dlls/msvcrt/ctype.c b/dlls/msvcrt/ctype.c index 3789cd7d75b..772357826eb 100644 --- a/dlls/msvcrt/ctype.c +++ b/dlls/msvcrt/ctype.c @@ -20,7 +20,6 @@ #include "msvcrt.h" #include "winnls.h" -#include "wine/unicode.h" /* Some abbreviations to make the following table readable */ #define _C_ MSVCRT__CONTROL diff --git a/dlls/msvcrt/data.c b/dlls/msvcrt/data.c index 26fb4a45109..969a16a8a2e 100644 --- a/dlls/msvcrt/data.c +++ b/dlls/msvcrt/data.c @@ -23,7 +23,7 @@ #include #include "msvcrt.h" -#include "wine/unicode.h" +#include #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); @@ -111,11 +111,11 @@ MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **wblk) int count = 1, len = 1, i = 0; /* keep space for the trailing NULLS */ MSVCRT_wchar_t *wptr; - for (wptr = wenviron_strings; *wptr; wptr += strlenW(wptr) + 1) + for (wptr = wenviron_strings; *wptr; wptr += MSVCRT_wcslen(wptr) + 1) { /* Don't count environment variables starting with '=' which are command shell specific */ if (*wptr != '=') count++; - len += strlenW(wptr) + 1; + len += MSVCRT_wcslen(wptr) + 1; } if (wblk) wblk = HeapReAlloc( GetProcessHeap(), 0, wblk, count* sizeof(MSVCRT_wchar_t*) + len * sizeof(MSVCRT_wchar_t)); @@ -126,7 +126,7 @@ MSVCRT_wchar_t ** msvcrt_SnapshotOfEnvironmentW(MSVCRT_wchar_t **wblk) if (count) { memcpy(&wblk[count],wenviron_strings,len * sizeof(MSVCRT_wchar_t)); - for (wptr = (MSVCRT_wchar_t*)&wblk[count]; *wptr; wptr += strlenW(wptr) + 1) + for (wptr = (MSVCRT_wchar_t*)&wblk[count]; *wptr; wptr += MSVCRT_wcslen(wptr) + 1) { /* Skip special environment strings set by the command shell */ if (*wptr != '=') wblk[i++] = wptr; @@ -163,7 +163,7 @@ static char **build_argv( WCHAR **wargv ) static WCHAR **cmdline_to_argv( const WCHAR *src, int *ret_argc ) { WCHAR **argv, *arg, *dst; - int argc, in_quotes = 0, bcount = 0, len = lstrlenW(src) + 1; + int argc, in_quotes = 0, bcount = 0, len = MSVCRT_wcslen(src) + 1; argc = 2 + len / 2; argv = HeapAlloc( GetProcessHeap(), 0, argc * sizeof(*argv) + len * sizeof(WCHAR) ); @@ -489,7 +489,7 @@ static int build_expanded_wargv(int *argc, MSVCRT_wchar_t **argv) int len = 0; is_expandable = FALSE; - for(path_len = strlenW(initial_wargv[i])-1; path_len>=0; path_len--) { + for(path_len = MSVCRT_wcslen(initial_wargv[i])-1; path_len>=0; path_len--) { if(initial_wargv[i][path_len]=='*' || initial_wargv[i][path_len]=='?') is_expandable = TRUE; else if(initial_wargv[i][path_len]=='\\' || initial_wargv[i][path_len]=='/') @@ -508,7 +508,7 @@ static int build_expanded_wargv(int *argc, MSVCRT_wchar_t **argv) (data.cFileName[1]=='.' && data.cFileName[2]=='\0'))) continue; - len = strlenW(data.cFileName)+1; + len = MSVCRT_wcslen(data.cFileName)+1; if(argv) { argv[args_no] = (MSVCRT_wchar_t*)(argv+*argc+1)+size; memcpy(argv[args_no], initial_wargv[i], path_len*sizeof(MSVCRT_wchar_t)); @@ -521,7 +521,7 @@ static int build_expanded_wargv(int *argc, MSVCRT_wchar_t **argv) } if(!len) { - len = strlenW(initial_wargv[i])+1; + len = MSVCRT_wcslen(initial_wargv[i])+1; if(argv) { argv[args_no] = (MSVCRT_wchar_t*)(argv+*argc+1)+size; memcpy(argv[args_no], initial_wargv[i], len*sizeof(MSVCRT_wchar_t)); diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c index aaf2f8a4145..61e1eaa6d6f 100644 --- a/dlls/msvcrt/dir.c +++ b/dlls/msvcrt/dir.c @@ -29,7 +29,6 @@ #include "windef.h" #include "winbase.h" #include "winternl.h" -#include "wine/unicode.h" #include "msvcrt.h" #include "wine/debug.h" @@ -92,7 +91,7 @@ static void msvcrt_wfttofd( const WIN32_FIND_DATAW *fd, struct MSVCRT__wfinddata RtlTimeToSecondsSince1970( (const LARGE_INTEGER *)&fd->ftLastWriteTime, &dw ); ft->time_write = dw; ft->size = fd->nFileSizeLow; - strcpyW(ft->name, fd->cFileName); + MSVCRT_wcscpy(ft->name, fd->cFileName); } /* INTERNAL: Translate WIN32_FIND_DATAW to wfinddata32_t */ @@ -112,7 +111,7 @@ static void msvcrt_wfttofd32(const WIN32_FIND_DATAW *fd, struct MSVCRT__wfinddat RtlTimeToSecondsSince1970( (const LARGE_INTEGER *)&fd->ftLastWriteTime, &dw ); ft->time_write = dw; ft->size = fd->nFileSizeLow; - strcpyW(ft->name, fd->cFileName); + MSVCRT_wcscpy(ft->name, fd->cFileName); } /* INTERNAL: Translate WIN32_FIND_DATAA to finddatai64_t */ @@ -172,7 +171,7 @@ static void msvcrt_wfttofd64( const WIN32_FIND_DATAW *fd, struct MSVCRT__wfindda RtlTimeToSecondsSince1970( (const LARGE_INTEGER *)&fd->ftLastWriteTime, &dw ); ft->time_write = dw; ft->size = ((__int64)fd->nFileSizeHigh) << 32 | fd->nFileSizeLow; - strcpyW(ft->name, fd->cFileName); + MSVCRT_wcscpy(ft->name, fd->cFileName); } /* INTERNAL: Translate WIN32_FIND_DATAA to finddata64i32_t */ @@ -212,7 +211,7 @@ static void msvcrt_wfttofdi64( const WIN32_FIND_DATAW *fd, struct MSVCRT__wfindd RtlTimeToSecondsSince1970( (const LARGE_INTEGER *)&fd->ftLastWriteTime, &dw ); ft->time_write = dw; ft->size = ((__int64)fd->nFileSizeHigh) << 32 | fd->nFileSizeLow; - strcpyW(ft->name, fd->cFileName); + MSVCRT_wcscpy(ft->name, fd->cFileName); } /* INTERNAL: Translate WIN32_FIND_DATAW to wfinddata64i32_t */ @@ -232,7 +231,7 @@ static void msvcrt_wfttofd64i32( const WIN32_FIND_DATAW *fd, struct MSVCRT__wfin RtlTimeToSecondsSince1970( (const LARGE_INTEGER *)&fd->ftLastWriteTime, &dw ); ft->time_write = dw; ft->size = fd->nFileSizeLow; - strcpyW(ft->name, fd->cFileName); + MSVCRT_wcscpy(ft->name, fd->cFileName); } /********************************************************************* @@ -807,7 +806,7 @@ MSVCRT_wchar_t* CDECL MSVCRT__wgetcwd(MSVCRT_wchar_t * buf, int size) *MSVCRT__errno() = MSVCRT_ERANGE; return NULL; /* buf too small */ } - strcpyW(buf,dir); + MSVCRT_wcscpy(buf,dir); return buf; } @@ -920,7 +919,7 @@ MSVCRT_wchar_t* CDECL MSVCRT__wgetdcwd(int drive, MSVCRT_wchar_t * buf, int size TRACE(":returning %s\n", debugstr_w(dir)); if (!buf) return MSVCRT__wcsdup(dir); /* allocate */ - strcpyW(buf,dir); + MSVCRT_wcscpy(buf,dir); } return buf; } @@ -1204,8 +1203,8 @@ int CDECL MSVCRT__wsplitpath_s(const MSVCRT_wchar_t* inpath, } if (ext) { - if (sz_ext <= strlenW(end)) goto do_error; - strcpyW( ext, end ); + if (sz_ext <= MSVCRT_wcslen(end)) goto do_error; + MSVCRT_wcscpy( ext, end ); } return 0; do_error: @@ -1408,7 +1407,7 @@ VOID CDECL MSVCRT__wmakepath(MSVCRT_wchar_t *path, const MSVCRT_wchar_t *drive, } if (directory && directory[0]) { - unsigned int len = strlenW(directory); + unsigned int len = MSVCRT_wcslen(directory); memmove(p, directory, len * sizeof(MSVCRT_wchar_t)); p += len; if (p[-1] != '/' && p[-1] != '\\') @@ -1416,7 +1415,7 @@ VOID CDECL MSVCRT__wmakepath(MSVCRT_wchar_t *path, const MSVCRT_wchar_t *drive, } if (filename && filename[0]) { - unsigned int len = strlenW(filename); + unsigned int len = MSVCRT_wcslen(filename); memmove(p, filename, len * sizeof(MSVCRT_wchar_t)); p += len; } @@ -1424,7 +1423,7 @@ VOID CDECL MSVCRT__wmakepath(MSVCRT_wchar_t *path, const MSVCRT_wchar_t *drive, { if (extension[0] != '.') *p++ = '.'; - strcpyW(p, extension); + MSVCRT_wcscpy(p, extension); } else *p = '\0'; @@ -1565,7 +1564,7 @@ int CDECL MSVCRT__wmakepath_s(MSVCRT_wchar_t *path, MSVCRT_size_t size, const MS if (directory && directory[0]) { - unsigned int len = strlenW(directory); + unsigned int len = MSVCRT_wcslen(directory); unsigned int needs_separator = directory[len - 1] != '/' && directory[len - 1] != '\\'; unsigned int copylen = min(size - 1, len); @@ -1592,7 +1591,7 @@ int CDECL MSVCRT__wmakepath_s(MSVCRT_wchar_t *path, MSVCRT_size_t size, const MS if (filename && filename[0]) { - unsigned int len = strlenW(filename); + unsigned int len = MSVCRT_wcslen(filename); unsigned int copylen = min(size - 1, len); if (size < 2) @@ -1609,7 +1608,7 @@ int CDECL MSVCRT__wmakepath_s(MSVCRT_wchar_t *path, MSVCRT_size_t size, const MS if (extension && extension[0]) { - unsigned int len = strlenW(extension); + unsigned int len = MSVCRT_wcslen(extension); unsigned int needs_period = extension[0] != '.'; unsigned int copylen; @@ -1750,7 +1749,7 @@ int CDECL MSVCRT__wsearchenv_s(const MSVCRT_wchar_t* file, const MSVCRT_wchar_t* if (count > MAX_PATH) FIXME("count > MAX_PATH not supported\n"); - fname_len = strlenW(file); + fname_len = MSVCRT_wcslen(file); *buf = '\0'; /* Try CWD first */ diff --git a/dlls/msvcrt/environ.c b/dlls/msvcrt/environ.c index ef8038d971e..222b8076b67 100644 --- a/dlls/msvcrt/environ.c +++ b/dlls/msvcrt/environ.c @@ -20,7 +20,6 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ -#include "wine/unicode.h" #include "msvcrt.h" #include "wine/debug.h" @@ -53,7 +52,7 @@ char * CDECL MSVCRT_getenv(const char *name) MSVCRT_wchar_t * CDECL MSVCRT__wgetenv(const MSVCRT_wchar_t *name) { MSVCRT_wchar_t **environ; - unsigned int length=strlenW(name); + unsigned int length=MSVCRT_wcslen(name); /* Initialize the _wenviron array if it's not already created. */ if (!MSVCRT__wenviron) @@ -62,7 +61,7 @@ MSVCRT_wchar_t * CDECL MSVCRT__wgetenv(const MSVCRT_wchar_t *name) for (environ = MSVCRT__wenviron; *environ; environ++) { MSVCRT_wchar_t *str = *environ; - MSVCRT_wchar_t *pos = strchrW(str,'='); + MSVCRT_wchar_t *pos = MSVCRT_wcschr(str,'='); if (pos && ((pos - str) == length) && !MSVCRT__wcsnicmp(str,name,length)) { TRACE("(%s): got %s\n", debugstr_w(name), debugstr_w(pos + 1)); @@ -131,7 +130,7 @@ int CDECL _wputenv(const MSVCRT_wchar_t *str) if (!str) return -1; - name = HeapAlloc(GetProcessHeap(), 0, (strlenW(str) + 1) * sizeof(MSVCRT_wchar_t)); + name = HeapAlloc(GetProcessHeap(), 0, (MSVCRT_wcslen(str) + 1) * sizeof(MSVCRT_wchar_t)); if (!name) return -1; dst = name; @@ -247,13 +246,13 @@ int CDECL _wdupenv_s(MSVCRT_wchar_t **buffer, MSVCRT_size_t *numberOfElements, if (!(e = MSVCRT__wgetenv(varname))) return *MSVCRT__errno() = MSVCRT_EINVAL; - sz = strlenW(e) + 1; + sz = MSVCRT_wcslen(e) + 1; if (!(*buffer = MSVCRT_malloc(sz * sizeof(MSVCRT_wchar_t)))) { if (numberOfElements) *numberOfElements = 0; return *MSVCRT__errno() = MSVCRT_ENOMEM; } - strcpyW(*buffer, e); + MSVCRT_wcscpy(*buffer, e); if (numberOfElements) *numberOfElements = sz; return 0; } @@ -302,12 +301,12 @@ int CDECL _wgetenv_s(MSVCRT_size_t *pReturnValue, MSVCRT_wchar_t *buffer, MSVCRT *pReturnValue = 0; return *MSVCRT__errno() = MSVCRT_EINVAL; } - *pReturnValue = strlenW(e) + 1; + *pReturnValue = MSVCRT_wcslen(e) + 1; if (numberOfElements < *pReturnValue) { return *MSVCRT__errno() = MSVCRT_ERANGE; } - strcpyW(buffer, e); + MSVCRT_wcscpy(buffer, e); return 0; } diff --git a/dlls/msvcrt/errno.c b/dlls/msvcrt/errno.c index 0497e59739d..e1685bbb46c 100644 --- a/dlls/msvcrt/errno.c +++ b/dlls/msvcrt/errno.c @@ -412,7 +412,7 @@ int CDECL MSVCRT___wcserror_s(MSVCRT_wchar_t* buffer, MSVCRT_size_t nc, const MS if (err < 0 || err > MSVCRT__sys_nerr) err = MSVCRT__sys_nerr; len = MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, NULL, 0) + 1 /* \n */; - if (str && *str) len += lstrlenW(str) + 2 /* ': ' */; + if (str && *str) len += MSVCRT_wcslen(str) + 2 /* ': ' */; if (len > nc) { MSVCRT_INVALID_PMT("buffer[nc] is too small", MSVCRT_ERANGE); @@ -424,7 +424,7 @@ int CDECL MSVCRT___wcserror_s(MSVCRT_wchar_t* buffer, MSVCRT_size_t nc, const MS lstrcatW(buffer, colonW); } else buffer[0] = '\0'; - len = lstrlenW(buffer); + len = MSVCRT_wcslen(buffer); MultiByteToWideChar(CP_ACP, 0, MSVCRT__sys_errlist[err], -1, buffer + len, 256 - len); lstrcatW(buffer, nlW); diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c index 9c42aa56993..e63cedede54 100644 --- a/dlls/msvcrt/file.c +++ b/dlls/msvcrt/file.c @@ -41,11 +41,10 @@ #include "windef.h" #include "winbase.h" #include "winternl.h" +#include "winnls.h" #include "msvcrt.h" #include "mtdll.h" -#include "wine/unicode.h" - #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); @@ -1535,7 +1534,7 @@ void CDECL MSVCRT_rewind(MSVCRT_FILE* file) static int msvcrt_get_flags(const MSVCRT_wchar_t* mode, int *open_flags, int* stream_flags) { - int plus = strchrW(mode, '+') != NULL; + int plus = MSVCRT_wcschr(mode, '+') != NULL; TRACE("%s\n", debugstr_w(mode)); @@ -3137,7 +3136,7 @@ int CDECL MSVCRT__wstat64(const MSVCRT_wchar_t* path, struct MSVCRT__stat64 * bu TRACE(":file (%s) buf(%p)\n",debugstr_w(path),buf); - plen = strlenW(path); + plen = MSVCRT_wcslen(path); while (plen && path[plen-1]==' ') plen--; @@ -4683,7 +4682,7 @@ int CDECL MSVCRT_fputs(const char *s, MSVCRT_FILE* file) */ int CDECL MSVCRT_fputws(const MSVCRT_wchar_t *s, MSVCRT_FILE* file) { - MSVCRT_size_t i, len = strlenW(s); + MSVCRT_size_t i, len = MSVCRT_wcslen(s); BOOL tmp_buf; int ret; diff --git a/dlls/msvcrt/locale.c b/dlls/msvcrt/locale.c index bde08f2117a..9a10ceabc4e 100644 --- a/dlls/msvcrt/locale.c +++ b/dlls/msvcrt/locale.c @@ -35,7 +35,6 @@ #include "mtdll.h" #include "wine/debug.h" -#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); @@ -568,8 +567,8 @@ MSVCRT_wchar_t* CDECL _W_Getdays(void) TRACE("\n"); for(i=0; i<7; i++) { - size += strlenW(cur->wstr.names.short_wday[i]) + 1; - size += strlenW(cur->wstr.names.wday[i]) + 1; + size += MSVCRT_wcslen(cur->wstr.names.short_wday[i]) + 1; + size += MSVCRT_wcslen(cur->wstr.names.wday[i]) + 1; } out = MSVCRT_malloc((size+1)*sizeof(*out)); if(!out) @@ -578,12 +577,12 @@ MSVCRT_wchar_t* CDECL _W_Getdays(void) size = 0; for(i=0; i<7; i++) { out[size++] = ':'; - len = strlenW(cur->wstr.names.short_wday[i]); + len = MSVCRT_wcslen(cur->wstr.names.short_wday[i]); memcpy(&out[size], cur->wstr.names.short_wday[i], len*sizeof(*out)); size += len; out[size++] = ':'; - len = strlenW(cur->wstr.names.wday[i]); + len = MSVCRT_wcslen(cur->wstr.names.wday[i]); memcpy(&out[size], cur->wstr.names.wday[i], len*sizeof(*out)); size += len; } @@ -642,8 +641,8 @@ MSVCRT_wchar_t* CDECL _W_Getmonths(void) TRACE("\n"); for(i=0; i<12; i++) { - size += strlenW(cur->wstr.names.short_mon[i]) + 1; - size += strlenW(cur->wstr.names.mon[i]) + 1; + size += MSVCRT_wcslen(cur->wstr.names.short_mon[i]) + 1; + size += MSVCRT_wcslen(cur->wstr.names.mon[i]) + 1; } out = MSVCRT_malloc((size+1)*sizeof(*out)); if(!out) @@ -652,12 +651,12 @@ MSVCRT_wchar_t* CDECL _W_Getmonths(void) size = 0; for(i=0; i<12; i++) { out[size++] = ':'; - len = strlenW(cur->wstr.names.short_mon[i]); + len = MSVCRT_wcslen(cur->wstr.names.short_mon[i]); memcpy(&out[size], cur->wstr.names.short_mon[i], len*sizeof(*out)); size += len; out[size++] = ':'; - len = strlenW(cur->wstr.names.mon[i]); + len = MSVCRT_wcslen(cur->wstr.names.mon[i]); memcpy(&out[size], cur->wstr.names.mon[i], len*sizeof(*out)); size += len; } diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 359ab6fdf4b..a065b8b003b 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -27,7 +27,7 @@ #include #include "msvcrt.h" -#include "wine/unicode.h" +#include "winnls.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 7449cbb2de6..76a327898b4 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -1211,6 +1211,9 @@ int __cdecl MSVCRT__iswupper_l(MSVCRT_wchar_t, MSVCRT__locale_t); int __cdecl MSVCRT__iswprint_l(MSVCRT_wchar_t, MSVCRT__locale_t); int __cdecl MSVCRT__iswpunct_l(MSVCRT_wchar_t, MSVCRT__locale_t); MSVCRT_size_t __cdecl MSVCRT_wcslen(const MSVCRT_wchar_t*); +MSVCRT_wchar_t* __cdecl MSVCRT_wcscpy(MSVCRT_wchar_t*, const MSVCRT_wchar_t*); +MSVCRT_wchar_t* __cdecl MSVCRT_wcschr(const MSVCRT_wchar_t*, MSVCRT_wchar_t); +MSVCRT_wchar_t* __cdecl MSVCRT_wcscat(MSVCRT_wchar_t*, const MSVCRT_wchar_t*); /* 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/printf.h b/dlls/msvcrt/printf.h index f776a1fa4b2..de0e6523adc 100644 --- a/dlls/msvcrt/printf.h +++ b/dlls/msvcrt/printf.h @@ -195,7 +195,7 @@ static inline int FUNC_NAME(pf_output_format_wstr)(FUNC_NAME(puts_clbk) pf_puts, if(flags->Precision>=0) len = MSVCRT_wcsnlen(str, flags->Precision); else - len = strlenW(str); + len = MSVCRT_wcslen(str); } if(flags->Precision>=0 && flags->Precision #include "msvcrt.h" +#include #include "mtdll.h" #include "wine/debug.h" -#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); @@ -44,15 +44,16 @@ static void msvcrt_search_executable(const MSVCRT_wchar_t *name, MSVCRT_wchar_t {{'.','c','o','m',0}, {'.','e','x','e',0}, {'.','b','a','t',0}, {'.','c','m','d',0}}; MSVCRT_wchar_t buffer[MAX_PATH]; - const MSVCRT_wchar_t *env, *p; + const MSVCRT_wchar_t *env, *p, *end; unsigned int i, name_len, path_len; int extension = 1; *fullname = '\0'; msvcrt_set_errno(ERROR_FILE_NOT_FOUND); - p = memchrW(name, '\0', MAX_PATH); - if (!p) p = name + MAX_PATH - 1; + end = name + MAX_PATH - 1; + for(p = name; p < end; p++) + if(!*p) break; name_len = p - name; /* FIXME extra-long names are silently truncated */ @@ -62,7 +63,7 @@ static void msvcrt_search_executable(const MSVCRT_wchar_t *name, MSVCRT_wchar_t /* try current dir first */ if (GetFileAttributesW(buffer) != INVALID_FILE_ATTRIBUTES) { - strcpyW(fullname, buffer); + MSVCRT_wcscpy(fullname, buffer); return; } @@ -77,7 +78,7 @@ static void msvcrt_search_executable(const MSVCRT_wchar_t *name, MSVCRT_wchar_t memcpy(buffer + name_len, suffix[i], 5 * sizeof(MSVCRT_wchar_t)); if (GetFileAttributesW(buffer) != INVALID_FILE_ATTRIBUTES) { - strcpyW(fullname, buffer); + MSVCRT_wcscpy(fullname, buffer); return; } } @@ -104,10 +105,10 @@ static void msvcrt_search_executable(const MSVCRT_wchar_t *name, MSVCRT_wchar_t } else buffer[path_len] = '\0'; - strcatW(buffer, name); + MSVCRT_wcscat(buffer, name); if (GetFileAttributesW(buffer) != INVALID_FILE_ATTRIBUTES) { - strcpyW(fullname, buffer); + MSVCRT_wcscpy(fullname, buffer); return; } } @@ -119,7 +120,7 @@ static void msvcrt_search_executable(const MSVCRT_wchar_t *name, MSVCRT_wchar_t memcpy(buffer + path_len + name_len, suffix[i], 5 * sizeof(MSVCRT_wchar_t)); if (GetFileAttributesW(buffer) != INVALID_FILE_ATTRIBUTES) { - strcpyW(fullname, buffer); + MSVCRT_wcscpy(fullname, buffer); return; } } @@ -202,7 +203,7 @@ static MSVCRT_wchar_t* msvcrt_argvtos(const MSVCRT_wchar_t* const* arg, MSVCRT_w size = 0; while (*a) { - size += strlenW(*a) + 1; + size += MSVCRT_wcslen(*a) + 1; a++; } @@ -215,7 +216,7 @@ static MSVCRT_wchar_t* msvcrt_argvtos(const MSVCRT_wchar_t* const* arg, MSVCRT_w p = ret; while (*a) { - int len = strlenW(*a); + int len = MSVCRT_wcslen(*a); memcpy(p,*a,len * sizeof(MSVCRT_wchar_t)); p += len; *p++ = delim; @@ -279,7 +280,7 @@ static MSVCRT_wchar_t *msvcrt_valisttos(const MSVCRT_wchar_t *arg0, __ms_va_list for (arg = arg0; arg; arg = va_arg( alist, MSVCRT_wchar_t * )) { - unsigned int len = strlenW( arg ) + 1; + unsigned int len = MSVCRT_wcslen( arg ) + 1; if (pos + len >= size) { size = max( 256, size * 2 ); @@ -291,7 +292,7 @@ static MSVCRT_wchar_t *msvcrt_valisttos(const MSVCRT_wchar_t *arg0, __ms_va_list } ret = new; } - strcpyW( ret + pos, arg ); + MSVCRT_wcscpy( ret + pos, arg ); pos += len; ret[pos - 1] = delim; } @@ -348,7 +349,7 @@ static MSVCRT_wchar_t *msvcrt_get_comspec(void) if (!(len = GetEnvironmentVariableW(comspec, NULL, 0))) len = ARRAY_SIZE(cmd); if ((ret = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t)))) { - if (!GetEnvironmentVariableW(comspec, ret, len)) strcpyW(ret, cmd); + if (!GetEnvironmentVariableW(comspec, ret, len)) MSVCRT_wcscpy(ret, cmd); } return ret; } @@ -1109,7 +1110,7 @@ MSVCRT_FILE* CDECL MSVCRT__wpopen(const MSVCRT_wchar_t* command, const MSVCRT_wc MSVCRT__close(fds[fdToDup]); if (!(comspec = msvcrt_get_comspec())) goto error; - len = strlenW(comspec) + strlenW(flag) + strlenW(command) + 1; + len = MSVCRT_wcslen(comspec) + MSVCRT_wcslen(flag) + MSVCRT_wcslen(command) + 1; if (!(fullcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t)))) { @@ -1117,9 +1118,9 @@ MSVCRT_FILE* CDECL MSVCRT__wpopen(const MSVCRT_wchar_t* command, const MSVCRT_wc goto error; } - strcpyW(fullcmd, comspec); - strcatW(fullcmd, flag); - strcatW(fullcmd, command); + MSVCRT_wcscpy(fullcmd, comspec); + MSVCRT_wcscat(fullcmd, flag); + MSVCRT_wcscat(fullcmd, command); if ((container->proc = (HANDLE)msvcrt_spawn(MSVCRT__P_NOWAIT, comspec, fullcmd, NULL, 1)) == INVALID_HANDLE_VALUE) @@ -1243,16 +1244,16 @@ int CDECL _wsystem(const MSVCRT_wchar_t* cmd) if ( comspec == NULL) return -1; - len = strlenW(comspec) + strlenW(flag) + strlenW(cmd) + 1; + len = MSVCRT_wcslen(comspec) + MSVCRT_wcslen(flag) + MSVCRT_wcslen(cmd) + 1; if (!(fullcmd = HeapAlloc(GetProcessHeap(), 0, len * sizeof(MSVCRT_wchar_t)))) { HeapFree(GetProcessHeap(), 0, comspec); return -1; } - strcpyW(fullcmd, comspec); - strcatW(fullcmd, flag); - strcatW(fullcmd, cmd); + MSVCRT_wcscpy(fullcmd, comspec); + MSVCRT_wcscat(fullcmd, flag); + MSVCRT_wcscat(fullcmd, cmd); res = msvcrt_spawn(MSVCRT__P_WAIT, comspec, fullcmd, NULL, 1); diff --git a/dlls/msvcrt/time.c b/dlls/msvcrt/time.c index f7bb452a437..b71f5ac1224 100644 --- a/dlls/msvcrt/time.c +++ b/dlls/msvcrt/time.c @@ -32,7 +32,6 @@ #include "winnls.h" #include "winternl.h" #include "wine/debug.h" -#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index bce1e89aeba..831a26eacad 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -28,7 +28,6 @@ #include "msvcrt.h" #include "winnls.h" #include "wtypes.h" -#include "wine/unicode.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(msvcrt); @@ -79,7 +78,7 @@ MSVCRT_wchar_t* CDECL MSVCRT__wcsdup( const MSVCRT_wchar_t* str ) MSVCRT_wchar_t* ret = NULL; if (str) { - int size = (strlenW(str) + 1) * sizeof(MSVCRT_wchar_t); + int size = (MSVCRT_wcslen(str) + 1) * sizeof(MSVCRT_wchar_t); ret = MSVCRT_malloc( size ); if (ret) memcpy( ret, str, size ); } @@ -298,7 +297,7 @@ int CDECL MSVCRT__wcsnset_s( MSVCRT_wchar_t *str, MSVCRT_size_t size, MSVCRT_wch MSVCRT_wchar_t* CDECL MSVCRT__wcsrev( MSVCRT_wchar_t* str ) { MSVCRT_wchar_t* ret = str; - MSVCRT_wchar_t* end = str + strlenW(str) - 1; + MSVCRT_wchar_t* end = str + MSVCRT_wcslen(str) - 1; while (end > str) { MSVCRT_wchar_t t = *end; @@ -552,7 +551,7 @@ static MSVCRT_size_t MSVCRT_wcsrtombs_l(char *mbstr, const MSVCRT_wchar_t **wcst MSVCRT_size_t i; if(!mbstr) - return strlenW(*wcstr); + return MSVCRT_wcslen(*wcstr); for(i=0; i 255) { @@ -1755,10 +1754,10 @@ MSVCRT_wchar_t * CDECL MSVCRT_wcstok_s( MSVCRT_wchar_t *str, const MSVCRT_wchar_ if (!str) str = *next_token; - while (*str && strchrW( delim, *str )) str++; + while (*str && MSVCRT_wcschr( delim, *str )) str++; if (!*str) return NULL; ret = str++; - while (*str && !strchrW( delim, *str )) str++; + while (*str && !MSVCRT_wcschr( delim, *str )) str++; if (*str) *str++ = 0; *next_token = str; return ret; @@ -2149,7 +2148,7 @@ INT CDECL MSVCRT_wcscpy_s( MSVCRT_wchar_t* wcDest, MSVCRT_size_t numElement, con return MSVCRT_EINVAL; } - size = strlenW(wcSrc) + 1; + size = MSVCRT_wcslen(wcSrc) + 1; if(!MSVCRT_CHECK_PMT_ERR(size <= numElement, MSVCRT_ERANGE)) { @@ -2295,7 +2294,7 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem, if (count == MSVCRT__TRUNCATE) { - srclen = strlenW(src); + srclen = MSVCRT_wcslen(src); if (srclen >= (elem - dststart)) { srclen = elem - dststart - 1; @@ -2303,7 +2302,7 @@ INT CDECL MSVCRT_wcsncat_s(MSVCRT_wchar_t *dst, MSVCRT_size_t elem, } } else - srclen = min(strlenW(src), count); + srclen = min(MSVCRT_wcslen(src), count); if (srclen < (elem - dststart)) { memcpy(&dst[dststart], src, srclen*sizeof(MSVCRT_wchar_t)); @@ -2766,7 +2765,7 @@ MSVCRT_size_t CDECL MSVCRT__wcsxfrm_l(MSVCRT_wchar_t *dest, const MSVCRT_wchar_t if(!locinfo->lc_handle[MSVCRT_LC_COLLATE]) { MSVCRT_wcsncpy(dest, src, len); - return strlenW(src); + return MSVCRT_wcslen(src); } ret = LCMapStringW(locinfo->lc_handle[MSVCRT_LC_COLLATE],