removed the str module
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
5ddc29dc5b
commit
b806865c21
@ -738,7 +738,6 @@ void hcl_freemem (hcl_t* hcl, void* ptr)
|
||||
|
||||
#include "../mod/_core.h"
|
||||
#include "../mod/_dic.h"
|
||||
#include "../mod/_str.h"
|
||||
#include "../mod/_sys.h"
|
||||
|
||||
static struct
|
||||
@ -750,7 +749,6 @@ static_modtab[] =
|
||||
{
|
||||
{ "core", hcl_mod_core },
|
||||
{ "dic", hcl_mod_dic },
|
||||
{ "str", hcl_mod_str },
|
||||
{ "sys", hcl_mod_sys }
|
||||
};
|
||||
#endif
|
||||
@ -985,7 +983,6 @@ hcl_pfbase_t* hcl_querymod (hcl_t* hcl, const hcl_ooch_t* pfid, hcl_oow_t pfidle
|
||||
return pfbase;
|
||||
}
|
||||
|
||||
|
||||
hcl_pfbase_t* hcl_findpfbase (hcl_t* hcl, hcl_pfinfo_t* pfinfo, hcl_oow_t pfcount, const hcl_ooch_t* name, hcl_oow_t namelen)
|
||||
{
|
||||
int n;
|
||||
@ -1000,7 +997,7 @@ hcl_pfbase_t* hcl_findpfbase (hcl_t* hcl, hcl_pfinfo_t* pfinfo, hcl_oow_t pfcoun
|
||||
/*mid = (left + right) / 2;*/
|
||||
mid = left + ((right - left) / 2);
|
||||
|
||||
n = hcl_comp_oochars_oocstr (name, namelen, pfinfo[mid].mthname);
|
||||
n = hcl_comp_oochars_bcstr(name, namelen, pfinfo[mid].mthname);
|
||||
if (n < 0) right = mid - 1; /* this substraction can make right negative. so i can't use hcl_oow_t for the variable */
|
||||
else if (n > 0) left = mid + 1;
|
||||
else return &pfinfo[mid].base;
|
||||
@ -1012,7 +1009,7 @@ hcl_pfbase_t* hcl_findpfbase (hcl_t* hcl, hcl_pfinfo_t* pfinfo, hcl_oow_t pfcoun
|
||||
for (base = 0, lim = pfcount; lim > 0; lim >>= 1)
|
||||
{
|
||||
mid = base + (lim >> 1);
|
||||
n = hcl_comp_oochars_oocstr (name, namelen, pfinfo[mid].mthname);
|
||||
n = hcl_comp_oochars_bcstr(name, namelen, pfinfo[mid].mthname);
|
||||
if (n == 0) return &pfinfo[mid].base;
|
||||
if (n > 0) { base = mid + 1; lim--; }
|
||||
}
|
||||
|
@ -1466,7 +1466,7 @@ struct hcl_pfbase_t
|
||||
typedef struct hcl_pfinfo_t hcl_pfinfo_t;
|
||||
struct hcl_pfinfo_t
|
||||
{
|
||||
hcl_ooch_t mthname[32];
|
||||
const hcl_bch_t* mthname;
|
||||
hcl_pfbase_t base;
|
||||
};
|
||||
/* =========================================================================
|
||||
|
@ -22,7 +22,6 @@ noinst_LTLIBRARIES =
|
||||
|
||||
noinst_LTLIBRARIES += libhcl-core.la
|
||||
noinst_LTLIBRARIES += libhcl-dic.la
|
||||
noinst_LTLIBRARIES += libhcl-str.la
|
||||
noinst_LTLIBRARIES += libhcl-sys.la
|
||||
|
||||
else
|
||||
@ -38,7 +37,6 @@ pkgmodexec_LTLIBRARIES =
|
||||
|
||||
pkgmodexec_LTLIBRARIES += libhcl-core.la
|
||||
pkgmodexec_LTLIBRARIES += libhcl-dic.la
|
||||
pkgmodexec_LTLIBRARIES += libhcl-str.la
|
||||
pkgmodexec_LTLIBRARIES += libhcl-sys.la
|
||||
|
||||
endif
|
||||
@ -55,12 +53,6 @@ libhcl_dic_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
libhcl_dic_la_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
libhcl_dic_la_LIBADD = $(LIBADD_COMMON)
|
||||
|
||||
libhcl_str_la_SOURCES = str.c _str.h
|
||||
libhcl_str_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_str_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
libhcl_str_la_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
libhcl_str_la_LIBADD = $(LIBADD_COMMON)
|
||||
|
||||
libhcl_sys_la_SOURCES = sys.c _sys.h
|
||||
libhcl_sys_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_sys_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
|
@ -155,15 +155,6 @@ libhcl_dic_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
@ENABLE_STATIC_MODULE_FALSE@am_libhcl_dic_la_rpath = -rpath \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ $(pkgmodexecdir)
|
||||
@ENABLE_STATIC_MODULE_TRUE@am_libhcl_dic_la_rpath =
|
||||
libhcl_str_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libhcl_str_la_OBJECTS = libhcl_str_la-str.lo
|
||||
libhcl_str_la_OBJECTS = $(am_libhcl_str_la_OBJECTS)
|
||||
libhcl_str_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
|
||||
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libhcl_str_la_CFLAGS) \
|
||||
$(CFLAGS) $(libhcl_str_la_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@ENABLE_STATIC_MODULE_FALSE@am_libhcl_str_la_rpath = -rpath \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ $(pkgmodexecdir)
|
||||
@ENABLE_STATIC_MODULE_TRUE@am_libhcl_str_la_rpath =
|
||||
libhcl_sys_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am_libhcl_sys_la_OBJECTS = libhcl_sys_la-sys.lo
|
||||
libhcl_sys_la_OBJECTS = $(am_libhcl_sys_la_OBJECTS)
|
||||
@ -190,7 +181,6 @@ depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
|
||||
am__maybe_remake_depfiles = depfiles
|
||||
am__depfiles_remade = ./$(DEPDIR)/libhcl_core_la-core.Plo \
|
||||
./$(DEPDIR)/libhcl_dic_la-dic.Plo \
|
||||
./$(DEPDIR)/libhcl_str_la-str.Plo \
|
||||
./$(DEPDIR)/libhcl_sys_la-sys.Plo
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
@ -212,9 +202,9 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
|
||||
am__v_CCLD_0 = @echo " CCLD " $@;
|
||||
am__v_CCLD_1 =
|
||||
SOURCES = $(libhcl_core_la_SOURCES) $(libhcl_dic_la_SOURCES) \
|
||||
$(libhcl_str_la_SOURCES) $(libhcl_sys_la_SOURCES)
|
||||
$(libhcl_sys_la_SOURCES)
|
||||
DIST_SOURCES = $(libhcl_core_la_SOURCES) $(libhcl_dic_la_SOURCES) \
|
||||
$(libhcl_str_la_SOURCES) $(libhcl_sys_la_SOURCES)
|
||||
$(libhcl_sys_la_SOURCES)
|
||||
am__can_run_installinfo = \
|
||||
case $$AM_UPDATE_INFO_DIR in \
|
||||
n|no|NO) false;; \
|
||||
@ -400,12 +390,10 @@ CFLAGS_COMMON =
|
||||
@ENABLE_STATIC_MODULE_FALSE@LIBADD_COMMON = -lhcl
|
||||
@ENABLE_STATIC_MODULE_TRUE@LIBADD_COMMON =
|
||||
@ENABLE_STATIC_MODULE_TRUE@noinst_LTLIBRARIES = libhcl-core.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ libhcl-dic.la libhcl-str.la \
|
||||
@ENABLE_STATIC_MODULE_TRUE@ libhcl-sys.la
|
||||
@ENABLE_STATIC_MODULE_TRUE@ libhcl-dic.la libhcl-sys.la
|
||||
@ENABLE_STATIC_MODULE_FALSE@pkgmodexecdir = $(libdir)
|
||||
@ENABLE_STATIC_MODULE_FALSE@pkgmodexec_LTLIBRARIES = libhcl-core.la \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ libhcl-dic.la libhcl-str.la \
|
||||
@ENABLE_STATIC_MODULE_FALSE@ libhcl-sys.la
|
||||
@ENABLE_STATIC_MODULE_FALSE@ libhcl-dic.la libhcl-sys.la
|
||||
libhcl_core_la_SOURCES = core.c _core.h
|
||||
libhcl_core_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_core_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
@ -416,11 +404,6 @@ libhcl_dic_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_dic_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
libhcl_dic_la_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
libhcl_dic_la_LIBADD = $(LIBADD_COMMON)
|
||||
libhcl_str_la_SOURCES = str.c _str.h
|
||||
libhcl_str_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_str_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
libhcl_str_la_LDFLAGS = $(LDFLAGS_COMMON)
|
||||
libhcl_str_la_LIBADD = $(LIBADD_COMMON)
|
||||
libhcl_sys_la_SOURCES = sys.c _sys.h
|
||||
libhcl_sys_la_CPPFLAGS = $(CPPFLAGS_COMMON)
|
||||
libhcl_sys_la_CFLAGS = $(CFLAGS_COMMON)
|
||||
@ -512,9 +495,6 @@ libhcl-core.la: $(libhcl_core_la_OBJECTS) $(libhcl_core_la_DEPENDENCIES) $(EXTRA
|
||||
libhcl-dic.la: $(libhcl_dic_la_OBJECTS) $(libhcl_dic_la_DEPENDENCIES) $(EXTRA_libhcl_dic_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libhcl_dic_la_LINK) $(am_libhcl_dic_la_rpath) $(libhcl_dic_la_OBJECTS) $(libhcl_dic_la_LIBADD) $(LIBS)
|
||||
|
||||
libhcl-str.la: $(libhcl_str_la_OBJECTS) $(libhcl_str_la_DEPENDENCIES) $(EXTRA_libhcl_str_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libhcl_str_la_LINK) $(am_libhcl_str_la_rpath) $(libhcl_str_la_OBJECTS) $(libhcl_str_la_LIBADD) $(LIBS)
|
||||
|
||||
libhcl-sys.la: $(libhcl_sys_la_OBJECTS) $(libhcl_sys_la_DEPENDENCIES) $(EXTRA_libhcl_sys_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libhcl_sys_la_LINK) $(am_libhcl_sys_la_rpath) $(libhcl_sys_la_OBJECTS) $(libhcl_sys_la_LIBADD) $(LIBS)
|
||||
|
||||
@ -526,7 +506,6 @@ distclean-compile:
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_core_la-core.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_dic_la-dic.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_str_la-str.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhcl_sys_la-sys.Plo@am__quote@ # am--include-marker
|
||||
|
||||
$(am__depfiles_remade):
|
||||
@ -573,13 +552,6 @@ libhcl_dic_la-dic.lo: dic.c
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_dic_la_CPPFLAGS) $(CPPFLAGS) $(libhcl_dic_la_CFLAGS) $(CFLAGS) -c -o libhcl_dic_la-dic.lo `test -f 'dic.c' || echo '$(srcdir)/'`dic.c
|
||||
|
||||
libhcl_str_la-str.lo: str.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_str_la_CPPFLAGS) $(CPPFLAGS) $(libhcl_str_la_CFLAGS) $(CFLAGS) -MT libhcl_str_la-str.lo -MD -MP -MF $(DEPDIR)/libhcl_str_la-str.Tpo -c -o libhcl_str_la-str.lo `test -f 'str.c' || echo '$(srcdir)/'`str.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhcl_str_la-str.Tpo $(DEPDIR)/libhcl_str_la-str.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='str.c' object='libhcl_str_la-str.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_str_la_CPPFLAGS) $(CPPFLAGS) $(libhcl_str_la_CFLAGS) $(CFLAGS) -c -o libhcl_str_la-str.lo `test -f 'str.c' || echo '$(srcdir)/'`str.c
|
||||
|
||||
libhcl_sys_la-sys.lo: sys.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhcl_sys_la_CPPFLAGS) $(CPPFLAGS) $(libhcl_sys_la_CFLAGS) $(CFLAGS) -MT libhcl_sys_la-sys.lo -MD -MP -MF $(DEPDIR)/libhcl_sys_la-sys.Tpo -c -o libhcl_sys_la-sys.lo `test -f 'sys.c' || echo '$(srcdir)/'`sys.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhcl_sys_la-sys.Tpo $(DEPDIR)/libhcl_sys_la-sys.Plo
|
||||
@ -722,7 +694,6 @@ clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
|
||||
distclean: distclean-am
|
||||
-rm -f ./$(DEPDIR)/libhcl_core_la-core.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_dic_la-dic.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_str_la-str.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_sys_la-sys.Plo
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
@ -771,7 +742,6 @@ installcheck-am:
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -f ./$(DEPDIR)/libhcl_core_la-core.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_dic_la-dic.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_str_la-str.Plo
|
||||
-rm -f ./$(DEPDIR)/libhcl_sys_la-sys.Plo
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
43
mod/_str.h
43
mod/_str.h
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _HCL_MOD_STR_H_
|
||||
#define _HCL_MOD_STR_H_
|
||||
|
||||
#include <hcl.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
HCL_EXPORT int hcl_mod_str (hcl_t* hcl, hcl_mod_t* mod);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
18
mod/core.c
18
mod/core.c
@ -377,15 +377,15 @@ static hcl_pfrc_t pf_core_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
|
||||
static hcl_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ { 'b','a','s','i','c','_','n','e','w','\0' }, { HCL_PFBASE_FUNC, pf_core_basic_new, 2, 2 } },
|
||||
{ { 'c','l','a','s','s','_','n','a','m','e','\0' }, { HCL_PFBASE_FUNC, pf_core_get_class_name, 1, 1 } },
|
||||
{ { 'c','r','e','s','p','_','t','o', '\0' }, { HCL_PFBASE_FUNC, pf_core_cresp_to, 2, 2 } },
|
||||
{ { 'g','e','t','\0' }, { HCL_PFBASE_FUNC, pf_core_get, 2, 2 } },
|
||||
{ { 'i','r','e','s','p','_','t','o', '\0' }, { HCL_PFBASE_FUNC, pf_core_iresp_to, 2, 2 } },
|
||||
{ { 'l','e','n','g','t','h','\0' }, { HCL_PFBASE_FUNC, pf_core_size, 1, 1 } },
|
||||
{ { 'p','u','t','\0' }, { HCL_PFBASE_FUNC, pf_core_put, 3, 3 } },
|
||||
{ { 's','i','z','e','\0' }, { HCL_PFBASE_FUNC, pf_core_size, 1, 1 } },
|
||||
{ { 's','l','i','c','e','\0' }, { HCL_PFBASE_FUNC, pf_core_slice, 3, 3 } }
|
||||
{ "basic_new", { HCL_PFBASE_FUNC, pf_core_basic_new, 2, 2 } },
|
||||
{ "class_name", { HCL_PFBASE_FUNC, pf_core_get_class_name, 1, 1 } },
|
||||
{ "cresp_to", { HCL_PFBASE_FUNC, pf_core_cresp_to, 2, 2 } },
|
||||
{ "get", { HCL_PFBASE_FUNC, pf_core_get, 2, 2 } },
|
||||
{ "iresp_to", { HCL_PFBASE_FUNC, pf_core_iresp_to, 2, 2 } },
|
||||
{ "length", { HCL_PFBASE_FUNC, pf_core_size, 1, 1 } },
|
||||
{ "put", { HCL_PFBASE_FUNC, pf_core_put, 3, 3 } },
|
||||
{ "size", { HCL_PFBASE_FUNC, pf_core_size, 1, 1 } },
|
||||
{ "slice", { HCL_PFBASE_FUNC, pf_core_slice, 3, 3 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -110,10 +110,10 @@ static hcl_pfrc_t pf_dic_walk (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
|
||||
static hcl_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ { 'g','e','t','\0' }, { HCL_PFBASE_FUNC, pf_dic_get, 2, 2 } },
|
||||
/* { { 'm','a','k','e','\0' }, { HCL_PFBASE_FUNC, pf_dic_make, 1, 1 } }, */
|
||||
{ { 'p','u','t','\0' }, { HCL_PFBASE_FUNC, pf_dic_put, 3, 3 } },
|
||||
{ { 'w','a','l','k','\0' }, { HCL_PFBASE_FUNC, pf_dic_walk, 2, 2 } },
|
||||
{ "get", { HCL_PFBASE_FUNC, pf_dic_get, 2, 2 } },
|
||||
/* { "make", { HCL_PFBASE_FUNC, pf_dic_make, 1, 1 } }, */
|
||||
{ "put", { HCL_PFBASE_FUNC, pf_dic_put, 3, 3 } },
|
||||
{ "walk", { HCL_PFBASE_FUNC, pf_dic_walk, 2, 2 } },
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
194
mod/str.c
194
mod/str.c
@ -1,194 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
|
||||
#include "_str.h"
|
||||
|
||||
static hcl_pfrc_t pf_str_at (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t str, pos;
|
||||
hcl_ooch_t cv;
|
||||
hcl_ooi_t size;
|
||||
hcl_ooi_t idx;
|
||||
|
||||
str = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
pos = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
|
||||
if (!HCL_IS_STRING(hcl, str))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not string - %O", str);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HCL_OOP_IS_SMOOI(pos))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not smooi - %O", pos);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
idx = HCL_OOP_TO_SMOOI(pos);
|
||||
size = HCL_OBJ_GET_SIZE(str);
|
||||
if (idx <= -1 || idx >= size)
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter out of range - %O", pos);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
cv = HCL_OBJ_GET_CHAR_VAL(str, idx);
|
||||
HCL_STACK_SETRET (hcl, nargs, HCL_CHAR_TO_OOP(cv));
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfrc_t pf_str_at_put (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t str, pos, val;
|
||||
hcl_ooch_t cv;
|
||||
hcl_ooi_t size;
|
||||
hcl_ooi_t idx;
|
||||
|
||||
str = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
pos = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
val = HCL_STACK_GETARG(hcl, nargs, 2);
|
||||
|
||||
if (!HCL_IS_STRING(hcl, str))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not string - %O", str);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HCL_OOP_IS_SMOOI(pos))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not integer - %O", pos);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
if (!HCL_OOP_IS_CHAR(val))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not character - %O", pos);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
idx = HCL_OOP_TO_SMOOI(pos);
|
||||
size = HCL_OBJ_GET_SIZE(str);
|
||||
if (idx <= -1 || idx >= size)
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter out of range - %O", pos);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
cv = HCL_OOP_TO_CHAR(val);
|
||||
HCL_OBJ_SET_CHAR_VAL(str, idx, cv);
|
||||
HCL_STACK_SETRET (hcl, nargs, val);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfrc_t pf_str_length (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t str;
|
||||
hcl_ooi_t size;
|
||||
|
||||
str = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
|
||||
if (!HCL_IS_STRING(hcl, str))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not string - %O", str);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
size = HCL_OBJ_GET_SIZE(str);
|
||||
HCL_STACK_SETRET (hcl, nargs, HCL_SMOOI_TO_OOP(size));
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfrc_t pf_str_slice (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
{
|
||||
hcl_oop_t str, slice, a1, a2;
|
||||
hcl_ooi_t size;
|
||||
hcl_ooi_t pos;
|
||||
hcl_ooi_t len;
|
||||
|
||||
str = HCL_STACK_GETARG(hcl, nargs, 0);
|
||||
a1 = HCL_STACK_GETARG(hcl, nargs, 1);
|
||||
a2 = HCL_STACK_GETARG(hcl, nargs, 2);
|
||||
|
||||
if (!HCL_IS_STRING(hcl, str))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "parameter not string - %O", str);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
if (!HCL_OOP_IS_SMOOI(a1))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "position not numeric - %O", a1);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
if (!HCL_OOP_IS_SMOOI(a2))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EINVAL, "length not numeric - %O", a2);
|
||||
return HCL_PF_FAILURE;
|
||||
}
|
||||
|
||||
size = HCL_OBJ_GET_SIZE(str);
|
||||
pos = HCL_OOP_TO_SMOOI(a1);
|
||||
len = HCL_OOP_TO_SMOOI(a2);
|
||||
|
||||
if (pos < 0) pos = 0;
|
||||
else if (pos >= size) pos = size;
|
||||
if (len >= size - pos) len = size - pos;
|
||||
slice = hcl_makestring(hcl, HCL_OBJ_GET_CHAR_PTR(str, pos), len, 0);
|
||||
if (HCL_UNLIKELY(!slice)) return HCL_PF_FAILURE;
|
||||
|
||||
HCL_STACK_SETRET (hcl, nargs, slice);
|
||||
return HCL_PF_SUCCESS;
|
||||
}
|
||||
|
||||
static hcl_pfinfo_t pfinfos[] =
|
||||
{
|
||||
/*{ { 'V','A','R','\0' }, { HCL_PFBASE_VAR, HCL_NULL, 0, 0 } },*/
|
||||
{ { 'a','t','\0' }, { HCL_PFBASE_FUNC, pf_str_at, 2, 2 } },
|
||||
{ { 'a','t','P','u','t','\0' }, { HCL_PFBASE_FUNC, pf_str_at_put, 3, 3 } },
|
||||
{ { 'l','e','n','g','t','h','\0' }, { HCL_PFBASE_FUNC, pf_str_length, 1, 1 } },
|
||||
{ { 's','i','z','e'}, { HCL_PFBASE_FUNC, pf_str_length, 1, 1 } },
|
||||
{ { 's','l','i','c','e'}, { HCL_PFBASE_FUNC, pf_str_slice, 3, 3 } },
|
||||
{ { 's','u','b','s','t','r'}, { HCL_PFBASE_FUNC, pf_str_slice, 3, 3 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static hcl_pfbase_t* query (hcl_t* hcl, hcl_mod_t* mod, const hcl_ooch_t* name, hcl_oow_t namelen)
|
||||
{
|
||||
return hcl_findpfbase(hcl, pfinfos, HCL_COUNTOF(pfinfos), name, namelen);
|
||||
}
|
||||
|
||||
static void unload (hcl_t* hcl, hcl_mod_t* mod)
|
||||
{
|
||||
}
|
||||
|
||||
int hcl_mod_str (hcl_t* hcl, hcl_mod_t* mod)
|
||||
{
|
||||
mod->query = query;
|
||||
mod->unload = unload;
|
||||
mod->ctx = HCL_NULL;
|
||||
return 0;
|
||||
}
|
@ -147,10 +147,10 @@ static hcl_pfrc_t pf_sys_random (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs)
|
||||
|
||||
static hcl_pfinfo_t pfinfos[] =
|
||||
{
|
||||
{ { 'r','a','n','d','o','m','\0' }, { HCL_PFBASE_FUNC, pf_sys_random, 0, 0 } },
|
||||
{ { 's','r','a','n','d','o','m','\0' }, { HCL_PFBASE_FUNC, pf_sys_srandom, 1, 1 } },
|
||||
{ { 's','t','i','m','e','\0' }, { HCL_PFBASE_FUNC, pf_sys_stime, 1, 1 } },
|
||||
{ { 't','i','m','e','\0' }, { HCL_PFBASE_FUNC, pf_sys_time, 0, 0 } }
|
||||
{ "random", { HCL_PFBASE_FUNC, pf_sys_random, 0, 0 } },
|
||||
{ "srandom", { HCL_PFBASE_FUNC, pf_sys_srandom, 1, 1 } },
|
||||
{ "stime", { HCL_PFBASE_FUNC, pf_sys_stime, 1, 1 } },
|
||||
{ "time", { HCL_PFBASE_FUNC, pf_sys_time, 0, 0 } }
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
@ -146,4 +146,4 @@ printf "[%O]\n" (" ":respondsTo "length")
|
||||
##printf "[%O]\n" (String:classVariableNames)
|
||||
##printf "[%O]\n" (String:instanceVariableNames)
|
||||
|
||||
printf "%O\n" #"abcdefg"
|
||||
##printf "%O\n" #"abcdefg"
|
||||
|
Loading…
Reference in New Issue
Block a user