Index: lib/rtl/path.c =================================================================== --- lib/rtl/path.c (révision 57313) +++ lib/rtl/path.c (copie de travail) @@ -35,9 +35,9 @@ const UNICODE_STRING DeviceRootString = RTL_CONSTANT_STRING(L"\\\\.\\"); const UNICODE_STRING RtlpDosDevicesUncPrefix = RTL_CONSTANT_STRING(L"\\??\\UNC\\"); -const UNICODE_STRING RtlpWin32NtRootSlash = RTL_CONSTANT_STRING(L"\\\\?\\"); -const UNICODE_STRING RtlpDosSlashCONDevice = RTL_CONSTANT_STRING(L"\\\\.\\CON"); -const UNICODE_STRING RtlpDosDevicesPrefix = RTL_CONSTANT_STRING(L"\\??\\"); +const UNICODE_STRING RtlpWin32NtRootSlash = RTL_CONSTANT_STRING(L"\\\\?\\"); +const UNICODE_STRING RtlpDosSlashCONDevice = RTL_CONSTANT_STRING(L"\\\\.\\CON"); +const UNICODE_STRING RtlpDosDevicesPrefix = RTL_CONSTANT_STRING(L"\\??\\"); const UNICODE_STRING RtlpDosLPTDevice = RTL_CONSTANT_STRING(L"LPT"); const UNICODE_STRING RtlpDosCOMDevice = RTL_CONSTANT_STRING(L"COM"); @@ -141,7 +141,7 @@ { /* Stop if we hit something else than a space or period */ c = PathCopy.Buffer[PathChars - 1]; - if ((c != '.') && (c != ' ')) break; + if ((c != L'.') && (c != L' ')) break; /* Fixup the lengths */ PathCopy.Length -= sizeof(WCHAR); @@ -160,15 +160,15 @@ { /* Check if the character is a path or drive separator */ c = *End; - if ((c == '\\') || (c == '/') || ((c == ':') && (End == PathCopy.Buffer + 1))) + if ((c == L'\\') || (c == L'/') || ((c == L':') && (End == PathCopy.Buffer + 1))) { /* Get the next lower case character */ End++; - c = *End | ' '; // ' ' == ('z' - 'Z') + c = *End | L' '; // L' ' == (L'z' - L'Z') /* Check if it's a DOS device (LPT, COM, PRN, AUX, or NUL) */ if ((End < &PathCopy.Buffer[OriginalLength / sizeof(WCHAR)]) && - ((c == 'l') || (c == 'c') || (c == 'p') || (c == 'a') || (c == 'n'))) + ((c == L'l') || (c == L'c') || (c == L'p') || (c == L'a') || (c == L'n'))) { /* Calculate the offset */ ReturnOffset = (USHORT)((PCHAR)End - (PCHAR)PathCopy.Buffer); @@ -190,8 +190,8 @@ } /* Get the next lower case character and check if it's a DOS device */ - c = *PathCopy.Buffer | ' '; // ' ' == ('z' - 'Z') - if ((c != 'l') && (c != 'c') && (c != 'p') && (c != 'a') && (c != 'n')) + c = *PathCopy.Buffer | L' '; // L' ' == (L'z' - L'Z') + if ((c != L'l') && (c != L'c') && (c != L'p') && (c != L'a') && (c != L'n')) { /* Not LPT, COM, PRN, AUX, or NUL */ return 0; @@ -204,12 +204,12 @@ while (Start < End) { c = *Start; - if ((c == '.') || (c == ':')) break; + if ((c == L'.') || (c == L':')) break; Start++; } /* And then go backwards to get rid of spaces */ - while ((Start > PathCopy.Buffer) && (Start[-1] == ' ')) --Start; + while ((Start > PathCopy.Buffer) && (Start[-1] == L' ')) --Start; /* Finally see how many characters are left, and that's our size */ PathChars = (USHORT)(Start - PathCopy.Buffer); @@ -217,7 +217,7 @@ /* Check if this is a COM or LPT port, which has a digit after it */ if ((PathChars == 4) && - (iswdigit(PathCopy.Buffer[3]) && (PathCopy.Buffer[3] != '0'))) + (iswdigit(PathCopy.Buffer[3]) && (PathCopy.Buffer[3] != L'0'))) { /* Don't compare the number part, just check for LPT or COM */ PathCopy.Length -= sizeof(WCHAR); @@ -261,7 +261,7 @@ *NameInvalid = TRUE; /* Copy the filename */ - RtlCopyMemory(Buffer, FileName->Buffer, FileName->Length); + RtlMoveMemory(Buffer, FileName->Buffer, FileName->Length); /* And add a dot at the end */ Buffer[Length / sizeof(WCHAR)] = L'.'; @@ -402,8 +402,8 @@ if (!NewBuffer) return STATUS_NO_MEMORY; /* Copy the prefix, and then the rest of the DOS path, and NULL-terminate */ - RtlCopyMemory(NewBuffer, RtlpDosDevicesPrefix.Buffer, RtlpDosDevicesPrefix.Length); - RtlCopyMemory((PCHAR)NewBuffer + RtlpDosDevicesPrefix.Length, + RtlMoveMemory(NewBuffer, RtlpDosDevicesPrefix.Buffer, RtlpDosDevicesPrefix.Length); + RtlMoveMemory((PCHAR)NewBuffer + RtlpDosDevicesPrefix.Length, DosPath->Buffer + RtlpDosDevicesPrefix.Length / sizeof(WCHAR), DosPath->Length - RtlpDosDevicesPrefix.Length); NewBuffer[DosLength / sizeof(WCHAR)] = UNICODE_NULL; @@ -422,7 +422,7 @@ { /* Loop from the back until we find a path separator */ p = &NewBuffer[(DosLength - 1) / sizeof (WCHAR)]; - while (p > NewBuffer) if (*p-- == '\\') break; + while (p > NewBuffer) if (*p-- == L'\\') break; /* Was one found? */ if (p > NewBuffer) @@ -468,7 +468,7 @@ PCURDIR CurrentDirectory; /* Assume MAX_PATH for now */ - DPRINT("Relative: %lx DosName: %wZ NtName: %wZ, PartName: %p, RelativeName: %p\n", + DPRINT("Relative: %lx DosName: %wZ NtName: %p, PartName: %p, RelativeName: %p\n", HaveRelative, DosName, NtName, PartName, RelativeName); MaxLength = sizeof(BigBuffer); @@ -478,7 +478,7 @@ /* Capture input string */ CapturedDosName = *DosName; - /* Check for \\?\\ form */ + /* Check for \\?\ form */ if ((CapturedDosName.Length <= RtlpWin32NtRootSlash.Length) || (CapturedDosName.Buffer[0] != RtlpWin32NtRootSlash.Buffer[0]) || (CapturedDosName.Buffer[1] != RtlpWin32NtRootSlash.Buffer[1]) || @@ -494,7 +494,7 @@ /* Allocate a buffer to hold the path */ NewBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, MaxLength); - DPRINT("Length: %lx\n", MaxLength); + DPRINT("MaxLength: %lx\n", MaxLength); if (!NewBuffer) return STATUS_NO_MEMORY; } else @@ -572,13 +572,13 @@ } /* Now copy the prefix and the buffer */ - RtlCopyMemory(NewBuffer, PrefixBuffer, PrefixLength); - RtlCopyMemory((PCHAR)NewBuffer + PrefixLength, - &Buffer[PrefixCut], + RtlMoveMemory(NewBuffer, PrefixBuffer, PrefixLength); + RtlMoveMemory((PCHAR)NewBuffer + PrefixLength, + Buffer + PrefixCut, PathLength - (PrefixCut * sizeof(WCHAR))); /* Compute the length */ - Length = PathLength - PrefixCut * sizeof(WCHAR) + PrefixLength; + Length = PathLength + PrefixLength - PrefixCut * sizeof(WCHAR); LengthChars = Length / sizeof(WCHAR); /* Setup the actual NT path string and terminate it */ @@ -642,12 +642,12 @@ if (RtlEqualUnicodeString(&FullPath, &CurrentDirectory->DosPath, TRUE)) { /* Make relative name string */ - RelativeName->RelativeName.Buffer = (PWSTR)((ULONG_PTR)NewBuffer + FullPath.Length - PrefixCut); + RelativeName->RelativeName.Buffer = (PWSTR)((ULONG_PTR)NewBuffer + PrefixLength + FullPath.Length - PrefixCut * sizeof(WCHAR)); RelativeName->RelativeName.Length = (USHORT)(PathLength - FullPath.Length); /* If relative name starts with \, skip it */ if (RelativeName->RelativeName.Buffer[0] == L'\\') { - RelativeName->RelativeName.Buffer = (PWSTR)((ULONG_PTR)RelativeName->RelativeName.Buffer + sizeof(WCHAR)); + RelativeName->RelativeName.Buffer++; RelativeName->RelativeName.Length -= sizeof(WCHAR); } RelativeName->RelativeName.MaximumLength = RelativeName->RelativeName.Length; @@ -959,7 +959,7 @@ } /* Copy the buffer since we seem to have space */ - RtlCopyMemory(Buffer, CurDirName, Bytes); + RtlMoveMemory(Buffer, CurDirName, Bytes); /* The buffer should end with a path separator */ ASSERT(Buffer[Length - 1] == OBJ_NAME_PATH_SEPARATOR); @@ -1153,7 +1153,7 @@ CurDirHandle = NULL; /* Copy full path */ - RtlCopyMemory(CurDir->DosPath.Buffer, FullPath.Buffer, FullPath.Length + sizeof(WCHAR)); + RtlMoveMemory(CurDir->DosPath.Buffer, FullPath.Buffer, FullPath.Length + sizeof(WCHAR)); CurDir->DosPath.Length = FullPath.Length; Status = STATUS_SUCCESS; @@ -1198,11 +1198,11 @@ WCHAR *p, *next; /* convert every / into a \ */ - for (p = path; *p; p++) if (*p == '/') *p = '\\'; + for (p = path; *p; p++) if (*p == L'/') *p = L'\\'; /* collapse duplicate backslashes */ next = path + max( 1, mark ); - for (p = next; *p; p++) if (*p != '\\' || next[-1] != '\\') *next++ = *p; + for (p = next; *p; p++) if (*p != L'\\' || next[-1] != L'\\') *next++ = *p; *next = 0; p = path + mark; @@ -1212,7 +1212,7 @@ { switch(p[1]) { - case '\\': /* .\ component */ + case L'\\': /* .\ component */ next = p + 2; memmove( p, next, (wcslen(next) + 1) * sizeof(WCHAR) ); continue; @@ -1220,14 +1220,14 @@ if (p > path + mark) p--; *p = 0; continue; - case '.': - if (p[2] == '\\') /* ..\ component */ + case L'.': + if (p[2] == L'\\') /* ..\ component */ { next = p + 3; if (p > path + mark) { p--; - while (p > path + mark && p[-1] != '\\') p--; + while (p > path + mark && p[-1] != L'\\') p--; } memmove( p, next, (wcslen(next) + 1) * sizeof(WCHAR) ); continue; @@ -1237,7 +1237,7 @@ if (p > path + mark) { p--; - while (p > path + mark && p[-1] != '\\') p--; + while (p > path + mark && p[-1] != L'\\') p--; if (p > path + mark) p--; } *p = 0; @@ -1247,17 +1247,17 @@ } } /* skip to the next component */ - while (*p && *p != '\\') p++; - if (*p == '\\') + while (*p && *p != L'\\') p++; + if (*p == L'\\') { /* remove last dot in previous dir name */ - if (p > path + mark && p[-1] == '.') memmove( p-1, p, (wcslen(p) + 1) * sizeof(WCHAR) ); + if (p > path + mark && p[-1] == L'.') memmove( p-1, p, (wcslen(p) + 1) * sizeof(WCHAR) ); else p++; } } /* remove trailing spaces and dots (yes, Windows really does that, don't ask) */ - while (p > path + mark && (p[-1] == ' ' || p[-1] == '.')) p--; + while (p > path + mark && (p[-1] == L' ' || p[-1] == L'.')) p--; *p = 0; } @@ -1297,7 +1297,7 @@ WCHAR tmp[4]; /* return error if name only consists of spaces */ - for (ptr = name; *ptr; ptr++) if (*ptr != ' ') break; + for (ptr = name; *ptr; ptr++) if (*ptr != L' ') break; if (!*ptr) return 0; RtlAcquirePebLock(); @@ -1326,14 +1326,14 @@ case RtlPathTypeDriveRelative: /* c:foo */ dep = 2; - if (towupper(name[0]) != towupper(cd->Buffer[0]) || cd->Buffer[1] != ':') + if (towupper(name[0]) != towupper(cd->Buffer[0]) || cd->Buffer[1] != L':') { UNICODE_STRING var, val; - tmp[0] = '='; + tmp[0] = L'='; tmp[1] = name[0]; - tmp[2] = ':'; - tmp[3] = '\0'; + tmp[2] = L':'; + tmp[3] = L'\0'; var.Length = 3 * sizeof(WCHAR); var.MaximumLength = 4 * sizeof(WCHAR); var.Buffer = tmp; @@ -1357,14 +1357,14 @@ /* fall thru */ case STATUS_BUFFER_TOO_SMALL: reqsize = val.Length + sizeof(WCHAR); /* append trailing '\\' */ - val.Buffer[val.Length / sizeof(WCHAR)] = '\\'; + val.Buffer[val.Length / sizeof(WCHAR)] = L'\\'; ins_str = val.Buffer; break; case STATUS_VARIABLE_NOT_FOUND: reqsize = 3 * sizeof(WCHAR); tmp[0] = name[0]; - tmp[1] = ':'; - tmp[2] = '\\'; + tmp[1] = L':'; + tmp[2] = L'\\'; ins_str = tmp; RtlFreeHeap(RtlGetProcessHeap(), 0, val.Buffer); break; @@ -1381,7 +1381,7 @@ case RtlPathTypeRelative: /* foo */ reqsize = cd->Length; ins_str = cd->Buffer; - if (cd->Buffer[1] != ':') + if (cd->Buffer[1] != L':') { ptr = skip_unc_prefix( cd->Buffer ); mark = ptr - cd->Buffer; @@ -1391,16 +1391,16 @@ case RtlPathTypeRooted: /* \xxx */ #ifdef __WINE__ - if (name[0] == '/') /* may be a Unix path */ + if (name[0] == L'/') /* may be a Unix path */ { const WCHAR *ptr = name; int drive = find_drive_root( &ptr ); if (drive != -1) { reqsize = 3 * sizeof(WCHAR); - tmp[0] = 'A' + drive; - tmp[1] = ':'; - tmp[2] = '\\'; + tmp[0] = L'A' + drive; + tmp[1] = L':'; + tmp[2] = L'\\'; ins_str = tmp; mark = 3; dep = ptr - name; @@ -1408,11 +1408,11 @@ } } #endif - if (cd->Buffer[1] == ':') + if (cd->Buffer[1] == L':') { reqsize = 2 * sizeof(WCHAR); tmp[0] = cd->Buffer[0]; - tmp[1] = ':'; + tmp[1] = L':'; ins_str = tmp; mark = 3; } @@ -1428,10 +1428,10 @@ case RtlPathTypeRootLocalDevice: /* \\. */ reqsize = 4 * sizeof(WCHAR); dep = 3; - tmp[0] = '\\'; - tmp[1] = '\\'; - tmp[2] = '.'; - tmp[3] = '\\'; + tmp[0] = L'\\'; + tmp[1] = L'\\'; + tmp[2] = L'.'; + tmp[3] = L'\\'; ins_str = tmp; mark = 4; break; @@ -1450,7 +1450,7 @@ } memmove(buffer + reqsize / sizeof(WCHAR), name + dep, deplen + sizeof(WCHAR)); - if (reqsize) memcpy(buffer, ins_str, reqsize); + if (reqsize) memmove(buffer, ins_str, reqsize); reqsize += deplen; if (ins_str != tmp && ins_str != cd->Buffer) @@ -1503,7 +1503,7 @@ if (8 + sz + 2 > size) return sz + 10; wcscpy(buffer, DeviceRootW); memmove(buffer + 4, name + offset, sz); - buffer[4 + sz / sizeof(WCHAR)] = '\0'; + buffer[4 + sz / sizeof(WCHAR)] = L'\0'; /* file_part isn't set in this case */ return sz + 8; } @@ -1520,12 +1520,12 @@ RtlFreeHeap(RtlGetProcessHeap(), 0, tmp); return reqsize + sizeof(WCHAR); } - memcpy( buffer, tmp, reqsize + sizeof(WCHAR) ); + memmove( buffer, tmp, reqsize + sizeof(WCHAR) ); RtlFreeHeap(RtlGetProcessHeap(), 0, tmp); } /* find file part */ - if (file_part && (ptr = wcsrchr(buffer, '\\')) != NULL && ptr >= buffer + 2 && *++ptr) + if (file_part && (ptr = wcsrchr(buffer, L'\\')) != NULL && ptr >= buffer + 2 && *++ptr) *file_part = ptr; return reqsize; } @@ -1654,7 +1654,7 @@ while (*p) { /* Looking for an extension */ - if (*p == '.') + if (*p == L'.') { /* No extension string needed -- it's part of the filename */ Extension = NULL; @@ -1712,7 +1712,7 @@ if (*Path) { /* Loop as long as there's no semicolon */ - while (*Path != ';') + while (*Path != L';') { /* Copy the next character */ *BufferStart++ = *Path++; @@ -1720,24 +1720,24 @@ } /* We found a semi-colon, to stop path processing on this loop */ - if (*Path == ';') ++Path; + if (*Path == L';') ++Path; } /* Add a terminating slash if needed */ - if ((BufferStart != NewBuffer) && (BufferStart[-1] != '\\')) + if ((BufferStart != NewBuffer) && (BufferStart[-1] != L'\\')) { - *BufferStart++ = '\\'; + *BufferStart++ = L'\\'; } /* Bail out if we reached the end */ if (!*Path) Path = NULL; /* Copy the file name and check if an extension is needed */ - RtlCopyMemory(BufferStart, FileName, FileNameLength); + RtlMoveMemory(BufferStart, FileName, FileNameLength); if (ExtensionLength) { /* Copy the extension too */ - RtlCopyMemory((PCHAR)BufferStart + FileNameLength, + RtlMoveMemory((PCHAR)BufferStart + FileNameLength, Extension, ExtensionLength + sizeof(WCHAR)); } @@ -2256,7 +2256,7 @@ } /* Copy the path in the string */ - RtlCopyMemory(StaticCandidateString.Buffer, p, ByteCount); + RtlMoveMemory(StaticCandidateString.Buffer, p, ByteCount); /* Get to the end of the string, and add the trailing slash if missing */ CandidateEnd = &StaticCandidateString.Buffer[ByteCount / sizeof(WCHAR)]; @@ -2266,7 +2266,7 @@ } /* Copy the filename now */ - RtlCopyMemory(CandidateEnd, + RtlMoveMemory(CandidateEnd, FileNameString->Buffer, FileNameString->Length); CandidateEnd += (FileNameString->Length / sizeof(WCHAR)); @@ -2275,7 +2275,7 @@ if (ExtensionString) { /* Copy the extension too */ - RtlCopyMemory(CandidateEnd, + RtlMoveMemory(CandidateEnd, ExtensionString->Buffer, ExtensionString->Length); CandidateEnd += (ExtensionString->Length / sizeof(WCHAR));