Defensive commit before experimenting with code::blocks

This commit is contained in:
Simon Brooke 2025-03-13 12:47:54 +00:00
parent c2ad3eda0d
commit ce1c72973d
3 changed files with 23 additions and 9 deletions

View file

@ -14,6 +14,10 @@
/** /**
* The maximum value we will allow in an integer cell. * The maximum value we will allow in an integer cell.
*
* NOTE: 20250312 this is 2^60. WHY? Given that we're using the sign bit
* inside the int64 record, we only have 63 value bits; but why did I decide
* not to use all 63?
*/ */
#define MAX_INTEGER ((__int128_t)0x0fffffffffffffffL) #define MAX_INTEGER ((__int128_t)0x0fffffffffffffffL)

View file

@ -83,7 +83,7 @@ struct cons_pointer read_path( URL_FILE * input, wint_t initial,
prefix = c_string_to_lisp_symbol( L"oblist" ); prefix = c_string_to_lisp_symbol( L"oblist" );
break; break;
case '$': case '$':
case L'§': case LSESSION:
prefix = c_string_to_lisp_symbol( L"session" ); prefix = c_string_to_lisp_symbol( L"session" );
break; break;
} }
@ -245,7 +245,7 @@ struct cons_pointer read_continuation( struct stack_frame *frame,
} }
break; break;
case '$': case '$':
case L'§': case LSESSION:
result = read_path( input, c, NIL ); result = read_path( input, c, NIL );
break; break;
default: default:
@ -298,9 +298,9 @@ struct cons_pointer read_number( struct stack_frame *frame,
initial ); initial );
for ( c = initial; iswdigit( c ) for ( c = initial; iswdigit( c )
|| c == L'.' || c == L'/' || c == L','; c = url_fgetwc( input ) ) { || c == LPERIOD || c == LSLASH || c == LCOMMA; c = url_fgetwc( input ) ) {
switch ( c ) { switch ( c ) {
case L'.': case LPERIOD:
if ( seen_period || !nilp( dividend ) ) { if ( seen_period || !nilp( dividend ) ) {
return throw_exception( c_string_to_lisp_string return throw_exception( c_string_to_lisp_string
( L"Malformed number: too many periods" ), ( L"Malformed number: too many periods" ),
@ -311,7 +311,7 @@ struct cons_pointer read_number( struct stack_frame *frame,
seen_period = true; seen_period = true;
} }
break; break;
case L'/': case LSLASH:
if ( seen_period || !nilp( dividend ) ) { if ( seen_period || !nilp( dividend ) ) {
return throw_exception( c_string_to_lisp_string return throw_exception( c_string_to_lisp_string
( L"Malformed number: dividend of rational must be integer" ), ( L"Malformed number: dividend of rational must be integer" ),
@ -324,11 +324,12 @@ struct cons_pointer read_number( struct stack_frame *frame,
result = make_integer( 0, NIL ); result = make_integer( 0, NIL );
} }
break; break;
case L',': case LCOMMA:
// silently ignore it. // silently ignore it.
break; break;
default: default:
result = add_integers( multiply_integers( result, base ), result = add_integers( multiply_integers( result, base ),
/* /todo: this won't work for hex digits */
make_integer( ( int ) c - ( int ) '0', make_integer( ( int ) c - ( int ) '0',
NIL ) ); NIL ) );
@ -402,7 +403,7 @@ struct cons_pointer read_list( struct stack_frame *frame,
for ( c = url_fgetwc( input ); for ( c = url_fgetwc( input );
iswblank( c ) || iswcntrl( c ); c = url_fgetwc( input ) ); iswblank( c ) || iswcntrl( c ); c = url_fgetwc( input ) );
if ( c == L'.' ) { if ( c == LPERIOD ) {
/* might be a dotted pair; indeed, if we rule out numbers with /* might be a dotted pair; indeed, if we rule out numbers with
* initial periods, it must be a dotted pair. \todo Ought to check, * initial periods, it must be a dotted pair. \todo Ought to check,
* howerver, that there's only one form after the period. */ * howerver, that there's only one form after the period. */
@ -433,7 +434,7 @@ struct cons_pointer read_map( struct stack_frame *frame,
make_hashmap( DFLT_HASHMAP_BUCKETS, NIL, TRUE ); make_hashmap( DFLT_HASHMAP_BUCKETS, NIL, TRUE );
wint_t c = initial; wint_t c = initial;
while ( c != L'}' ) { while ( c != LCBRACE ) {
struct cons_pointer key = struct cons_pointer key =
read_continuation( frame, frame_pointer, env, input, c ); read_continuation( frame, frame_pointer, env, input, c );
@ -446,7 +447,7 @@ struct cons_pointer read_map( struct stack_frame *frame,
/* skip commaa and whitespace at this point. */ /* skip commaa and whitespace at this point. */
for ( c = url_fgetwc( input ); for ( c = url_fgetwc( input );
c == L',' || iswblank( c ) || iswcntrl( c ); c == LCOMMA || iswblank( c ) || iswcntrl( c );
c = url_fgetwc( input ) ); c = url_fgetwc( input ) );
result = result =

View file

@ -13,6 +13,15 @@
#include "memory/consspaceobject.h" #include "memory/consspaceobject.h"
/* characters (other than arabic numberals) used in number representations */
#define LCOMMA L','
#define LPERIOD L'.'
#define LSLASH L'/'
/* ... used in map representations */
#define LCBRACE L'}'
/* ... used in path representations */
#define LSESSION L'§'
/** /**
* read the next object on this input stream and return a cons_pointer to it. * read the next object on this input stream and return a cons_pointer to it.
*/ */