Tactical commit
This commit is contained in:
parent
8334e2bf1f
commit
b15c0e8f89
|
@ -76,20 +76,16 @@ struct cons_pointer make_integer( int64_t value, struct cons_pointer more ) {
|
|||
* \see add_integers
|
||||
*/
|
||||
__int128_t cell_value( struct cons_pointer c, char op, bool is_first_cell ) {
|
||||
long int val = nilp( c ) ?
|
||||
0 :
|
||||
pointer2cell( c ).payload.integer.value;
|
||||
long int val = nilp( c ) ? 0 : pointer2cell( c ).payload.integer.value;
|
||||
|
||||
long int carry = is_first_cell ? 0 : ( MAX_INTEGER + 1 );
|
||||
|
||||
__int128_t result = ( __int128_t ) integerp( c ) ?
|
||||
( val == 0 ) ?
|
||||
carry :
|
||||
val :
|
||||
op == '*' ? 1 : 0;
|
||||
( val == 0 ) ? carry : val : op == '*' ? 1 : 0;
|
||||
debug_printf( DEBUG_ARITH,
|
||||
L"cell_value: raw value is %ld, is_first_cell = %s; %4.4s; returning ",
|
||||
val, is_first_cell ? "true" : "false", pointer2cell(c).tag.bytes);
|
||||
val, is_first_cell ? "true" : "false",
|
||||
pointer2cell( c ).tag.bytes );
|
||||
debug_print_128bit( result, DEBUG_ARITH );
|
||||
debug_println( DEBUG_ARITH );
|
||||
|
||||
|
@ -110,8 +106,7 @@ __int128_t cell_value( struct cons_pointer c, char op, bool is_first_cell ) {
|
|||
*/
|
||||
__int128_t int128_to_integer( __int128_t val,
|
||||
struct cons_pointer less_significant,
|
||||
struct cons_pointer new)
|
||||
{
|
||||
struct cons_pointer new ) {
|
||||
struct cons_pointer cursor = NIL;
|
||||
__int128_t carry = 0;
|
||||
|
||||
|
@ -145,7 +140,9 @@ struct cons_pointer make_integer_128(__int128_t val,
|
|||
if ( MAX_INTEGER >= val ) {
|
||||
result = make_integer( ( long int ) val, less_significant );
|
||||
} else {
|
||||
less_significant = make_integer( (long int)val & MAX_INTEGER, less_significant);
|
||||
less_significant =
|
||||
make_integer( ( long int ) val & MAX_INTEGER,
|
||||
less_significant );
|
||||
val = val >> 60;
|
||||
}
|
||||
|
||||
|
@ -285,7 +282,8 @@ struct cons_pointer multiply_integers( struct cons_pointer a,
|
|||
partial = add_integers( partial, new );
|
||||
}
|
||||
|
||||
d = integerp(d) ? pointer2cell( d ).payload.integer.more : NIL;
|
||||
d = integerp( d ) ? pointer2cell( d ).payload.integer.
|
||||
more : NIL;
|
||||
is_first_d = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,8 @@
|
|||
/* we use a global one for convenience */
|
||||
static CURLM *multi_handle;
|
||||
|
||||
wint_t ungotten = 0;
|
||||
|
||||
/* curl calls this routine to get more data */
|
||||
static size_t write_callback( char *buffer,
|
||||
size_t size, size_t nitems, void *userp ) {
|
||||
|
@ -452,6 +454,13 @@ URL_FILE *file_to_url_file( FILE * f ) {
|
|||
wint_t url_fgetwc( URL_FILE * input ) {
|
||||
wint_t result = -1;
|
||||
|
||||
debug_printf( DEBUG_IO, L"url_fgetwc: ungotten = %d\n", ungotten );
|
||||
|
||||
if ( ungotten != 0 ) {
|
||||
/* TODO: not thread safe */
|
||||
result = ungotten;
|
||||
ungotten = 0;
|
||||
} else {
|
||||
switch ( input->type ) {
|
||||
case CFTYPE_FILE:
|
||||
fwide( input->handle.file, 1 ); /* wide characters */
|
||||
|
@ -459,20 +468,55 @@ wint_t url_fgetwc( URL_FILE * input ) {
|
|||
break;
|
||||
|
||||
case CFTYPE_CURL:{
|
||||
debug_print( L"url_fgetwc: stream is URL\n", DEBUG_IO );
|
||||
|
||||
char *cbuff =
|
||||
calloc( sizeof( wchar_t ) + 1, sizeof( char ) );
|
||||
wchar_t *wbuff = calloc( 2, sizeof( wchar_t ) );
|
||||
|
||||
mbstowcs( wbuff, (char *)&input->buffer[input->buffer_pos], 1 );
|
||||
size_t count = 0;
|
||||
|
||||
debug_print( L"url_fgetwc: about to call url_fgets\n", DEBUG_IO );
|
||||
url_fgets( cbuff, 1, input );
|
||||
debug_print( L"url_fgetwc: back from url_fgets\n", DEBUG_IO );
|
||||
int c = ( int ) cbuff[0];
|
||||
debug_printf( DEBUG_IO, L"url_fgetwc: (first) character = %d (%c)\n", c, c & 0xf7 );
|
||||
/* The value of each individual byte indicates its UTF-8 function, as follows:
|
||||
*
|
||||
* 00 to 7F hex (0 to 127): first and only byte of a sequence.
|
||||
* 80 to BF hex (128 to 191): continuing byte in a multi-byte sequence.
|
||||
* C2 to DF hex (194 to 223): first byte of a two-byte sequence.
|
||||
* E0 to EF hex (224 to 239): first byte of a three-byte sequence.
|
||||
* F0 to FF hex (240 to 255): first byte of a four-byte sequence.
|
||||
*/
|
||||
if ( c <= 0x07 ) {
|
||||
count = 1;
|
||||
} else if ( c >= '0xc2' && c <= '0xdf' ) {
|
||||
count = 2;
|
||||
} else if ( c >= '0xe0' && c <= '0xef' ) {
|
||||
count = 3;
|
||||
} else if ( c >= '0xf0' && c <= '0xff' ) {
|
||||
count = 4;
|
||||
}
|
||||
|
||||
if ( count > 1 ) {
|
||||
url_fgets( cbuff, --count, input );
|
||||
}
|
||||
mbstowcs( wbuff, cbuff, 1 ); //(char *)(&input->buffer[input->buffer_pos]), 1 );
|
||||
result = wbuff[0];
|
||||
use_one_wide( input );
|
||||
|
||||
free( wbuff );
|
||||
free( cbuff );
|
||||
}
|
||||
break;
|
||||
case CFTYPE_NONE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
debug_printf( DEBUG_IO, L"url_fgetwc returning %d (%C)\n", result, result);
|
||||
debug_printf( DEBUG_IO, L"url_fgetwc returning %d (%C)\n", result,
|
||||
result );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -486,18 +530,19 @@ wint_t url_ungetwc( wint_t wc, URL_FILE * input ) {
|
|||
break;
|
||||
|
||||
case CFTYPE_CURL:{
|
||||
wchar_t *wbuff = calloc( 2, sizeof( wchar_t ) );
|
||||
char *cbuff = calloc( 5, sizeof( char ) );
|
||||
|
||||
wbuff[0] = wc;
|
||||
result = wcstombs( cbuff, wbuff, 1 );
|
||||
|
||||
input->buffer_pos -= strlen( cbuff );
|
||||
|
||||
free( cbuff );
|
||||
free( wbuff );
|
||||
|
||||
result = result > 0 ? wc : result;
|
||||
ungotten = wc;
|
||||
// wchar_t *wbuff = calloc( 2, sizeof( wchar_t ) );
|
||||
// char *cbuff = calloc( 5, sizeof( char ) );
|
||||
//
|
||||
// wbuff[0] = wc;
|
||||
// result = wcstombs( cbuff, wbuff, 1 );
|
||||
//
|
||||
// input->buffer_pos -= strlen( cbuff );
|
||||
//
|
||||
// free( cbuff );
|
||||
// free( wbuff );
|
||||
//
|
||||
// result = result > 0 ? wc : result;
|
||||
break;
|
||||
case CFTYPE_NONE:
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue