From 43c430a6d837d99f30dbcdb770f676e60ddb1ffb Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Fri, 3 May 2019 12:28:33 +0200 Subject: [PATCH] cmd: Build with msvcrt. Signed-off-by: Alexandre Julliard --- programs/cmd/Makefile.in | 3 +- programs/cmd/batch.c | 94 ++++----- programs/cmd/builtins.c | 422 +++++++++++++++++++-------------------- programs/cmd/directory.c | 80 ++++---- programs/cmd/wcmd.h | 6 +- programs/cmd/wcmdmain.c | 202 ++++++++++--------- 6 files changed, 403 insertions(+), 404 deletions(-) diff --git a/programs/cmd/Makefile.in b/programs/cmd/Makefile.in index f10aa3995bc..2525477f2dd 100644 --- a/programs/cmd/Makefile.in +++ b/programs/cmd/Makefile.in @@ -1,7 +1,8 @@ MODULE = cmd.exe -APPMODE = -mconsole -municode IMPORTS = shell32 user32 advapi32 +EXTRADLLFLAGS = -mconsole -municode -mno-cygwin + C_SRCS = \ batch.c \ builtins.c \ diff --git a/programs/cmd/batch.c b/programs/cmd/batch.c index 3bb325537b6..f494b80ae2f 100644 --- a/programs/cmd/batch.c +++ b/programs/cmd/batch.c @@ -76,7 +76,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA /* If processing a call :label, 'goto' the label in question */ if (startLabel) { - strcpyW(param1, startLabel); + lstrcpyW(param1, startLabel); WCMD_goto(NULL); } @@ -162,7 +162,7 @@ WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, while (TRUE) { /* Absorb repeated word delimiters until we get to the next token (or the end!) */ - while (*p && (strchrW(delims, *p) != NULL)) + while (*p && (wcschr(delims, *p) != NULL)) p++; if (*p == '\0') return param; @@ -176,7 +176,7 @@ WCHAR *WCMD_parameter_with_delims (WCHAR *s, int n, WCHAR **start, /* Loop character by character, but just need to special case quotes */ while (*p) { /* Once we have found a delimiter, break */ - if (strchrW(delims, *p) != NULL) break; + if (wcschr(delims, *p) != NULL) break; /* Very odd special case - Seems as if a ( acts as a delimiter which is not swallowed but is effective only when it comes between the program @@ -319,7 +319,7 @@ void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHA } else if (drv) *drv = '\0'; - end = path + strlenW(path); + end = path + lstrlenW(path); /* search for begin of file extension */ for(p=end; p>path && *--p!='\\' && *p!='/'; ) @@ -471,21 +471,21 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) whereas if you start applying other modifiers to it, you get the filename the batch label is in */ if (*lastModifier == '0' && modifierLen > 1) { - strcpyW(outputparam, context->batchfileW); + lstrcpyW(outputparam, context->batchfileW); } else if ((*lastModifier >= '0' && *lastModifier <= '9')) { - strcpyW(outputparam, + lstrcpyW(outputparam, WCMD_parameter (context -> command, *lastModifier-'0' + context -> shift_count[*lastModifier-'0'], NULL, FALSE, TRUE)); } else { int foridx = FOR_VAR_IDX(*lastModifier); - strcpyW(outputparam, forloopcontext.variable[foridx]); + lstrcpyW(outputparam, forloopcontext.variable[foridx]); } /* 1. Handle '~' : Strip surrounding quotes */ if (outputparam[0]=='"' && - memchrW(firstModifier, '~', modifierLen) != NULL) { - int len = strlenW(outputparam); + wmemchr(firstModifier, '~', modifierLen) != NULL) { + int len = lstrlenW(outputparam); if (outputparam[len-1] == '"') { outputparam[len-1]=0x00; len = len - 1; @@ -494,11 +494,11 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) } /* 2. Handle the special case of a $ */ - if (memchrW(firstModifier, '$', modifierLen) != NULL) { + if (wmemchr(firstModifier, '$', modifierLen) != NULL) { /* Special Case: Search envar specified in $[envvar] for outputparam Note both $ and : are guaranteed otherwise check above would fail */ - WCHAR *begin = strchrW(firstModifier, '$') + 1; - WCHAR *end = strchrW(firstModifier, ':'); + WCHAR *begin = wcschr(firstModifier, '$') + 1; + WCHAR *end = wcschr(firstModifier, ':'); WCHAR env[MAX_PATH]; DWORD size; @@ -535,13 +535,13 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) } /* 2. Handle 'a' : Output attributes (File doesn't have to exist) */ - if (memchrW(firstModifier, 'a', modifierLen) != NULL) { + if (wmemchr(firstModifier, 'a', modifierLen) != NULL) { WCHAR defaults[] = {'-','-','-','-','-','-','-','-','-','\0'}; doneModifier = TRUE; if (exists) { - strcpyW(thisoutput, defaults); + lstrcpyW(thisoutput, defaults); if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) thisoutput[0]='d'; if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) @@ -557,12 +557,12 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) /* FIXME: What are 6 and 7? */ if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) thisoutput[8]='l'; - strcatW(finaloutput, thisoutput); + lstrcatW(finaloutput, thisoutput); } } /* 3. Handle 't' : Date+time (File doesn't have to exist) */ - if (memchrW(firstModifier, 't', modifierLen) != NULL) { + if (wmemchr(firstModifier, 't', modifierLen) != NULL) { SYSTEMTIME systime; int datelen; @@ -570,22 +570,22 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) doneModifier = TRUE; if (exists) { - if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW); + if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); /* Format the time */ FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &systime); GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime, NULL, thisoutput, MAX_PATH); - strcatW(thisoutput, spaceW); - datelen = strlenW(thisoutput); + lstrcatW(thisoutput, spaceW); + datelen = lstrlenW(thisoutput); GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &systime, NULL, (thisoutput+datelen), MAX_PATH-datelen); - strcatW(finaloutput, thisoutput); + lstrcatW(finaloutput, thisoutput); } } /* 4. Handle 'z' : File length (File doesn't have to exist) */ - if (memchrW(firstModifier, 'z', modifierLen) != NULL) { + if (wmemchr(firstModifier, 'z', modifierLen) != NULL) { /* FIXME: Output full 64 bit size (sprintf does not support I64 here) */ ULONG/*64*/ fullsize = /*(fileInfo.nFileSizeHigh << 32) +*/ fileInfo.nFileSizeLow; @@ -593,33 +593,33 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) doneModifier = TRUE; if (exists) { - if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW); + if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); wsprintfW(thisoutput, fmt, fullsize); - strcatW(finaloutput, thisoutput); + lstrcatW(finaloutput, thisoutput); } } /* 4. Handle 's' : Use short paths (File doesn't have to exist) */ - if (memchrW(firstModifier, 's', modifierLen) != NULL) { - if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW); + if (wmemchr(firstModifier, 's', modifierLen) != NULL) { + if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); /* Convert fullfilename's path to a short path - Save filename away as only path is valid, name may not exist which causes GetShortPathName to fail if it is provided */ if (filepart) { - strcpyW(thisoutput, filepart); + lstrcpyW(thisoutput, filepart); *filepart = 0x00; GetShortPathNameW(fullfilename, fullfilename, ARRAY_SIZE(fullfilename)); - strcatW(fullfilename, thisoutput); + lstrcatW(fullfilename, thisoutput); } } /* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */ /* Note this overrides d,p,n,x */ - if (memchrW(firstModifier, 'f', modifierLen) != NULL) { + if (wmemchr(firstModifier, 'f', modifierLen) != NULL) { doneModifier = TRUE; - if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW); - strcatW(finaloutput, fullfilename); + if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); + lstrcatW(finaloutput, fullfilename); } else { WCHAR drive[10]; @@ -633,65 +633,65 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute) WCMD_splitpath(fullfilename, drive, dir, fname, ext); /* 5. Handle 'd' : Drive Letter */ - if (memchrW(firstModifier, 'd', modifierLen) != NULL) { + if (wmemchr(firstModifier, 'd', modifierLen) != NULL) { if (addSpace) { - strcatW(finaloutput, spaceW); + lstrcatW(finaloutput, spaceW); addSpace = FALSE; } - strcatW(finaloutput, drive); + lstrcatW(finaloutput, drive); doneModifier = TRUE; doneFileModifier = TRUE; } /* 6. Handle 'p' : Path */ - if (memchrW(firstModifier, 'p', modifierLen) != NULL) { + if (wmemchr(firstModifier, 'p', modifierLen) != NULL) { if (addSpace) { - strcatW(finaloutput, spaceW); + lstrcatW(finaloutput, spaceW); addSpace = FALSE; } - strcatW(finaloutput, dir); + lstrcatW(finaloutput, dir); doneModifier = TRUE; doneFileModifier = TRUE; } /* 7. Handle 'n' : Name */ - if (memchrW(firstModifier, 'n', modifierLen) != NULL) { + if (wmemchr(firstModifier, 'n', modifierLen) != NULL) { if (addSpace) { - strcatW(finaloutput, spaceW); + lstrcatW(finaloutput, spaceW); addSpace = FALSE; } - strcatW(finaloutput, fname); + lstrcatW(finaloutput, fname); doneModifier = TRUE; doneFileModifier = TRUE; } /* 8. Handle 'x' : Ext */ - if (memchrW(firstModifier, 'x', modifierLen) != NULL) { + if (wmemchr(firstModifier, 'x', modifierLen) != NULL) { if (addSpace) { - strcatW(finaloutput, spaceW); + lstrcatW(finaloutput, spaceW); addSpace = FALSE; } - strcatW(finaloutput, ext); + lstrcatW(finaloutput, ext); doneModifier = TRUE; doneFileModifier = TRUE; } /* If 's' but no other parameter, dump the whole thing */ if (!doneFileModifier && - memchrW(firstModifier, 's', modifierLen) != NULL) { + wmemchr(firstModifier, 's', modifierLen) != NULL) { doneModifier = TRUE; - if (finaloutput[0] != 0x00) strcatW(finaloutput, spaceW); - strcatW(finaloutput, fullfilename); + if (finaloutput[0] != 0x00) lstrcatW(finaloutput, spaceW); + lstrcatW(finaloutput, fullfilename); } } } /* If No other modifier processed, just add in parameter */ - if (!doneModifier) strcpyW(finaloutput, outputparam); + if (!doneModifier) lstrcpyW(finaloutput, outputparam); /* Finish by inserting the replacement into the string */ WCMD_strsubstW(*start, lastModifier+1, finaloutput, -1); @@ -714,7 +714,7 @@ void WCMD_call (WCHAR *command) { WCHAR gotoLabel[MAX_PATH]; - strcpyW(gotoLabel, param1); + lstrcpyW(gotoLabel, param1); if (context) { diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 209de26f10f..5fc192101d0 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -208,7 +208,7 @@ static BOOL WCMD_ask_confirm (const WCHAR *message, BOOL showSureText, WCMD_output_asis (confirm); WCMD_output_asis (options); WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), answer, ARRAY_SIZE(answer), &count); - answer[0] = toupperW(answer[0]); + answer[0] = towupper(answer[0]); if (answer[0] == Ybuffer[0]) return TRUE; if (answer[0] == Nbuffer[0]) @@ -292,14 +292,14 @@ void WCMD_choice (const WCHAR * args) { ptr = WCMD_skip_leading_spaces(my_command); while (*ptr == '/') { - switch (toupperW(ptr[1])) { + switch (towupper(ptr[1])) { case 'C': ptr += 2; /* the colon is optional */ if (*ptr == ':') ptr++; - if (!*ptr || isspaceW(*ptr)) { + if (!*ptr || iswspace(*ptr)) { WINE_FIXME("bad parameter %s for /C\n", wine_dbgstr_w(ptr)); heap_free(my_command); return; @@ -307,7 +307,7 @@ void WCMD_choice (const WCHAR * args) { /* remember the allowed keys (overwrite previous /C option) */ opt_c = ptr; - while (*ptr && (!isspaceW(*ptr))) + while (*ptr && (!iswspace(*ptr))) ptr++; if (*ptr) { @@ -344,13 +344,13 @@ void WCMD_choice (const WCHAR * args) { ptr++; count = 0; - while (((answer[count] = *ptr)) && isdigitW(*ptr) && (count < 15)) { + while (((answer[count] = *ptr)) && iswdigit(*ptr) && (count < 15)) { count++; ptr++; } answer[count] = 0; - opt_timeout = atoiW(answer); + opt_timeout = wcstol(answer, NULL, 10); ptr = WCMD_skip_leading_spaces(ptr); break; @@ -381,7 +381,7 @@ void WCMD_choice (const WCHAR * args) { WCMD_output_asis(ptr); if (!opt_s) { - struprW(opt_c); + wcsupr(opt_c); WINE_TRACE("case insensitive answer-list: %s\n", wine_dbgstr_w(opt_c)); } @@ -405,9 +405,9 @@ void WCMD_choice (const WCHAR * args) { WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), answer, 1, &count); if (!opt_s) - answer[0] = toupperW(answer[0]); + answer[0] = towupper(answer[0]); - ptr = strchrW(opt_c, answer[0]); + ptr = wcschr(opt_c, answer[0]); if (ptr) { WCMD_output_asis(answer); WCMD_output_asis(newlineW); @@ -643,23 +643,23 @@ void WCMD_copy(WCHAR * args) { if (*thisparam == '/') { while (*thisparam == '/') { thisparam++; - if (toupperW(*thisparam) == 'D') { + if (towupper(*thisparam) == 'D') { opt_d = TRUE; if (opt_d) WINE_FIXME("copy /D support not implemented yet\n"); - } else if (toupperW(*thisparam) == 'Y') { + } else if (towupper(*thisparam) == 'Y') { opt_y = TRUE; - } else if (toupperW(*thisparam) == '-' && toupperW(*(thisparam+1)) == 'Y') { + } else if (towupper(*thisparam) == '-' && towupper(*(thisparam+1)) == 'Y') { opt_noty = TRUE; - } else if (toupperW(*thisparam) == 'V') { + } else if (towupper(*thisparam) == 'V') { opt_v = TRUE; if (opt_v) WINE_FIXME("copy /V support not implemented yet\n"); - } else if (toupperW(*thisparam) == 'N') { + } else if (towupper(*thisparam) == 'N') { opt_n = TRUE; if (opt_n) WINE_FIXME("copy /N support not implemented yet\n"); - } else if (toupperW(*thisparam) == 'Z') { + } else if (towupper(*thisparam) == 'Z') { opt_z = TRUE; if (opt_z) WINE_FIXME("copy /Z support not implemented yet\n"); - } else if (toupperW(*thisparam) == 'A') { + } else if (towupper(*thisparam) == 'A') { if (binarymode != 0) { binarymode = 0; WINE_TRACE("Subsequent files will be handled as ASCII\n"); @@ -671,7 +671,7 @@ void WCMD_copy(WCHAR * args) { lastcopyentry->binarycopy = binarymode; } } - } else if (toupperW(*thisparam) == 'B') { + } else if (towupper(*thisparam) == 'B') { if (binarymode != 1) { binarymode = 1; WINE_TRACE("Subsequent files will be handled as binary\n"); @@ -730,7 +730,7 @@ void WCMD_copy(WCHAR * args) { /* Time to work out the name. Allocate at least enough space (deliberately too much to leave space to append \* to the end) , then copy in character by character. Strip off quotes if we find them. */ - len = strlenW(thisparam) + (sizeof(WCHAR) * 5); /* 5 spare characters, null + \*.* */ + len = lstrlenW(thisparam) + (sizeof(WCHAR) * 5); /* 5 spare characters, null + \*.* */ thiscopy->name = heap_xalloc(len*sizeof(WCHAR)); memset(thiscopy->name, 0x00, len); @@ -807,8 +807,8 @@ void WCMD_copy(WCHAR * args) { if (destination == NULL) { WINE_TRACE("No destination supplied, so need to calculate it\n"); - strcpyW(destname, dotW); - strcatW(destname, slashW); + lstrcpyW(destname, dotW); + lstrcatW(destname, slashW); destination = heap_xalloc(sizeof(COPY_FILES)); if (destination == NULL) goto exitreturn; @@ -835,7 +835,7 @@ void WCMD_copy(WCHAR * args) { (attributes & FILE_ATTRIBUTE_DIRECTORY))) { destisdirectory = TRUE; - if (!ends_with_backslash( destname )) strcatW(destname, slashW); + if (!ends_with_backslash( destname )) lstrcatW(destname, slashW); WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(destname)); } } @@ -857,7 +857,7 @@ void WCMD_copy(WCHAR * args) { } else if (!destisdirectory) { /* We have been asked to copy to a filename. Default to ascii IF the source contains wildcards (true even if only one match) */ - if (strpbrkW(sourcelist->name, wildcardsW) != NULL) { + if (wcspbrk(sourcelist->name, wildcardsW) != NULL) { anyconcats = TRUE; /* We really are concatenating to a single file */ if (destination->binarycopy == -1) { destination->binarycopy = 0; @@ -876,7 +876,7 @@ void WCMD_copy(WCHAR * args) { wine_dbgstr_w(destname), appendfirstsource); /* Remember if the destination is a device */ - if (strncmpW(destination->name, deviceW, strlenW(deviceW)) == 0) { + if (wcsncmp(destination->name, deviceW, lstrlenW(deviceW)) == 0) { WINE_TRACE("Destination is a device\n"); dstisdevice = TRUE; } @@ -916,17 +916,17 @@ void WCMD_copy(WCHAR * args) { /* We need to know where the filename part starts, so append * and recalculate the full resulting path */ - strcatW(thiscopy->name, starW); + lstrcatW(thiscopy->name, starW); GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart); WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath)); - } else if ((strpbrkW(srcpath, wildcardsW) == NULL) && + } else if ((wcspbrk(srcpath, wildcardsW) == NULL) && (attributes != INVALID_FILE_ATTRIBUTES) && (attributes & FILE_ATTRIBUTE_DIRECTORY)) { /* We need to know where the filename part starts, so append \* and recalculate the full resulting path */ - strcatW(thiscopy->name, slashstarW); + lstrcatW(thiscopy->name, slashstarW); GetFullPathNameW(thiscopy->name, ARRAY_SIZE(srcpath), srcpath, &filenamepart); WINE_TRACE("Directory, so full name is now '%s'\n", wine_dbgstr_w(srcpath)); } @@ -935,7 +935,7 @@ void WCMD_copy(WCHAR * args) { wine_dbgstr_w(srcpath), anyconcats); /* If the source is a device, just use it, otherwise search */ - if (strncmpW(srcpath, deviceW, strlenW(deviceW)) == 0) { + if (wcsncmp(srcpath, deviceW, lstrlenW(deviceW)) == 0) { WINE_TRACE("Source is a device\n"); srcisdevice = TRUE; srcname = &srcpath[4]; /* After the \\.\ prefix */ @@ -961,11 +961,11 @@ void WCMD_copy(WCHAR * args) { } else { /* Build final destination name */ - strcpyW(outname, destination->name); - if (destisdirectory || appendfirstsource) strcatW(outname, srcname); + lstrcpyW(outname, destination->name); + if (destisdirectory || appendfirstsource) lstrcatW(outname, srcname); /* Build source name */ - if (!srcisdevice) strcpyW(filenamepart, srcname); + if (!srcisdevice) lstrcpyW(filenamepart, srcname); /* Do we just overwrite (we do if we are writing to a device) */ overwrite = !prompt; @@ -1104,7 +1104,7 @@ static BOOL create_full_path(WCHAR* path) start = path+2; /* Strip trailing slashes. */ - for (p = path + strlenW(path) - 1; p != start && *p == '\\'; p--) + for (p = path + lstrlenW(path) - 1; p != start && *p == '\\'; p--) *p = 0; /* Step through path, creating intermediate directories as needed. */ @@ -1162,7 +1162,7 @@ static void WCMD_delete_parse_attributes(DWORD *wantSet, DWORD *wantClear) { *wantClear=0; /* For each /A argument */ - for (p=strstrW(quals, parmA); p != NULL; p=strstrW(p, parmA)) { + for (p=wcsstr(quals, parmA); p != NULL; p=wcsstr(p, parmA)) { /* Skip /A itself */ p += 2; @@ -1207,7 +1207,7 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted) static const WCHAR parmP[] = {'/','P','\0'}; static const WCHAR parmQ[] = {'/','Q','\0'}; - if ((strstrW(quals, parmQ) == NULL) && (strstrW(quals, parmP) == NULL)) { + if ((wcsstr(quals, parmQ) == NULL) && (wcsstr(quals, parmP) == NULL)) { static const WCHAR anyExt[]= {'.','*','\0'}; WCHAR drive[10]; WCHAR dir[MAX_PATH]; @@ -1220,8 +1220,8 @@ static BOOL WCMD_delete_confirm_wildcard(const WCHAR *filename, BOOL *pPrompted) WCMD_splitpath(fpath, drive, dir, fname, ext); /* Only prompt for * and *.*, not *a, a*, *.a* etc */ - if ((strcmpW(fname, starW) == 0) && - (*ext == 0x00 || (strcmpW(ext, anyExt) == 0))) { + if ((lstrcmpW(fname, starW) == 0) && + (*ext == 0x00 || (lstrcmpW(ext, anyExt) == 0))) { WCHAR question[MAXSTRING]; static const WCHAR fmt[] = {'%','s',' ','\0'}; @@ -1260,7 +1260,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { WCMD_delete_parse_attributes(&wanted_attrs, &unwanted_attrs); - strcpyW(argCopy, thisArg); + lstrcpyW(argCopy, thisArg); WINE_TRACE("del: Processing arg %s (quals:%s)\n", wine_dbgstr_w(argCopy), wine_dbgstr_w(quals)); @@ -1279,15 +1279,15 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { /* Support del by just deleting all files dirname\* */ if (handleParm - && (strchrW(argCopy,'*') == NULL) - && (strchrW(argCopy,'?') == NULL) + && (wcschr(argCopy,'*') == NULL) + && (wcschr(argCopy,'?') == NULL) && (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { WCHAR modifiedParm[MAX_PATH]; static const WCHAR slashStar[] = {'\\','*','\0'}; - strcpyW(modifiedParm, argCopy); - strcatW(modifiedParm, slashStar); + lstrcpyW(modifiedParm, argCopy); + lstrcatW(modifiedParm, slashStar); FindClose(hff); found = TRUE; WCMD_delete_one(modifiedParm); @@ -1295,14 +1295,14 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { } else if (handleParm) { /* Build the filename to delete as \ */ - strcpyW (fpath, argCopy); + lstrcpyW (fpath, argCopy); do { - p = strrchrW (fpath, '\\'); + p = wcsrchr (fpath, '\\'); if (p != NULL) { *++p = '\0'; - strcatW (fpath, fd.cFileName); + lstrcatW (fpath, fd.cFileName); } - else strcpyW (fpath, fd.cFileName); + else lstrcpyW (fpath, fd.cFileName); if (!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { BOOL ok; @@ -1311,7 +1311,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { && ((fd.dwFileAttributes & unwanted_attrs) == 0); /* /P means prompt for each file */ - if (ok && strstrW (quals, parmP) != NULL) { + if (ok && wcsstr (quals, parmP) != NULL) { WCHAR* question; /* Ask for confirmation */ @@ -1326,7 +1326,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { /* If file is read only, and /A:r or /F supplied, delete it */ if (fd.dwFileAttributes & FILE_ATTRIBUTE_READONLY && ((wanted_attrs & FILE_ATTRIBUTE_READONLY) || - strstrW (quals, parmF) != NULL)) { + wcsstr (quals, parmF) != NULL)) { SetFileAttributesW(fpath, fd.dwFileAttributes & ~FILE_ATTRIBUTE_READONLY); } @@ -1340,7 +1340,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { } /* Now recurse into all subdirectories handling the parameter in the same way */ - if (strstrW (quals, parmS) != NULL) { + if (wcsstr (quals, parmS) != NULL) { WCHAR thisDir[MAX_PATH]; int cPos; @@ -1354,9 +1354,9 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { GetFullPathNameW(argCopy, ARRAY_SIZE(thisDir), thisDir, NULL); WCMD_splitpath(thisDir, drive, dir, fname, ext); - strcpyW(thisDir, drive); - strcatW(thisDir, dir); - cPos = strlenW(thisDir); + lstrcpyW(thisDir, drive); + lstrcatW(thisDir, dir); + cPos = lstrlenW(thisDir); WINE_TRACE("Searching recursively in '%s'\n", wine_dbgstr_w(thisDir)); @@ -1375,18 +1375,18 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) { do { if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - (strcmpW(fd.cFileName, dotdotW) != 0) && - (strcmpW(fd.cFileName, dotW) != 0)) { + (lstrcmpW(fd.cFileName, dotdotW) != 0) && + (lstrcmpW(fd.cFileName, dotW) != 0)) { DIRECTORY_STACK *nextDir; WCHAR subParm[MAX_PATH]; /* Work out search parameter in sub dir */ - strcpyW (subParm, thisDir); - strcatW (subParm, fd.cFileName); - strcatW (subParm, slashW); - strcatW (subParm, fname); - strcatW (subParm, ext); + lstrcpyW (subParm, thisDir); + lstrcatW (subParm, fd.cFileName); + lstrcatW (subParm, slashW); + lstrcatW (subParm, fname); + lstrcatW (subParm, ext); WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(subParm)); /* Allocate memory, add to list */ @@ -1472,16 +1472,16 @@ BOOL WCMD_delete (WCHAR *args) { */ static WCHAR *WCMD_strtrim(const WCHAR *s) { - DWORD len = strlenW(s); + DWORD len = lstrlenW(s); const WCHAR *start = s; WCHAR* result; result = heap_xalloc((len + 1) * sizeof(WCHAR)); - while (isspaceW(*start)) start++; + while (iswspace(*start)) start++; if (*start) { const WCHAR *end = s + len - 1; - while (end > start && isspaceW(*end)) end--; + while (end > start && iswspace(*end)) end--; memcpy(result, start, (end - start + 2) * sizeof(WCHAR)); result[end - start + 1] = '\0'; } else { @@ -1511,7 +1511,7 @@ void WCMD_echo (const WCHAR *args) trimmed = WCMD_strtrim(args); if (!trimmed) return; - count = strlenW(trimmed); + count = lstrlenW(trimmed); if (count == 0 && origcommand[0]!='.' && origcommand[0]!=':' && origcommand[0]!=';' && origcommand[0]!='/') { if (echo_mode) WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), onW); @@ -1668,7 +1668,7 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip, { WCHAR *pos = options; - int len = strlenW(pos); + int len = lstrlenW(pos); static const WCHAR eolW[] = {'e','o','l','='}; static const WCHAR skipW[] = {'s','k','i','p','='}; static const WCHAR tokensW[] = {'t','o','k','e','n','s','='}; @@ -1678,8 +1678,8 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip, static const WCHAR forf_defaulttokens[] = {'1', '\0'}; /* Initialize to defaults */ - strcpyW(delims, forf_defaultdelims); - strcpyW(tokens, forf_defaulttokens); + lstrcpyW(delims, forf_defaultdelims); + lstrcpyW(tokens, forf_defaulttokens); *eol = 0; *skip = 0; *usebackq = FALSE; @@ -1707,7 +1707,7 @@ static BOOL WCMD_parse_forf_options(WCHAR *options, WCHAR *eol, int *skip, pos, ARRAY_SIZE(skipW), skipW, ARRAY_SIZE(skipW)) == CSTR_EQUAL) { WCHAR *nextchar = NULL; pos = pos + ARRAY_SIZE(skipW); - *skip = strtoulW(pos, &nextchar, 0); + *skip = wcstoul(pos, &nextchar, 0); WINE_TRACE("Found skip as %d lines\n", *skip); pos = nextchar; @@ -1776,15 +1776,15 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) { /* Build a generic search and add all directories on the list of directories still to walk */ - strcpyW(fullitem, dirsToWalk->dirName); - strcatW(fullitem, slashstarW); + lstrcpyW(fullitem, dirsToWalk->dirName); + lstrcatW(fullitem, slashstarW); hff = FindFirstFileW(fullitem, &fd); if (hff != INVALID_HANDLE_VALUE) { do { WINE_TRACE("Looking for subdirectories\n"); if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - (strcmpW(fd.cFileName, dotdotW) != 0) && - (strcmpW(fd.cFileName, dotW) != 0)) + (lstrcmpW(fd.cFileName, dotdotW) != 0) && + (lstrcmpW(fd.cFileName, dotW) != 0)) { /* Allocate memory, add to list */ DIRECTORY_STACK *toWalk = heap_xalloc(sizeof(DIRECTORY_STACK)); @@ -1792,10 +1792,10 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) { toWalk->next = remainingDirs->next; remainingDirs->next = toWalk; remainingDirs = toWalk; - toWalk->dirName = heap_xalloc(sizeof(WCHAR) * (strlenW(dirsToWalk->dirName) + 2 + strlenW(fd.cFileName))); - strcpyW(toWalk->dirName, dirsToWalk->dirName); - strcatW(toWalk->dirName, slashW); - strcatW(toWalk->dirName, fd.cFileName); + toWalk->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(dirsToWalk->dirName) + 2 + lstrlenW(fd.cFileName))); + lstrcpyW(toWalk->dirName, dirsToWalk->dirName); + lstrcatW(toWalk->dirName, slashW); + lstrcatW(toWalk->dirName, fd.cFileName); WINE_TRACE("Added to stack %s (%p->%p)\n", wine_dbgstr_w(toWalk->dirName), toWalk, toWalk->next); } @@ -1864,11 +1864,11 @@ static int WCMD_for_nexttoken(int lasttoken, WCHAR *tokenstr, } /* Get the next number */ - nextnumber1 = strtoulW(pos, &nextchar, 10); + nextnumber1 = wcstoul(pos, &nextchar, 10); /* If it is followed by a minus, it's a range, so get the next one as well */ if (*nextchar == '-') { - nextnumber2 = strtoulW(nextchar+1, &nextchar, 10); + nextnumber2 = wcstoul(nextchar+1, &nextchar, 10); /* We want to return the lowest number that is higher than lasttoken but only if range is positive */ @@ -2095,7 +2095,7 @@ static HANDLE WCMD_forf_getinputhandle(BOOL usebackq, WCHAR *itemstr, BOOL iscmd if (trimmed) { itemstr = trimmed; } - itemstr[strlenW(itemstr)-1] = 0x00; + itemstr[lstrlenW(itemstr)-1] = 0x00; itemstr++; } @@ -2174,7 +2174,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { while (thisArg && *thisArg == '/') { WINE_TRACE("Processing qualifier at %s\n", wine_dbgstr_w(thisArg)); thisArg++; - switch (toupperW(*thisArg)) { + switch (towupper(*thisArg)) { case 'D': expandDirs = TRUE; break; case 'L': useNumbers = TRUE; break; @@ -2185,10 +2185,10 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { { /* When recursing directories, use current directory as the starting point unless subsequently overridden */ - doRecurse = (toupperW(*thisArg) == 'R'); + doRecurse = (towupper(*thisArg) == 'R'); if (doRecurse) GetCurrentDirectoryW(ARRAY_SIZE(optionsRoot), optionsRoot); - doFileset = (toupperW(*thisArg) == 'F'); + doFileset = (towupper(*thisArg) == 'F'); /* Retrieve next parameter to see if is root/options (raw form required with for /f, or unquoted in for /r) */ @@ -2198,7 +2198,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { only care about it if it is the path/options */ if (thisArg && *thisArg != '/' && *thisArg != '%') { parameterNo++; - strcpyW(optionsRoot, thisArg); + lstrcpyW(optionsRoot, thisArg); } break; } @@ -2235,7 +2235,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { } /* Variable should follow */ - strcpyW(variable, thisArg); + lstrcpyW(variable, thisArg); WINE_TRACE("Variable identified as %s\n", wine_dbgstr_w(variable)); varidx = FOR_VAR_IDX(variable[1]); @@ -2313,7 +2313,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { /* Take a copy of the item returned from WCMD_parameter as it is held in a static buffer which can be overwritten during parsing of the for body */ WCHAR item[MAXSTRING]; - strcpyW(item, staticitem); + lstrcpyW(item, staticitem); thisCmdStart = cmdStart; @@ -2327,16 +2327,16 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { /* Now build the item to use / search for in the specified directory, as it is fully qualified in the /R case */ if (dirsToWalk) { - strcpyW(fullitem, dirsToWalk->dirName); - strcatW(fullitem, slashW); - strcatW(fullitem, item); + lstrcpyW(fullitem, dirsToWalk->dirName); + lstrcatW(fullitem, slashW); + lstrcatW(fullitem, item); } else { - WCHAR *prefix = strrchrW(item, '\\'); + WCHAR *prefix = wcsrchr(item, '\\'); if (prefix) prefixlen = (prefix - item) + 1; - strcpyW(fullitem, item); + lstrcpyW(fullitem, item); } - if (strpbrkW (fullitem, wildcards)) { + if (wcspbrk (fullitem, wildcards)) { hff = FindFirstFileW(fullitem, &fd); if (hff != INVALID_HANDLE_VALUE) { do { @@ -2346,20 +2346,20 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { /* Handle as files or dirs appropriately, but ignore . and .. */ if (isDirectory == expandDirs && - (strcmpW(fd.cFileName, dotdotW) != 0) && - (strcmpW(fd.cFileName, dotW) != 0)) + (lstrcmpW(fd.cFileName, dotdotW) != 0) && + (lstrcmpW(fd.cFileName, dotW) != 0)) { thisCmdStart = cmdStart; WINE_TRACE("Processing FOR filename %s\n", wine_dbgstr_w(fd.cFileName)); if (doRecurse) { - strcpyW(fullitem, dirsToWalk->dirName); - strcatW(fullitem, slashW); - strcatW(fullitem, fd.cFileName); + lstrcpyW(fullitem, dirsToWalk->dirName); + lstrcatW(fullitem, slashW); + lstrcatW(fullitem, fd.cFileName); } else { if (prefixlen) lstrcpynW(fullitem, item, prefixlen + 1); fullitem[prefixlen] = 0x00; - strcatW(fullitem, fd.cFileName); + lstrcatW(fullitem, fd.cFileName); } doExecuted = TRUE; @@ -2394,7 +2394,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { } else if (useNumbers) { /* Convert the first 3 numbers to signed longs and save */ - if (itemNum <=3) numbers[itemNum-1] = atolW(item); + if (itemNum <=3) numbers[itemNum-1] = wcstol(item, NULL, 10); /* else ignore them! */ /* Filesets - either a list of files, or a command to run and parse the output */ @@ -2452,14 +2452,14 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { /* Remove leading and trailing character, ready to parse with delims= delimiters Note that the last quote is removed from the set and the string terminates there to mimic windows */ - WCHAR *strend = strrchrW(itemStart, forf_usebackq?'\'':'"'); + WCHAR *strend = wcsrchr(itemStart, forf_usebackq?'\'':'"'); if (strend) { *strend = 0x00; itemStart++; } /* Copy the item away from the global buffer used by WCMD_parameter */ - strcpyW(buffer, itemStart); + lstrcpyW(buffer, itemStart); WCMD_parse_line(cmdStart, firstCmd, &cmdEnd, variable[1], buffer, &doExecuted, &forf_skip, forf_eol, forf_delims, forf_tokens); @@ -2487,7 +2487,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { (numbers[1]<0)? i>=numbers[2] : i<=numbers[2]; i=i + numbers[1]) { - sprintfW(thisNum, fmt, i); + swprintf(thisNum, ARRAY_SIZE(thisNum), fmt, i); WINE_TRACE("Processing FOR number %s\n", wine_dbgstr_w(thisNum)); thisCmdStart = cmdStart; @@ -2549,7 +2549,7 @@ void WCMD_give_help (const WCHAR *args) size_t i; args = WCMD_skip_leading_spaces((WCHAR*) args); - if (strlenW(args) == 0) { + if (lstrlenW(args) == 0) { WCMD_output_asis (WCMD_LoadMessage(WCMD_ALLHELP)); } else { @@ -2567,8 +2567,8 @@ void WCMD_give_help (const WCHAR *args) args, -1, externals[i], -1) == CSTR_EQUAL) { WCHAR cmd[128]; static const WCHAR helpW[] = {' ', '/','?','\0'}; - strcpyW(cmd, args); - strcatW(cmd, helpW); + lstrcpyW(cmd, args); + lstrcatW(cmd, helpW); WCMD_run_program(cmd, FALSE); return; } @@ -2613,7 +2613,7 @@ void WCMD_goto (CMD_LIST **cmdList) { /* Support goto :label as well as goto label plus remove trailing chars */ if (*paramStart == ':') paramStart++; - labelend = strpbrkW(paramStart, labelEndsW); + labelend = wcspbrk(paramStart, labelEndsW); if (labelend) *labelend = 0x00; WINE_TRACE("goto label: '%s'\n", wine_dbgstr_w(paramStart)); @@ -2639,18 +2639,18 @@ void WCMD_goto (CMD_LIST **cmdList) { str = string; /* Ignore leading whitespace or no-echo character */ - while (*str=='@' || isspaceW (*str)) str++; + while (*str=='@' || iswspace (*str)) str++; /* If the first real character is a : then this is a label */ if (*str == ':') { str++; /* Skip spaces between : and label */ - while (isspaceW (*str)) str++; + while (iswspace (*str)) str++; WINE_TRACE("str before brk %s\n", wine_dbgstr_w(str)); /* Label ends at whitespace or redirection characters */ - labelend = strpbrkW(str, labelEndsW); + labelend = wcspbrk(str, labelEndsW); if (labelend) *labelend = 0x00; WINE_TRACE("comparing found label %s\n", wine_dbgstr_w(str)); @@ -2690,7 +2690,7 @@ void WCMD_pushd (const WCHAR *args) WCHAR *thisdir; static const WCHAR parmD[] = {'/','D','\0'}; - if (strchrW(args, '/') != NULL) { + if (wcschr(args, '/') != NULL) { SetLastError(ERROR_INVALID_PARAMETER); WCMD_print_error(); return; @@ -2706,7 +2706,7 @@ void WCMD_pushd (const WCHAR *args) } /* Change directory using CD code with /D parameter */ - strcpyW(quals, parmD); + lstrcpyW(quals, parmD); GetCurrentDirectoryW (1024, thisdir); errorlevel = 0; WCMD_setshow_default(args); @@ -2781,8 +2781,8 @@ static int evaluate_if_comparison(const WCHAR *leftOperand, const WCHAR *operato : lstrcmpW (leftOperand, rightOperand) == 0; /* Check if we have plain integers (in decimal, octal or hexadecimal notation) */ - leftOperand_int = strtolW(leftOperand, &endptr_leftOp, 0); - rightOperand_int = strtolW(rightOperand, &endptr_rightOp, 0); + leftOperand_int = wcstol(leftOperand, &endptr_leftOp, 0); + rightOperand_int = wcstol(rightOperand, &endptr_rightOp, 0); int_operands = (!*endptr_leftOp) && (!*endptr_rightOp); /* Perform actual (integer or string) comparison */ @@ -2861,16 +2861,16 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) static const WCHAR existW[] = {'e','x','i','s','t','\0'}; static const WCHAR defdW[] = {'d','e','f','i','n','e','d','\0'}; static const WCHAR parmI[] = {'/','I','\0'}; - int caseInsensitive = (strstrW(quals, parmI) != NULL); + int caseInsensitive = (wcsstr(quals, parmI) != NULL); negate = !lstrcmpiW(param1,notW); - strcpyW(condition, (negate ? param2 : param1)); + lstrcpyW(condition, (negate ? param2 : param1)); WINE_TRACE("Condition: %s\n", wine_dbgstr_w(condition)); if (!lstrcmpiW (condition, errlvlW)) { WCHAR *param = WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE); WCHAR *endptr; - long int param_int = strtolW(param, &endptr, 10); + long int param_int = wcstol(param, &endptr, 10); if (*endptr) goto syntax_err; test = ((long int)errorlevel >= param_int); WCMD_parameter(p, 2+negate, &command, FALSE, FALSE); @@ -2879,10 +2879,10 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) WIN32_FIND_DATAW fd; HANDLE hff; WCHAR *param = WCMD_parameter(p, 1+negate, NULL, FALSE, FALSE); - int len = strlenW(param); + int len = lstrlenW(param); /* FindFirstFile does not like a directory path ending in '\', append a '.' */ - if (len && param[len-1] == '\\') strcatW(param, dotW); + if (len && param[len-1] == '\\') lstrcatW(param, dotW); hff = FindFirstFileW(param, &fd); test = (hff != INVALID_HANDLE_VALUE ); @@ -2899,24 +2899,24 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) WCHAR leftOperand[MAXSTRING], rightOperand[MAXSTRING], operator[MAXSTRING]; WCHAR *paramStart; - strcpyW(leftOperand, WCMD_parameter(p, negate+caseInsensitive, ¶mStart, TRUE, FALSE)); + lstrcpyW(leftOperand, WCMD_parameter(p, negate+caseInsensitive, ¶mStart, TRUE, FALSE)); if (!*leftOperand) goto syntax_err; /* Note: '==' can't be returned by WCMD_parameter since '=' is a separator */ - p = paramStart + strlenW(leftOperand); + p = paramStart + lstrlenW(leftOperand); while (*p == ' ' || *p == '\t') p++; - if (!strncmpW(p, eqeqW, strlenW(eqeqW))) - strcpyW(operator, eqeqW); + if (!wcsncmp(p, eqeqW, lstrlenW(eqeqW))) + lstrcpyW(operator, eqeqW); else { - strcpyW(operator, WCMD_parameter(p, 0, ¶mStart, FALSE, FALSE)); + lstrcpyW(operator, WCMD_parameter(p, 0, ¶mStart, FALSE, FALSE)); if (!*operator) goto syntax_err; } - p += strlenW(operator); + p += lstrlenW(operator); - strcpyW(rightOperand, WCMD_parameter(p, 0, ¶mStart, TRUE, FALSE)); + lstrcpyW(rightOperand, WCMD_parameter(p, 0, ¶mStart, TRUE, FALSE)); if (!*rightOperand) goto syntax_err; @@ -2924,7 +2924,7 @@ void WCMD_if (WCHAR *p, CMD_LIST **cmdList) if (test == -1) goto syntax_err; - p = paramStart + strlenW(rightOperand); + p = paramStart + lstrlenW(rightOperand); WCMD_parameter(p, 0, &command, FALSE, FALSE); } @@ -2962,7 +2962,7 @@ void WCMD_move (void) /* If no destination supplied, assume current directory */ if (param2[0] == 0x00) { - strcpyW(param2, dotW); + lstrcpyW(param2, dotW); } /* If 2nd parm is directory, then use original filename */ @@ -2988,21 +2988,21 @@ void WCMD_move (void) WINE_TRACE("Processing file '%s'\n", wine_dbgstr_w(fd.cFileName)); /* Build src & dest name */ - strcpyW(src, drive); - strcatW(src, dir); + lstrcpyW(src, drive); + lstrcatW(src, dir); /* See if dest is an existing directory */ attribs = GetFileAttributesW(output); if (attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY)) { - strcpyW(dest, output); - strcatW(dest, slashW); - strcatW(dest, fd.cFileName); + lstrcpyW(dest, output); + lstrcatW(dest, slashW); + lstrcatW(dest, fd.cFileName); } else { - strcpyW(dest, output); + lstrcpyW(dest, output); } - strcatW(src, fd.cFileName); + lstrcatW(src, fd.cFileName); WINE_TRACE("Source '%s'\n", wine_dbgstr_w(src)); WINE_TRACE("Dest '%s'\n", wine_dbgstr_w(dest)); @@ -3014,9 +3014,9 @@ void WCMD_move (void) DWORD len; /* /-Y has the highest priority, then /Y and finally the COPYCMD env. variable */ - if (strstrW (quals, parmNoY)) + if (wcsstr (quals, parmNoY)) force = FALSE; - else if (strstrW (quals, parmY)) + else if (wcsstr (quals, parmY)) force = TRUE; else { static const WCHAR copyCmdW[] = {'C','O','P','Y','C','M','D','\0'}; @@ -3107,7 +3107,7 @@ void WCMD_remove_dir (WCHAR *args) { /* If subdirectory search not supplied, just try to remove and report error if it fails (eg if it contains a file) */ - if (strstrW (quals, parmS) == NULL) { + if (wcsstr (quals, parmS) == NULL) { if (!RemoveDirectoryW(thisArg)) WCMD_print_error (); /* Otherwise use ShFileOp to recursively remove a directory */ @@ -3116,7 +3116,7 @@ void WCMD_remove_dir (WCHAR *args) { SHFILEOPSTRUCTW lpDir; /* Ask first */ - if (strstrW (quals, parmQ) == NULL) { + if (wcsstr (quals, parmQ) == NULL) { BOOL ok; WCHAR question[MAXSTRING]; static const WCHAR fmt[] = {'%','s',' ','\0'}; @@ -3180,7 +3180,7 @@ void WCMD_rename (void) } /* Destination cannot contain a drive letter or directory separator */ - if ((strchrW(param2,':') != NULL) || (strchrW(param2,'\\') != NULL)) { + if ((wcschr(param2,':') != NULL) || (wcschr(param2,'\\') != NULL)) { SetLastError(ERROR_INVALID_PARAMETER); WCMD_print_error(); errorlevel = 1; @@ -3191,7 +3191,7 @@ void WCMD_rename (void) GetFullPathNameW(param1, ARRAY_SIZE(input), input, NULL); WINE_TRACE("Rename from '%s'('%s') to '%s'\n", wine_dbgstr_w(input), wine_dbgstr_w(param1), wine_dbgstr_w(param2)); - dotDst = strchrW(param2, '.'); + dotDst = wcschr(param2, '.'); /* Split into components */ WCMD_splitpath(input, drive, dir, fname, ext); @@ -3214,29 +3214,29 @@ void WCMD_rename (void) ren jim.* fred.* etc However, windows has a more complex algorithm supporting eg ?'s and *'s mid name */ - dotSrc = strchrW(fd.cFileName, '.'); + dotSrc = wcschr(fd.cFileName, '.'); /* Build src & dest name */ - strcpyW(src, drive); - strcatW(src, dir); - strcpyW(dest, src); - dirLen = strlenW(src); - strcatW(src, fd.cFileName); + lstrcpyW(src, drive); + lstrcatW(src, dir); + lstrcpyW(dest, src); + dirLen = lstrlenW(src); + lstrcatW(src, fd.cFileName); /* Build name */ if (param2[0] == '*') { - strcatW(dest, fd.cFileName); + lstrcatW(dest, fd.cFileName); if (dotSrc) dest[dirLen + (dotSrc - fd.cFileName)] = 0x00; } else { - strcatW(dest, param2); + lstrcatW(dest, param2); if (dotDst) dest[dirLen + (dotDst - param2)] = 0x00; } /* Build Extension */ if (dotDst && (*(dotDst+1)=='*')) { - if (dotSrc) strcatW(dest, dotSrc); + if (dotSrc) lstrcatW(dest, dotSrc); } else if (dotDst) { - strcatW(dest, dotDst); + lstrcatW(dest, dotDst); } WINE_TRACE("Source '%s'\n", wine_dbgstr_w(src)); @@ -3268,7 +3268,7 @@ static WCHAR *WCMD_dupenv( const WCHAR *env ) len = 0; while ( env[len] ) - len += (strlenW(&env[len]) + 1); + len += (lstrlenW(&env[len]) + 1); env_copy = LocalAlloc (LMEM_FIXED, (len+1) * sizeof (WCHAR) ); if (!env_copy) @@ -3307,9 +3307,9 @@ void WCMD_setlocal (const WCHAR *s) { /* ENABLEDELAYEDEXPANSION / DISABLEDELAYEDEXPANSION could be parm1 or parm2 (if both ENABLEEXTENSIONS and ENABLEDELAYEDEXPANSION supplied for example) */ - if (!strcmpiW(param1, ondelayW) || !strcmpiW(param2, ondelayW)) { + if (!wcsicmp(param1, ondelayW) || !wcsicmp(param2, ondelayW)) { newdelay = TRUE; - } else if (!strcmpiW(param1, offdelayW) || !strcmpiW(param2, offdelayW)) { + } else if (!wcsicmp(param1, offdelayW) || !wcsicmp(param2, offdelayW)) { newdelay = FALSE; } else { newdelay = delayedsubst; @@ -3373,8 +3373,8 @@ void WCMD_endlocal (void) { old = WCMD_dupenv (env); len = 0; while (old[len]) { - n = strlenW(&old[len]) + 1; - p = strchrW(&old[len] + 1, '='); + n = lstrlenW(&old[len]) + 1; + p = wcschr(&old[len] + 1, '='); if (p) { *p++ = 0; @@ -3391,8 +3391,8 @@ void WCMD_endlocal (void) { delayedsubst = temp->delayedsubst; WINE_TRACE("Delayed expansion now %d\n", delayedsubst); while (env[len]) { - n = strlenW(&env[len]) + 1; - p = strchrW(&env[len] + 1, '='); + n = lstrlenW(&env[len]) + 1; + p = wcschr(&env[len] + 1, '='); if (p) { *p++ = 0; @@ -3437,7 +3437,7 @@ void WCMD_setshow_default (const WCHAR *args) { WINE_TRACE("Request change to directory '%s'\n", wine_dbgstr_w(args)); /* Skip /D and trailing whitespace if on the front of the command line */ - if (strlenW(args) >= 2 && + if (lstrlenW(args) >= 2 && CompareStringW(LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, args, 2, parmD, -1) == CSTR_EQUAL) { @@ -3447,8 +3447,8 @@ void WCMD_setshow_default (const WCHAR *args) { } GetCurrentDirectoryW(ARRAY_SIZE(cwd), cwd); - if (strlenW(args) == 0) { - strcatW (cwd, newlineW); + if (lstrlenW(args) == 0) { + lstrcatW (cwd, newlineW); WCMD_output_asis (cwd); } else { @@ -3503,7 +3503,7 @@ void WCMD_setshow_default (const WCHAR *args) { /* Restore old directory if drive letter would change, and CD x:\directory /D (or pushd c:\directory) not supplied */ - if ((strstrW(quals, parmD) == NULL) && + if ((wcsstr(quals, parmD) == NULL) && (param1[1] == ':') && (toupper(param1[0]) != toupper(cwd[0]))) { SetCurrentDirectoryW(cwd); } @@ -3515,7 +3515,7 @@ void WCMD_setshow_default (const WCHAR *args) { drive */ if ((string[1] == ':') && IsCharAlphaW(string[0])) { WCHAR env[4]; - strcpyW(env, equalW); + lstrcpyW(env, equalW); memcpy(env+1, string, 2 * sizeof(WCHAR)); env[3] = 0x00; WINE_TRACE("Setting '%s' to '%s'\n", wine_dbgstr_w(env), wine_dbgstr_w(string)); @@ -3539,10 +3539,10 @@ void WCMD_setshow_date (void) { DWORD count; static const WCHAR parmT[] = {'/','T','\0'}; - if (strlenW(param1) == 0) { + if (lstrlenW(param1) == 0) { if (GetDateFormatW(LOCALE_USER_DEFAULT, 0, NULL, NULL, curdate, ARRAY_SIZE(curdate))) { WCMD_output (WCMD_LoadMessage(WCMD_CURRENTDATE), curdate); - if (strstrW (quals, parmT) == NULL) { + if (wcsstr (quals, parmT) == NULL) { WCMD_output (WCMD_LoadMessage(WCMD_NEWDATE)); WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count); if (count > 2) { @@ -3567,7 +3567,7 @@ static int WCMD_compare( const void *a, const void *b ) int r; const WCHAR * const *str_a = a, * const *str_b = b; r = CompareStringW( LOCALE_USER_DEFAULT, NORM_IGNORECASE | SORT_STRINGSORT, - *str_a, strcspnW(*str_a, equalW), *str_b, strcspnW(*str_b, equalW) ); + *str_a, wcscspn(*str_a, equalW), *str_b, wcscspn(*str_b, equalW) ); if( r == CSTR_LESS_THAN ) return -1; if( r == CSTR_GREATER_THAN ) return 1; return 0; @@ -3585,11 +3585,11 @@ static int WCMD_setshow_sortenv(const WCHAR *s, const WCHAR *stub) UINT count=0, len=0, i, displayedcount=0, stublen=0; const WCHAR **str; - if (stub) stublen = strlenW(stub); + if (stub) stublen = lstrlenW(stub); /* count the number of strings, and the total length */ while ( s[len] ) { - len += (strlenW(&s[len]) + 1); + len += (lstrlenW(&s[len]) + 1); count++; } @@ -3599,7 +3599,7 @@ static int WCMD_setshow_sortenv(const WCHAR *s, const WCHAR *stub) return 0; str[0] = s; for( i=1; iisnum) { WCHAR tmpstr[MAXSTRING]; if (GetEnvironmentVariableW(thisvar->variable, tmpstr, MAXSTRING)) { - result = strtoulW(tmpstr,NULL,0); + result = wcstoul(tmpstr,NULL,0); } WINE_TRACE("Envvar %s converted to %d\n", wine_dbgstr_w(thisvar->variable), result); } else { @@ -3891,7 +3891,7 @@ static int WCMD_reduce(OPSTACK **opstack, VARSTACK **varstack) { WCHAR result[MAXSTRING]; /* Build the result, then push it onto the stack */ - sprintfW(result, intFormat, var1); + swprintf(result, ARRAY_SIZE(result), intFormat, var1); WINE_TRACE("Assigning %s a value %s\n", wine_dbgstr_w((*varstack)->variable), wine_dbgstr_w(result)); SetEnvironmentVariableW((*varstack)->variable, result); @@ -3936,7 +3936,7 @@ static int WCMD_handleExpression(WCHAR **expr, int *ret, int depth) if (!*pos) goto exprreturn; /* If we have found anything other than an operator then it's a number/variable */ - if (strchrW(mathDelims, *pos) == NULL) { + if (wcschr(mathDelims, *pos) == NULL) { WCHAR *parmstart, *parm, *dupparm; WCHAR *nextpos; @@ -3948,14 +3948,14 @@ static int WCMD_handleExpression(WCHAR **expr, int *ret, int depth) } lastwasnumber = TRUE; - if (isdigitW(*pos)) { + if (iswdigit(*pos)) { /* For a number - just push it onto the stack */ - int num = strtoulW(pos, &nextpos, 0); + int num = wcstoul(pos, &nextpos, 0); WCMD_pushnumber(NULL, num, &varstackhead); pos = nextpos; /* Verify the number was validly formed */ - if (*nextpos && (strchrW(mathDelims, *nextpos) == NULL)) { + if (*nextpos && (wcschr(mathDelims, *nextpos) == NULL)) { rc = WCMD_BADHEXOCT; goto exprerrorreturn; } @@ -3965,7 +3965,7 @@ static int WCMD_handleExpression(WCHAR **expr, int *ret, int depth) parm = WCMD_parameter_with_delims(pos, 0, &parmstart, FALSE, FALSE, mathDelims); dupparm = heap_strdupW(parm); WCMD_pushnumber(dupparm, 0, &varstackhead); - pos = parmstart + strlenW(dupparm); + pos = parmstart + lstrlenW(dupparm); } continue; } @@ -4174,14 +4174,14 @@ void WCMD_setshow_env (WCHAR *s) { } /* If no parameter, or no '=' sign, return an error */ - if (!(*s) || ((p = strchrW (s, '=')) == NULL )) { + if (!(*s) || ((p = wcschr (s, '=')) == NULL )) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_NOARG)); return; } /* Output the prompt */ *p++ = '\0'; - if (strlenW(p) != 0) WCMD_output_asis(p); + if (lstrlenW(p) != 0) WCMD_output_asis(p); /* Read the reply */ WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, ARRAY_SIZE(string), &count); @@ -4206,7 +4206,7 @@ void WCMD_setshow_env (WCHAR *s) { WCHAR *src,*dst; /* Remove all quotes before doing any calculations */ - thisexpr = heap_xalloc((strlenW(s+2)+1) * sizeof(WCHAR)); + thisexpr = heap_xalloc((lstrlenW(s+2)+1) * sizeof(WCHAR)); src = s+2; dst = thisexpr; while (*src) { @@ -4229,7 +4229,7 @@ void WCMD_setshow_env (WCHAR *s) { /* If we have no context (interactive or cmd.exe /c) print the final result */ if (!context) { static const WCHAR fmt[] = {'%','d','\0'}; - sprintfW(string, fmt, result); + swprintf(string, ARRAY_SIZE(string), fmt, result); WCMD_output_asis(string); } @@ -4244,7 +4244,7 @@ void WCMD_setshow_env (WCHAR *s) { WINE_TRACE("set: Stripped command line '%s'\n", wine_dbgstr_w(s)); } - p = strchrW (s, '='); + p = wcschr (s, '='); if (p == NULL) { env = GetEnvironmentStringsW(); if (WCMD_setshow_sortenv( env, s ) == 0) { @@ -4255,7 +4255,7 @@ void WCMD_setshow_env (WCHAR *s) { } *p++ = '\0'; - if (strlenW(p) == 0) p = NULL; + if (lstrlenW(p) == 0) p = NULL; WINE_TRACE("set: Setting var '%s' to '%s'\n", wine_dbgstr_w(s), wine_dbgstr_w(p)); status = SetEnvironmentVariableW(s, p); @@ -4280,7 +4280,7 @@ void WCMD_setshow_path (const WCHAR *args) { static const WCHAR pathW[] = {'P','A','T','H','\0'}; static const WCHAR pathEqW[] = {'P','A','T','H','=','\0'}; - if (strlenW(param1) == 0 && strlenW(param2) == 0) { + if (lstrlenW(param1) == 0 && lstrlenW(param2) == 0) { status = GetEnvironmentVariableW(pathW, string, ARRAY_SIZE(string)); if (status != 0) { WCMD_output_asis ( pathEqW); @@ -4309,13 +4309,13 @@ void WCMD_setshow_prompt (void) { WCHAR *s; static const WCHAR promptW[] = {'P','R','O','M','P','T','\0'}; - if (strlenW(param1) == 0) { + if (lstrlenW(param1) == 0) { SetEnvironmentVariableW(promptW, NULL); } else { s = param1; while ((*s == '=') || (*s == ' ') || (*s == '\t')) s++; - if (strlenW(s) == 0) { + if (lstrlenW(s) == 0) { SetEnvironmentVariableW(promptW, NULL); } else SetEnvironmentVariableW(promptW, s); @@ -4336,11 +4336,11 @@ void WCMD_setshow_time (void) { SYSTEMTIME st; static const WCHAR parmT[] = {'/','T','\0'}; - if (strlenW(param1) == 0) { + if (lstrlenW(param1) == 0) { GetLocalTime(&st); if (GetTimeFormatW(LOCALE_USER_DEFAULT, 0, &st, NULL, curtime, ARRAY_SIZE(curtime))) { WCMD_output (WCMD_LoadMessage(WCMD_CURRENTTIME), curtime); - if (strstrW (quals, parmT) == NULL) { + if (wcsstr (quals, parmT) == NULL) { WCMD_output (WCMD_LoadMessage(WCMD_NEWTIME)); WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, ARRAY_SIZE(buffer), &count); if (count > 2) { @@ -4366,7 +4366,7 @@ void WCMD_shift (const WCHAR *args) { int start; if (context != NULL) { - WCHAR *pos = strchrW(args, '/'); + WCHAR *pos = wcschr(args, '/'); int i; if (pos == NULL) { @@ -4406,11 +4406,11 @@ void WCMD_start(WCHAR *args) PROCESS_INFORMATION pi; GetWindowsDirectoryW( file, MAX_PATH ); - strcatW( file, exeW ); - cmdline = heap_xalloc( (strlenW(file) + strlenW(args) + 8) * sizeof(WCHAR) ); - strcpyW( cmdline, file ); - strcatW( cmdline, spaceW ); - cmdline_params = cmdline + strlenW(cmdline); + lstrcatW( file, exeW ); + cmdline = heap_xalloc( (lstrlenW(file) + lstrlenW(args) + 8) * sizeof(WCHAR) ); + lstrcpyW( cmdline, file ); + lstrcatW( cmdline, spaceW ); + cmdline_params = cmdline + lstrlenW(cmdline); /* The start built-in has some special command-line parsing properties * which will be outlined here. @@ -4466,13 +4466,13 @@ void WCMD_start(WCHAR *args) cmdline_params[argN - args] = '\0'; /* Add quoted title */ - strcatW(cmdline_params, prefixQuote); - strcatW(cmdline_params, thisArg); - strcatW(cmdline_params, postfixQuote); + lstrcatW(cmdline_params, prefixQuote); + lstrcatW(cmdline_params, thisArg); + lstrcatW(cmdline_params, postfixQuote); /* Concatenate remaining command-line */ thisArg = WCMD_parameter_with_delims(args, argno, &argN, TRUE, FALSE, startDelims); - strcatW(cmdline_params, argN + strlenW(thisArg)); + lstrcatW(cmdline_params, argN + lstrlenW(thisArg)); break; } @@ -4490,7 +4490,7 @@ void WCMD_start(WCHAR *args) /* build command-line if not built yet */ if (!have_title) { - strcatW( cmdline, args ); + lstrcatW( cmdline, args ); } memset( &st, 0, sizeof(STARTUPINFOW) ); @@ -4596,7 +4596,7 @@ void WCMD_more (WCHAR *args) { /* Prefix the NLS more with '-- ', then load the text */ errorlevel = 0; - strcpyW(moreStr, moreStart); + lstrcpyW(moreStr, moreStart); LoadStringW(hinst, WCMD_MORESTR, &moreStr[3], ARRAY_SIZE(moreStr)-3); if (param1[0] == 0x00) { @@ -4700,7 +4700,7 @@ void WCMD_verify (const WCHAR *args) { int count; - count = strlenW(args); + count = lstrlenW(args); if (count == 0) { if (verify_mode) WCMD_output (WCMD_LoadMessage(WCMD_VERIFYPROMPT), onW); else WCMD_output (WCMD_LoadMessage(WCMD_VERIFYPROMPT), offW); @@ -4743,7 +4743,7 @@ int WCMD_volume(BOOL set_label, const WCHAR *path) WCHAR string[MAX_PATH], label[MAX_PATH], curdir[MAX_PATH]; BOOL status; - if (strlenW(path) == 0) { + if (lstrlenW(path) == 0) { status = GetCurrentDirectoryW(ARRAY_SIZE(curdir), curdir); if (!status) { WCMD_print_error (); @@ -4753,7 +4753,7 @@ int WCMD_volume(BOOL set_label, const WCHAR *path) } else { static const WCHAR fmt[] = {'%','s','\\','\0'}; - if ((path[1] != ':') || (strlenW(path) != 2)) { + if ((path[1] != ':') || (lstrlenW(path) != 2)) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_SYNTAXERR)); return 0; } @@ -4781,7 +4781,7 @@ int WCMD_volume(BOOL set_label, const WCHAR *path) string[count-1] = '\0'; /* ReadFile output is not null-terminated! */ if (string[count-2] == '\r') string[count-2] = '\0'; /* Under Windoze we get CRLF! */ } - if (strlenW(path) != 0) { + if (lstrlenW(path) != 0) { if (!SetVolumeLabelW(curdir, string)) WCMD_print_error (); } else { @@ -4801,7 +4801,7 @@ int WCMD_volume(BOOL set_label, const WCHAR *path) void WCMD_exit (CMD_LIST **cmdList) { static const WCHAR parmB[] = {'/','B','\0'}; - int rc = atoiW(param1); /* Note: atoi of empty parameter is 0 */ + int rc = wcstol(param1, NULL, 10); /* Note: wcstol of empty parameter is 0 */ if (context && lstrcmpiW(quals, parmB) == 0) { errorlevel = rc; @@ -4833,7 +4833,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) { /* See if parameter includes '=' */ errorlevel = 0; - newValue = strchrW(args, '='); + newValue = wcschr(args, '='); if (newValue) accessOptions |= KEY_WRITE; /* Open a key to HKEY_CLASSES_ROOT for enumerating */ @@ -4864,8 +4864,8 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) { (!(keyName[0] == '.') && (!assoc))) { WCHAR subkey[MAXSTRING]; - strcpyW(subkey, keyName); - if (!assoc) strcatW(subkey, shOpCmdW); + lstrcpyW(subkey, keyName); + if (!assoc) lstrcatW(subkey, shOpCmdW); if (RegOpenKeyExW(key, subkey, 0, accessOptions, &readKey) == ERROR_SUCCESS) { @@ -4892,13 +4892,13 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) { WCHAR subkey[MAXSTRING]; /* Query terminates the parameter at the first space */ - strcpyW(keyValue, args); - space = strchrW(keyValue, ' '); + lstrcpyW(keyValue, args); + space = wcschr(keyValue, ' '); if (space) *space=0x00; /* Set up key name */ - strcpyW(subkey, keyValue); - if (!assoc) strcatW(subkey, shOpCmdW); + lstrcpyW(subkey, keyValue); + if (!assoc) lstrcatW(subkey, shOpCmdW); if (RegOpenKeyExW(key, subkey, 0, accessOptions, &readKey) == ERROR_SUCCESS) { @@ -4933,8 +4933,8 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) { newValue++; /* Set up key name */ - strcpyW(subkey, args); - if (!assoc) strcatW(subkey, shOpCmdW); + lstrcpyW(subkey, args); + if (!assoc) lstrcatW(subkey, shOpCmdW); /* If nothing after '=' then clear value - only valid for ASSOC */ if (*newValue == 0x00) { @@ -4967,7 +4967,7 @@ void WCMD_assoc (const WCHAR *args, BOOL assoc) { if (rc == ERROR_SUCCESS) { rc = RegSetValueExW(readKey, NULL, 0, REG_SZ, (LPBYTE)newValue, - sizeof(WCHAR) * (strlenW(newValue) + 1)); + sizeof(WCHAR) * (lstrlenW(newValue) + 1)); RegCloseKey(readKey); } @@ -4999,7 +4999,7 @@ void WCMD_color (void) { CONSOLE_SCREEN_BUFFER_INFO consoleInfo; HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); - if (param1[0] != 0x00 && strlenW(param1) > 2) { + if (param1[0] != 0x00 && lstrlenW(param1) > 2) { WCMD_output_stderr(WCMD_LoadMessage(WCMD_ARGERR)); return; } @@ -5019,7 +5019,7 @@ void WCMD_color (void) { if (param1[0] == 0x00) { color = defaultColor; } else { - color = strtoulW(param1, NULL, 16); + color = wcstoul(param1, NULL, 16); } /* Fail if fg == bg color */ diff --git a/programs/cmd/directory.c b/programs/cmd/directory.c index 1576ab7de5a..02ea487f2c4 100644 --- a/programs/cmd/directory.c +++ b/programs/cmd/directory.c @@ -59,7 +59,7 @@ static WCHAR * WCMD_strrev (WCHAR *buff) { int r, i; WCHAR b; - r = strlenW (buff); + r = lstrlenW (buff); for (i=0; idirName, parms->dirName) == 0) { + while (parms && lstrcmpW(inputparms->dirName, parms->dirName) == 0) { concurrentDirs++; /* Work out the full path + filename */ - strcpyW(real_path, parms->dirName); - strcatW(real_path, parms->fileName); + lstrcpyW(real_path, parms->dirName); + lstrcatW(real_path, parms->fileName); /* Load all files into an in memory structure */ WINE_TRACE("Looking for matches to '%s'\n", wine_dbgstr_w(real_path)); @@ -293,7 +293,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le /* Keep running track of longest filename for wide output */ if (wide || orderByCol) { - int tmpLen = strlenW(fd[entry_count-1].cFileName) + 3; + int tmpLen = lstrlenW(fd[entry_count-1].cFileName) + 3; if (fd[entry_count-1].dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) tmpLen = tmpLen + 2; if (tmpLen > widest) widest = tmpLen; } @@ -310,8 +310,8 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le } /* Work out the actual current directory name without a trailing \ */ - strcpyW(real_path, parms->dirName); - real_path[strlenW(parms->dirName)-1] = 0x00; + lstrcpyW(real_path, parms->dirName); + real_path[lstrlenW(parms->dirName)-1] = 0x00; /* Output the results */ if (!bare) { @@ -368,8 +368,8 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le /* /Q gets file ownership information */ if (usernames) { - strcpyW (string, inputparms->dirName); - strcatW (string, fd[i].cFileName); + lstrcpyW (string, inputparms->dirName); + lstrcatW (string, fd[i].cFileName); WCMD_getfileowner(string, username, ARRAY_SIZE(username)); } @@ -391,11 +391,11 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le static const WCHAR fmt[] = {'[','%','1',']','\0'}; WCMD_output (fmt, fd[i].cFileName); dir_count++; - tmp_width = tmp_width + strlenW(fd[i].cFileName) + 2; + tmp_width = tmp_width + lstrlenW(fd[i].cFileName) + 2; } else { static const WCHAR fmt[] = {'%','1','\0'}; WCMD_output (fmt, fd[i].cFileName); - tmp_width = tmp_width + strlenW(fd[i].cFileName) ; + tmp_width = tmp_width + lstrlenW(fd[i].cFileName) ; file_count++; file_size.u.LowPart = fd[i].nFileSizeLow; file_size.u.HighPart = fd[i].nFileSizeHigh; @@ -419,8 +419,8 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le if (usernames) WCMD_output (fmt3, username); WCMD_output(fmt4,fd[i].cFileName); } else { - if (!((strcmpW(fd[i].cFileName, dotW) == 0) || - (strcmpW(fd[i].cFileName, dotdotW) == 0))) { + if (!((lstrcmpW(fd[i].cFileName, dotW) == 0) || + (lstrcmpW(fd[i].cFileName, dotdotW) == 0))) { WCMD_output (fmt5, recurse?inputparms->dirName:nullW, fd[i].cFileName); } else { addNewLine = FALSE; @@ -484,16 +484,16 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le WIN32_FIND_DATAW finddata; /* Build path to search */ - strcpyW(string, inputparms->dirName); - strcatW(string, starW); + lstrcpyW(string, inputparms->dirName); + lstrcatW(string, starW); WINE_TRACE("Recursive, looking for '%s'\n", wine_dbgstr_w(string)); hff = FindFirstFileW(string, &finddata); if (hff != INVALID_HANDLE_VALUE) { do { if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - (strcmpW(finddata.cFileName, dotdotW) != 0) && - (strcmpW(finddata.cFileName, dotW) != 0)) { + (lstrcmpW(finddata.cFileName, dotdotW) != 0) && + (lstrcmpW(finddata.cFileName, dotW) != 0)) { DIRECTORY_STACK *thisDir; int dirsToCopy = concurrentDirs; @@ -504,9 +504,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le dirsToCopy--; /* Work out search parameter in sub dir */ - strcpyW (string, inputparms->dirName); - strcatW (string, finddata.cFileName); - strcatW (string, slashW); + lstrcpyW (string, inputparms->dirName); + lstrcatW (string, finddata.cFileName); + lstrcatW (string, slashW); WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string)); /* Allocate memory, add to list */ @@ -613,8 +613,8 @@ void WCMD_directory (WCHAR *args) if (GetEnvironmentVariableW(dircmdW, string, ARRAY_SIZE(string))) { p = string; while ( (*p = toupper(*p)) ) ++p; - strcatW(string,quals); - strcpyW(quals, string); + lstrcatW(string,quals); + lstrcpyW(quals, string); } byte_total = 0; @@ -789,7 +789,7 @@ void WCMD_directory (WCHAR *args) argno = 0; argN = args; GetCurrentDirectoryW(MAX_PATH, cwd); - strcatW(cwd, slashW); + lstrcatW(cwd, slashW); /* Loop through all args, calculating full effective directory */ fullParms = NULL; @@ -801,7 +801,7 @@ void WCMD_directory (WCHAR *args) WINE_TRACE("Found parm '%s'\n", wine_dbgstr_w(thisArg)); if (thisArg[1] == ':' && thisArg[2] == '\\') { - strcpyW(fullname, thisArg); + lstrcpyW(fullname, thisArg); } else if (thisArg[1] == ':' && thisArg[2] != '\\') { WCHAR envvar[4]; static const WCHAR envFmt[] = {'=','%','c',':','\0'}; @@ -810,14 +810,14 @@ void WCMD_directory (WCHAR *args) static const WCHAR noEnvFmt[] = {'%','c',':','\0'}; wsprintfW(fullname, noEnvFmt, thisArg[0]); } - strcatW(fullname, slashW); - strcatW(fullname, &thisArg[2]); + lstrcatW(fullname, slashW); + lstrcatW(fullname, &thisArg[2]); } else if (thisArg[0] == '\\') { memcpy(fullname, cwd, 2 * sizeof(WCHAR)); - strcpyW(fullname+2, thisArg); + lstrcpyW(fullname+2, thisArg); } else { - strcpyW(fullname, cwd); - strcatW(fullname, thisArg); + lstrcpyW(fullname, cwd); + lstrcatW(fullname, thisArg); } WINE_TRACE("Using location '%s'\n", wine_dbgstr_w(fullname)); @@ -828,16 +828,16 @@ void WCMD_directory (WCHAR *args) * path references a directory, we need to list the *contents* of that * directory not the directory file itself. */ - if ((strchrW(path, '*') == NULL) && (strchrW(path, '%') == NULL)) { + if ((wcschr(path, '*') == NULL) && (wcschr(path, '%') == NULL)) { status = GetFileAttributesW(path); if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) { - if (!ends_with_backslash( path )) strcatW( path, slashW ); - strcatW (path, starW); + if (!ends_with_backslash( path )) lstrcatW( path, slashW ); + lstrcatW (path, starW); } } else { /* Special case wildcard search with no extension (ie parameters ending in '.') as GetFullPathName strips off the additional '.' */ - if (fullname[strlenW(fullname)-1] == '.') strcatW(path, dotW); + if (fullname[lstrlenW(fullname)-1] == '.') lstrcatW(path, dotW); } WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path)); @@ -853,13 +853,13 @@ void WCMD_directory (WCHAR *args) wine_dbgstr_w(drive), wine_dbgstr_w(dir), wine_dbgstr_w(fname), wine_dbgstr_w(ext)); - thisEntry->dirName = heap_xalloc(sizeof(WCHAR) * (strlenW(drive)+strlenW(dir)+1)); - strcpyW(thisEntry->dirName, drive); - strcatW(thisEntry->dirName, dir); + thisEntry->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(drive)+lstrlenW(dir)+1)); + lstrcpyW(thisEntry->dirName, drive); + lstrcatW(thisEntry->dirName, dir); - thisEntry->fileName = heap_xalloc(sizeof(WCHAR) * (strlenW(fname)+strlenW(ext)+1)); - strcpyW(thisEntry->fileName, fname); - strcatW(thisEntry->fileName, ext); + thisEntry->fileName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(fname)+lstrlenW(ext)+1)); + lstrcpyW(thisEntry->fileName, fname); + lstrcatW(thisEntry->fileName, ext); } } diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 359c7191758..12c878c3c94 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -28,8 +28,8 @@ #include #include #include +#include #include -#include /* msdn specified max for Win XP */ #define MAXSTRING 8192 @@ -137,7 +137,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str) if(str) { size_t size; - size = (strlenW(str)+1)*sizeof(WCHAR); + size = (lstrlenW(str)+1)*sizeof(WCHAR); ret = heap_xalloc(size); memcpy(ret, str, size); } @@ -147,7 +147,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str) static inline BOOL ends_with_backslash( const WCHAR *path ) { - return path[0] && path[strlenW(path) - 1] == '\\'; + return path[0] && path[lstrlenW(path) - 1] == '\\'; } /* Data structure to hold context when executing batch files */ diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 589a39cd297..29e498a48dd 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -25,7 +25,6 @@ * - Lots of functionality missing from builtins */ -#include "config.h" #include #include "wcmd.h" #include "shellapi.h" @@ -271,7 +270,7 @@ static void WCMD_output_asis_handle (DWORD std_handle, const WCHAR *message) { numChars = 0; if (++line_count >= max_height - 1) { line_count = 0; - WCMD_output_asis_len(pagedMessage, strlenW(pagedMessage), handle); + WCMD_output_asis_len(pagedMessage, lstrlenW(pagedMessage), handle); WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, ARRAY_SIZE(string), &count); } } while (((message = ptr) != NULL) && (*ptr)); @@ -346,7 +345,7 @@ static void WCMD_show_prompt (BOOL newLine) { len = GetEnvironmentVariableW(envPrompt, prompt_string, ARRAY_SIZE(prompt_string)); if ((len == 0) || (len >= ARRAY_SIZE(prompt_string))) { static const WCHAR dfltPrompt[] = {'$','P','$','G','\0'}; - strcpyW (prompt_string, dfltPrompt); + lstrcpyW (prompt_string, dfltPrompt); } p = prompt_string; q = out_string; @@ -403,7 +402,7 @@ static void WCMD_show_prompt (BOOL newLine) { case 'P': status = GetCurrentDirectoryW(ARRAY_SIZE(curdir), curdir); if (status) { - strcatW (q, curdir); + lstrcatW (q, curdir); while (*q) q++; } break; @@ -418,7 +417,7 @@ static void WCMD_show_prompt (BOOL newLine) { while (*q) q++; break; case 'V': - strcatW (q, version_string); + lstrcatW (q, version_string); while (*q) q++; break; case '_': @@ -462,7 +461,7 @@ void WCMD_strsubstW(WCHAR *start, const WCHAR *next, const WCHAR *insert, int le if (len < 0) len=insert ? lstrlenW(insert) : 0; if (start+len != next) - memmove(start+len, next, (strlenW(next) + 1) * sizeof(*next)); + memmove(start+len, next, (lstrlenW(next) + 1) * sizeof(*next)); if (insert) memcpy(start, insert, len * sizeof(*insert)); } @@ -529,7 +528,7 @@ static inline BOOL WCMD_is_magic_envvar(const WCHAR *s, const WCHAR *magicvar) if (s[0] != '%') return FALSE; /* Didn't begin with % */ - len = strlenW(s); + len = lstrlenW(s); if (len < 2 || s[len-1] != '%') return FALSE; /* Didn't end with another % */ @@ -573,7 +572,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) /* Find the end of the environment variable, and extract name */ Delims[0] = startchar; - endOfVar = strpbrkW(start+1, Delims); + endOfVar = wcspbrk(start+1, Delims); if (endOfVar == NULL || *endOfVar==' ') { @@ -593,13 +592,13 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) /* If ':' found, process remaining up until '%' (or stop at ':' if a missing '%' */ if (*endOfVar==':') { - WCHAR *endOfVar2 = strchrW(endOfVar+1, startchar); + WCHAR *endOfVar2 = wcschr(endOfVar+1, startchar); if (endOfVar2 != NULL) endOfVar = endOfVar2; } memcpy(thisVar, start, ((endOfVar - start) + 1) * sizeof(WCHAR)); thisVar[(endOfVar - start)+1] = 0x00; - colonpos = strchrW(thisVar+1, ':'); + colonpos = wcschr(thisVar+1, ':'); /* If there's complex substitution, just need %var% for now to get the expanded data to play with */ @@ -624,22 +623,22 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) if (WCMD_is_magic_envvar(thisVar, ErrorLvl)) { static const WCHAR fmt[] = {'%','d','\0'}; wsprintfW(thisVarContents, fmt, errorlevel); - len = strlenW(thisVarContents); + len = lstrlenW(thisVarContents); } else if (WCMD_is_magic_envvar(thisVar, Date)) { GetDateFormatW(LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, thisVarContents, MAXSTRING); - len = strlenW(thisVarContents); + len = lstrlenW(thisVarContents); } else if (WCMD_is_magic_envvar(thisVar, Time)) { GetTimeFormatW(LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, thisVarContents, MAXSTRING); - len = strlenW(thisVarContents); + len = lstrlenW(thisVarContents); } else if (WCMD_is_magic_envvar(thisVar, Cd)) { GetCurrentDirectoryW(MAXSTRING, thisVarContents); - len = strlenW(thisVarContents); + len = lstrlenW(thisVarContents); } else if (WCMD_is_magic_envvar(thisVar, Random)) { static const WCHAR fmt[] = {'%','d','\0'}; wsprintfW(thisVarContents, fmt, rand() % 32768); - len = strlenW(thisVarContents); + len = lstrlenW(thisVarContents); } else { len = ExpandEnvironmentStringsW(thisVar, thisVarContents, ARRAY_SIZE(thisVarContents)); @@ -668,7 +667,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) if (colonpos == NULL) { WCMD_strsubstW(start, endOfVar + 1, NULL, 0); } else { - len = strlenW(thisVar); + len = lstrlenW(thisVar); thisVar[len-1] = 0x00; /* If %:...% supplied, : is retained */ if (colonpos == thisVar+1) { @@ -706,11 +705,11 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) if (savedchar == '~') { int substrposition, substrlength = 0; - WCHAR *commapos = strchrW(colonpos+2, ','); + WCHAR *commapos = wcschr(colonpos+2, ','); WCHAR *startCopy; - substrposition = atolW(colonpos+2); - if (commapos) substrlength = atolW(commapos+1); + substrposition = wcstol(colonpos+2, NULL, 10); + if (commapos) substrlength = wcstol(commapos+1, NULL, 10); /* Check bounds */ if (substrposition >= 0) { @@ -735,7 +734,7 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) /* search and replace manipulation */ } else { - WCHAR *equalspos = strstrW(colonpos, equalW); + WCHAR *equalspos = wcsstr(colonpos, equalW); WCHAR *replacewith = equalspos+1; WCHAR *found = NULL; WCHAR *searchIn; @@ -745,29 +744,29 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) s = heap_strdupW(endOfVar + 1); /* Null terminate both strings */ - thisVar[strlenW(thisVar)-1] = 0x00; + thisVar[lstrlenW(thisVar)-1] = 0x00; *equalspos = 0x00; /* Since we need to be case insensitive, copy the 2 buffers */ searchIn = heap_strdupW(thisVarContents); - CharUpperBuffW(searchIn, strlenW(thisVarContents)); + CharUpperBuffW(searchIn, lstrlenW(thisVarContents)); searchFor = heap_strdupW(colonpos+1); - CharUpperBuffW(searchFor, strlenW(colonpos+1)); + CharUpperBuffW(searchFor, lstrlenW(colonpos+1)); /* Handle wildcard case */ if (*(colonpos+1) == '*') { /* Search for string to replace */ - found = strstrW(searchIn, searchFor+1); + found = wcsstr(searchIn, searchFor+1); if (found) { /* Do replacement */ - strcpyW(start, replacewith); - strcatW(start, thisVarContents + (found-searchIn) + strlenW(searchFor+1)); - strcatW(start, s); + lstrcpyW(start, replacewith); + lstrcatW(start, thisVarContents + (found-searchIn) + lstrlenW(searchFor+1)); + lstrcatW(start, s); } else { /* Copy as is */ - strcpyW(start, thisVarContents); - strcatW(start, s); + lstrcpyW(start, thisVarContents); + lstrcatW(start, s); } } else { @@ -776,18 +775,18 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) WCHAR *outputposn = start; *start = 0x00; - while ((found = strstrW(lastFound, searchFor))) { + while ((found = wcsstr(lastFound, searchFor))) { lstrcpynW(outputposn, thisVarContents + (lastFound-searchIn), (found - lastFound)+1); outputposn = outputposn + (found - lastFound); - strcatW(outputposn, replacewith); - outputposn = outputposn + strlenW(replacewith); - lastFound = found + strlenW(searchFor); + lstrcatW(outputposn, replacewith); + outputposn = outputposn + lstrlenW(replacewith); + lastFound = found + lstrlenW(searchFor); } - strcatW(outputposn, + lstrcatW(outputposn, thisVarContents + (lastFound-searchIn)); - strcatW(outputposn, s); + lstrcatW(outputposn, s); } heap_free(s); heap_free(searchIn); @@ -832,8 +831,8 @@ static void handleExpansion(WCHAR *cmd, BOOL atExecute, BOOL delayed) { } /* Find the next environment variable delimiter */ - normalp = strchrW(p, '%'); - if (delayed) delayedp = strchrW(p, '!'); + normalp = wcschr(p, '%'); + if (delayed) delayedp = wcschr(p, '!'); if (!normalp) p = delayedp; else if (!delayedp) p = normalp; else p = min(p,delayedp); @@ -868,7 +867,7 @@ static void handleExpansion(WCHAR *cmd, BOOL atExecute, BOOL delayed) { WCHAR *startOfParms = NULL; WCHAR *thisParm = WCMD_parameter(context -> command, 0, &startOfParms, TRUE, TRUE); if (startOfParms != NULL) { - startOfParms += strlenW(thisParm); + startOfParms += lstrlenW(thisParm); while (*startOfParms==' ' || *startOfParms == '\t') startOfParms++; WCMD_strsubstW(p, p+2, startOfParms, -1); } else @@ -889,8 +888,8 @@ static void handleExpansion(WCHAR *cmd, BOOL atExecute, BOOL delayed) { } /* Find the next environment variable delimiter */ - normalp = strchrW(p, '%'); - if (delayed) delayedp = strchrW(p, '!'); + normalp = wcschr(p, '%'); + if (delayed) delayedp = wcschr(p, '!'); if (!normalp) p = delayedp; else if (!delayedp) p = normalp; else p = min(p,delayedp); @@ -919,7 +918,7 @@ static void WCMD_parse (const WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2) case '/': *q++ = *s++; while ((*s != '\0') && (*s != ' ') && *s != '/') { - *q++ = toupperW (*s++); + *q++ = towupper (*s++); } *q = '\0'; break; @@ -1057,30 +1056,30 @@ void WCMD_run_program (WCHAR *command, BOOL called) if (!firstParam) return; /* Calculate the search path and stem to search for */ - if (strpbrkW (firstParam, delims) == NULL) { /* No explicit path given, search path */ + if (wcspbrk (firstParam, delims) == NULL) { /* No explicit path given, search path */ static const WCHAR curDir[] = {'.',';','\0'}; - strcpyW(pathtosearch, curDir); + lstrcpyW(pathtosearch, curDir); len = GetEnvironmentVariableW(envPath, &pathtosearch[2], ARRAY_SIZE(pathtosearch)-2); if ((len == 0) || (len >= ARRAY_SIZE(pathtosearch) - 2)) { static const WCHAR curDir[] = {'.','\0'}; - strcpyW (pathtosearch, curDir); + lstrcpyW (pathtosearch, curDir); } - if (strchrW(firstParam, '.') != NULL) extensionsupplied = TRUE; - if (strlenW(firstParam) >= MAX_PATH) + if (wcschr(firstParam, '.') != NULL) extensionsupplied = TRUE; + if (lstrlenW(firstParam) >= MAX_PATH) { WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_LINETOOLONG)); return; } - strcpyW(stemofsearch, firstParam); + lstrcpyW(stemofsearch, firstParam); } else { /* Convert eg. ..\fred to include a directory by removing file part */ GetFullPathNameW(firstParam, ARRAY_SIZE(pathtosearch), pathtosearch, NULL); - lastSlash = strrchrW(pathtosearch, '\\'); - if (lastSlash && strchrW(lastSlash, '.') != NULL) extensionsupplied = TRUE; - strcpyW(stemofsearch, lastSlash+1); + lastSlash = wcsrchr(pathtosearch, '\\'); + if (lastSlash && wcschr(lastSlash, '.') != NULL) extensionsupplied = TRUE; + lstrcpyW(stemofsearch, lastSlash+1); /* Reduce pathtosearch to a path with trailing '\' to support c:\a.bat and c:\windows\a.bat syntax */ @@ -1090,7 +1089,7 @@ void WCMD_run_program (WCHAR *command, BOOL called) /* Now extract PATHEXT */ len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext)); if ((len == 0) || (len >= ARRAY_SIZE(pathext))) { - strcpyW (pathext, dfltPathExt); + lstrcpyW (pathext, dfltPathExt); } /* Loop through the search path, dir by dir */ @@ -1118,28 +1117,28 @@ void WCMD_run_program (WCHAR *command, BOOL called) thisDir[(pos-pathposn)] = 0x00; pathposn = pos+1; } else { /* Reached string end */ - strcpyW(thisDir, pathposn); + lstrcpyW(thisDir, pathposn); pathposn = NULL; } /* Remove quotes */ - length = strlenW(thisDir); + length = lstrlenW(thisDir); if (thisDir[length - 1] == '"') thisDir[length - 1] = 0; if (*thisDir != '"') - strcpyW(temp, thisDir); + lstrcpyW(temp, thisDir); else - strcpyW(temp, thisDir + 1); + lstrcpyW(temp, thisDir + 1); /* Since you can have eg. ..\.. on the path, need to expand to full information */ GetFullPathNameW(temp, MAX_PATH, thisDir, NULL); /* 1. If extension supplied, see if that file exists */ - strcatW(thisDir, slashW); - strcatW(thisDir, stemofsearch); - pos = &thisDir[strlenW(thisDir)]; /* Pos = end of name */ + lstrcatW(thisDir, slashW); + lstrcatW(thisDir, stemofsearch); + pos = &thisDir[lstrlenW(thisDir)]; /* Pos = end of name */ /* 1. If extension supplied, see if that file exists */ if (extensionsupplied) { @@ -1154,7 +1153,7 @@ void WCMD_run_program (WCHAR *command, BOOL called) WIN32_FIND_DATAW finddata; static const WCHAR allFiles[] = {'.','*','\0'}; - strcatW(thisDir,allFiles); + lstrcatW(thisDir,allFiles); h = FindFirstFileW(thisDir, &finddata); FindClose(h); if (h != INVALID_HANDLE_VALUE) { @@ -1163,14 +1162,14 @@ void WCMD_run_program (WCHAR *command, BOOL called) /* 3. Yes - Try each path ext */ while (thisExt) { - WCHAR *nextExt = strchrW(thisExt, ';'); + WCHAR *nextExt = wcschr(thisExt, ';'); if (nextExt) { memcpy(pos, thisExt, (nextExt-thisExt) * sizeof(WCHAR)); pos[(nextExt-thisExt)] = 0x00; thisExt = nextExt+1; } else { - strcpyW(pos, thisExt); + lstrcpyW(pos, thisExt); thisExt = NULL; } @@ -1189,14 +1188,14 @@ void WCMD_run_program (WCHAR *command, BOOL called) SHFILEINFOW psfi; DWORD console; HINSTANCE hinst; - WCHAR *ext = strrchrW( thisDir, '.' ); + WCHAR *ext = wcsrchr( thisDir, '.' ); static const WCHAR batExt[] = {'.','b','a','t','\0'}; static const WCHAR cmdExt[] = {'.','c','m','d','\0'}; WINE_TRACE("Found as %s\n", wine_dbgstr_w(thisDir)); /* Special case BAT and CMD */ - if (ext && (!strcmpiW(ext, batExt) || !strcmpiW(ext, cmdExt))) { + if (ext && (!wcsicmp(ext, batExt) || !wcsicmp(ext, cmdExt))) { BOOL oldinteractive = interactive; interactive = FALSE; WCMD_batch (thisDir, command, called, NULL, INVALID_HANDLE_VALUE); @@ -1301,7 +1300,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, /* Move copy of the command onto the heap so it can be expanded */ new_cmd = heap_xalloc(MAXSTRING * sizeof(WCHAR)); - strcpyW(new_cmd, command); + lstrcpyW(new_cmd, command); cmd = new_cmd; /* Move copy of the redirects onto the heap so it can be expanded */ @@ -1357,7 +1356,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, wsprintfW (new_redir, redirOut, redirects, (*cmdList)->nextcommand->pipeFile); WINE_TRACE("Redirects now %s\n", wine_dbgstr_w(new_redir)); } else { - strcpyW(new_redir, redirects); + lstrcpyW(new_redir, redirects); } /* Expand variables in command line mode only (batch mode will @@ -1381,8 +1380,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, /* According to MSDN CreateProcess docs, special env vars record the current directory on each drive, in the form =C: so see if one specified, and if so go back to it */ - strcpyW(envvar, equalW); - strcatW(envvar, cmd); + lstrcpyW(envvar, equalW); + lstrcatW(envvar, cmd); if (GetEnvironmentVariableW(envvar, dir, MAX_PATH) == 0) { static const WCHAR fmt[] = {'%','s','\\','\0'}; wsprintfW(cmd, fmt, cmd); @@ -1424,7 +1423,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, (*cmdList)->pipeFile[0] = 0x00; /* Otherwise STDIN could come from a '<' redirect */ - } else if ((pos = strchrW(new_redir,'<')) != NULL) { + } else if ((pos = wcschr(new_redir,'<')) != NULL) { h = CreateFileW(WCMD_parameter(++pos, 0, NULL, FALSE, FALSE), GENERIC_READ, FILE_SHARE_READ, &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h == INVALID_HANDLE_VALUE) { @@ -1437,7 +1436,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, } /* Scan the whole command looking for > and 2> */ - while (redir != NULL && ((pos = strchrW(redir,'>')) != NULL)) { + while (redir != NULL && ((pos = wcschr(redir,'>')) != NULL)) { int handle = 0; if (pos > redir && (*(pos-1)=='2')) @@ -1586,7 +1585,7 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, WCMD_setshow_time (); break; case WCMD_TITLE: - if (strlenW(&whichcmd[count]) > 0) + if (lstrlenW(&whichcmd[count]) > 0) WCMD_title(&whichcmd[count+1]); break; case WCMD_TYPE: @@ -1668,7 +1667,7 @@ WCHAR *WCMD_LoadMessage(UINT id) { if (!LoadStringW(GetModuleHandleW(NULL), id, msg, ARRAY_SIZE(msg))) { WINE_FIXME("LoadString failed with %d\n", GetLastError()); - strcpyW(msg, failedMsg); + lstrcpyW(msg, failedMsg); } return msg; } @@ -1858,7 +1857,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE /* If initial command read in, use that, otherwise get input from handle */ if (optionalcmd != NULL) { - strcpyW(extraSpace, optionalcmd); + lstrcpyW(extraSpace, optionalcmd); } else if (readFrom == INVALID_HANDLE_VALUE) { WINE_FIXME("No command nor handle supplied\n"); } else { @@ -1868,7 +1867,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE curPos = extraSpace; /* Handle truncated input - issue warning */ - if (strlenW(extraSpace) == MAXSTRING -1) { + if (lstrlenW(extraSpace) == MAXSTRING -1) { WCMD_output_asis_stderr(WCMD_LoadMessage(WCMD_TRUNCATEDLINE)); WCMD_output_asis_stderr(extraSpace); WCMD_output_asis_stderr(newlineW); @@ -1886,7 +1885,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE static const WCHAR echoCol[] = {'e','c','h','o',':'}; static const WCHAR echoSlash[] = {'e','c','h','o','/'}; const DWORD len = ARRAY_SIZE(echoDot); - DWORD curr_size = strlenW(curPos); + DWORD curr_size = lstrlenW(curPos); DWORD min_len = (curr_size < len ? curr_size : len); WCMD_show_prompt(TRUE); WCMD_output_asis(curPos); @@ -2422,7 +2421,7 @@ int wmain (int argc, WCHAR *argvW[]) if (!GetEnvironmentVariableW(comspecW, comspec, ARRAY_SIZE(comspec))) { GetSystemDirectoryW(comspec, ARRAY_SIZE(comspec) - ARRAY_SIZE(cmdW)); - strcatW(comspec, cmdW); + lstrcatW(comspec, cmdW); SetEnvironmentVariableW(comspecW, comspec); } @@ -2433,11 +2432,10 @@ int wmain (int argc, WCHAR *argvW[]) GetVersionExW(&osv); /* Pre initialize some messages */ - strcpyW(anykey, WCMD_LoadMessage(WCMD_ANYKEY)); - sprintf(osver, "%d.%d.%d (%s)", osv.dwMajorVersion, osv.dwMinorVersion, - osv.dwBuildNumber, PACKAGE_VERSION); + lstrcpyW(anykey, WCMD_LoadMessage(WCMD_ANYKEY)); + sprintf(osver, "%d.%d.%d", osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber); cmd = WCMD_format_string(WCMD_LoadMessage(WCMD_VERSION), osver); - strcpyW(version_string, cmd); + lstrcpyW(version_string, cmd); LocalFree(cmd); cmd = NULL; @@ -2461,29 +2459,29 @@ int wmain (int argc, WCHAR *argvW[]) } c=argPos[1]; - if (tolowerW(c)=='c') { + if (towlower(c)=='c') { opt_c = TRUE; - } else if (tolowerW(c)=='q') { + } else if (towlower(c)=='q') { opt_q = TRUE; - } else if (tolowerW(c)=='k') { + } else if (towlower(c)=='k') { opt_k = TRUE; - } else if (tolowerW(c)=='s') { + } else if (towlower(c)=='s') { opt_s = TRUE; - } else if (tolowerW(c)=='a') { + } else if (towlower(c)=='a') { unicodeOutput = FALSE; - } else if (tolowerW(c)=='u') { + } else if (towlower(c)=='u') { unicodeOutput = TRUE; - } else if (tolowerW(c)=='v' && argPos[2]==':') { - delayedsubst = strncmpiW(&argPos[3], offW, 3); + } else if (towlower(c)=='v' && argPos[2]==':') { + delayedsubst = wcsnicmp(&argPos[3], offW, 3); if (delayedsubst) WINE_TRACE("Delayed substitution is on\n"); - } else if (tolowerW(c)=='t' && argPos[2]==':') { - opt_t=strtoulW(&argPos[3], NULL, 16); - } else if (tolowerW(c)=='x' || tolowerW(c)=='y') { + } else if (towlower(c)=='t' && argPos[2]==':') { + opt_t=wcstoul(&argPos[3], NULL, 16); + } else if (towlower(c)=='x' || towlower(c)=='y') { /* Ignored for compatibility with Windows */ } if (argPos[2]==0 || argPos[2]==' ' || argPos[2]=='\t' || - tolowerW(c)=='v') { + towlower(c)=='v') { args++; WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE); } @@ -2524,19 +2522,19 @@ int wmain (int argc, WCHAR *argvW[]) if (!opt_s) { /* 1. Confirm there is at least one quote */ - q1 = strchrW(argPos, '"'); + q1 = wcschr(argPos, '"'); if (!q1) opt_s=1; } if (!opt_s) { /* 2. Confirm there is a second quote */ - q2 = strchrW(q1+1, '"'); + q2 = wcschr(q1+1, '"'); if (!q2) opt_s=1; } if (!opt_s) { /* 3. Ensure there are no more quotes */ - if (strchrW(q2+1, '"')) opt_s=1; + if (wcschr(q2+1, '"')) opt_s=1; } /* check first parameter for a space and invalid characters. There must not be any @@ -2568,16 +2566,16 @@ int wmain (int argc, WCHAR *argvW[]) /* Now extract PATHEXT */ len = GetEnvironmentVariableW(envPathExt, pathext, ARRAY_SIZE(pathext)); if ((len == 0) || (len >= ARRAY_SIZE(pathext))) { - strcpyW (pathext, dfltPathExt); + lstrcpyW (pathext, dfltPathExt); } /* If the supplied parameter has any directory information, look there */ WINE_TRACE("First parameter is '%s'\n", wine_dbgstr_w(thisArg)); - if (strchrW(thisArg, '\\') != NULL) { + if (wcschr(thisArg, '\\') != NULL) { GetFullPathNameW(thisArg, ARRAY_SIZE(string), string, NULL); WINE_TRACE("Full path name '%s'\n", wine_dbgstr_w(string)); - p = string + strlenW(string); + p = string + lstrlenW(string); /* Does file exist with this name? */ if (GetFileAttributesW(string) != INVALID_FILE_ATTRIBUTES) { @@ -2588,14 +2586,14 @@ int wmain (int argc, WCHAR *argvW[]) /* No - try with each of the PATHEXT extensions */ while (!found && thisExt) { - WCHAR *nextExt = strchrW(thisExt, ';'); + WCHAR *nextExt = wcschr(thisExt, ';'); if (nextExt) { memcpy(p, thisExt, (nextExt-thisExt) * sizeof(WCHAR)); p[(nextExt-thisExt)] = 0x00; thisExt = nextExt+1; } else { - strcpyW(p, thisExt); + lstrcpyW(p, thisExt); thisExt = NULL; } @@ -2618,7 +2616,7 @@ int wmain (int argc, WCHAR *argvW[]) /* No - try with each of the PATHEXT extensions */ while (!found && thisExt) { - WCHAR *nextExt = strchrW(thisExt, ';'); + WCHAR *nextExt = wcschr(thisExt, ';'); if (nextExt) { *nextExt = 0; @@ -2716,7 +2714,7 @@ int wmain (int argc, WCHAR *argvW[]) size = ARRAY_SIZE(strvalue); RegQueryValueExW(key, dfltColorW, NULL, NULL, (LPBYTE)strvalue, &size); - value = strtoulW(strvalue, NULL, 10); + value = wcstoul(strvalue, NULL, 10); } } RegCloseKey(key); @@ -2737,7 +2735,7 @@ int wmain (int argc, WCHAR *argvW[]) size = ARRAY_SIZE(strvalue); RegQueryValueExW(key, dfltColorW, NULL, NULL, (LPBYTE)strvalue, &size); - value = strtoulW(strvalue, NULL, 10); + value = wcstoul(strvalue, NULL, 10); } } RegCloseKey(key);