update for type correctness
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-04-06 16:52:53 +09:00
parent 50bf4a1c0c
commit d578ded2c8
14 changed files with 65 additions and 62 deletions

View File

@ -195,11 +195,11 @@ static int handle_logopt (hcl_t* hcl, const hcl_bch_t* logstr)
{ "debug-", 0, HCL_LOG_DEBUG }, { "debug-", 0, HCL_LOG_DEBUG },
/* exclude a specific level */ /* exclude a specific level */
{ "-fatal", 1, ~HCL_LOG_FATAL }, { "-fatal", 1, ~(hcl_bitmask_t)HCL_LOG_FATAL },
{ "-error", 1, ~HCL_LOG_ERROR }, { "-error", 1, ~(hcl_bitmask_t)HCL_LOG_ERROR },
{ "-warn", 1, ~HCL_LOG_WARN }, { "-warn", 1, ~(hcl_bitmask_t)HCL_LOG_WARN },
{ "-info", 1, ~HCL_LOG_INFO }, { "-info", 1, ~(hcl_bitmask_t)HCL_LOG_INFO },
{ "-debug", 1, ~HCL_LOG_DEBUG }, { "-debug", 1, ~(hcl_bitmask_t)HCL_LOG_DEBUG },
}; };
cm = hcl_find_bchar_in_bcstr(logstr, ','); cm = hcl_find_bchar_in_bcstr(logstr, ',');

View File

