Author: tkreuzer
Date: Mon Feb 21 23:11:53 2011
New Revision: 50861
URL:
http://svn.reactos.org/svn/reactos?rev=50861&view=rev
Log:
[CRT]
Improve _getdrive and _tchdir. Patch by devpao (devotip at tiscali dot it), small
formatting change by me.
See issue #5848 for more details.
Modified:
trunk/reactos/lib/sdk/crt/direct/chdir.c
trunk/reactos/lib/sdk/crt/direct/getdrive.c
Modified: trunk/reactos/lib/sdk/crt/direct/chdir.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/direct/chdir.c…
==============================================================================
--- trunk/reactos/lib/sdk/crt/direct/chdir.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/direct/chdir.c [iso-8859-1] Mon Feb 21 23:11:53 2011
@@ -17,10 +17,13 @@
}
/* Update the drive-specific current directory variable */
- if (GetCurrentDirectoryW(MAX_PATH, newdir) && newdir[1] == L':')
+ if (GetCurrentDirectoryW(MAX_PATH, newdir) >= 2)
{
- WCHAR envvar[4] = { L'=', towupper(newdir[0]), L':',
L'\0' };
- SetEnvironmentVariableW(envvar, newdir);
+ if (newdir[1] == L':')
+ {
+ WCHAR envvar[4] = { L'=', towupper(newdir[0]), L':',
L'\0' };
+ SetEnvironmentVariableW(envvar, newdir);
+ }
}
return 0;
Modified: trunk/reactos/lib/sdk/crt/direct/getdrive.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/sdk/crt/direct/getdriv…
==============================================================================
--- trunk/reactos/lib/sdk/crt/direct/getdrive.c [iso-8859-1] (original)
+++ trunk/reactos/lib/sdk/crt/direct/getdrive.c [iso-8859-1] Mon Feb 21 23:11:53 2011
@@ -20,9 +20,12 @@
int _getdrive(void)
{
WCHAR buffer[MAX_PATH];
- if (GetCurrentDirectoryW( MAX_PATH, buffer ) &&
- buffer[0] >= 'A' && buffer[0] <= 'z' &&
buffer[1] == ':')
- return towupper(buffer[0]) - 'A' + 1;
+ if (GetCurrentDirectoryW( MAX_PATH, buffer )>=2)
+ {
+ buffer[0]=towupper(buffer[0]);
+ if (buffer[0] >= L'A' && buffer[0] <= L'Z'
&& buffer[1] == L':')
+ return buffer[0] - L'A' + 1;
+ }
return 0;
}