enhanced the logfmtv to handle encoding conversion of the format string
This commit is contained in:
parent
bf49aa1260
commit
ef51ee4a1d
10
lib/bigint.c
10
lib/bigint.c
@ -40,7 +40,7 @@
|
||||
#define IS_SIGN_DIFF(x,y) (((x) ^ (y)) < 0)
|
||||
|
||||
/* digit character array */
|
||||
static char* _digitc = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
static char _digitc[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
|
||||
/* exponent table */
|
||||
static hcl_uint8_t _exp_tab[] =
|
||||
@ -1114,12 +1114,12 @@ static HCL_INLINE hcl_oow_t multiply_unsigned_array_karatsuba (hcl_t* hcl, const
|
||||
tmplen[0] = ndigits_xh + ndigits_yh;
|
||||
tmplen[1] = ndigits_yl + ndigits_yh + 1;
|
||||
if (tmplen[1] < tmplen[0]) tmplen[1] = tmplen[0];
|
||||
tmp[1] = hcl_callocmem (hcl, HCL_SIZEOF(hcl_liw_t) * tmplen[1]); /* TODO: should i use the object memory? */
|
||||
tmp[1] = (hcl_liw_t*)hcl_callocmem(hcl, HCL_SIZEOF(hcl_liw_t) * tmplen[1]); /* TODO: should i use the object memory? */
|
||||
if (!tmp[1]) goto oops;
|
||||
|
||||
/* make a temporary for (a0 + a1) and (a0 * b0) */
|
||||
tmplen[0] = ndigits_xl + ndigits_yl + 1;
|
||||
tmp[0] = hcl_callocmem (hcl, HCL_SIZEOF(hcl_liw_t) * tmplen[0]);
|
||||
tmp[0] = (hcl_liw_t*)hcl_callocmem(hcl, HCL_SIZEOF(hcl_liw_t) * tmplen[0]);
|
||||
if (!tmp[0]) goto oops;
|
||||
|
||||
/* tmp[0] = a0 + a1 */
|
||||
@ -3619,7 +3619,7 @@ hcl_oop_t hcl_strtoint (hcl_t* hcl, const hcl_ooch_t* str, hcl_oow_t len, int ra
|
||||
|
||||
if (outlen > HCL_COUNTOF(hw))
|
||||
{
|
||||
hwp = hcl_allocmem (hcl, outlen * HCL_SIZEOF(hw[0]));
|
||||
hwp = (hcl_liw_t*)hcl_allocmem(hcl, outlen * HCL_SIZEOF(hw[0]));
|
||||
if (!hwp) return HCL_NULL;
|
||||
}
|
||||
else
|
||||
@ -3667,7 +3667,7 @@ hcl_oop_t hcl_strtoint (hcl_t* hcl, const hcl_ooch_t* str, hcl_oow_t len, int ra
|
||||
outlen = (end - str) / safe_ndigits + 1;
|
||||
if (outlen > HCL_COUNTOF(hw))
|
||||
{
|
||||
hwp = hcl_allocmem (hcl, outlen * HCL_SIZEOF(hcl_liw_t));
|
||||
hwp = (hcl_liw_t*)hcl_allocmem(hcl, outlen * HCL_SIZEOF(hcl_liw_t));
|
||||
if (!hwp) return HCL_NULL;
|
||||
}
|
||||
else
|
||||
|
@ -98,7 +98,7 @@ static int add_temporary_variable (hcl_t* hcl, hcl_oop_t name, hcl_oow_t dup_che
|
||||
hcl_oow_t newcapa;
|
||||
|
||||
newcapa = HCL_ALIGN (hcl->c->tv.capa + 1, TV_BUFFER_ALIGN); /* TODO: set a better resizing policy */
|
||||
tmp = hcl_reallocmem (hcl, hcl->c->tv.ptr, newcapa);
|
||||
tmp = (hcl_oop_t*)hcl_reallocmem (hcl, hcl->c->tv.ptr, newcapa);
|
||||
if (!tmp) return -1;
|
||||
|
||||
hcl->c->tv.capa = newcapa;
|
||||
@ -495,7 +495,7 @@ static HCL_INLINE int _insert_cframe (hcl_t* hcl, hcl_ooi_t index, int opcode, h
|
||||
hcl_oow_t newcapa;
|
||||
|
||||
newcapa = HCL_ALIGN (hcl->c->cfs.top + 256, 256); /* TODO: adjust this capacity */
|
||||
tmp = hcl_reallocmem (hcl, hcl->c->cfs.ptr, newcapa * HCL_SIZEOF(hcl_cframe_t));
|
||||
tmp = (hcl_cframe_t*)hcl_reallocmem (hcl, hcl->c->cfs.ptr, newcapa * HCL_SIZEOF(hcl_cframe_t));
|
||||
if (!tmp)
|
||||
{
|
||||
hcl->c->cfs.top--;
|
||||
|
@ -111,7 +111,7 @@ static hcl_oop_cons_t find_or_upsert (hcl_t* hcl, hcl_oop_dic_t dic, hcl_oop_cha
|
||||
#if defined(SYMBOL_ONLY_KEY)
|
||||
index = hcl_hashoochars(key->slot, HCL_OBJ_GET_SIZE(key)) % HCL_OBJ_GET_SIZE(dic->bucket);
|
||||
#else
|
||||
if (hcl_hashobj(hcl, key, &index) <= -1) return HCL_NULL;
|
||||
if (hcl_hashobj(hcl, (hcl_oop_t)key, &index) <= -1) return HCL_NULL;
|
||||
index %= HCL_OBJ_GET_SIZE(dic->bucket);
|
||||
#endif
|
||||
|
||||
@ -136,7 +136,7 @@ static hcl_oop_cons_t find_or_upsert (hcl_t* hcl, hcl_oop_dic_t dic, hcl_oop_cha
|
||||
ass = (hcl_oop_cons_t)dic->bucket->slot[index];
|
||||
HCL_ASSERT (hcl, HCL_IS_CONS(hcl,ass));
|
||||
|
||||
n = hcl_equalobjs(hcl, key, ass->car);
|
||||
n = hcl_equalobjs(hcl, (hcl_oop_t)key, ass->car);
|
||||
if (n <= -1) return HCL_NULL;
|
||||
if (n >= 1)
|
||||
{
|
||||
@ -197,7 +197,7 @@ static hcl_oop_cons_t find_or_upsert (hcl_t* hcl, hcl_oop_dic_t dic, hcl_oop_cha
|
||||
/* recalculate the index for the expanded bucket */
|
||||
index = hcl_hashoochars(key->slot, HCL_OBJ_GET_SIZE(key)) % HCL_OBJ_GET_SIZE(dic->bucket);
|
||||
#else
|
||||
hcl_hashobj(hcl, key, &index); /* this must succeed as i know 'key' is hashable */
|
||||
hcl_hashobj(hcl, (hcl_oop_t)key, &index); /* this must succeed as i know 'key' is hashable */
|
||||
index %= HCL_OBJ_GET_SIZE(dic->bucket);
|
||||
#endif
|
||||
|
||||
|
@ -165,7 +165,7 @@ static HCL_INLINE int prepare_to_alloc_pid (hcl_t* hcl)
|
||||
new_capa = HCL_SMOOI_MAX;
|
||||
}
|
||||
|
||||
tmp = 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;
|
||||
|
||||
hcl->proc_map_free_first = hcl->proc_map_capa;
|
||||
@ -1022,7 +1022,7 @@ static int start_initial_process_and_context (hcl_t* hcl, hcl_ooi_t initial_ip)
|
||||
ctx->method_or_nargs = HCL_SMOOI_TO_OOP(0);
|
||||
/* TODO: XXXXX */
|
||||
ctx->ntmprs = HCL_SMOOI_TO_OOP(0);
|
||||
ctx->home = ctx; /* is this correct??? */
|
||||
ctx->home = (hcl_oop_t)ctx; /* is this correct??? */
|
||||
/* END XXXXX */
|
||||
|
||||
/* [NOTE]
|
||||
|
4
lib/gc.c
4
lib/gc.c
@ -182,7 +182,7 @@ hcl_oop_t hcl_moveoop (hcl_t* hcl, hcl_oop_t oop)
|
||||
nbytes_aligned = get_payload_bytes (hcl, oop);
|
||||
|
||||
/* allocate space in the new heap */
|
||||
tmp = hcl_allocheapmem (hcl, hcl->newheap, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
tmp = (hcl_oop_t)hcl_allocheapmem (hcl, hcl->newheap, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
|
||||
/* allocation here must not fail because
|
||||
* i'm allocating the new space in a new heap for
|
||||
@ -447,7 +447,7 @@ hcl_oop_t hcl_shallowcopy (hcl_t* hcl, hcl_oop_t oop)
|
||||
total_bytes = HCL_SIZEOF(hcl_obj_t) + get_payload_bytes(hcl, oop);
|
||||
|
||||
hcl_pushtmp (hcl, &oop);
|
||||
z = hcl_allocbytes (hcl, total_bytes);
|
||||
z = (hcl_oop_t)hcl_allocbytes (hcl, total_bytes);
|
||||
hcl_poptmp(hcl);
|
||||
|
||||
HCL_MEMCPY (z, oop, total_bytes);
|
||||
|
@ -138,11 +138,8 @@
|
||||
/* ========================================================================= */
|
||||
/* SOURCE CODE I/O FOR COMPILER */
|
||||
/* ========================================================================= */
|
||||
typedef struct hcl_iotok_t hcl_iotok_t;
|
||||
struct hcl_iotok_t
|
||||
enum hcl_iotok_type_t
|
||||
{
|
||||
enum
|
||||
{
|
||||
HCL_IOTOK_EOF,
|
||||
HCL_IOTOK_CHARLIT,
|
||||
HCL_IOTOK_STRLIT,
|
||||
@ -169,11 +166,15 @@ struct hcl_iotok_t
|
||||
HCL_IOTOK_VBAR,
|
||||
|
||||
HCL_IOTOK_INCLUDE
|
||||
} type;
|
||||
};
|
||||
typedef enum hcl_iotok_type_t hcl_iotok_type_t;
|
||||
|
||||
typedef struct hcl_iotok_t hcl_iotok_t;
|
||||
struct hcl_iotok_t
|
||||
{
|
||||
hcl_iotok_type_t type;
|
||||
hcl_oocs_t name;
|
||||
hcl_oow_t name_capa;
|
||||
|
||||
hcl_ioloc_t loc;
|
||||
};
|
||||
|
||||
@ -638,7 +639,7 @@ enum hcl_bcode_t
|
||||
|
||||
typedef hcl_ooi_t (*hcl_outbfmt_t) (
|
||||
hcl_t* hcl,
|
||||
hcl_oow_t mask,
|
||||
int mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
@ -1042,21 +1043,21 @@ int hcl_addbuiltinprims (
|
||||
/* ========================================================================= */
|
||||
hcl_ooi_t hcl_proutbfmt (
|
||||
hcl_t* hcl,
|
||||
hcl_oow_t mask,
|
||||
int mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
hcl_ooi_t hcl_proutufmt (
|
||||
hcl_t* hcl,
|
||||
hcl_oow_t mask,
|
||||
int mask,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
int hcl_outfmtobj (
|
||||
hcl_t* hcl,
|
||||
hcl_oow_t mask,
|
||||
int mask,
|
||||
hcl_oop_t obj,
|
||||
hcl_outbfmt_t outbfmt
|
||||
);
|
||||
|
@ -167,6 +167,14 @@ typedef hcl_rbt_pair_t* (*hcl_rbt_cbserter_t) (
|
||||
void* ctx /**< callback context */
|
||||
);
|
||||
|
||||
|
||||
enum hcl_rbt_pair_color_t
|
||||
{
|
||||
HCL_RBT_RED,
|
||||
HCL_RBT_BLACK
|
||||
};
|
||||
typedef enum hcl_rbt_pair_color_t hcl_rbt_pair_color_t;
|
||||
|
||||
/**
|
||||
* The hcl_rbt_pair_t type defines red-black tree pair. A pair is composed
|
||||
* of a key and a value. It maintains pointers to the beginning of a key and
|
||||
@ -188,11 +196,7 @@ struct hcl_rbt_pair_t
|
||||
} val;
|
||||
|
||||
/* management information below */
|
||||
enum
|
||||
{
|
||||
HCL_RBT_RED,
|
||||
HCL_RBT_BLACK
|
||||
} color;
|
||||
hcl_rbt_pair_color_t color;
|
||||
hcl_rbt_pair_t* parent;
|
||||
hcl_rbt_pair_t* child[2]; /* left and right */
|
||||
};
|
||||
|
14
lib/hcl.c
14
lib/hcl.c
@ -34,7 +34,7 @@ hcl_t* hcl_open (hcl_mmgr_t* mmgr, hcl_oow_t xtnsize, hcl_oow_t heapsize, const
|
||||
/* if this assertion fails, correct the type definition in hcl.h */
|
||||
HCL_ASSERT (hcl, HCL_SIZEOF(hcl_oow_t) == HCL_SIZEOF(hcl_oop_t));
|
||||
|
||||
hcl = HCL_MMGR_ALLOC (mmgr, HCL_SIZEOF(*hcl) + xtnsize);
|
||||
hcl = (hcl_t*)HCL_MMGR_ALLOC(mmgr, HCL_SIZEOF(*hcl) + xtnsize);
|
||||
if (hcl)
|
||||
{
|
||||
if (hcl_init(hcl, mmgr, heapsize, vmprim) <= -1)
|
||||
@ -113,7 +113,7 @@ int hcl_init (hcl_t* hcl, hcl_mmgr_t* mmgr, hcl_oow_t heapsz, const hcl_vmprim_t
|
||||
* routine still function despite some side-effects when
|
||||
* reallocation fails */
|
||||
/* +1 required for consistency with put_oocs and put_ooch in logfmt.c */
|
||||
hcl->log.ptr = hcl_allocmem (hcl, (hcl->log.capa + 1) * HCL_SIZEOF(*hcl->log.ptr));
|
||||
hcl->log.ptr = (hcl_ooch_t*)hcl_allocmem (hcl, (hcl->log.capa + 1) * HCL_SIZEOF(*hcl->log.ptr));
|
||||
if (!hcl->log.ptr) goto oops;
|
||||
|
||||
/*hcl->permheap = hcl_makeheap (hcl, what is the best size???);
|
||||
@ -154,7 +154,7 @@ static hcl_rbt_walk_t unload_module (hcl_rbt_t* rbt, hcl_rbt_pair_t* pair, void*
|
||||
hcl_t* hcl = (hcl_t*)ctx;
|
||||
hcl_mod_data_t* mdp;
|
||||
|
||||
mdp = HCL_RBT_VPTR(pair);
|
||||
mdp = (hcl_mod_data_t*)HCL_RBT_VPTR(pair);
|
||||
HCL_ASSERT (hcl, mdp != HCL_NULL);
|
||||
|
||||
mdp->pair = HCL_NULL; /* to prevent hcl_closemod() from calling hcl_rbt_delete() */
|
||||
@ -283,7 +283,7 @@ int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value)
|
||||
return 0;
|
||||
|
||||
case HCL_LOG_MASK:
|
||||
hcl->option.log_mask = *(const unsigned int*)value;
|
||||
hcl->option.log_mask = *(const int*)value;
|
||||
return 0;
|
||||
|
||||
case HCL_LOG_MAXCAPA:
|
||||
@ -338,7 +338,7 @@ int hcl_getoption (hcl_t* hcl, hcl_option_t id, void* value)
|
||||
return 0;
|
||||
|
||||
case HCL_LOG_MASK:
|
||||
*(unsigned int*)value = hcl->option.log_mask;
|
||||
*(int*)value = hcl->option.log_mask;
|
||||
return 0;
|
||||
|
||||
case HCL_LOG_MAXCAPA:
|
||||
@ -367,7 +367,7 @@ hcl_cb_t* hcl_regcb (hcl_t* hcl, hcl_cb_t* tmpl)
|
||||
{
|
||||
hcl_cb_t* actual;
|
||||
|
||||
actual = hcl_allocmem (hcl, HCL_SIZEOF(*actual));
|
||||
actual = (hcl_cb_t*)hcl_allocmem(hcl, HCL_SIZEOF(*actual));
|
||||
if (!actual) return HCL_NULL;
|
||||
|
||||
*actual = *tmpl;
|
||||
@ -556,7 +556,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
|
||||
}
|
||||
|
||||
/* attempt to get hcl_mod_xxx where xxx is the module name*/
|
||||
load = hcl->vmprim.dl_getsym(hcl, md.handle, buf);
|
||||
load = (hcl_mod_load_t)hcl->vmprim.dl_getsym(hcl, md.handle, buf);
|
||||
if (!load)
|
||||
{
|
||||
hcl_seterrbfmt (hcl, hcl_geterrnum(hcl), "unable to get module symbol [%js] in [%.*js]", buf, namelen, name);
|
||||
|
12
lib/hcl.h
12
lib/hcl.h
@ -692,7 +692,7 @@ typedef void* (*hcl_vmprim_dlopen_t) (hcl_t* hcl, const hcl_ooch_t* name, int fl
|
||||
typedef void (*hcl_vmprim_dlclose_t) (hcl_t* hcl, void* handle);
|
||||
typedef void* (*hcl_vmprim_dlgetsym_t) (hcl_t* hcl, void* handle, const hcl_ooch_t* name);
|
||||
|
||||
typedef void (*hcl_log_write_t) (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* msg, hcl_oow_t len);
|
||||
typedef void (*hcl_log_write_t) (hcl_t* hcl, int mask, const hcl_ooch_t* msg, hcl_oow_t len);
|
||||
typedef void (*hcl_syserrstrb_t) (hcl_t* hcl, int syserr, hcl_bch_t* buf, hcl_oow_t len);
|
||||
typedef void (*hcl_syserrstru_t) (hcl_t* hcl, int syserr, hcl_uch_t* buf, hcl_oow_t len);
|
||||
|
||||
@ -885,7 +885,7 @@ typedef void (*hcl_mod_gc_t) (
|
||||
struct hcl_mod_t
|
||||
{
|
||||
/* input */
|
||||
const hcl_ooch_t name[HCL_MOD_NAME_LEN_MAX + 1];
|
||||
/*const*/ hcl_ooch_t name[HCL_MOD_NAME_LEN_MAX + 1];
|
||||
|
||||
/* user-defined data */
|
||||
hcl_mod_query_t query;
|
||||
@ -948,7 +948,7 @@ struct hcl_t
|
||||
struct
|
||||
{
|
||||
int trait;
|
||||
unsigned int log_mask;
|
||||
int log_mask;
|
||||
hcl_oow_t log_maxcapa;
|
||||
hcl_oow_t dfl_symtab_size;
|
||||
hcl_oow_t dfl_sysdic_size;
|
||||
@ -1049,7 +1049,7 @@ struct hcl_t
|
||||
{
|
||||
struct
|
||||
{
|
||||
hcl_uch_t* ptr;
|
||||
hcl_ooch_t* ptr;
|
||||
hcl_oow_t capa;
|
||||
hcl_oow_t len;
|
||||
} xbuf;
|
||||
@ -1584,14 +1584,14 @@ HCL_EXPORT hcl_pfbase_t* hcl_findpfbase (
|
||||
* ========================================================================= */
|
||||
HCL_EXPORT hcl_ooi_t hcl_logbfmt (
|
||||
hcl_t* hcl,
|
||||
hcl_oow_t mask,
|
||||
int mask,
|
||||
const hcl_bch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
HCL_EXPORT hcl_ooi_t hcl_logufmt (
|
||||
hcl_t* hcl,
|
||||
hcl_oow_t mask,
|
||||
int mask,
|
||||
const hcl_uch_t* fmt,
|
||||
...
|
||||
);
|
||||
|
40
lib/logfmt.c
40
lib/logfmt.c
@ -130,14 +130,14 @@ static hcl_bch_t bch_nullstr[] = { '(','n','u','l','l', ')','\0' };
|
||||
|
||||
typedef int (*hcl_fmtout_putch_t) (
|
||||
hcl_t* hcl,
|
||||
hcl_oow_t mask,
|
||||
int mask,
|
||||
hcl_ooch_t c,
|
||||
hcl_oow_t len
|
||||
);
|
||||
|
||||
typedef int (*hcl_fmtout_putcs_t) (
|
||||
hcl_t* hcl,
|
||||
hcl_oow_t mask,
|
||||
int mask,
|
||||
const hcl_ooch_t* ptr,
|
||||
hcl_oow_t len
|
||||
);
|
||||
@ -146,7 +146,7 @@ typedef struct hcl_fmtout_t hcl_fmtout_t;
|
||||
struct hcl_fmtout_t
|
||||
{
|
||||
hcl_oow_t count; /* out */
|
||||
hcl_oow_t mask; /* in */
|
||||
int mask; /* in */
|
||||
hcl_fmtout_putch_t putch; /* in */
|
||||
hcl_fmtout_putcs_t putcs; /* in */
|
||||
};
|
||||
@ -183,9 +183,9 @@ static hcl_bch_t* sprintn_upper (hcl_bch_t* nbuf, hcl_uintmax_t num, int base, h
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
static int put_ooch (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
static int put_ooch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
{
|
||||
/* this is not equivalent to put_oocs(hcl,mask,&ch, 1);
|
||||
/* this is not equivalent to put_oocs(hcl,mask,&ch,1);
|
||||
* this function is to emit a single character multiple times */
|
||||
hcl_oow_t rem;
|
||||
|
||||
@ -231,7 +231,7 @@ redo:
|
||||
}
|
||||
|
||||
/* +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)
|
||||
{
|
||||
make_do:
|
||||
@ -278,7 +278,7 @@ redo:
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_oocs (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
static int put_oocs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
hcl_oow_t rem;
|
||||
|
||||
@ -325,7 +325,7 @@ redo:
|
||||
}
|
||||
|
||||
/* +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)
|
||||
{
|
||||
make_do:
|
||||
@ -408,7 +408,7 @@ static int _logufmtv (hcl_t* hcl, const hcl_uch_t* fmt, hcl_fmtout_t* data, va_l
|
||||
return __logufmtv (hcl, fmt, data, ap, hcl_logbfmt);
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_logbfmt (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_logbfmt (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
int x;
|
||||
va_list ap;
|
||||
@ -441,7 +441,7 @@ hcl_ooi_t hcl_logbfmt (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ...)
|
||||
return (x <= -1)? -1: fo.count;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_logufmt (hcl_t* hcl, hcl_oow_t mask, const hcl_uch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_logufmt (hcl_t* hcl, int mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
int x;
|
||||
va_list ap;
|
||||
@ -474,7 +474,7 @@ hcl_ooi_t hcl_logufmt (hcl_t* hcl, hcl_oow_t mask, const hcl_uch_t* fmt, ...)
|
||||
* HELPER FOR PRINTING
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
static int put_prch (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
static int put_prch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
{
|
||||
/* TODO: better error handling, buffering.
|
||||
* should buffering be done by the printer callback? */
|
||||
@ -501,7 +501,7 @@ static int put_prch (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_prcs (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
static int put_prcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
/* TODO: better error handling, buffering
|
||||
* should buffering be done by the printer callback? */
|
||||
@ -517,7 +517,7 @@ static int put_prcs (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow_
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static hcl_ooi_t __prbfmtv (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ...);
|
||||
static hcl_ooi_t __prbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...);
|
||||
|
||||
static int _prbfmtv (hcl_t* hcl, const hcl_bch_t* fmt, hcl_fmtout_t* data, va_list ap)
|
||||
{
|
||||
@ -529,7 +529,7 @@ static int _prufmtv (hcl_t* hcl, const hcl_uch_t* fmt, hcl_fmtout_t* data, va_li
|
||||
return __logufmtv (hcl, fmt, data, ap, __prbfmtv);
|
||||
}
|
||||
|
||||
static hcl_ooi_t __prbfmtv (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ...)
|
||||
static hcl_ooi_t __prbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hcl_fmtout_t fo;
|
||||
@ -545,7 +545,7 @@ static hcl_ooi_t __prbfmtv (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ..
|
||||
return fo.count;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_proutbfmt (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_proutbfmt (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
int x;
|
||||
va_list ap;
|
||||
@ -562,7 +562,7 @@ hcl_ooi_t hcl_proutbfmt (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ...)
|
||||
return (x <= -1)? -1: fo.count;
|
||||
}
|
||||
|
||||
hcl_ooi_t hcl_proutufmt (hcl_t* hcl, hcl_oow_t mask, const hcl_uch_t* fmt, ...)
|
||||
hcl_ooi_t hcl_proutufmt (hcl_t* hcl, int mask, const hcl_uch_t* fmt, ...)
|
||||
{
|
||||
int x;
|
||||
va_list ap;
|
||||
@ -583,7 +583,7 @@ hcl_ooi_t hcl_proutufmt (hcl_t* hcl, hcl_oow_t mask, const hcl_uch_t* fmt, ...)
|
||||
* ERROR MESSAGE FORMATTING
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
static int put_errch (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
static int put_errch (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
{
|
||||
hcl_oow_t max;
|
||||
|
||||
@ -602,7 +602,7 @@ static int put_errch (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t ch, hcl_oow_t len)
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_errcs (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
static int put_errcs (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
hcl_oow_t max;
|
||||
|
||||
@ -619,7 +619,7 @@ static int put_errcs (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow
|
||||
}
|
||||
|
||||
|
||||
static hcl_ooi_t __errbfmtv (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ...);
|
||||
static hcl_ooi_t __errbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...);
|
||||
|
||||
static int _errbfmtv (hcl_t* hcl, const hcl_bch_t* fmt, hcl_fmtout_t* data, va_list ap)
|
||||
{
|
||||
@ -631,7 +631,7 @@ static int _errufmtv (hcl_t* hcl, const hcl_uch_t* fmt, hcl_fmtout_t* data, va_l
|
||||
return __logufmtv (hcl, fmt, data, ap, __errbfmtv);
|
||||
}
|
||||
|
||||
static hcl_ooi_t __errbfmtv (hcl_t* hcl, hcl_oow_t mask, const hcl_bch_t* fmt, ...)
|
||||
static hcl_ooi_t __errbfmtv (hcl_t* hcl, int mask, const hcl_bch_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
hcl_fmtout_t fo;
|
||||
|
@ -63,7 +63,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* NOTE: data output is aborted if the data limit is reached or
|
||||
* I/O error occurs */
|
||||
@ -92,9 +92,7 @@
|
||||
static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_list ap, hcl_outbfmt_t outbfmt)
|
||||
{
|
||||
const fmtchar_t* percent;
|
||||
#if defined(FMTCHAR_IS_OOCH)
|
||||
const fmtchar_t* checkpoint;
|
||||
#endif
|
||||
hcl_bch_t nbuf[MAXNBUF], bch;
|
||||
const hcl_bch_t* nbufp;
|
||||
int n, base, neg, sign;
|
||||
@ -138,27 +136,39 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
|
||||
}
|
||||
PUT_OOCS (checkpoint, fmt - checkpoint - 1);
|
||||
#else
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
/* fmtchar is bch. ooch is uch. convert bch to uch */
|
||||
checkpoint = fmt;
|
||||
while ((fch = *fmt++) != '%' || stop)
|
||||
{
|
||||
#if defined(HCL_OOCH_IS_UCH)
|
||||
if (fch == '\0') goto done;
|
||||
/* ooch is uch. fmtchar is bch */
|
||||
/* TODO: convert bch to uch */
|
||||
if (fch == '\0') break;
|
||||
}
|
||||
while (checkpoint < fmt - 1)
|
||||
{
|
||||
hcl_oow_t cvlen, bclen;
|
||||
bclen = fmt - checkpoint - 1;
|
||||
cvlen = hcl->cmgr->bctouc(checkpoint, bclen, &ch);
|
||||
if (cvlen == 0 || cvlen > bclen) goto oops;
|
||||
checkpoint += cvlen;
|
||||
PUT_OOCH (ch, 1);
|
||||
}
|
||||
if (fch == '\0') goto done;
|
||||
#else
|
||||
while ((fch = *fmt++) != '%' || stop)
|
||||
{
|
||||
hcl_bch_t bcsbuf[HCL_MBLEN_MAX + 1];
|
||||
hcl_oow_t ucslen, bcslen;
|
||||
|
||||
if (fch == '\0') goto done;
|
||||
|
||||
/* ooch is bch. fmtchar is uch */
|
||||
/* fmtchar is uch. ooch is bch. convert uch to bch */
|
||||
ucslen = 1;
|
||||
bcslen = 1;
|
||||
if (hcl_convutooochars (hcl, &fch, &ucslen, bcsbuf, &bcslen) <= -1) goto oops;
|
||||
bcslen = HCL_COUNTOF(bcsbuf);
|
||||
if (hcl_convutooochars(hcl, &fch, &ucslen, bcsbuf, &bcslen) <= -1) goto oops;
|
||||
PUT_OOCS (bcsbuf, bcslen);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
percent = fmt - 1;
|
||||
|
||||
padc = ' ';
|
||||
|
36
lib/main.c
36
lib/main.c
@ -193,7 +193,7 @@ static const hcl_bch_t* get_base_name (const hcl_bch_t* path)
|
||||
|
||||
static HCL_INLINE hcl_ooi_t open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
{
|
||||
xtn_t* xtn = hcl_getxtn(hcl);
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||
bb_t* bb = HCL_NULL;
|
||||
|
||||
/* TOOD: support predefined include directory as well */
|
||||
@ -214,7 +214,7 @@ static HCL_INLINE hcl_ooi_t open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
fb = get_base_name (fn);
|
||||
parlen = fb - fn;
|
||||
|
||||
bb = hcl_callocmem (hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (parlen + bcslen + 1)));
|
||||
bb = (bb_t*)hcl_callocmem (hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (parlen + bcslen + 1)));
|
||||
if (!bb) goto oops;
|
||||
|
||||
bb->fn = (hcl_bch_t*)(bb + 1);
|
||||
@ -232,7 +232,7 @@ static HCL_INLINE hcl_ooi_t open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
|
||||
pathlen = hcl_countbcstr (xtn->read_path);
|
||||
|
||||
bb = hcl_callocmem (hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (pathlen + 1)));
|
||||
bb = (bb_t*)hcl_callocmem (hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (pathlen + 1)));
|
||||
if (!bb) goto oops;
|
||||
|
||||
bb->fn = (hcl_bch_t*)(bb + 1);
|
||||
@ -269,7 +269,7 @@ oops:
|
||||
|
||||
static HCL_INLINE hcl_ooi_t close_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
{
|
||||
/*xtn_t* xtn = hcl_getxtn(hcl);*/
|
||||
/*xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);*/
|
||||
bb_t* bb;
|
||||
|
||||
bb = (bb_t*)arg->handle;
|
||||
@ -285,7 +285,7 @@ static HCL_INLINE hcl_ooi_t close_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
|
||||
static HCL_INLINE hcl_ooi_t read_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
{
|
||||
/*xtn_t* xtn = hcl_getxtn(hcl);*/
|
||||
/*xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);*/
|
||||
bb_t* bb;
|
||||
hcl_oow_t bcslen, ucslen, remlen;
|
||||
int x;
|
||||
@ -350,7 +350,7 @@ static hcl_ooi_t read_handler (hcl_t* hcl, hcl_iocmd_t cmd, void* arg)
|
||||
|
||||
static HCL_INLINE hcl_ooi_t open_output(hcl_t* hcl, hcl_iooutarg_t* arg)
|
||||
{
|
||||
xtn_t* xtn = hcl_getxtn(hcl);
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||
FILE* fp;
|
||||
|
||||
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__)
|
||||
@ -372,7 +372,7 @@ static HCL_INLINE hcl_ooi_t open_output(hcl_t* hcl, hcl_iooutarg_t* arg)
|
||||
|
||||
static HCL_INLINE hcl_ooi_t close_output (hcl_t* hcl, hcl_iooutarg_t* arg)
|
||||
{
|
||||
/*xtn_t* xtn = hcl_getxtn(hcl);*/
|
||||
/*xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);*/
|
||||
FILE* fp;
|
||||
|
||||
fp = (FILE*)arg->handle;
|
||||
@ -386,7 +386,7 @@ static HCL_INLINE hcl_ooi_t close_output (hcl_t* hcl, hcl_iooutarg_t* arg)
|
||||
|
||||
static HCL_INLINE hcl_ooi_t write_output (hcl_t* hcl, hcl_iooutarg_t* arg)
|
||||
{
|
||||
/*xtn_t* xtn = hcl_getxtn(hcl);*/
|
||||
/*xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);*/
|
||||
hcl_bch_t bcsbuf[1024];
|
||||
hcl_oow_t bcslen, ucslen, donelen;
|
||||
int x;
|
||||
@ -462,7 +462,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
|
||||
if (bufcapa <= HCL_COUNTOF(stabuf)) bufptr = stabuf;
|
||||
else
|
||||
{
|
||||
bufptr = hcl_allocmem(hcl, bufcapa * HCL_SIZEOF(*bufptr));
|
||||
bufptr = (hcl_bch_t*)hcl_allocmem(hcl, bufcapa * HCL_SIZEOF(*bufptr));
|
||||
if (!bufptr) return HCL_NULL;
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ static void* dl_getsym (hcl_t* hcl, void* handle, const hcl_ooch_t* name)
|
||||
if (bcslen >= HCL_COUNTOF(stabuf) - 2)
|
||||
{
|
||||
bufcapa = bcslen + 3;
|
||||
bufptr = hcl_allocmem(hcl, bufcapa * HCL_SIZEOF(*bufptr));
|
||||
bufptr = (hcl_bch_t*)hcl_allocmem(hcl, bufcapa * HCL_SIZEOF(*bufptr));
|
||||
if (!bufptr) return HCL_NULL;
|
||||
}
|
||||
else
|
||||
@ -705,7 +705,7 @@ static int write_all (int fd, const char* ptr, hcl_oow_t len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void log_write (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
static void log_write (hcl_t* hcl, int mask, const hcl_ooch_t* msg, hcl_oow_t len)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
# error NOT IMPLEMENTED
|
||||
@ -717,7 +717,7 @@ static void log_write (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* msg, hcl_oo
|
||||
hcl_oow_t ucslen, bcslen, msgidx;
|
||||
int n;
|
||||
|
||||
xtn_t* xtn = hcl_getxtn(hcl);
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||
int logfd;
|
||||
|
||||
if (mask & HCL_LOG_STDERR)
|
||||
@ -1076,7 +1076,7 @@ static void vm_gettime (hcl_t* hcl, hcl_ntime_t* now)
|
||||
static void vm_sleep (hcl_t* hcl, const hcl_ntime_t* dur)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
xtn_t* xtn = hcl_getxtn(hcl);
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||
if (xtn->waitable_timer)
|
||||
{
|
||||
LARGE_INTEGER li;
|
||||
@ -1150,7 +1150,7 @@ static void vm_sleep (hcl_t* hcl, const hcl_ntime_t* dur)
|
||||
|
||||
static void fini_hcl (hcl_t* hcl)
|
||||
{
|
||||
xtn_t* xtn = hcl_getxtn(hcl);
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
|
||||
if (xtn->logfd >= 0)
|
||||
{
|
||||
close (xtn->logfd);
|
||||
@ -1162,7 +1162,7 @@ static void fini_hcl (hcl_t* hcl)
|
||||
|
||||
static int handle_logopt (hcl_t* hcl, const hcl_bch_t* str)
|
||||
{
|
||||
xtn_t* xtn = hcl_getxtn (hcl);
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn (hcl);
|
||||
hcl_bch_t* xstr = (hcl_bch_t*)str;
|
||||
hcl_bch_t* cm, * flt;
|
||||
|
||||
@ -1245,7 +1245,7 @@ static int handle_logopt (hcl_t* hcl, const hcl_bch_t* str)
|
||||
#if defined(HCL_BUILD_DEBUG)
|
||||
static int handle_dbgopt (hcl_t* hcl, const hcl_bch_t* str)
|
||||
{
|
||||
xtn_t* xtn = hcl_getxtn (hcl);
|
||||
xtn_t* xtn = (xtn_t*)hcl_getxtn (hcl);
|
||||
const hcl_bch_t* cm, * flt;
|
||||
hcl_oow_t len;
|
||||
unsigned int trait, dbgopt = 0;
|
||||
@ -1395,7 +1395,7 @@ static void print_synerr (hcl_t* hcl)
|
||||
hcl_synerr_t synerr;
|
||||
xtn_t* xtn;
|
||||
|
||||
xtn = hcl_getxtn (hcl);
|
||||
xtn = (xtn_t*)hcl_getxtn (hcl);
|
||||
hcl_getsynerr (hcl, &synerr);
|
||||
|
||||
hcl_logbfmt (hcl,HCL_LOG_STDERR, "ERROR: ");
|
||||
@ -1545,7 +1545,7 @@ int main (int argc, char* argv[])
|
||||
hcl_setoption (hcl, HCL_LOG_MASK, &trait);*/
|
||||
}
|
||||
|
||||
xtn = hcl_getxtn (hcl);
|
||||
xtn = (xtn_t*)hcl_getxtn (hcl);
|
||||
xtn->logfd = -1;
|
||||
xtn->logfd_istty = 0;
|
||||
|
||||
|
14
lib/obj.c
14
lib/obj.c
@ -35,7 +35,7 @@ void* hcl_allocbytes (hcl_t* hcl, hcl_oow_t size)
|
||||
if ((hcl->option.trait & HCL_DEBUG_GC) && !(hcl->option.trait & HCL_NOGC)) hcl_gc (hcl);
|
||||
#endif
|
||||
|
||||
ptr = hcl_allocheapmem(hcl, hcl->curheap, size);
|
||||
ptr = (hcl_uint8_t*)hcl_allocheapmem(hcl, hcl->curheap, size);
|
||||
if (!ptr && hcl->errnum == HCL_EOOMEM && !(hcl->option.trait & HCL_NOGC))
|
||||
{
|
||||
hcl_gc (hcl);
|
||||
@ -45,7 +45,7 @@ void* hcl_allocbytes (hcl_t* hcl, hcl_oow_t size)
|
||||
(hcl_oow_t)(hcl->curheap->limit - hcl->curheap->base),
|
||||
(hcl_oow_t)(hcl->curheap->limit - hcl->curheap->ptr)
|
||||
);
|
||||
ptr = hcl_allocheapmem (hcl, hcl->curheap, size);
|
||||
ptr = (hcl_uint8_t*)hcl_allocheapmem (hcl, hcl->curheap, size);
|
||||
/* TODO: grow heap if ptr is still null. */
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ static HCL_INLINE hcl_oop_t alloc_oop_array (hcl_t* hcl, int brand, hcl_oow_t si
|
||||
|
||||
if (HCL_UNLIKELY(ngc))
|
||||
{
|
||||
hdr = hcl_callocmem(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
hdr = (hcl_oop_oop_t)hcl_callocmem(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -73,7 +73,7 @@ static HCL_INLINE hcl_oop_t alloc_oop_array (hcl_t* hcl, int brand, hcl_oow_t si
|
||||
* HCL_SIZEOF(hcl_oop_t) will guarantee the starting address
|
||||
* of the allocated space to be an even number.
|
||||
* see HCL_OOP_IS_NUMERIC() and HCL_OOP_IS_POINTER() */
|
||||
hdr = hcl_allocbytes(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
hdr = (hcl_oop_oop_t)hcl_allocbytes(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
}
|
||||
if (!hdr) return HCL_NULL;
|
||||
|
||||
@ -104,7 +104,7 @@ hcl_oop_t hcl_allocoopobjwithtrailer (hcl_t* hcl, hcl_oow_t size, const hcl_oob_
|
||||
nbytes = (size + 1) * HCL_SIZEOF(hcl_oop_t) + blen;
|
||||
nbytes_aligned = HCL_ALIGN(nbytes, HCL_SIZEOF(hcl_oop_t));
|
||||
|
||||
hdr = hcl_allocbytes(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
hdr = (hcl_oop_oop_t)hcl_allocbytes(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
if (!hdr) return HCL_NULL;
|
||||
|
||||
hdr->_flags = HCL_OBJ_MAKE_FLAGS(HCL_OBJ_TYPE_OOP, HCL_SIZEOF(hcl_oop_t), 0, 0, 0, 0, 1, 0);
|
||||
@ -148,9 +148,9 @@ static HCL_INLINE hcl_oop_t alloc_numeric_array (hcl_t* hcl, int brand, const vo
|
||||
* of the allocated space to be an even number.
|
||||
* see HCL_OOP_IS_NUMERIC() and HCL_OOP_IS_POINTER() */
|
||||
if (HCL_UNLIKELY(ngc))
|
||||
hdr = hcl_callocmem(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
hdr = (hcl_oop_t)hcl_callocmem(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
else
|
||||
hdr = hcl_allocbytes(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
hdr = (hcl_oop_t)hcl_allocbytes(hcl, HCL_SIZEOF(hcl_obj_t) + nbytes_aligned);
|
||||
if (!hdr) return HCL_NULL;
|
||||
|
||||
hdr->_flags = HCL_OBJ_MAKE_FLAGS(type, unit, extra, 0, 0, ngc, 0, 0);
|
||||
|
@ -56,7 +56,7 @@ hcl_oop_t hcl_makeprim (hcl_t* hcl, hcl_pfimpl_t primimpl, hcl_oow_t minargs, hc
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
static void log_char_object (hcl_t* hcl, hcl_oow_t mask, hcl_oop_char_t msg)
|
||||
static void log_char_object (hcl_t* hcl, int mask, hcl_oop_char_t msg)
|
||||
{
|
||||
hcl_ooi_t n;
|
||||
hcl_oow_t rem;
|
||||
@ -98,7 +98,7 @@ static hcl_pfrc_t pf_log (hcl_t* hcl, hcl_ooi_t nargs)
|
||||
{
|
||||
/* TODO: accept log level */
|
||||
hcl_oop_t msg;
|
||||
hcl_oow_t mask;
|
||||
int mask;
|
||||
hcl_ooi_t k;
|
||||
|
||||
/*level = HCL_STACK_GET(hcl, hcl->sp - nargs + 1);
|
||||
@ -378,7 +378,7 @@ static hcl_pfrc_t pf_integer_rem (hcl_t* hcl, hcl_ooi_t nargs)
|
||||
|
||||
|
||||
|
||||
static int put_formatted_chars (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t ch, hcl_oow_t len)
|
||||
static int put_formatted_chars (hcl_t* hcl, int mask, const hcl_ooch_t ch, hcl_oow_t len)
|
||||
{
|
||||
/* TODO: better error handling, buffering.
|
||||
* should buffering be done by the printer callback? */
|
||||
@ -405,7 +405,7 @@ static int put_formatted_chars (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t ch,
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
static int put_formatted_string (hcl_t* hcl, hcl_oow_t mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
static int put_formatted_string (hcl_t* hcl, int mask, const hcl_ooch_t* ptr, hcl_oow_t len)
|
||||
{
|
||||
/* TODO: better error handling, buffering
|
||||
* should be done by the printer callback? */
|
||||
|
@ -57,7 +57,7 @@ static HCL_INLINE int push (hcl_t* hcl, print_stack_t* info)
|
||||
hcl_oow_t new_capa;
|
||||
|
||||
new_capa = HCL_ALIGN (hcl->p.s.capa + 1, PRINT_STACK_ALIGN);
|
||||
tmp = hcl_reallocmem (hcl, hcl->p.s.ptr, new_capa * HCL_SIZEOF(*info));
|
||||
tmp = (print_stack_t*)hcl_reallocmem(hcl, hcl->p.s.ptr, new_capa * HCL_SIZEOF(*info));
|
||||
if (!tmp) return -1;
|
||||
|
||||
hcl->p.s.ptr = tmp;
|
||||
@ -114,7 +114,7 @@ static struct
|
||||
};
|
||||
|
||||
|
||||
static HCL_INLINE int print_single_char (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t ch, hcl_outbfmt_t outbfmt)
|
||||
static HCL_INLINE int print_single_char (hcl_t* hcl, int mask, hcl_ooch_t ch, hcl_outbfmt_t outbfmt)
|
||||
{
|
||||
if (ch < ' ')
|
||||
{
|
||||
@ -168,7 +168,7 @@ static HCL_INLINE int print_single_char (hcl_t* hcl, hcl_oow_t mask, hcl_ooch_t
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hcl_outfmtobj (hcl_t* hcl, hcl_oow_t mask, hcl_oop_t obj, hcl_outbfmt_t outbfmt)
|
||||
int hcl_outfmtobj (hcl_t* hcl, int mask, hcl_oop_t obj, hcl_outbfmt_t outbfmt)
|
||||
{
|
||||
hcl_oop_t cur;
|
||||
print_stack_t ps;
|
||||
|
@ -311,7 +311,7 @@ static int copy_string_to (hcl_t* hcl, const hcl_oocs_t* src, hcl_oocs_t* dst, h
|
||||
|
||||
capa = HCL_ALIGN(len, BUFFER_ALIGN);
|
||||
|
||||
tmp = hcl_reallocmem (hcl, dst->ptr, HCL_SIZEOF(*tmp) * capa);
|
||||
tmp = (hcl_ooch_t*)hcl_reallocmem (hcl, dst->ptr, HCL_SIZEOF(*tmp) * capa);
|
||||
if (!tmp) return -1;
|
||||
|
||||
dst->ptr = tmp;
|
||||
@ -1916,7 +1916,7 @@ static int read_object (hcl_t* hcl)
|
||||
static struct
|
||||
{
|
||||
int closer;
|
||||
int synerr;
|
||||
hcl_synerrnum_t synerr;
|
||||
} req[] =
|
||||
{
|
||||
{ HCL_IOTOK_RPAREN, HCL_SYNERR_RPAREN }, /* XLIST () */
|
||||
@ -2268,7 +2268,7 @@ int hcl_attachio (hcl_t* hcl, hcl_ioimpl_t reader, hcl_ioimpl_t printer)
|
||||
cbp = hcl_regcb (hcl, &cb);
|
||||
if (!cbp) return -1;
|
||||
|
||||
hcl->c = hcl_callocmem (hcl, HCL_SIZEOF(*hcl->c));
|
||||
hcl->c = (hcl_compiler_t*)hcl_callocmem (hcl, HCL_SIZEOF(*hcl->c));
|
||||
if (!hcl->c)
|
||||
{
|
||||
hcl_deregcb (hcl, cbp);
|
||||
|
14
lib/utl.c
14
lib/utl.c
@ -370,7 +370,7 @@ int hcl_concatoocstrtosbuf (hcl_t* hcl, const hcl_ooch_t* str, int id)
|
||||
newcapa = HCL_ALIGN(p->len + len, 512); /* TODO: adjust this capacity */
|
||||
|
||||
/* +1 to handle line ending injection more easily */
|
||||
tmp = hcl_reallocmem (hcl, p->ptr, (newcapa + 1) * HCL_SIZEOF(*tmp));
|
||||
tmp = (hcl_ooch_t*)hcl_reallocmem(hcl, p->ptr, (newcapa + 1) * HCL_SIZEOF(*tmp));
|
||||
if (!tmp) return -1;
|
||||
|
||||
p->ptr = tmp;
|
||||
@ -802,7 +802,7 @@ HCL_INLINE hcl_uch_t* hcl_dupbtoucharswithheadroom (hcl_t* hcl, hcl_oow_t headro
|
||||
return HCL_NULL;
|
||||
}
|
||||
|
||||
ptr = hcl_allocmem (hcl, headroom_bytes + ((outlen + 1) * HCL_SIZEOF(hcl_uch_t)));
|
||||
ptr = (hcl_uch_t*)hcl_allocmem(hcl, headroom_bytes + ((outlen + 1) * HCL_SIZEOF(hcl_uch_t)));
|
||||
if (!ptr) return HCL_NULL;
|
||||
|
||||
inlen = bcslen;
|
||||
@ -835,7 +835,7 @@ HCL_INLINE hcl_bch_t* hcl_duputobcharswithheadroom (hcl_t* hcl, hcl_oow_t headro
|
||||
return HCL_NULL;
|
||||
}
|
||||
|
||||
ptr = hcl_allocmem (hcl, headroom_bytes + ((outlen + 1) * HCL_SIZEOF(hcl_bch_t)));
|
||||
ptr = (hcl_bch_t*)hcl_allocmem(hcl, headroom_bytes + ((outlen + 1) * HCL_SIZEOF(hcl_bch_t)));
|
||||
if (!ptr) return HCL_NULL;
|
||||
|
||||
inlen = ucslen;
|
||||
@ -867,7 +867,7 @@ HCL_INLINE hcl_uch_t* hcl_dupbtoucstrwithheadroom (hcl_t* hcl, hcl_oow_t headroo
|
||||
}
|
||||
|
||||
outlen++;
|
||||
ptr = hcl_allocmem (hcl, headroom_bytes + (outlen * HCL_SIZEOF(hcl_uch_t)));
|
||||
ptr = (hcl_uch_t*)hcl_allocmem (hcl, headroom_bytes + (outlen * HCL_SIZEOF(hcl_uch_t)));
|
||||
if (!ptr) return HCL_NULL;
|
||||
|
||||
hcl_convbtoucstr (hcl, bcs, &inlen, ptr, &outlen);
|
||||
@ -892,7 +892,7 @@ HCL_INLINE hcl_bch_t* hcl_duputobcstrwithheadroom (hcl_t* hcl, hcl_oow_t headroo
|
||||
}
|
||||
|
||||
outlen++;
|
||||
ptr = hcl_allocmem (hcl, headroom_bytes + (outlen * HCL_SIZEOF(hcl_bch_t)));
|
||||
ptr = (hcl_bch_t*)hcl_allocmem (hcl, headroom_bytes + (outlen * HCL_SIZEOF(hcl_bch_t)));
|
||||
if (!ptr) return HCL_NULL;
|
||||
|
||||
ptr = (hcl_bch_t*)((hcl_oob_t*)ptr + headroom_bytes);
|
||||
@ -912,7 +912,7 @@ hcl_uch_t* hcl_dupuchars (hcl_t* hcl, const hcl_uch_t* ucs, hcl_oow_t ucslen)
|
||||
{
|
||||
hcl_uch_t* ptr;
|
||||
|
||||
ptr = hcl_allocmem (hcl, (ucslen + 1) * HCL_SIZEOF(hcl_uch_t));
|
||||
ptr = (hcl_uch_t*)hcl_allocmem (hcl, (ucslen + 1) * HCL_SIZEOF(hcl_uch_t));
|
||||
if (!ptr) return HCL_NULL;
|
||||
|
||||
hcl_copyuchars (ptr, ucs, ucslen);
|
||||
@ -924,7 +924,7 @@ hcl_bch_t* hcl_dupbchars (hcl_t* hcl, const hcl_bch_t* bcs, hcl_oow_t bcslen)
|
||||
{
|
||||
hcl_bch_t* ptr;
|
||||
|
||||
ptr = hcl_allocmem (hcl, (bcslen + 1) * HCL_SIZEOF(hcl_bch_t));
|
||||
ptr = (hcl_bch_t*)hcl_allocmem (hcl, (bcslen + 1) * HCL_SIZEOF(hcl_bch_t));
|
||||
if (!ptr) return HCL_NULL;
|
||||
|
||||
hcl_copybchars (ptr, bcs, bcslen);
|
||||
|
Loading…
Reference in New Issue
Block a user