Closes #18. Change to char32_t everywhere; builds fine, behaviour as before.

This commit is contained in:
Simon Brooke 2026-04-20 12:10:38 +01:00
parent 812a1be7d9
commit c59825d7fe
33 changed files with 116 additions and 76 deletions

View file

@ -103,7 +103,7 @@ char *lisp_string_to_c_string( struct cons_pointer s ) {
len++;
}
wchar_t *buffer = calloc( len + 1, sizeof( wchar_t ) );
char32_t *buffer = calloc( len + 1, sizeof( char32_t ) );
/* worst case, one wide char = four utf bytes */
result = calloc( ( len * 4 ) + 1, sizeof( char ) );
@ -164,8 +164,8 @@ wint_t url_fgetwc( URL_FILE *input ) {
case CFTYPE_CURL:{
char *cbuff =
calloc( sizeof( wchar_t ) + 2, sizeof( char ) );
wchar_t *wbuff = calloc( 2, sizeof( wchar_t ) );
calloc( sizeof( char32_t ) + 2, sizeof( char ) );
char32_t *wbuff = calloc( 2, sizeof( char32_t ) );
size_t count = 0;
@ -265,7 +265,7 @@ lisp_close( struct stack_frame *frame, struct cons_pointer frame_pointer,
return result;
}
struct cons_pointer add_meta_integer( struct cons_pointer meta, wchar_t *key,
struct cons_pointer add_meta_integer( struct cons_pointer meta, char32_t *key,
long int value ) {
return
make_cons( make_cons
@ -273,17 +273,17 @@ struct cons_pointer add_meta_integer( struct cons_pointer meta, wchar_t *key,
make_integer( value, NIL ) ), meta );
}
struct cons_pointer add_meta_string( struct cons_pointer meta, wchar_t *key,
struct cons_pointer add_meta_string( struct cons_pointer meta, char32_t *key,
char *value ) {
value = trim( value );
wchar_t buffer[strlen( value ) + 1];
char32_t buffer[strlen( value ) + 1];
mbstowcs( buffer, value, strlen( value ) + 1 );
return make_cons( make_cons( c_string_to_lisp_keyword( key ),
c_string_to_lisp_string( buffer ) ), meta );
}
struct cons_pointer add_meta_time( struct cons_pointer meta, wchar_t *key,
struct cons_pointer add_meta_time( struct cons_pointer meta, char32_t *key,
time_t *value ) {
/* I don't yet have a concept of a date-time object, which is a
* bit of an oversight! */
@ -317,7 +317,7 @@ static size_t write_meta_callback( char *string, size_t size, size_t nmemb,
s[offset] = ( char ) 0;
char *name = trim( s );
char *value = trim( &s[++offset] );
wchar_t wname[strlen( name )];
char32_t wname[strlen( name )];
mbstowcs( wname, name, strlen( name ) + 1 );
@ -548,7 +548,7 @@ lisp_slurp( struct stack_frame *frame, struct cons_pointer frame_pointer,
debug_println( DEBUG_IO );
struct cons_space_object *cell = &pointer2cell( cursor );
cursor = make_string( ( wchar_t ) c, NIL );
cursor = make_string( ( char32_t ) c, NIL );
cell->payload.string.cdr = cursor;
}
}

View file

@ -37,7 +37,7 @@
void print_string_contents( URL_FILE *output, struct cons_pointer pointer ) {
while ( stringp( pointer ) || symbolp( pointer ) || keywordp( pointer ) ) {
struct cons_space_object *cell = &pointer2cell( pointer );
wchar_t c = cell->payload.string.character;
char32_t c = cell->payload.string.character;
if ( c != '\0' ) {
url_fputwc( c, output );