fix signed -vs- unsigned issue; chars > 127 were being read incorrectly in cfactor
parent
a7036e5e7a
commit
eaacbf635e
|
@ -33,6 +33,9 @@ typedef unsigned long int CELL;
|
|||
typedef unsigned short CHAR;
|
||||
#define CHARS ((signed)sizeof(CHAR))
|
||||
|
||||
/* must always be 8 bits */
|
||||
typedef unsigned char BYTE;
|
||||
|
||||
/* Memory heap size */
|
||||
#define DEFAULT_ARENA (5 * 1024 * 1024)
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ bool perform_copy_from_io_task(PORT* port, PORT* other_port)
|
|||
if(can_write(other_port,port->buf_fill))
|
||||
{
|
||||
write_string_raw(other_port,
|
||||
(char*)(port->buffer + 1),
|
||||
(BYTE*)(port->buffer + 1),
|
||||
port->buf_fill);
|
||||
port->buf_pos = port->buf_fill = 0;
|
||||
}
|
||||
|
|
|
@ -55,14 +55,14 @@ INLINE void cput(CELL where, CHAR what)
|
|||
*((CHAR*)where) = what;
|
||||
}
|
||||
|
||||
INLINE char bget(CELL where)
|
||||
INLINE BYTE bget(CELL where)
|
||||
{
|
||||
return *((char*)where);
|
||||
return *((BYTE*)where);
|
||||
}
|
||||
|
||||
INLINE void bput(CELL where, char what)
|
||||
INLINE void bput(CELL where, BYTE what)
|
||||
{
|
||||
*((char*)where) = what;
|
||||
*((BYTE*)where) = what;
|
||||
}
|
||||
|
||||
bool in_zone(ZONE* z, CELL pointer);
|
||||
|
|
|
@ -42,7 +42,7 @@ bool read_step(PORT* port)
|
|||
bool read_line_step(PORT* port)
|
||||
{
|
||||
int i;
|
||||
char ch;
|
||||
BYTE ch;
|
||||
|
||||
SBUF* line = untag_sbuf(port->line);
|
||||
|
||||
|
@ -158,7 +158,7 @@ void primitive_read_line_8(void)
|
|||
bool read_count_step(PORT* port)
|
||||
{
|
||||
int i;
|
||||
char ch;
|
||||
BYTE ch;
|
||||
|
||||
SBUF* line = untag_sbuf(port->line);
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ STRING* grow_string(STRING* string, FIXNUM capacity, CHAR fill)
|
|||
}
|
||||
|
||||
/* untagged */
|
||||
STRING* from_c_string(const char* c_string)
|
||||
STRING* from_c_string(const BYTE* c_string)
|
||||
{
|
||||
CELL length = strlen(c_string);
|
||||
STRING* s = allot_string(length);
|
||||
|
@ -72,12 +72,12 @@ STRING* from_c_string(const char* c_string)
|
|||
}
|
||||
|
||||
/* untagged */
|
||||
char* to_c_string(STRING* s)
|
||||
BYTE* to_c_string(STRING* s)
|
||||
{
|
||||
STRING* _c_str = allot_string(s->capacity / CHARS + 1);
|
||||
CELL i;
|
||||
|
||||
char* c_str = (char*)(_c_str + 1);
|
||||
BYTE* c_str = (BYTE*)(_c_str + 1);
|
||||
|
||||
for(i = 0; i < s->capacity; i++)
|
||||
c_str[i] = string_nth(s,i);
|
||||
|
|
|
@ -16,8 +16,8 @@ STRING* allot_string(FIXNUM capacity);
|
|||
STRING* string(FIXNUM capacity, CELL fill);
|
||||
void hash_string(STRING* str);
|
||||
STRING* grow_string(STRING* string, FIXNUM capacity, CHAR fill);
|
||||
char* to_c_string(STRING* s);
|
||||
STRING* from_c_string(const char* c_string);
|
||||
BYTE* to_c_string(STRING* s);
|
||||
STRING* from_c_string(const BYTE* c_string);
|
||||
|
||||
#define SREF(string,index) ((CELL)string + sizeof(STRING) + index * CHARS)
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/* Return true if write was done */
|
||||
void write_step(PORT* port)
|
||||
{
|
||||
char* chars = (char*)port->buffer + sizeof(STRING);
|
||||
BYTE* chars = (BYTE*)port->buffer + sizeof(STRING);
|
||||
|
||||
FIXNUM amount = write(port->fd,chars + port->buf_pos,
|
||||
port->buf_fill - port->buf_pos);
|
||||
|
@ -70,7 +70,7 @@ bool perform_write_io_task(PORT* port)
|
|||
|
||||
void write_char_8(PORT* port, FIXNUM ch)
|
||||
{
|
||||
char c = (char)ch;
|
||||
BYTE c = (BYTE)ch;
|
||||
|
||||
pending_io_error(port);
|
||||
|
||||
|
@ -82,7 +82,7 @@ void write_char_8(PORT* port, FIXNUM ch)
|
|||
}
|
||||
|
||||
/* Caller must ensure buffer is of the right size. */
|
||||
void write_string_raw(PORT* port, char* str, CELL len)
|
||||
void write_string_raw(PORT* port, BYTE* str, CELL len)
|
||||
{
|
||||
/* Append string to buffer */
|
||||
memcpy((void*)((CELL)port->buffer + sizeof(STRING)
|
||||
|
@ -93,7 +93,7 @@ void write_string_raw(PORT* port, char* str, CELL len)
|
|||
|
||||
void write_string_8(PORT* port, STRING* str)
|
||||
{
|
||||
char* c_str;
|
||||
BYTE* c_str;
|
||||
|
||||
pending_io_error(port);
|
||||
|
||||
|
|
|
@ -4,6 +4,6 @@ void primitive_can_write(void);
|
|||
void primitive_add_write_io_task(void);
|
||||
bool perform_write_io_task(PORT* port);
|
||||
void write_char_8(PORT* port, FIXNUM ch);
|
||||
void write_string_raw(PORT* port, char* str, CELL len);
|
||||
void write_string_raw(PORT* port, BYTE* str, CELL len);
|
||||
void write_string_8(PORT* port, STRING* str);
|
||||
void primitive_write_8(void);
|
||||
|
|
Loading…
Reference in New Issue