X-Git-Url: https://git.saurik.com/apple/security.git/blobdiff_plain/5c19dc3ae3bd8e40a9c028b0deddd50ff337692c..d64be36ead0ce792f249208635bc8db368d6cdd2:/OSX/libsecurity_codesigning/antlr2/src/TokenStreamRewriteEngine.cpp diff --git a/OSX/libsecurity_codesigning/antlr2/src/TokenStreamRewriteEngine.cpp b/OSX/libsecurity_codesigning/antlr2/src/TokenStreamRewriteEngine.cpp index 4279355e..a44f3ef0 100644 --- a/OSX/libsecurity_codesigning/antlr2/src/TokenStreamRewriteEngine.cpp +++ b/OSX/libsecurity_codesigning/antlr2/src/TokenStreamRewriteEngine.cpp @@ -129,29 +129,30 @@ void TokenStreamRewriteEngine::toStream( std::ostream& out, size_t tokenCursor = firstToken; // make sure we don't run out of the tokens we have... - if( lastToken > (tokens.size() - 1) ) - lastToken = tokens.size() - 1; + if( lastToken > (tokens.size() - 1) ) { + lastToken = tokens.size() - 1; + } - while ( tokenCursor <= lastToken ) - { + while ( tokenCursor <= lastToken ) + { // std::cout << "tokenCursor = " << tokenCursor << " first prog index = " << (*rewriteOpIndex)->getIndex() << std::endl; - if( rewriteOpIndex != rewriteOpEnd ) - { - size_t up_to_here = std::min(lastToken,(*rewriteOpIndex)->getIndex()); - while( tokenCursor < up_to_here ) - out << tokens[tokenCursor++]->getText(); - } - while ( rewriteOpIndex != rewriteOpEnd && - tokenCursor == (*rewriteOpIndex)->getIndex() && - tokenCursor <= lastToken ) - { - tokenCursor = (*rewriteOpIndex)->execute(out); - ++rewriteOpIndex; - } - if( tokenCursor <= lastToken ) - out << tokens[tokenCursor++]->getText(); - } + if( rewriteOpIndex != rewriteOpEnd ) + { + size_t up_to_here = std::min(lastToken,(*rewriteOpIndex)->getIndex()); + while( tokenCursor < up_to_here ) + out << tokens[tokenCursor++]->getText(); + } + while ( rewriteOpIndex != rewriteOpEnd && + tokenCursor == (*rewriteOpIndex)->getIndex() && + tokenCursor <= lastToken ) + { + tokenCursor = (*rewriteOpIndex)->execute(out); + ++rewriteOpIndex; + } + if( tokenCursor <= lastToken ) + out << tokens[tokenCursor++]->getText(); + } // std::cout << "Handling tail operations # left = " << std::distance(rewriteOpIndex,rewriteOpEnd) << std::endl; // now see if there are operations (append) beyond last token index std::for_each( rewriteOpIndex, rewriteOpEnd, executeOperation(out) );