@ -460,7 +460,7 @@ static HCL_INLINE int prepare_to_alloc_pid (hcl_t* hcl)
} }
tmp = (hcl_oop_t*)hcl_reallocmem(hcl, hcl->proc_map, HCL_SIZEOF(hcl_oop_t) * new_capa); tmp = (hcl_oop_t*)hcl_reallocmem(hcl, hcl->proc_map, HCL_SIZEOF(hcl_oop_t) * new_capa);
if (!tmp) return -1; if (HCL_UNLIKELY(!tmp)) return -1;
hcl->proc_map_free_first = hcl->proc_map_capa; hcl->proc_map_free_first = hcl->proc_map_capa;
for (i = hcl->proc_map_capa, j = hcl->proc_map_capa + 1; j < new_capa; i++, j++) for (i = hcl->proc_map_capa, j = hcl->proc_map_capa + 1; j < new_capa; i++, j++)
@ -1579,8 +1579,8 @@ static int add_sem_to_sem_io_tuple (hcl_t* hcl, hcl_oop_semaphore_t sem, hcl_ooi
/* TODO: specify the maximum io_handle supported and check it here instead of just relying on memory allocation success/failure? */ /* TODO: specify the maximum io_handle supported and check it here instead of just relying on memory allocation success/failure? */
new_capa = HCL_ALIGN_POW2(io_handle + 1, SEM_IO_MAP_ALIGN); new_capa = HCL_ALIGN_POW2(io_handle + 1, SEM_IO_MAP_ALIGN);
tmp = hcl_reallocmem (hcl, hcl->sem_io_map, HCL_SIZEOF(*tmp) * new_capa); tmp = (hcl_ooi_t*)hcl_reallocmem(hcl, hcl->sem_io_map, HCL_SIZEOF(*tmp) * new_capa);
if (!tmp) if (HCL_UNLIKELY(!tmp))
{ {
const hcl_ooch_t* oldmsg = hcl_backuperrmsg(hcl); const hcl_ooch_t* oldmsg = hcl_backuperrmsg(hcl);
hcl_seterrbfmt (hcl, hcl->errnum, "handle %zd out of supported range - %js", oldmsg); hcl_seterrbfmt (hcl, hcl->errnum, "handle %zd out of supported range - %js", oldmsg);
@ -1611,8 +1611,8 @@ static int add_sem_to_sem_io_tuple (hcl_t* hcl, hcl_oop_semaphore_t sem, hcl_ooi
/* no overflow check when calculating the new capacity /* no overflow check when calculating the new capacity
* owing to SEM_IO_TUPLE_MAX check above */ * owing to SEM_IO_TUPLE_MAX check above */
new_capa = hcl->sem_io_tuple_capa + SEM_IO_TUPLE_INC; new_capa = hcl->sem_io_tuple_capa + SEM_IO_TUPLE_INC;
tmp = hcl_reallocmem (hcl, hcl->sem_io_tuple, HCL_SIZEOF(hcl_sem_tuple_t) * new_capa); tmp = (hcl_sem_tuple_t*)hcl_reallocmem(hcl, hcl->sem_io_tuple, HCL_SIZEOF(hcl_sem_tuple_t) * new_capa);
if (!tmp) return -1; if (HCL_UNLIKELY(!tmp)) return -1;
hcl->sem_io_tuple = tmp; hcl->sem_io_tuple = tmp;
hcl->sem_io_tuple_capa = new_capa; hcl->sem_io_tuple_capa = new_capa;
@ -2523,7 +2523,7 @@ static HCL_INLINE int exec_syscmd (hcl_t* hcl, hcl_ooi_t nargs)
/* TODO: close file descriptors??? */ /* TODO: close file descriptors??? */
argv = (hcl_bch_t**)hcl_allocmem(hcl, (nargs + 2) * HCL_SIZEOF(*argv)); argv = (hcl_bch_t**)hcl_allocmem(hcl, (nargs + 2) * HCL_SIZEOF(*argv));
if (argv) if (HCL_LIKELY(argv))
{ {
argv[0] = cmd; argv[0] = cmd;
HCL_DEBUG1 (hcl, "NARG %d\n", (int)nargs); HCL_DEBUG1 (hcl, "NARG %d\n", (int)nargs);

View File

@ -1581,8 +1581,8 @@ redo:
} }
/* +1 to handle line ending injection more easily */ /* +1 to handle line ending injection more easily */
tmp = hcl_reallocmem(hcl, hcl->log.ptr, (newcapa + 1) * HCL_SIZEOF(*tmp)); tmp = (hcl_ooch_t*)hcl_reallocmem(hcl, hcl->log.ptr, (newcapa + 1) * HCL_SIZEOF(*tmp));
if (!tmp) if (HCL_UNLIKELY(!tmp))
{ {
make_do: make_do:
if (hcl->log.len > 0) if (hcl->log.len > 0)

View File

@ -33,7 +33,7 @@ static struct
{ {
hcl_oow_t len; hcl_oow_t len;
hcl_ooch_t ptr[20]; hcl_ooch_t ptr[20];
int syncode; hcl_syncode_t syncode;
hcl_oow_t offset; hcl_oow_t offset;
} syminfo[] = } syminfo[] =
{ {
@ -1294,7 +1294,7 @@ static int ignite_2 (hcl_t* hcl)
hcl->symtab->tally = HCL_SMOOI_TO_OOP(0); hcl->symtab->tally = HCL_SMOOI_TO_OOP(0);
} }
if (HCL_LIKELY(hcl->symtab->bucket == hcl->_nil)) if (HCL_LIKELY((hcl_oop_t)hcl->symtab->bucket == hcl->_nil))
{ {
/* It's important to assign the result of hcl_instantiate() to a temporary /* It's important to assign the result of hcl_instantiate() to a temporary
* variable first and then assign it to hcl->symtab->bucket. * variable first and then assign it to hcl->symtab->bucket.
@ -1321,7 +1321,7 @@ static int ignite_2 (hcl_t* hcl)
hcl->sysdic->tally = HCL_SMOOI_TO_OOP(0); hcl->sysdic->tally = HCL_SMOOI_TO_OOP(0);
} }
if (HCL_LIKELY(hcl->sysdic->bucket == hcl->_nil)) if (HCL_LIKELY((hcl_oop_t)hcl->sysdic->bucket == hcl->_nil))
{ {
/* It's important to assign the result of hcl_instantiate() to a temporary /* It's important to assign the result of hcl_instantiate() to a temporary
* variable first and then assign it to hcl->symtab->bucket. * variable first and then assign it to hcl->symtab->bucket.
@ -1576,7 +1576,7 @@ oops:
return -1; return -1;
} }
int hcl_getsyncodebyoocs_noseterr (hcl_t* hcl, const hcl_oocs_t* name) hcl_syncode_t hcl_getsyncodebyoocs_noseterr (hcl_t* hcl, const hcl_oocs_t* name)
{ {
hcl_oow_t i; hcl_oow_t i;
for (i = 0; i < HCL_COUNTOF(syminfo); i++) for (i = 0; i < HCL_COUNTOF(syminfo); i++)
@ -1584,10 +1584,10 @@ int hcl_getsyncodebyoocs_noseterr (hcl_t* hcl, const hcl_oocs_t* name)
if (hcl_comp_oochars(syminfo[i].ptr, syminfo[i].len, name->ptr, name->len) == 0) if (hcl_comp_oochars(syminfo[i].ptr, syminfo[i].len, name->ptr, name->len) == 0)
return syminfo[i].syncode; return syminfo[i].syncode;
} }
return 0; /* 0 indicates no syntax code found */ return HCL_SYNCODE_NONE; /* indicates no syntax code found */
} }
int hcl_getsyncode_noseterr (hcl_t* hcl, const hcl_ooch_t* ptr, const hcl_oow_t len) hcl_syncode_t hcl_getsyncode_noseterr (hcl_t* hcl, const hcl_ooch_t* ptr, const hcl_oow_t len)
{ {
hcl_oow_t i; hcl_oow_t i;
for (i = 0; i < HCL_COUNTOF(syminfo); i++) for (i = 0; i < HCL_COUNTOF(syminfo); i++)
@ -1595,7 +1595,7 @@ int hcl_getsyncode_noseterr (hcl_t* hcl, const hcl_ooch_t* ptr, const hcl_oow_t
if (hcl_comp_oochars(syminfo[i].ptr, syminfo[i].len, ptr, len) == 0) if (hcl_comp_oochars(syminfo[i].ptr, syminfo[i].len, ptr, len) == 0)
return syminfo[i].syncode; return syminfo[i].syncode;
} }
return 0; /* 0 indicates no syntax code found */ return HCL_SYNCODE_NONE; /* indicates no syntax code found */
} }
const hcl_ooch_t* hcl_getsyncodename_noseterr (hcl_t* hcl, hcl_syncode_t syncode) const hcl_ooch_t* hcl_getsyncodename_noseterr (hcl_t* hcl, hcl_syncode_t syncode)

View File

@ -396,7 +396,7 @@ enum hcl_cnode_flag_t
{ {
HCL_CNODE_AUTO_FORGED = (1 << 0) HCL_CNODE_AUTO_FORGED = (1 << 0)
}; };
typedef enum hcl_cnode_flagt hcl_cnode_flag_t; typedef enum hcl_cnode_flag_t hcl_cnode_flag_t;
#define HCL_CNODE_GET_TYPE(x) ((x)->cn_type) #define HCL_CNODE_GET_TYPE(x) ((x)->cn_type)
#define HCL_CNODE_GET_FLAGS(x) ((x)->cn_flags) #define HCL_CNODE_GET_FLAGS(x) ((x)->cn_flags)
@ -1554,12 +1554,12 @@ void hcl_gc_ms_sweep_lazy (
hcl_oow_t allocsize hcl_oow_t allocsize
); );
int hcl_getsyncodebyoocs_noseterr ( hcl_syncode_t hcl_getsyncodebyoocs_noseterr (
hcl_t* hcl, hcl_t* hcl,
const hcl_oocs_t* name const hcl_oocs_t* name
); );
int hcl_getsyncode_noseterr ( hcl_syncode_t hcl_getsyncode_noseterr (
hcl_t* hcl, hcl_t* hcl,
const hcl_ooch_t* ptr, const hcl_ooch_t* ptr,
const hcl_oow_t len const hcl_oow_t len

View File

@ -157,7 +157,7 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, const hcl_vmprim_t* vmprim)
if (HCL_UNLIKELY(!hcl->log.ptr)) goto oops; if (HCL_UNLIKELY(!hcl->log.ptr)) goto oops;
hcl->gci.stack.capa = HCL_ALIGN_POW2(1, 1024); /* TODO: is this a good initial size? */ hcl->gci.stack.capa = HCL_ALIGN_POW2(1, 1024); /* TODO: is this a good initial size? */
hcl->gci.stack.ptr = hcl_allocmem(hcl, (hcl->gci.stack.capa + 1) * HCL_SIZEOF(*hcl->gci.stack.ptr)); hcl->gci.stack.ptr = (hcl_oop_t*)hcl_allocmem(hcl, (hcl->gci.stack.capa + 1) * HCL_SIZEOF(*hcl->gci.stack.ptr));
if (HCL_UNLIKELY(!hcl->gci.stack.ptr)) goto oops; if (HCL_UNLIKELY(!hcl->gci.stack.ptr)) goto oops;
n = hcl_rbt_init(&hcl->modtab, hcl, HCL_SIZEOF(hcl_ooch_t), 1); n = hcl_rbt_init(&hcl->modtab, hcl, HCL_SIZEOF(hcl_ooch_t), 1);
@ -397,7 +397,7 @@ void hcl_reset (hcl_t* hcl)
hcl_gc (hcl, 1); hcl_gc (hcl, 1);
} }
static int dup_str_opt (hcl_t* hcl, const void* value, hcl_oocs_t* tmp) static int dup_str_opt (hcl_t* hcl, const hcl_ooch_t* value, hcl_oocs_t* tmp)
{ {
if (value) if (value)
{ {
@ -440,10 +440,10 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
hcl_bch_t* v1; hcl_bch_t* v1;
hcl_uch_t* v2; hcl_uch_t* v2;
v1 = hcl_dupbcstr(hcl, value, HCL_NULL); v1 = hcl_dupbcstr(hcl, (const hcl_bch_t*)value, HCL_NULL);
if (HCL_UNLIKELY(!v1)) return -1; if (HCL_UNLIKELY(!v1)) return -1;
v2 = hcl_dupbtoucstr(hcl, value, HCL_NULL); v2 = hcl_dupbtoucstr(hcl, (const hcl_bch_t*)value, HCL_NULL);
if (HCL_UNLIKELY(!v2)) if (HCL_UNLIKELY(!v2))
{ {
hcl_freemem (hcl, v1); hcl_freemem (hcl, v1);
@ -460,10 +460,10 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
hcl_uch_t* v1; hcl_uch_t* v1;
hcl_bch_t* v2; hcl_bch_t* v2;
v1 = hcl_dupucstr(hcl, value, HCL_NULL); v1 = hcl_dupucstr(hcl, (const hcl_uch_t*)value, HCL_NULL);
if (HCL_UNLIKELY(!v1)) return -1; if (HCL_UNLIKELY(!v1)) return -1;
v2 = hcl_duputobcstr(hcl, value, HCL_NULL); v2 = hcl_duputobcstr(hcl, (const hcl_uch_t*)value, HCL_NULL);
if (HCL_UNLIKELY(!v2)) if (HCL_UNLIKELY(!v2))
{ {
hcl_freemem (hcl, v1); hcl_freemem (hcl, v1);
@ -557,7 +557,7 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
hcl_oocs_t tmp; hcl_oocs_t tmp;
int idx; int idx;
if (dup_str_opt(hcl, value, &tmp) <= -1) return -1; if (dup_str_opt(hcl, (const hcl_ooch_t*)value, &tmp) <= -1) return -1;
idx = id - HCL_MOD_LIBDIRS; idx = id - HCL_MOD_LIBDIRS;
if (hcl->option.mod[idx].ptr) hcl_freemem (hcl, hcl->option.mod[idx].ptr); if (hcl->option.mod[idx].ptr) hcl_freemem (hcl, hcl->option.mod[idx].ptr);

View File

@ -1992,7 +1992,9 @@ typedef enum hcl_brand_t hcl_brand_t;
enum hcl_syncode_t enum hcl_syncode_t
{ {
/* SYNCODE 0 means it's not a syncode object. so it begins with 1 */ HCL_SYNCODE_NONE = 0,
/* SYNCODE 0 means it's not a syncode object. so the actual code begins with 1 */
/* these enumerators can be set in the SYNCODE flags for a symbol */ /* these enumerators can be set in the SYNCODE flags for a symbol */
HCL_SYNCODE_AND = 1, HCL_SYNCODE_AND = 1,
HCL_SYNCODE_BREAK, HCL_SYNCODE_BREAK,

View File

@ -26,17 +26,17 @@
static void* xma_alloc (hcl_mmgr_t* mmgr, hcl_oow_t size) static void* xma_alloc (hcl_mmgr_t* mmgr, hcl_oow_t size)
{ {
return hcl_xma_alloc(mmgr->ctx, size); return hcl_xma_alloc((hcl_xma_t*)mmgr->ctx, size);
} }
static void* xma_realloc (hcl_mmgr_t* mmgr, void* ptr, hcl_oow_t size) static void* xma_realloc (hcl_mmgr_t* mmgr, void* ptr, hcl_oow_t size)
{ {
return hcl_xma_realloc(mmgr->ctx, ptr, size); return hcl_xma_realloc((hcl_xma_t*)mmgr->ctx, ptr, size);
} }
static void xma_free (hcl_mmgr_t* mmgr, void* ptr) static void xma_free (hcl_mmgr_t* mmgr, void* ptr)
{ {
hcl_xma_free (mmgr->ctx, ptr); hcl_xma_free ((hcl_xma_t*)mmgr->ctx, ptr);
} }
hcl_heap_t* hcl_makeheap (hcl_t* hcl, hcl_oow_t size) hcl_heap_t* hcl_makeheap (hcl_t* hcl, hcl_oow_t size)

View File

@ -506,7 +506,7 @@ static HCL_INLINE int decode_spec (hcl_t* hcl, hcl_oop_class_t _class, hcl_oow_t
if (HCL_CLASS_SPEC_IS_INDEXED(spec)) if (HCL_CLASS_SPEC_IS_INDEXED(spec))
{ {
indexed_type = HCL_CLASS_SPEC_INDEXED_TYPE(spec); indexed_type = (hcl_obj_type_t)HCL_CLASS_SPEC_INDEXED_TYPE(spec);
/* the number of the fixed fields for a non-pointer object are supported. /* the number of the fixed fields for a non-pointer object are supported.
* the fixed fields of a pointer object holds named instance variables * the fixed fields of a pointer object holds named instance variables
@ -603,19 +603,19 @@ hcl_oop_t hcl_instantiate (hcl_t* hcl, hcl_oop_class_t _class, const void* vptr,
break; break;
case HCL_OBJ_TYPE_CHAR: case HCL_OBJ_TYPE_CHAR:
oop = hcl_alloccharobj(hcl, HCL_BRAND_INSTANCE, vptr, alloclen); oop = hcl_alloccharobj(hcl, HCL_BRAND_INSTANCE, (const hcl_ooch_t*)vptr, alloclen);
break; break;
case HCL_OBJ_TYPE_BYTE: case HCL_OBJ_TYPE_BYTE:
oop = hcl_allocbyteobj(hcl, HCL_BRAND_INSTANCE, vptr, alloclen); oop = hcl_allocbyteobj(hcl, HCL_BRAND_INSTANCE, (const hcl_oob_t*)vptr, alloclen);
break; break;
case HCL_OBJ_TYPE_HALFWORD: case HCL_OBJ_TYPE_HALFWORD:
oop = hcl_allochalfwordobj(hcl, HCL_BRAND_INSTANCE, vptr, alloclen); oop = hcl_allochalfwordobj(hcl, HCL_BRAND_INSTANCE, (const hcl_oohw_t*)vptr, alloclen);
break; break;
case HCL_OBJ_TYPE_WORD: case HCL_OBJ_TYPE_WORD:
oop = hcl_allocwordobj(hcl, HCL_BRAND_INSTANCE, vptr, alloclen); oop = hcl_allocwordobj(hcl, HCL_BRAND_INSTANCE, (const hcl_oow_t*)vptr, alloclen);
break; break;
/* TODO: more types... HCL_OBJ_TYPE_INT... HCL_OBJ_TYPE_FLOAT, HCL_OBJ_TYPE_UINT16, etc*/ /* TODO: more types... HCL_OBJ_TYPE_INT... HCL_OBJ_TYPE_FLOAT, HCL_OBJ_TYPE_UINT16, etc*/

View File

@ -547,7 +547,8 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int*
hcl_cnode_t* head, * tail; hcl_cnode_t* head, * tail;
hcl_oow_t count; hcl_oow_t count;
hcl_loc_t loc; hcl_loc_t loc;
int fv, concode; int fv;
hcl_concode_t concode;
/* the stack must not be empty - cannot leave a list without entering it */ /* the stack must not be empty - cannot leave a list without entering it */
HCL_ASSERT (hcl, hcl->c->r.st != HCL_NULL); HCL_ASSERT (hcl, hcl->c->r.st != HCL_NULL);
@ -558,7 +559,7 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, hcl_loc_t* list_loc, int*
count = rstl->count; count = rstl->count;
fv = rstl->flagv; fv = rstl->flagv;
loc = rstl->loc; loc = rstl->loc;
concode = LIST_FLAG_GET_CONCODE(fv); concode = (hcl_concode_t)LIST_FLAG_GET_CONCODE(fv);
hcl->c->r.st = rstl->prev; /* pop off */ hcl->c->r.st = rstl->prev; /* pop off */
hcl_freemem (hcl, rstl); /* dispose of the stack node */ hcl_freemem (hcl, rstl); /* dispose of the stack node */
@ -797,7 +798,7 @@ static HCL_INLINE int can_comma_list (hcl_t* hcl)
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0; if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0;
cc = LIST_FLAG_GET_CONCODE(rstl->flagv); cc = (hcl_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv);
if (cc == HCL_CONCODE_XLIST) if (cc == HCL_CONCODE_XLIST)
{ {
/* defun f(a :: b c) { b := (a + 10); c := (a + 20) } /* defun f(a :: b c) { b := (a + 10); c := (a + 20) }
@ -849,7 +850,7 @@ static HCL_INLINE int can_colon_list (hcl_t* hcl)
/* multiple single-colons - e.g. #{ "abc": : 20 } */ /* multiple single-colons - e.g. #{ "abc": : 20 } */
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0; if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0;
cc = LIST_FLAG_GET_CONCODE(rstl->flagv); cc = (hcl_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv);
if (cc == HCL_CONCODE_XLIST) if (cc == HCL_CONCODE_XLIST)
{ {
/* method defintion with defun - e.g. defun String:length() /* method defintion with defun - e.g. defun String:length()
@ -882,7 +883,7 @@ static HCL_INLINE int can_coloneq_list (hcl_t* hcl)
/* repeated delimiters - e.g (a := := ...) (a : := ... ) */ /* repeated delimiters - e.g (a := := ...) (a : := ... ) */
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0; if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0;
cc = LIST_FLAG_GET_CONCODE(rstl->flagv); cc = (hcl_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv);
/* assignment only in XLIST */ /* assignment only in XLIST */
if (cc != HCL_CONCODE_XLIST) return 0; if (cc != HCL_CONCODE_XLIST) return 0;
@ -911,7 +912,7 @@ static HCL_INLINE int can_binop_list (hcl_t* hcl)
/* repeated delimiters - e.g (a ++ ++ ...) (a : := ... ) */ /* repeated delimiters - e.g (a ++ ++ ...) (a : := ... ) */
if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0; if (rstl->flagv & (COMMAED | COLONED | COLONEQED | BINOPED)) return 0;
cc = LIST_FLAG_GET_CONCODE(rstl->flagv); cc = (hcl_concode_t)LIST_FLAG_GET_CONCODE(rstl->flagv);
/* assignment only in XLIST */ /* assignment only in XLIST */
if (cc != HCL_CONCODE_XLIST) return 0; if (cc != HCL_CONCODE_XLIST) return 0;
@ -2771,7 +2772,7 @@ static int flx_quoted_token (hcl_t* hcl, hcl_ooci_t c) /* string, character */
* byte-string and byte-character literals are 1 greater than * byte-string and byte-character literals are 1 greater than
* string and character literals. * see the definition of * string and character literals. * see the definition of
* hcl_tok_type_t in hcl-prv.h */ * hcl_tok_type_t in hcl-prv.h */
FEED_WRAP_UP (hcl, qt->tok_type + qt->is_byte); /* HCL_TOK_STRLIT or HCL_TOK_CHARLIT */ FEED_WRAP_UP (hcl, (hcl_tok_type_t)(qt->tok_type + qt->is_byte)); /* HCL_TOK_STRLIT or HCL_TOK_CHARLIT */
if (TOKEN_NAME_LEN(hcl) < qt->min_len) goto invalid_token; if (TOKEN_NAME_LEN(hcl) < qt->min_len) goto invalid_token;
goto consumed; goto consumed;
} }

View File

@ -929,7 +929,7 @@ hcl_errnum_t hcl_syserrstrb (hcl_t* hcl, int syserr_type, int syserr_code, hcl_b
* a positive error code upon failure */ * a positive error code upon failure */
x = (hcl_oow_t)strerror_r(syserr_code, buf, len); x = (hcl_oow_t)strerror_r(syserr_code, buf, len);
if (x != (hcl_oow_t)buf && buf[0] == '\0' && x != 0 && x > 1024 && x != (hcl_oow_t)-1) if (x != (hcl_oow_t)buf && buf[0] == '\0' && x != 0 && x > 1024 && x != (hcl_oow_t)-1)
hcl_copy_bcstr (buf, len, (void*)x); hcl_copy_bcstr (buf, len, (const hcl_bch_t*)x);
} }
#else #else
/* this may be thread unsafe */ /* this may be thread unsafe */
@ -3643,7 +3643,7 @@ static HCL_INLINE int read_udi_stream_bytes (hcl_t* hcl, hcl_io_udiarg_t* arg)
bcslen = (bb->len < HCL_COUNTOF(arg->buf.b))? bb->len: HCL_COUNTOF(arg->buf.b); bcslen = (bb->len < HCL_COUNTOF(arg->buf.b))? bb->len: HCL_COUNTOF(arg->buf.b);
ucslen = bcslen; ucslen = bcslen;
hcl_copy_bchars (arg->buf.b, bb->buf, bcslen); hcl_copy_bchars ((hcl_bch_t*)arg->buf.b, bb->buf, bcslen);
remlen = bb->len - bcslen; remlen = bb->len - bcslen;
if (remlen > 0) HCL_MEMMOVE (bb->buf, &bb->buf[bcslen], remlen); if (remlen > 0) HCL_MEMMOVE (bb->buf, &bb->buf[bcslen], remlen);

View File

@ -204,7 +204,7 @@ hcl_oop_t hcl_makesymbolwithbcstr (hcl_t* hcl, const hcl_bch_t* ptr)
hcl_oop_t hcl_makesymbolwithucstr (hcl_t* hcl, const hcl_uch_t* ptr) hcl_oop_t hcl_makesymbolwithucstr (hcl_t* hcl, const hcl_uch_t* ptr)
{ {
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
return hcl_makesymbol(hcl, ptr, hcl_count_bcstr(ptr)); return hcl_makesymbol(hcl, ptr, hcl_count_ucstr(ptr));
#else #else
hcl_uch_t* bcsptr; hcl_uch_t* bcsptr;
hcl_oow_t bcslen; hcl_oow_t bcslen;

View File

@ -558,7 +558,7 @@ hcl_oow_t hcl_byte_to_bcstr (hcl_uint8_t byte, hcl_bch_t* buf, hcl_oow_t size, i
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
HCL_INLINE int hcl_conv_bchars_to_uchars_with_cmgr (const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_cmgr_t* cmgr, int all) int hcl_conv_bchars_to_uchars_with_cmgr (const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_cmgr_t* cmgr, int all)
{ {
const hcl_bch_t* p; const hcl_bch_t* p;
int ret = 0; int ret = 0;
@ -677,7 +677,7 @@ HCL_INLINE int hcl_conv_bchars_to_uchars_with_cmgr (const hcl_bch_t* bcs, hcl_oo
return ret; return ret;
} }
HCL_INLINE int hcl_conv_bcstr_to_ucstr_with_cmgr (const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_cmgr_t* cmgr, int all) int hcl_conv_bcstr_to_ucstr_with_cmgr (const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_cmgr_t* cmgr, int all)
{ {
const hcl_bch_t* bp; const hcl_bch_t* bp;
hcl_oow_t mlen, wlen; hcl_oow_t mlen, wlen;
@ -698,7 +698,7 @@ HCL_INLINE int hcl_conv_bcstr_to_ucstr_with_cmgr (const hcl_bch_t* bcs, hcl_oow_
return n; return n;
} }
HCL_INLINE int hcl_conv_uchars_to_bchars_with_cmgr (const hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_cmgr_t* cmgr) int hcl_conv_uchars_to_bchars_with_cmgr (const hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_cmgr_t* cmgr)
{ {
const hcl_uch_t* p = ucs; const hcl_uch_t* p = ucs;
const hcl_uch_t* end = ucs + *ucslen; const hcl_uch_t* end = ucs + *ucslen;
@ -765,7 +765,7 @@ HCL_INLINE int hcl_conv_uchars_to_bchars_with_cmgr (const hcl_uch_t* ucs, hcl_oo
return ret; return ret;
} }
HCL_INLINE int hcl_conv_ucstr_to_bcstr_with_cmgr (const hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_cmgr_t* cmgr) int hcl_conv_ucstr_to_bcstr_with_cmgr (const hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_cmgr_t* cmgr)
{ {
const hcl_uch_t* p = ucs; const hcl_uch_t* p = ucs;
int ret = 0; int ret = 0;
@ -1052,7 +1052,7 @@ int hcl_convutobcstr (hcl_t* hcl, const hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_b
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
HCL_INLINE hcl_uch_t* hcl_dupbtoucharswithheadroom (hcl_t* hcl, hcl_oow_t headroom_bytes, const hcl_bch_t* bcs, hcl_oow_t bcslen, hcl_oow_t* ucslen) hcl_uch_t* hcl_dupbtoucharswithheadroom (hcl_t* hcl, hcl_oow_t headroom_bytes, const hcl_bch_t* bcs, hcl_oow_t bcslen, hcl_oow_t* ucslen)
{ {
hcl_oow_t inlen, outlen; hcl_oow_t inlen, outlen;
hcl_uch_t* ptr; hcl_uch_t* ptr;
@ -1085,7 +1085,7 @@ hcl_uch_t* hcl_dupbtouchars (hcl_t* hcl, const hcl_bch_t* bcs, hcl_oow_t bcslen,
return hcl_dupbtoucharswithheadroom (hcl, 0, bcs, bcslen, ucslen); return hcl_dupbtoucharswithheadroom (hcl, 0, bcs, bcslen, ucslen);
} }
HCL_INLINE hcl_bch_t* hcl_duputobcharswithheadroom (hcl_t* hcl, hcl_oow_t headroom_bytes, const hcl_uch_t* ucs, hcl_oow_t ucslen, hcl_oow_t* bcslen) hcl_bch_t* hcl_duputobcharswithheadroom (hcl_t* hcl, hcl_oow_t headroom_bytes, const hcl_uch_t* ucs, hcl_oow_t ucslen, hcl_oow_t* bcslen)
{ {
hcl_oow_t inlen, outlen; hcl_oow_t inlen, outlen;
hcl_bch_t* ptr; hcl_bch_t* ptr;
@ -1117,7 +1117,7 @@ hcl_bch_t* hcl_duputobchars (hcl_t* hcl, const hcl_uch_t* ucs, hcl_oow_t ucslen,
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
HCL_INLINE hcl_uch_t* hcl_dupbtoucstrwithheadroom (hcl_t* hcl, hcl_oow_t headroom_bytes, const hcl_bch_t* bcs, hcl_oow_t* ucslen) hcl_uch_t* hcl_dupbtoucstrwithheadroom (hcl_t* hcl, hcl_oow_t headroom_bytes, const hcl_bch_t* bcs, hcl_oow_t* ucslen)
{ {
hcl_oow_t inlen, outlen; hcl_oow_t inlen, outlen;
hcl_uch_t* ptr; hcl_uch_t* ptr;
@ -1142,7 +1142,7 @@ hcl_uch_t* hcl_dupbtoucstr (hcl_t* hcl, const hcl_bch_t* bcs, hcl_oow_t* ucslen)
return hcl_dupbtoucstrwithheadroom (hcl, 0, bcs, ucslen); return hcl_dupbtoucstrwithheadroom (hcl, 0, bcs, ucslen);
} }
HCL_INLINE hcl_bch_t* hcl_duputobcstrwithheadroom (hcl_t* hcl, hcl_oow_t headroom_bytes, const hcl_uch_t* ucs, hcl_oow_t* bcslen) hcl_bch_t* hcl_duputobcstrwithheadroom (hcl_t* hcl, hcl_oow_t headroom_bytes, const hcl_uch_t* ucs, hcl_oow_t* bcslen)
{ {
hcl_oow_t inlen, outlen; hcl_oow_t inlen, outlen;
hcl_bch_t* ptr; hcl_bch_t* ptr;

View File

@ -330,8 +330,8 @@ int hcl_unmarshalcode (hcl_t* hcl, hcl_code_t* code, hcl_xchg_reader_t rdr, void
newcapa = nbytes; newcapa = nbytes;
if (HCL_UNLIKELY(newcapa <= 0)) newcapa++; if (HCL_UNLIKELY(newcapa <= 0)) newcapa++;
newcapa = HCL_ALIGN(newcapa, HCL_BC_BUFFER_ALIGN); newcapa = HCL_ALIGN(newcapa, HCL_BC_BUFFER_ALIGN);
newptr = hcl_reallocmem(hcl, code->bc.ptr, newcapa); newptr = (hcl_oob_t*)hcl_reallocmem(hcl, code->bc.ptr, newcapa);
if (!newptr) goto oops; if (HCL_UNLIKELY(!newptr)) goto oops;
code->bc.ptr = newptr; code->bc.ptr = newptr;
code->bc.capa = newcapa; code->bc.capa = newcapa;
@ -550,7 +550,7 @@ static int mem_code_writer (hcl_t* hcl, const void* ptr, hcl_oow_t len, void* ct
newcapa = dst->len + len; newcapa = dst->len + len;
newcapa = HCL_ALIGN_POW2(newcapa, 64); newcapa = HCL_ALIGN_POW2(newcapa, 64);
newptr = hcl_reallocmem(hcl, dst->ptr, newcapa); newptr = (hcl_uint8_t*)hcl_reallocmem(hcl, dst->ptr, newcapa);
if (HCL_UNLIKELY(!newptr)) return -1; if (HCL_UNLIKELY(!newptr)) return -1;
dst->ptr = newptr; dst->ptr = newptr;