From 5c0d0a5c3dc071f2e8d89c6360295aa151ee09df Mon Sep 17 00:00:00 2001 From: Royce Mitchell III Date: Wed, 21 Sep 2005 01:44:18 +0000 Subject: [PATCH] give set/a access to "special" variables like errorlevel svn path=/trunk/; revision=17960 --- reactos/subsys/system/cmd/cmd.h | 1 + reactos/subsys/system/cmd/set.c | 19 ++++--------------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/reactos/subsys/system/cmd/cmd.h b/reactos/subsys/system/cmd/cmd.h index cf8ba9ad41b..ebd574f9c9f 100644 --- a/reactos/subsys/system/cmd/cmd.h +++ b/reactos/subsys/system/cmd/cmd.h @@ -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); diff --git a/reactos/subsys/system/cmd/set.c b/reactos/subsys/system/cmd/set.c index 4c9e950ec57..9eb6d6c8e9a 100644 --- a/reactos/subsys/system/cmd/set.c +++ b/reactos/subsys/system/cmd/set.c @@ -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; }