mirror of
https://github.com/reactos/reactos.git
synced 2026-07-03 09:44:49 +08:00
give set/a access to "special" variables like errorlevel
svn path=/trunk/; revision=17960
This commit is contained in:
@@ -99,6 +99,7 @@ INT cmd_cls (LPTSTR, LPTSTR);
|
||||
|
||||
/* Prototypes for CMD.C */
|
||||
VOID ParseCommandLine (LPTSTR);
|
||||
LPCTSTR GetEnvVarOrSpecial ( LPCTSTR varName );
|
||||
VOID AddBreakHandler (VOID);
|
||||
VOID RemoveBreakHandler (VOID);
|
||||
|
||||
|
||||
@@ -173,25 +173,14 @@ ident_len ( LPCTSTR p )
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user