sqlparser/sqlparser.cpp
// Append the token with the specified value
Append the token with the specified value
Append the token with the specified value
Token* SqlParser::Append(Token *token, const char *str, const wchar_t *wstr, size_t len, Token *format)
{
	if(token == NULL)
		return NULL;
	Token *append = new Token();
	if(format == NULL)
		*append = *token;
	else
		*append = *format;
	append->prev = NULL;
	append->next = NULL;
	append->t_str = NULL;
	append->t_wstr = NULL;
	append->t_len = 0;
	if(str != NULL && str[0] == '\n')
	{
		Token newline;
#ifdef WIN32
		newline.type = TOKEN_SYMBOL;
		newline.chr = '\r';
	    AppendCopy(token, &newline);
#endif
		newline.type = TOKEN_SYMBOL;
		newline.chr = '\n';
	    AppendCopy(token, &newline);
		Token *prev = (format != NULL) ? format->prev : token->prev;
		while(prev != NULL && (prev->Compare(' ', L' ') == true || prev->Compare('\t', L'\t') == true))
		{
			AppendCopy(token, prev);
			prev = prev->prev;
		}
		Token::Change(append, str + 1, wstr + 1, len - 1);
	}
	else
		Token::Change(append, str, wstr, len);
    Append(token, append);
	return append;
}
Token * SqlParser :: Append ( Token * token , const char * str , const wchar_t * wstr , size_t len , Token * format ) { if ( token == NULL ) return NULL ; Token * append = new Token ( ) ; if ( format == NULL ) * append = * token ; else * append = * format ; append -> prev = NULL ; append -> next = NULL ; append -> t_str = NULL ; append -> t_wstr = NULL ; append -> t_len = 0 ; if ( str != NULL && str [ 0 ] == ' \n ' ) { Token newline ; #ifdef WIN32 newline . type = TOKEN_SYMBOL ; newline . chr = ' \r ' ; AppendCopy ( token , & newline ) ; #endif newline . type = TOKEN_SYMBOL ; newline . chr = ' \n ' ; AppendCopy ( token , & newline ) ; Token * prev = ( format != NULL ) ? format -> prev : token -> prev ; while ( prev != NULL && ( prev -> Compare ( ' ' , L' ' ) == true || prev -> Compare ( ' \t ' , L' \t ' ) == true ) ) { AppendCopy ( token , prev ) ; prev = prev -> prev ; } Token :: Change ( append , str + 1 , wstr + 1 , len - 1 ) ; } else Token :: Change ( append , str , wstr , len ) ; Append ( token , append ) ; return append ; }
Append the token with the specified value
Append the token with the specified value
// If token starts with newline, add the same number of spaces before appended token // Add newline token first // Copy all blankes  // Skip new line in the token