added stix_compoocharsbcstr(), stix_compbcharsbcstr().
added code to handle statically linked modules. fixed more build issues
This commit is contained in:
@ -60,8 +60,8 @@ libstix_la_LDFLAGS = $(LDFLAGS_LIB_COMMON)
|
||||
libstix_la_LIBADD = $(LIBADD_LIB_COMMON)
|
||||
|
||||
if ENABLE_STATIC_MODULE
|
||||
libstix_la_LDFLAGS += -I$(abs_builddir)/../mod
|
||||
libstix_la_LIBADD += -lstix-stdio
|
||||
libstix_la_LDFLAGS += -L$(abs_builddir)/../mod
|
||||
libstix_la_LIBADD += -lstix-console -lstix-stdio -ltermcap
|
||||
endif
|
||||
|
||||
bin_PROGRAMS = stix
|
||||
|
@ -83,8 +83,8 @@ host_triplet = @host@
|
||||
# to the first number in -version-info above
|
||||
@WIN32_TRUE@am__append_1 = -DSTIX_DEFAULT_MODPREFIX=\"libstix-\" -DSTIX_DEFAULT_MODPOSTFIX=\"-1\"
|
||||
@WIN32_FALSE@am__append_2 = -DSTIX_DEFAULT_MODPREFIX=\"$(libdir)/libstix-\" -DSTIX_DEFAULT_MODPOSTFIX=\"\"
|
||||
@ENABLE_STATIC_MODULE_TRUE@am__append_3 = -I$(abs_builddir)/../mod
|
||||
@ENABLE_STATIC_MODULE_TRUE@am__append_4 = -lstix-stdio
|
||||
@ENABLE_STATIC_MODULE_TRUE@am__append_3 = -L$(abs_builddir)/../mod
|
||||
@ENABLE_STATIC_MODULE_TRUE@am__append_4 = -lstix-console -lstix-stdio -ltermcap
|
||||
bin_PROGRAMS = stix$(EXEEXT)
|
||||
subdir = lib
|
||||
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
|
||||
|
@ -2869,7 +2869,7 @@ int stix_getpfnum (stix_t* stix, const stix_ooch_t* ptr, stix_oow_t len)
|
||||
|
||||
for (i = 0; i < STIX_COUNTOF(pftab); i++)
|
||||
{
|
||||
if (stix_compucharsbcstr(ptr, len, pftab[i].name) == 0)
|
||||
if (stix_compoocharsbcstr(ptr, len, pftab[i].name) == 0)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ extern "C" {
|
||||
# define stix_hashchars(ptr,len) stix_hashuchars(ptr,len)
|
||||
# define stix_equaloochars(str1,str2,len) stix_equaluchars(str1,str2,len)
|
||||
# define stix_compoocbcstr(str1,str2) stix_compucbcstr(str1,str2)
|
||||
# define stix_compoocharsbcstr(str1,len1,str2) stix_compucharsbcstr(str1,len1,str2)
|
||||
# define stix_compoocstr(str1,str2) stix_compucstr(str1,str2)
|
||||
# define stix_copyoochars(dst,src,len) stix_copyuchars(dst,src,len)
|
||||
# define stix_copybctooochars(dst,src,len) stix_copybtouchars(dst,src,len)
|
||||
@ -48,6 +49,7 @@ extern "C" {
|
||||
# define stix_hashchars(ptr,len) stix_hashbchars(ptr,len)
|
||||
# define stix_equaloochars(str1,str2,len) stix_equalbchars(str1,str2,len)
|
||||
# define stix_compoocbcstr(str1,str2) stix_compbcstr(str1,str2)
|
||||
# define stix_compoocharsbcstr(str1,len1,str2) stix_compbcharsbcstr(str1,len1,str2)
|
||||
# define stix_compoocstr(str1,str2) stix_compbcstr(str1,str2)
|
||||
# define stix_copyoochars(dst,src,len) stix_copybchars(dst,src,len)
|
||||
# define stix_copybctooochars(dst,src,len) stix_copybchars(dst,src,len)
|
||||
@ -110,6 +112,12 @@ STIX_EXPORT int stix_compucharsbcstr (
|
||||
const stix_bch_t* str2
|
||||
);
|
||||
|
||||
STIX_EXPORT int stix_compbcharsbcstr (
|
||||
const stix_bch_t* str1,
|
||||
stix_oow_t len,
|
||||
const stix_bch_t* str2
|
||||
);
|
||||
|
||||
STIX_EXPORT void stix_copyuchars (
|
||||
stix_uch_t* dst,
|
||||
const stix_uch_t* src,
|
||||
|
@ -347,6 +347,23 @@ void stix_freemem (stix_t* stix, void* ptr)
|
||||
#define MOD_PREFIX "stix_mod_"
|
||||
#define MOD_PREFIX_LEN 9
|
||||
|
||||
#if defined(STIX_ENABLE_STATIC_MODULE)
|
||||
|
||||
#include "../mod/console.h"
|
||||
#include "../mod/_stdio.h"
|
||||
|
||||
static struct
|
||||
{
|
||||
stix_bch_t* modname;
|
||||
int (*modload) (stix_t* stix, stix_mod_t* mod);
|
||||
}
|
||||
static_modtab[] =
|
||||
{
|
||||
{ "console", stix_mod_console },
|
||||
{ "stdio", stix_mod_stdio },
|
||||
};
|
||||
#endif
|
||||
|
||||
stix_mod_data_t* stix_openmod (stix_t* stix, const stix_ooch_t* name, stix_oow_t namelen)
|
||||
{
|
||||
stix_rbt_pair_t* pair;
|
||||
@ -387,7 +404,7 @@ stix_mod_data_t* stix_openmod (stix_t* stix, const stix_ooch_t* name, stix_oow_t
|
||||
/* TODO: binary search ... */
|
||||
for (n = 0; n < STIX_COUNTOF(static_modtab); n++)
|
||||
{
|
||||
if (stix_compoocstr (static_modtab[n].modname, name, name_len....) == 0)
|
||||
if (stix_compoocharsbcstr (name, namelen, static_modtab[n].modname) == 0)
|
||||
{
|
||||
load = static_modtab[n].modload;
|
||||
break;
|
||||
@ -405,12 +422,12 @@ stix_mod_data_t* stix_openmod (stix_t* stix, const stix_ooch_t* name, stix_oow_t
|
||||
/* found the module in the staic module table */
|
||||
|
||||
STIX_MEMSET (&md, 0, STIX_SIZEOF(md));
|
||||
stix_copyoochars (md.name, name, namelen);
|
||||
stix_copyoochars ((stix_ooch_t*)md.mod.name, name, namelen);
|
||||
/* Note md.handle is STIX_NULL for a static module */
|
||||
|
||||
/* i copy-insert 'md' into the table before calling 'load'.
|
||||
* to pass the same address to load(), query(), etc */
|
||||
pair = stix_rbt_insert (stix->modtab, name, namelen, &md, STIX_SIZEOF(md));
|
||||
pair = stix_rbt_insert (&stix->modtab, (stix_ooch_t*)name, namelen, &md, STIX_SIZEOF(md));
|
||||
if (pair == STIX_NULL)
|
||||
{
|
||||
stix->errnum = STIX_ESYSMEM;
|
||||
@ -418,9 +435,9 @@ stix_mod_data_t* stix_openmod (stix_t* stix, const stix_ooch_t* name, stix_oow_t
|
||||
}
|
||||
|
||||
mdp = (stix_mod_data_t*)STIX_RBT_VPTR(pair);
|
||||
if (load (&mdp->mod, stix) <= -1)
|
||||
if (load (stix, &mdp->mod) <= -1)
|
||||
{
|
||||
stix_rbt_delete (stix->modtab, segs[0].ptr, segs[0].len);
|
||||
stix_rbt_delete (&stix->modtab, (stix_ooch_t*)name, namelen);
|
||||
return STIX_NULL;
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,15 @@ int stix_compucharsbcstr (const stix_uch_t* str1, stix_oow_t len, const stix_bch
|
||||
return (*str1 > *str2)? 1: -1;
|
||||
}
|
||||
|
||||
int stix_compbcharsbcstr (const stix_bch_t* str1, stix_oow_t len, const stix_bch_t* str2)
|
||||
{
|
||||
const stix_bch_t* end = str1 + len;
|
||||
while (str1 < end && *str2 != '\0' && *str1 == *str2) str1++, str2++;
|
||||
if (str1 == end && *str2 == '\0') return 0;
|
||||
if (*str1 == *str2) return (str1 < end)? 1: -1;
|
||||
return (*str1 > *str2)? 1: -1;
|
||||
}
|
||||
|
||||
void stix_copyuchars (stix_uch_t* dst, const stix_uch_t* src, stix_oow_t len)
|
||||
{
|
||||
stix_oow_t i;
|
||||
|
Reference in New Issue
Block a user