That seems to fix it!

This commit is contained in:
Simon Brooke 2019-01-30 00:39:43 +00:00
parent eb49ca4e2d
commit 86319fd1c3
2 changed files with 14 additions and 13 deletions

View file

@ -260,11 +260,11 @@ int index_of( char c, char *s ) {
char *trim( char *s ) { char *trim( char *s ) {
int i; int i;
for ( i = strlen( s ); ( isblank( s[i] ) || iscntrl( s[i] ) ) && i > -1; for ( i = strlen( s ); ( isblank( s[i] ) || iscntrl( s[i] ) ) && i >= 0;
i-- ) { i-- ) {
s[i] = ( char ) 0; s[i] = ( char ) 0;
} }
for ( i = 0; isblank( s[i] ) && s[i] != 0; i++ ); for ( i = 0; ( isblank( s[i] ) || iscntrl( s[i] ) ) && s[i] != 0; i++ );
return ( char * ) &s[i]; return ( char * ) &s[i];
} }
@ -313,7 +313,7 @@ static size_t write_meta_callback( char *string, size_t size, size_t nmemb,
if ( offset != -1 ) { if ( offset != -1 ) {
s[offset] = ( char ) 0; s[offset] = ( char ) 0;
char *name = s; char *name = trim( s );
char *value = trim( &s[++offset] ); char *value = trim( &s[++offset] );
wchar_t *wname = calloc( strlen( name ), sizeof( wchar_t ) ); wchar_t *wname = calloc( strlen( name ), sizeof( wchar_t ) );
wchar_t *wvalue = calloc( strlen( value ), sizeof( wchar_t ) ); wchar_t *wvalue = calloc( strlen( value ), sizeof( wchar_t ) );

View file

@ -323,19 +323,18 @@ struct cons_pointer make_write_stream( URL_FILE * output,
} }
/** /**
* Return a lisp keyword representation of this wide character string. * Return a lisp keyword representation of this wide character string. In keywords,
* I am accepting only lower case characters and numbers.
*/ */
struct cons_pointer c_string_to_lisp_keyword( wchar_t *symbol ) { struct cons_pointer c_string_to_lisp_keyword( wchar_t *symbol ) {
struct cons_pointer result = NIL; struct cons_pointer result = NIL;
for (int i = 0; symbol[i] != '\0'; i++) { for ( int i = wcslen( symbol ) -1; i >= 0; i-- ) {
if(iswalpha(symbol[i] && !iswlower(symbol[i]))) { wchar_t c = towlower(symbol[i]);
symbol[i] = towlower(symbol[i]);
}
}
for ( int i = wcslen( symbol ); i > 0; i-- ) { if (iswalnum(c) || c == L'-') {
result = make_keyword( symbol[i - 1], result ); result = make_keyword( c, result );
}
} }
return result; return result;
@ -347,8 +346,10 @@ struct cons_pointer c_string_to_lisp_keyword( wchar_t *symbol ) {
struct cons_pointer c_string_to_lisp_string( wchar_t *string ) { struct cons_pointer c_string_to_lisp_string( wchar_t *string ) {
struct cons_pointer result = NIL; struct cons_pointer result = NIL;
for ( int i = wcslen( string ); i > 0; i-- ) { for ( int i = wcslen( string ) - 1; i >= 0; i-- ) {
result = make_string( string[i - 1], result ); if (iswprint(string[i]) && string[i] != '"') {
result = make_string( string[i], result );
}
} }
return result; return result;