void trimWhitespaceFromFunctionEnd ( ) { assert ( callStack . getCurrentElement ( ) . type == PushPopType . Function ) ; int functionStartPoint = callStack . getCurrentElement ( ) . functionStartInOuputStream ; // If the start point has become -1, it means that some non-whitespace // text has been pushed, so it's safe to go as far back as we're able. if ( functionStartPoint == - 1 ) { functionStartPoint = 0 ; } // Trim whitespace from END of function call for ( int i = outputStream . size ( ) - 1 ; i >= functionStartPoint ; i -- ) { RTObject obj = outputStream . get ( i ) ; if ( ! ( obj instanceof StringValue ) ) continue ; StringValue txt = ( StringValue ) obj ; if ( obj instanceof ControlCommand ) break ; if ( txt . isNewline ( ) || txt . isInlineWhitespace ( ) ) { outputStream . remove ( i ) ; outputStreamDirty ( ) ; } else { break ; } } }
whitespace is trimmed in one go here when we pop the function .