give set/a access to "special" variables like errorlevel
Modified: trunk/reactos/subsys/system/cmd/cmd.h
Modified: trunk/reactos/subsys/system/cmd/set.c

Modified: trunk/reactos/subsys/system/cmd/cmd.h
--- trunk/reactos/subsys/system/cmd/cmd.h	2005-09-21 01:27:54 UTC (rev 17959)
+++ trunk/reactos/subsys/system/cmd/cmd.h	2005-09-21 01:44:18 UTC (rev 17960)
@@ -99,6 +99,7 @@
 
 /* Prototypes for CMD.C */
 VOID ParseCommandLine (LPTSTR);
+LPCTSTR GetEnvVarOrSpecial ( LPCTSTR varName );
 VOID AddBreakHandler (VOID);
 VOID RemoveBreakHandler (VOID);
 

Modified: trunk/reactos/subsys/system/cmd/set.c
--- trunk/reactos/subsys/system/cmd/set.c	2005-09-21 01:27:54 UTC (rev 17959)
+++ trunk/reactos/subsys/system/cmd/set.c	2005-09-21 01:44:18 UTC (rev 17960)
@@ -173,25 +173,14 @@
 static BOOL
 seta_identval ( LPCTSTR ident, INT* result )
 {
-	// get size of buffer for env var
-	LPTSTR buf;
-	DWORD dwBuffer = GetEnvironmentVariable ( ident, NULL, 0 );
-	// if GetEnvironmentVariable() fails, it returns 0
-	if ( !dwBuffer )
+	LPCTSTR identVal = GetEnvVarOrSpecial ( ident );
+	if ( !identVal )
 	{
-		// TODO FIXME - is it correct to report a value of 0 for non-existant variables?
+		/* TODO FIXME - what to do upon failure? */
 		*result = 0;
 		return FALSE;
 	}
-	buf = (LPTSTR)alloca ( dwBuffer * sizeof(TCHAR) );
-	if ( !buf )
-	{
-		// TODO FIXME - is it correct to report 0 when report resources low... should we error somehow?
-		*result = 0;
-		return FALSE;
-	}
-	GetEnvironmentVariable ( ident, buf, dwBuffer );
-	*result = _ttoi ( buf );
+	*result = _ttoi ( identVal );
 	return TRUE;
 }