defined moo_fmt_intmax_to_oocstr and moo_fmt_uintmx_to_oocstr

This commit is contained in:
hyunghwan.chung 2019-11-22 08:23:33 +00:00
parent aaa5a50e8c
commit 597864a4ba
4 changed files with 44 additions and 35 deletions

View File

@ -56,7 +56,6 @@ pkglib_LTLIBRARIES = libmoo.la libmoox.la
################################################## ##################################################
libmoo_la_SOURCES = \ libmoo_la_SOURCES = \
bct-lab.h \ bct-lab.h \
chr.c \
moo.h \ moo.h \
moo-chr.h \ moo-chr.h \
moo-cmn.h \ moo-cmn.h \
@ -67,6 +66,7 @@ libmoo_la_SOURCES = \
pack1.h \ pack1.h \
unpack.h \ unpack.h \
bigint.c \ bigint.c \
chr.c \
comp.c \ comp.c \
debug.c \ debug.c \
decode.c \ decode.c \

View File

@ -153,7 +153,7 @@ am__installdirs = "$(DESTDIR)$(pkglibdir)" \
"$(DESTDIR)$(pkgincludedir)" "$(DESTDIR)$(pkgincludedir)"
LTLIBRARIES = $(pkglib_LTLIBRARIES) LTLIBRARIES = $(pkglib_LTLIBRARIES)
am__DEPENDENCIES_1 = 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-comp.lo libmoo_la-debug.lo libmoo_la-decode.lo \
libmoo_la-dic.lo libmoo_la-err.lo libmoo_la-exec.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 \ 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 = \ libmoo_la_SOURCES = \
bct-lab.h \ bct-lab.h \
chr.c \
moo.h \ moo.h \
moo-chr.h \ moo-chr.h \
moo-cmn.h \ moo-cmn.h \
@ -477,6 +476,7 @@ libmoo_la_SOURCES = \
pack1.h \ pack1.h \
unpack.h \ unpack.h \
bigint.c \ bigint.c \
chr.c \
comp.c \ comp.c \
debug.c \ debug.c \
decode.c \ decode.c \
@ -676,13 +676,6 @@ am--depfiles: $(am__depfiles_remade)
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< @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 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_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 @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@ @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 @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 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_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 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-comp.Tpo $(DEPDIR)/libmoo_la-comp.Plo

View File

@ -1035,7 +1035,7 @@ static int fmt_outv (moo_fmtout_t* fmtout, va_list ap)
if (lm_flag & LF_J) if (lm_flag & LF_J)
{ {
#if (MOO_SIZEOF___FLOAT128 > 0) && defined(HAVE_QUADMATH_SNPRINTF) && (MOO_SIZEOF_FLTMAX_T == MOO_SIZEOF___FLOAT128) #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; dtype = LF_QD;
#elif MOO_SIZEOF_FLTMAX_T == MOO_SIZEOF_DOUBLE #elif MOO_SIZEOF_FLTMAX_T == MOO_SIZEOF_DOUBLE
v_d = va_arg(ap, moo_fltmax_t); 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)) 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; dtype = LF_LD;
} }
#if (MOO_SIZEOF___FLOAT128 > 0) && defined(HAVE_QUADMATH_SNPRINTF) #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 else
{ {
v_d = va_arg (ap, double); v_d = va_arg(ap, double);
} }
fmtlen = fmt - percent; 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++) for (i = 0, num = 0; i < MOO_SIZEOF(moo_uintmax_t) / MOO_SIZEOF(moo_oow_t); i++)
{ {
#if defined(MOO_ENDIAN_BIG) #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 #else
register int shift = i * MOO_SIZEOF(moo_oow_t); 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); num |= (moo_uintmax_t)x << (shift * MOO_BITS_PER_BYTE);
#endif #endif
} }
#else #else
num = va_arg (ap, moo_uintmax_t); num = va_arg(ap, moo_uintmax_t);
#endif #endif
} }
else if (lm_flag & LF_T) 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++) for (i = 0, num = 0; i < MOO_SIZEOF(moo_intmax_t) / MOO_SIZEOF(moo_oow_t); i++)
{ {
#if defined(MOO_ENDIAN_BIG) #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 #else
register int shift = i * MOO_SIZEOF(moo_oow_t); 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); num |= (moo_uintmax_t)x << (shift * MOO_BITS_PER_BYTE);
#endif #endif
} }
#else #else
num = va_arg (ap, moo_intmax_t); num = va_arg(ap, moo_intmax_t);
#endif #endif
} }
else if (lm_flag & LF_T) else if (lm_flag & LF_T)
num = va_arg(ap, moo_intptr_t/*moo_ptrdiff_t*/); num = va_arg(ap, moo_intptr_t/*moo_ptrdiff_t*/);
else if (lm_flag & LF_Z) 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) #if (MOO_SIZEOF_LONG_LONG > 0)
else if (lm_flag & LF_Q) else if (lm_flag & LF_Q)
num = va_arg (ap, long long int); num = va_arg(ap, long long int);
#endif #endif
else if (lm_flag & (LF_L | LF_LD)) 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) 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) else if (lm_flag & LF_C)
num = (char)va_arg (ap, int); num = (char)va_arg(ap, int);
else else
num = va_arg (ap, int); num = va_arg(ap, int);
number: number:
if (sign && (moo_intmax_t)num < 0) if (sign && (moo_intmax_t)num < 0)

View File

@ -308,16 +308,6 @@ MOO_EXPORT int moo_fmt_intmax_to_ucstr (
const moo_uch_t* prefix /**< prefix */ 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 * 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() * 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 */ 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() */ /* TODO: moo_fmt_fltmax_to_bcstr()... moo_fmt_fltmax_to_ucstr() */