From 597864a4bae9d89363b0e768e3aa1a23e42bb628 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Fri, 22 Nov 2019 08:23:33 +0000 Subject: [PATCH] defined moo_fmt_intmax_to_oocstr and moo_fmt_uintmx_to_oocstr --- moo/lib/Makefile.am | 2 +- moo/lib/Makefile.in | 18 +++++++++--------- moo/lib/fmt.c | 30 +++++++++++++++--------------- moo/lib/moo-fmt.h | 29 +++++++++++++++++++---------- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/moo/lib/Makefile.am b/moo/lib/Makefile.am index e4db126..4109a7f 100644 --- a/moo/lib/Makefile.am +++ b/moo/lib/Makefile.am @@ -56,7 +56,6 @@ pkglib_LTLIBRARIES = libmoo.la libmoox.la ################################################## libmoo_la_SOURCES = \ bct-lab.h \ - chr.c \ moo.h \ moo-chr.h \ moo-cmn.h \ @@ -67,6 +66,7 @@ libmoo_la_SOURCES = \ pack1.h \ unpack.h \ bigint.c \ + chr.c \ comp.c \ debug.c \ decode.c \ diff --git a/moo/lib/Makefile.in b/moo/lib/Makefile.in index 4891998..c0cb4d8 100644 --- a/moo/lib/Makefile.in +++ b/moo/lib/Makefile.in @@ -153,7 +153,7 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)" \ "$(DESTDIR)$(pkgincludedir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) am__DEPENDENCIES_1 = -am_libmoo_la_OBJECTS = libmoo_la-chr.lo libmoo_la-bigint.lo \ +am_libmoo_la_OBJECTS = libmoo_la-bigint.lo libmoo_la-chr.lo \ libmoo_la-comp.lo libmoo_la-debug.lo libmoo_la-decode.lo \ libmoo_la-dic.lo libmoo_la-err.lo libmoo_la-exec.lo \ libmoo_la-fmt.lo libmoo_la-gc.lo libmoo_la-heap.lo \ @@ -466,7 +466,6 @@ pkglib_LTLIBRARIES = libmoo.la libmoox.la ################################################## libmoo_la_SOURCES = \ bct-lab.h \ - chr.c \ moo.h \ moo-chr.h \ moo-cmn.h \ @@ -477,6 +476,7 @@ libmoo_la_SOURCES = \ pack1.h \ unpack.h \ bigint.c \ + chr.c \ comp.c \ debug.c \ decode.c \ @@ -676,13 +676,6 @@ am--depfiles: $(am__depfiles_remade) @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< -libmoo_la-chr.lo: chr.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_la-chr.lo -MD -MP -MF $(DEPDIR)/libmoo_la-chr.Tpo -c -o libmoo_la-chr.lo `test -f 'chr.c' || echo '$(srcdir)/'`chr.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-chr.Tpo $(DEPDIR)/libmoo_la-chr.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='chr.c' object='libmoo_la-chr.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) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_la-chr.lo `test -f 'chr.c' || echo '$(srcdir)/'`chr.c - libmoo_la-bigint.lo: bigint.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_la-bigint.lo -MD -MP -MF $(DEPDIR)/libmoo_la-bigint.Tpo -c -o libmoo_la-bigint.lo `test -f 'bigint.c' || echo '$(srcdir)/'`bigint.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-bigint.Tpo $(DEPDIR)/libmoo_la-bigint.Plo @@ -690,6 +683,13 @@ libmoo_la-bigint.lo: bigint.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) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_la-bigint.lo `test -f 'bigint.c' || echo '$(srcdir)/'`bigint.c +libmoo_la-chr.lo: chr.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_la-chr.lo -MD -MP -MF $(DEPDIR)/libmoo_la-chr.Tpo -c -o libmoo_la-chr.lo `test -f 'chr.c' || echo '$(srcdir)/'`chr.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-chr.Tpo $(DEPDIR)/libmoo_la-chr.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='chr.c' object='libmoo_la-chr.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) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libmoo_la-chr.lo `test -f 'chr.c' || echo '$(srcdir)/'`chr.c + libmoo_la-comp.lo: comp.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmoo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libmoo_la-comp.lo -MD -MP -MF $(DEPDIR)/libmoo_la-comp.Tpo -c -o libmoo_la-comp.lo `test -f 'comp.c' || echo '$(srcdir)/'`comp.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-comp.Tpo $(DEPDIR)/libmoo_la-comp.Plo diff --git a/moo/lib/fmt.c b/moo/lib/fmt.c index bf5f753..90b4bf7 100644 --- a/moo/lib/fmt.c +++ b/moo/lib/fmt.c @@ -1035,7 +1035,7 @@ static int fmt_outv (moo_fmtout_t* fmtout, va_list ap) if (lm_flag & LF_J) { #if (MOO_SIZEOF___FLOAT128 > 0) && defined(HAVE_QUADMATH_SNPRINTF) && (MOO_SIZEOF_FLTMAX_T == MOO_SIZEOF___FLOAT128) - v_qd = va_arg (ap, moo_fltmax_t); + v_qd = va_arg(ap, moo_fltmax_t); dtype = LF_QD; #elif MOO_SIZEOF_FLTMAX_T == MOO_SIZEOF_DOUBLE v_d = va_arg(ap, moo_fltmax_t); @@ -1065,7 +1065,7 @@ static int fmt_outv (moo_fmtout_t* fmtout, va_list ap) } else if (lm_flag & (LF_LD | LF_L)) { - v_ld = va_arg (ap, long double); + v_ld = va_arg(ap, long double); dtype = LF_LD; } #if (MOO_SIZEOF___FLOAT128 > 0) && defined(HAVE_QUADMATH_SNPRINTF) @@ -1081,7 +1081,7 @@ static int fmt_outv (moo_fmtout_t* fmtout, va_list ap) } else { - v_d = va_arg (ap, double); + v_d = va_arg(ap, double); } fmtlen = fmt - percent; @@ -1234,15 +1234,15 @@ static int fmt_outv (moo_fmtout_t* fmtout, va_list ap) for (i = 0, num = 0; i < MOO_SIZEOF(moo_uintmax_t) / MOO_SIZEOF(moo_oow_t); i++) { #if defined(MOO_ENDIAN_BIG) - num = num << (8 * MOO_SIZEOF(moo_oow_t)) | (va_arg (ap, moo_oow_t)); + num = num << (8 * MOO_SIZEOF(moo_oow_t)) | (va_arg(ap, moo_oow_t)); #else register int shift = i * MOO_SIZEOF(moo_oow_t); - moo_oow_t x = va_arg (ap, moo_oow_t); + moo_oow_t x = va_arg(ap, moo_oow_t); num |= (moo_uintmax_t)x << (shift * MOO_BITS_PER_BYTE); #endif } #else - num = va_arg (ap, moo_uintmax_t); + num = va_arg(ap, moo_uintmax_t); #endif } else if (lm_flag & LF_T) @@ -1276,34 +1276,34 @@ static int fmt_outv (moo_fmtout_t* fmtout, va_list ap) for (i = 0, num = 0; i < MOO_SIZEOF(moo_intmax_t) / MOO_SIZEOF(moo_oow_t); i++) { #if defined(MOO_ENDIAN_BIG) - num = num << (8 * MOO_SIZEOF(moo_oow_t)) | (va_arg (ap, moo_oow_t)); + num = num << (8 * MOO_SIZEOF(moo_oow_t)) | (va_arg(ap, moo_oow_t)); #else register int shift = i * MOO_SIZEOF(moo_oow_t); - moo_oow_t x = va_arg (ap, moo_oow_t); + moo_oow_t x = va_arg(ap, moo_oow_t); num |= (moo_uintmax_t)x << (shift * MOO_BITS_PER_BYTE); #endif } #else - num = va_arg (ap, moo_intmax_t); + num = va_arg(ap, moo_intmax_t); #endif } else if (lm_flag & LF_T) num = va_arg(ap, moo_intptr_t/*moo_ptrdiff_t*/); else if (lm_flag & LF_Z) - num = va_arg (ap, moo_ooi_t); + num = va_arg(ap, moo_ooi_t); #if (MOO_SIZEOF_LONG_LONG > 0) else if (lm_flag & LF_Q) - num = va_arg (ap, long long int); + num = va_arg(ap, long long int); #endif else if (lm_flag & (LF_L | LF_LD)) - num = va_arg (ap, long int); + num = va_arg(ap, long int); else if (lm_flag & LF_H) - num = (short int)va_arg (ap, int); + num = (short int)va_arg(ap, int); else if (lm_flag & LF_C) - num = (char)va_arg (ap, int); + num = (char)va_arg(ap, int); else - num = va_arg (ap, int); + num = va_arg(ap, int); number: if (sign && (moo_intmax_t)num < 0) diff --git a/moo/lib/moo-fmt.h b/moo/lib/moo-fmt.h index 43c9b71..59e91fa 100644 --- a/moo/lib/moo-fmt.h +++ b/moo/lib/moo-fmt.h @@ -308,16 +308,6 @@ MOO_EXPORT int moo_fmt_intmax_to_ucstr ( const moo_uch_t* prefix /**< prefix */ ); -/** \def moo_fmt_intmax - * The moo_fmt_intmax() macro maps to moo_fmt_intmax_to_bcstr() if - * #MOO_OOCH_IS_BCH, and moo_fmt_intmax_to_ucstr() if #MOO_CHAR_IS_WCHAR. - */ -#ifdef MOO_OOCH_IS_BCH -# define moo_fmt_intmax(b,sz,v,bf,pr,fc,pf) moo_fmt_intmax_to_bcstr(b,sz,v,bf,pr,fc,pf) -#else -# define moo_fmt_intmax(b,sz,v,bf,pr,fc,pf) moo_fmt_intmax_to_ucstr(b,sz,v,bf,pr,fc,pf) -#endif - /** * The moo_fmt_uintmax_to_bcstr() function formats an unsigned integer \a value * to a multibyte string buffer. It behaves the same as moo_fmt_uintmax_to_bcstr() @@ -333,6 +323,25 @@ MOO_EXPORT int moo_fmt_uintmax_to_bcstr ( const moo_bch_t* prefix /**< prefix */ ); +MOO_EXPORT int moo_fmt_uintmax_to_ucstr ( + moo_uch_t* buf, /**< buffer pointer */ + int bufsize, /**< buffer size */ + moo_uintmax_t value, /**< integer to format */ + int base_and_flags, /**< base ORed with flags */ + int precision, /**< precision */ + moo_uch_t fillchar, /**< fill character */ + const moo_uch_t* prefix /**< prefix */ +); + +#if defined(MOO_OOCH_IS_BCH) +# define moo_fmt_intmax_to_oocstr moo_fmt_intmax_to_bcstr +# define moo_fmt_uintmax_to_oocstr moo_fmt_uintmax_to_bcstr +#else +# define moo_fmt_intmax_to_oocstr moo_fmt_intmax_to_ucstr +# define moo_fmt_uintmax_to_oocstr moo_fmt_uintmax_to_ucstr +#endif + + /* TODO: moo_fmt_fltmax_to_bcstr()... moo_fmt_fltmax_to_ucstr() */