From: Leon W. <moo...@us...> - 2004-11-08 07:08:14
|
Update of /cvsroot/anyedit/AnyEditv2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21051 Modified Files: ToolRunner.cpp Log Message: Rewrote Macro Parsing, it now recognizes macros better. Index: ToolRunner.cpp =================================================================== RCS file: /cvsroot/anyedit/AnyEditv2/ToolRunner.cpp,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ToolRunner.cpp 30 Sep 2004 13:11:15 -0000 1.20 --- ToolRunner.cpp 8 Nov 2004 07:07:55 -0000 1.21 *************** *** 39,42 **** --- 39,45 ---- #endif + #define TR_MACRO_MIN 3 + #define TR_MACRO_MAX 8 + // Default constructor CToolRunner::CToolRunner() *************** *** 243,249 **** { CString szBuild; int begin = 0; int bthing = 0; ! int ething = 0; // Keep searching till the end of the string. --- 246,254 ---- { CString szBuild; + CString szResult; + int iCount; int begin = 0; int bthing = 0; ! bool bBrace; // Keep searching till the end of the string. *************** *** 264,299 **** if( szArgument[begin] == '$' ) { ! // $$ is replaced by a single $ ! szBuild += "$"; begin = bthing + 1; continue; } ! // Find the end of the argument, depending on the second character. ! // If the argument is between () we search for the ')' else we expect ! // a space. if( szArgument[begin] == '(' ) { ++ begin; ! ething = szArgument.Find( ')', begin ); } ! else { ! ething = szArgument.Find( ' ', begin ); ! if( ething == -1 ) ething = szArgument.GetLength(); } ! ! // If our start and end point differ we found a macro. ! // Grab it and get the value it represents. ! if( begin != ething ) { ! CString szTemp; ! szTemp += szArgument.Mid( begin, ething - begin ); ! szBuild += GetValueForArguments( szTemp ); ! ! // If we searched for a ')' as the end of the macro, skip it. ! if( ething != szArgument.GetLength() && szArgument[ething] != ' ' ) begin = ++ ething; ! else begin = ething; } } else --- 269,307 ---- if( szArgument[begin] == '$' ) { ! // $$ is replaced by a single $, so skip this one. begin = bthing + 1; continue; } ! bBrace = false; if( szArgument[begin] == '(' ) { ++ begin; ! bBrace = true; } ! ! szResult.Empty(); ! for( iCount = TR_MACRO_MIN; iCount <= TR_MACRO_MAX; ++ iCount ) { ! if( begin + iCount > szArgument.GetLength() ) break; ! szResult = GetValueForArguments( szArgument.Mid( begin, iCount ) ); ! if( !szResult.IsEmpty() ) break; } ! ! ! // Did we have a valid macro? ! if( szResult.IsEmpty() ) { ! // No, ok continue after the character $, but first add it because we skipped it. ! szBuild += _T("$"); ! continue; } + else + { + begin += iCount; + if( bBrace && begin < szArgument.GetLength() && szArgument[begin] == ')' ) ++ begin; + szBuild += szResult; + } + } else *************** *** 317,327 **** int iIndex; CString szTemp; ! CMisc misc; ! if( "FILEPATH" == szArgument ) { if( NULL == m_pActiveDoc ) return _T(""); else return m_pActiveDoc->GetPathName(); } ! if( "FILENAME" == szArgument ) { if( NULL == m_pActiveDoc ) return _T(""); --- 325,335 ---- int iIndex; CString szTemp; ! ! if( _T("FILEPATH") == szArgument ) { if( NULL == m_pActiveDoc ) return _T(""); else return m_pActiveDoc->GetPathName(); } ! if( _T("FILENAME") == szArgument ) { if( NULL == m_pActiveDoc ) return _T(""); *************** *** 331,335 **** else return szTemp.Right( szTemp.GetLength() - iIndex - 1 ); } ! if( "FILEBASE" == szArgument ) { if( NULL == m_pActiveDoc ) return _T(""); --- 339,343 ---- else return szTemp.Right( szTemp.GetLength() - iIndex - 1 ); } ! if( _T("FILEBASE") == szArgument ) { if( NULL == m_pActiveDoc ) return _T(""); *************** *** 342,346 **** else return szTemp.Mid( iIndex + 1, iIndex2 - iIndex - 1 ); } ! if( "FILEDIR" == szArgument ) { if( NULL == m_pActiveDoc ) return _T(""); --- 350,354 ---- else return szTemp.Mid( iIndex + 1, iIndex2 - iIndex - 1 ); } ! if( _T("FILEDIR") == szArgument ) { if( NULL == m_pActiveDoc ) return _T(""); *************** *** 350,354 **** else return szTemp.Left( iIndex ); } ! if( "WSPDIR" == szArgument ) { if( theApp.GetWorkspace()->empty() ) return _T(""); --- 358,362 ---- else return szTemp.Left( iIndex ); } ! if( _T("WSPDIR") == szArgument ) { if( theApp.GetWorkspace()->empty() ) return _T(""); *************** *** 358,362 **** else return szTemp.Left( iIndex ); } ! if( "PRJDIR" == szArgument ) { if( theApp.GetWorkspace()->empty() ) return _T(""); --- 366,370 ---- else return szTemp.Left( iIndex ); } ! if( _T("PRJDIR") == szArgument ) { if( theApp.GetWorkspace()->empty() ) return _T(""); *************** *** 367,371 **** else return szTemp.Left( iIndex ); } ! if( "CURSEL" == szArgument ) { if( NULL == m_pActiveView ) return _T(""); --- 375,379 ---- else return szTemp.Left( iIndex ); } ! if( _T("CURSEL") == szArgument ) { if( NULL == m_pActiveView ) return _T(""); *************** *** 374,378 **** else return pScintillaEx->GetSelText(); } ! if( "CURLINE" == szArgument ) { if( NULL == m_pActiveView ) return _T(""); --- 382,386 ---- else return pScintillaEx->GetSelText(); } ! if( _T("CURLINE") == szArgument ) { if( NULL == m_pActiveView ) return _T(""); *************** *** 390,394 **** } } ! if( "CURWORD" == szArgument ) { if( NULL == m_pActiveView ) return _T(""); --- 398,402 ---- } } ! if( _T("CURWORD") == szArgument ) { if( NULL == m_pActiveView ) return _T(""); *************** *** 409,413 **** } } ! if( "ROW" == szArgument ) { if( NULL == m_pActiveView ) return _T(""); --- 417,421 ---- } } ! if( _T("ROW") == szArgument ) { if( NULL == m_pActiveView ) return _T(""); *************** *** 423,427 **** } } ! if( "COL" == szArgument ) { if( NULL == m_pActiveView ) return _T(""); --- 431,435 ---- } } ! if( _T("COL") == szArgument ) { if( NULL == m_pActiveView ) return _T(""); |