diff --git a/Makefile.in b/Makefile.in index 39b7e92..9608650 100644 --- a/Makefile.in +++ b/Makefile.in @@ -166,8 +166,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \ $(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \ $(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \ $(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \ - ac/compile ac/config.guess ac/config.sub ac/install-sh \ - ac/ltmain.sh ac/missing + ac/compile ac/config.guess ac/config.sub ac/depcomp \ + ac/install-sh ac/ltmain.sh ac/missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) diff --git a/bin/Makefile.am b/bin/Makefile.am index 4ec1fc2..1a66565 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -30,7 +30,7 @@ hcl_LDFLAGS = $(LDFLAGS_ALL_COMMON) hcl_LDADD = $(LIBADD_LIB_COMMON) -lhcl hcl_DEPENDENCIES = ../lib/libhcl.la -if ENABLE_HCLEX +if ENABLE_HCLX ## cb-impl.c is included in libhclx. ## so ../lib/cb-impl.h and ../lib/cb-impl.c are not listed as sources diff --git a/bin/main.c b/bin/main.c index 1a3ac71..7fc219f 100644 --- a/bin/main.c +++ b/bin/main.c @@ -1150,6 +1150,7 @@ int main (int argc, char* argv[]) * -- instead of returning -1 immediately. --*/ set_signal (SIGINT, handle_sigint); +hcl_prbfmt (hcl, "this is good %s %10hs %hs\n", "whole new world. 1234567890 from this point onward, any failure leasd to jumping to oops label", "as이거 좋은거잖아dkfjsdakfjsadklfjasd", "1111"); while (1) { hcl_oop_t obj; diff --git a/configure b/configure index 9f6d398..6f0fa69 100755 --- a/configure +++ b/configure @@ -651,8 +651,8 @@ HCL_SIZEOF_LONG_LONG HCL_SIZEOF_CHAR32_T HCL_SIZEOF_CHAR16_T HCL_SIZEOF_WCHAR_T -ENABLE_HCLEX_FALSE -ENABLE_HCLEX_TRUE +ENABLE_HCLX_FALSE +ENABLE_HCLX_TRUE ENABLE_LIBUNWIND_FALSE ENABLE_LIBUNWIND_TRUE ENABLE_LIBLTDL_FALSE @@ -824,7 +824,7 @@ enable_dynamic_module enable_static_module enable_libltdl enable_libunwind -enable_hclex +enable_hclx ' ac_precious_vars='build_alias host_alias @@ -1482,7 +1482,7 @@ Optional Features: library(default. no) --enable-libltdl use libltdl(default. no) --enable-libunwind use libunwind(default. no) - --enable-hclex build libhclex(default. no) + --enable-hclx build libhclx(default. no) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -21256,20 +21256,20 @@ else fi -# Check whether --enable-hclex was given. -if test "${enable_hclex+set}" = set; then : - enableval=$enable_hclex; enable_hclex_is=$enableval +# Check whether --enable-hclx was given. +if test "${enable_hclx+set}" = set; then : + enableval=$enable_hclx; enable_hclx_is=$enableval else - enable_hclex_is=no + enable_hclx_is=no fi - if test "x${enable_hclex_is}" = "xyes"; then - ENABLE_HCLEX_TRUE= - ENABLE_HCLEX_FALSE='#' + if test "x${enable_hclx_is}" = "xyes"; then + ENABLE_HCLX_TRUE= + ENABLE_HCLX_FALSE='#' else - ENABLE_HCLEX_TRUE='#' - ENABLE_HCLEX_FALSE= + ENABLE_HCLX_TRUE='#' + ENABLE_HCLX_FALSE= fi @@ -21479,8 +21479,8 @@ if test -z "${ENABLE_LIBUNWIND_TRUE}" && test -z "${ENABLE_LIBUNWIND_FALSE}"; th as_fn_error $? "conditional \"ENABLE_LIBUNWIND\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${ENABLE_HCLEX_TRUE}" && test -z "${ENABLE_HCLEX_FALSE}"; then - as_fn_error $? "conditional \"ENABLE_HCLEX\" was never defined. +if test -z "${ENABLE_HCLX_TRUE}" && test -z "${ENABLE_HCLX_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_HCLX\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi diff --git a/configure.ac b/configure.ac index 6f6cee5..0423dee 100644 --- a/configure.ac +++ b/configure.ac @@ -693,13 +693,13 @@ then fi AM_CONDITIONAL(ENABLE_LIBUNWIND, test "x${enable_libunwind_is}" = "xyes") -dnl ===== enable-hclex ===== -AC_ARG_ENABLE([hclex], - [AS_HELP_STRING([--enable-hclex],[build libhclex(default. no)])], - enable_hclex_is=$enableval, - enable_hclex_is=no +dnl ===== enable-hclx ===== +AC_ARG_ENABLE([hclx], + [AS_HELP_STRING([--enable-hclx],[build libhclx(default. no)])], + enable_hclx_is=$enableval, + enable_hclx_is=no ) -AM_CONDITIONAL(ENABLE_HCLEX, test "x${enable_hclex_is}" = "xyes") +AM_CONDITIONAL(ENABLE_HCLX, test "x${enable_hclx_is}" = "xyes") AC_SUBST(HCL_SIZEOF_WCHAR_T, $ac_cv_sizeof_wchar_t) AC_SUBST(HCL_SIZEOF_CHAR16_T, $ac_cv_sizeof_char16_t) diff --git a/lib/Makefile.am b/lib/Makefile.am index 4fa1e0c..c54fe6a 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -101,7 +101,7 @@ libhcl_la_LIBADD += -lhcl-sys libhcl_la_DEPENDENCIES += $(abs_builddir)/../mod/libhcl-sys.la endif -if ENABLE_HCLEX +if ENABLE_HCLX pkglib_LTLIBRARIES += libhclx.la pkginclude_HEADERS += hcl-c.h hcl-s.h hcl-tmr.h hcl-xutl.h hcl-json.h libhclx_la_SOURCES = \ diff --git a/lib/fmt.c b/lib/fmt.c index a1b66ed..1ebfc5c 100644 --- a/lib/fmt.c +++ b/lib/fmt.c @@ -1646,9 +1646,6 @@ static int print_bcs (hcl_fmtout_t* fmtout, const hcl_bch_t* ptr, hcl_oow_t len) ucslen = HCL_COUNTOF(ucsbuf); hcl_conv_bchars_to_uchars_with_cmgr(ptr, &bcslen, ucsbuf, &ucslen, hcl->cmgr, 1); - hcl->c->outarg.ptr = ucsbuf; - hcl->c->outarg.len = ucslen; - ucsptr = ucsbuf; while (ucslen > 0) { @@ -1690,9 +1687,11 @@ static int print_bcs (hcl_fmtout_t* fmtout, const hcl_bch_t* ptr, hcl_oow_t len) static int print_ucs (hcl_fmtout_t* fmtout, const hcl_uch_t* ptr, hcl_oow_t len) { hcl_t* hcl = (hcl_t*)fmtout->ctx; - hcl_uch_t* optr; + #if defined(HCL_OOCH_IS_UCH) + hcl_uch_t* optr; + optr = (hcl_uch_t*)ptr; while (len > 0) { @@ -1707,17 +1706,41 @@ static int print_ucs (hcl_fmtout_t* fmtout, const hcl_uch_t* ptr, hcl_oow_t len) len -= hcl->c->outarg.xlen; } #else - /* TODO: */ + hcl_oow_t bcslen, ucslen; + hcl_ooch_t bcsbuf[64], * bcsptr; + + while (len > 0) + { + ucslen = len; + bcslen = HCL_COUNTOF(bcsbuf); + hcl_conv_uchars_to_bchars_with_cmgr(ptr, &ucslen, bcsbuf, &bcslen, hcl->cmgr); + + bcsptr = bcsbuf; + while (ucslen > 0) + { + hcl->c->outarg.ptr = bcsptr; + hcl->c->outarg.len = bcslen; + + if (hcl->c->printer(hcl, HCL_IO_WRITE, &hcl->c->outarg) <= -1) return -1; + if (hcl->c->outarg.xlen <= 0) return 0; /* end of stream. but not failure */ + + HCL_ASSERT (hcl, hcl->c->outarg.xlen <= len); + bcsptr += hcl->c->outarg.xlen; + bcslen -= hcl->c->outarg.xlen; + } + + ptr += ucslen; + len -= ucslen; + } #endif return 1; /* success */ } -hcl_ooi_t hcl_prbfmt (hcl_t* hcl, const hcl_bch_t* fmt, ...) +hcl_ooi_t hcl_prbfmtv (hcl_t* hcl, const hcl_bch_t* fmt, va_list ap) { int x; - va_list ap; hcl_fmtout_t fo; HCL_MEMSET (&fo, 0, HCL_SIZEOF(fo)); @@ -1725,21 +1748,31 @@ hcl_ooi_t hcl_prbfmt (hcl_t* hcl, const hcl_bch_t* fmt, ...) fo.fmt_str = fmt; fo.ctx = hcl; fo.mask = 0; - fo.putbcs = log_bcs; - fo.putucs = log_ucs; + fo.putbcs = print_bcs; + fo.putucs = print_ucs; fo.putobj = hcl_fmt_object_; - va_start (ap, fmt); x = fmt_outv(&fo, ap); - va_end (ap); return (x <= -1)? -1: fo.count; } -hcl_ooi_t hcl_prufmt (hcl_t* hcl, const hcl_uch_t* fmt, ...) +hcl_ooi_t hcl_prbfmt (hcl_t* hcl, const hcl_bch_t* fmt, ...) +{ + hcl_ooi_t x; + va_list ap; + + va_start (ap, fmt); + x = hcl_prbfmtv(hcl, fmt, ap); + va_end (ap); + + return x; +} + +hcl_ooi_t hcl_prufmtv (hcl_t* hcl, const hcl_uch_t* fmt, va_list ap) { int x; - va_list ap; + hcl_fmtout_t fo; HCL_MEMSET (&fo, 0, HCL_SIZEOF(fo)); @@ -1747,17 +1780,26 @@ hcl_ooi_t hcl_prufmt (hcl_t* hcl, const hcl_uch_t* fmt, ...) fo.fmt_str = fmt; fo.ctx = hcl; fo.mask = 0; - fo.putbcs = log_bcs; - fo.putucs = log_ucs; + fo.putbcs = print_bcs; + fo.putucs = print_ucs; fo.putobj = hcl_fmt_object_; - va_start (ap, fmt); x = fmt_outv(&fo, ap); - va_end (ap); return (x <= -1)? -1: fo.count; } +hcl_ooi_t hcl_prufmt (hcl_t* hcl, const hcl_uch_t* fmt, ...) +{ + hcl_ooi_t x; + va_list ap; + + va_start (ap, fmt); + x = hcl_prufmtv(hcl, fmt, ap); + va_end (ap); + + return x; +} /* -------------------------------------------------------------------------- * SUPPORT FOR FORMATTED OUTPUT TO BE USED BY BUILTIN PRIMITIVE FUNCTIONS diff --git a/lib/hcl.h b/lib/hcl.h index f31b162..01d2be9 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -1825,12 +1825,31 @@ HCL_EXPORT hcl_ooi_t hcl_prbfmt ( ... ); +HCL_EXPORT hcl_ooi_t hcl_prbfmtv ( + hcl_t* hcl, + const hcl_bch_t* fmt, + va_list ap +); + HCL_EXPORT hcl_ooi_t hcl_prufmt ( hcl_t* hcl, const hcl_uch_t* fmt, ... ); +HCL_EXPORT hcl_ooi_t hcl_prufmtv ( + hcl_t* hcl, + const hcl_uch_t* fmt, + va_list ap +); + +#if defined(HCL_OOCH_IS_UCH) +# define hcl_proofmt hcl_prufmt +# define hcl_proofmtv hcl_prufmtv +#else +# define hcl_proofmt hcl_prbfmt +# define hcl_proofmtv hcl_prbfmtv +#endif /* ========================================================================= * OBJECT MANAGEMENT * ========================================================================= */