@ -202,7 +202,7 @@ char * next_token(void) {
@@ -202,7 +202,7 @@ char * next_token(void) {
trace ( TRACE_TOKENS , " Token %d:%d %s " , state . line_num , state . token_num , state . token ) ;
if ( ( state . token ! = NULL ) & & ( strcmp ( state . token , keyword_comment ) = = 0 ) ) {
trace ( TRACE_TOKENS , " Detected comment %d " , state . line_num ) ;
while ( next_token ( ) ) { } // burn all the symbols
state . token = NULL ; // burn the line
}
return state . token ;
}
@ -211,12 +211,27 @@ char * start_line(void) {
@@ -211,12 +211,27 @@ char * start_line(void) {
while ( fgets ( state . line , sizeof ( state . line ) / sizeof ( state . line [ 0 ] ) , description ) ! = NULL ) { //state.line = readline(NULL))) {
state . line_num + + ;
const size_t length = strlen ( state . line ) ;
if ( length > 1 & & state . line [ length - 2 ] = = ' \r ' ) {
trace ( TRACE_TOKENS , " Discarding carriage return " ) ;
if ( length = = 2 ) { // empty line of just carriage return, loop again
continue ;
}
state . line [ length - 2 ] = ' \0 ' ;
} else if ( length > 0 & & state . line [ length - 1 ] = = ' \n ' ) {
trace ( TRACE_TOKENS , " Discarding newline " ) ;
if ( length = = 1 ) { // empty line of just carriage return, loop again
continue ;
}
state . line [ length - 1 ] = ' \0 ' ;
}
state . token = strtok ( state . line , token_delimiters ) ;
state . token_num = 1 ;
trace ( TRACE_TOKENS , " Token %d:%d %s " , state . line_num , state . token_num , state . token ) ;
trace ( TRACE_TOKENS , " Start of line t oken %d:%d %s" , state . line_num , state . token_num , state . token ) ;
if ( state . token ! = NULL ) {
break ;
break ;
}
}