Author: jmorlan Date: Sun Feb 15 21:00:27 2009 New Revision: 39618
URL: http://svn.reactos.org/svn/reactos?rev=39618&view=rev Log: SET /A improvements: - Strip quotes from expression - Use _tcstol instead of _ttoi to parse numbers, allowing hex/octal numbers to be used - Skip space after an identifier - Don't echo result when in a batch file
Modified: trunk/reactos/base/shell/cmd/set.c
Modified: trunk/reactos/base/shell/cmd/set.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/set.c?rev=39... ============================================================================== --- trunk/reactos/base/shell/cmd/set.c [iso-8859-1] (original) +++ trunk/reactos/base/shell/cmd/set.c [iso-8859-1] Sun Feb 15 21:00:27 2009 @@ -106,7 +106,9 @@ /* the /A does *NOT* have to be followed by a whitespace */ if ( !_tcsnicmp (param, _T("/A"), 2) ) { - BOOL Success = seta_eval ( skip_ws(param+2) ); + BOOL Success; + StripQuotes(param); + Success = seta_eval ( skip_ws(param+2) ); if(!Success) { /*might seem random but this is what windows xp does */ @@ -230,7 +232,7 @@ *result = 0; return FALSE; } - *result = _ttoi ( identVal ); + *result = _tcstol ( identVal, NULL, 0 ); return TRUE; }
@@ -283,18 +285,16 @@ p = skip_ws ( p + 1 ); if ( !seta_stmt ( &p, &rval ) ) return FALSE; - if ( *p != _T(')') ) + if ( *p++ != _T(')') ) { ConErrResPuts ( STRING_EXPECTED_CLOSE_PAREN ); return FALSE; } *result = rval; - p = skip_ws ( p + 1 ); } else if ( isdigit(*p) ) { - *result = _ttoi ( p ); - p = skip_ws ( p + _tcsspn ( p, _T("1234567890") ) ); + *result = _tcstol ( p, (LPTSTR *)&p, 0 ); } else if ( __iscsymf(*p) ) { @@ -309,7 +309,7 @@ ConErrResPuts ( STRING_EXPECTED_NUMBER_OR_VARIABLE ); return FALSE; } - *p_ = p; + *p_ = skip_ws ( p ); return TRUE; }
@@ -447,6 +447,7 @@ PARSE_IDENT(ident,identlen,p); if ( identlen ) { + p = skip_ws(p); if ( *p == _T('=') ) op = *p, p = skip_ws(p+1); else if ( _tcschr ( _T("*/%+-&^|"), *p ) && p[1] == _T('=') ) @@ -531,7 +532,8 @@ } if ( !seta_stmt ( &p, &rval ) ) return FALSE; - ConOutPrintf ( _T("%i"), rval ); + if ( !bc ) + ConOutPrintf ( _T("%i"), rval ); return TRUE; }