+ while (*SourcePtr != UNICODE_NULL)
+ {
+ while (*SourcePtr != UNICODE_NULL)
+ {
+ if (*SourcePtr == L'=')
+ {
+ /* Store the '=' sign */
+ *DestPtr++ = *SourcePtr++;
+
+ /* Check if this is likely a full path */
+ if (isalphaW(SourcePtr[0])
+ && (SourcePtr[1] == L':')
+ && ((SourcePtr[2] == '\\') || (SourcePtr[2] == '/')))
+ {
+ PWCHAR Delimiter = wcschr(SourcePtr, L';');
+ ULONG NumChars;
+
+ if (Delimiter != NULL)
+ {
+ wcsncpy(PathBuffer,
+ SourcePtr,
+ min(Delimiter - SourcePtr, MAX_PATH));
+
+ /* Seek to the part after the delimiter */
+ SourcePtr = Delimiter + 1;
+ }
+ else
+ {
+ wcsncpy(PathBuffer, SourcePtr, MAX_PATH);
+
+ /* Seek to the end of the string */
+ SourcePtr = wcschr(SourcePtr, UNICODE_NULL);
+ }
+
+ /* Convert the path into a short path */
+ NumChars = GetShortPathNameW(PathBuffer,
+ DestPtr,
+ EnvironmentSize - (DestPtr - NewEnvironment));
+ if (NumChars)
+ {
+ /*
+ * If it failed, this block won't be executed, so it
+ * will continue from the character after the '=' sign.
+ */
+ DestPtr += NumChars;
+
+ /* Append the delimiter */
+ if (Delimiter != NULL) *DestPtr++ = L';';
+ }
+ }
+ }
+ else if (islowerW(*SourcePtr)) *DestPtr++ = toupperW(*SourcePtr++);
+ else *DestPtr++ = *SourcePtr++;
+ }
+
+ /* Copy the terminating NULL character */
+ *DestPtr++ = *SourcePtr++;
+ }