engine/source/preprocessorlib/pp_parser.c
// self->token contains the first token of the macro/message if self->overread == true
self->token contains the first token of the macro/message if self->overread == true
self - > token contains the first token of the macro / message if self - > overread == true
HRESULT pp_parser_readline(pp_parser *self, char *buf, int bufsize)
{
    int total_length = 1;
    if(FAILED(pp_parser_lex_token(self, true)))
    {
        return E_FAIL;
    }
    buf[0] = '\0';
    while(1)
    {
        if(self->token.theType == PP_TOKEN_EOF)
        {
            self->overread = true;
            break;
        }
        else if(self->token.theType == PP_TOKEN_NEWLINE)
        {
            break;
        }
        if((total_length + strlen(self->token.theSource)) > bufsize)
        {
            pp_error(self, "length of macro or message contents is too long; must be <= %i characters", bufsize);
            return E_FAIL;
        }
        strcat(buf, self->token.theSource);
        total_length += strlen(self->token.theSource);
        if(FAILED(pp_parser_lex_token(self, false)))
        {
            return E_FAIL;
        }
    }
    return S_OK;
}
HRESULT pp_parser_readline ( pp_parser * self , char * buf , int bufsize ) { int total_length = 1 ; if ( FAILED ( pp_parser_lex_token ( self , true ) ) ) { return E_FAIL ; } buf [ 0 ] = ' \0 ' ; while ( 1 ) { if ( self -> token . theType == PP_TOKEN_EOF ) { self -> overread = true ; break ; } else if ( self -> token . theType == PP_TOKEN_NEWLINE ) { break ; } if ( ( total_length + strlen ( self -> token . theSource ) ) > bufsize ) { pp_error ( self , " " , bufsize ) ; return E_FAIL ; } strcat ( buf , self -> token . theSource ) ; total_length += strlen ( self -> token . theSource ) ; if ( FAILED ( pp_parser_lex_token ( self , false ) ) ) { return E_FAIL ; } } return S_OK ; }
self->token contains the first token of the macro/message if self->overread == true
self - > token contains the first token of the macro / message if self - > overread == true
// Prevent buffer overflow