Fixed bug which caused reader to infinite loop if symbol contained non-alnum.

This commit is contained in:
Simon Brooke 2017-10-15 15:14:34 +01:00
parent 0685442e1a
commit 89b4f093f9
2 changed files with 9 additions and 1 deletions

View file

@ -89,8 +89,11 @@ int main( int argc, char *argv[] ) {
bind_function( "type", &lisp_type );
bind_function( "add", &lisp_add );
bind_function( "+", &lisp_add );
bind_function( "multiply", &lisp_multiply );
bind_function( "*", &lisp_multiply );
bind_function( "subtract", &lisp_subtract );
bind_function( "-", &lisp_subtract );
/*
* primitive special forms

View file

@ -20,6 +20,7 @@
#include "consspaceobject.h"
#include "integer.h"
#include "intern.h"
#include "print.h"
#include "read.h"
#include "real.h"
@ -194,7 +195,7 @@ struct cons_pointer read_symbol( FILE * input, wint_t initial ) {
ungetwc( initial, input );
break;
default:
if ( iswalnum( initial ) ) {
if ( iswprint( initial ) && ! iswblank( initial ) ) {
result =
make_symbol( initial, read_symbol( input, fgetwc( input ) ) );
} else {
@ -206,6 +207,10 @@ struct cons_pointer read_symbol( FILE * input, wint_t initial ) {
}
break;
}
fputws(L"Read symbol '", stderr);
print(stderr, result);
fputws(L"'\n", stderr);
return result;
}