renamed logfmtv to fmtoutv and made related changes

This commit is contained in:
hyunghwan.chung 2019-01-25 07:49:01 +00:00
parent 365518f7c3
commit c3705dd340
6 changed files with 59 additions and 60 deletions

View File

@ -75,8 +75,8 @@ libmoo_la_SOURCES = \
dic.c \
err.c \
exec.c \
logfmtv.h \
logfmt.c \
fmtout.c \
fmtoutv.h \
gc.c \
heap.c \
moo.c \

View File

@ -169,7 +169,7 @@ am__DEPENDENCIES_5 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
$(am__DEPENDENCIES_3) $(am__DEPENDENCIES_4)
am_libmoo_la_OBJECTS = libmoo_la-bigint.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-logfmt.lo \
libmoo_la-err.lo libmoo_la-exec.lo libmoo_la-fmtout.lo \
libmoo_la-gc.lo libmoo_la-heap.lo libmoo_la-moo.lo \
libmoo_la-number.lo libmoo_la-obj.lo libmoo_la-opt.lo \
libmoo_la-pf-basic.lo libmoo_la-pf-sys.lo libmoo_la-pf-utf8.lo \
@ -404,6 +404,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@ -466,8 +467,8 @@ libmoo_la_SOURCES = \
dic.c \
err.c \
exec.c \
logfmtv.h \
logfmt.c \
fmtout.c \
fmtoutv.h \
gc.c \
heap.c \
moo.c \
@ -653,9 +654,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-dic.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-err.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-exec.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-fmtout.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-gc.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-heap.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-logfmt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-moo.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-number.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmoo_la-obj.Plo@am__quote@
@ -745,12 +746,12 @@ libmoo_la-exec.lo: exec.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-exec.lo `test -f 'exec.c' || echo '$(srcdir)/'`exec.c
libmoo_la-logfmt.lo: logfmt.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-logfmt.lo -MD -MP -MF $(DEPDIR)/libmoo_la-logfmt.Tpo -c -o libmoo_la-logfmt.lo `test -f 'logfmt.c' || echo '$(srcdir)/'`logfmt.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-logfmt.Tpo $(DEPDIR)/libmoo_la-logfmt.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='logfmt.c' object='libmoo_la-logfmt.lo' libtool=yes @AMDEPBACKSLASH@
libmoo_la-fmtout.lo: fmtout.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-fmtout.lo -MD -MP -MF $(DEPDIR)/libmoo_la-fmtout.Tpo -c -o libmoo_la-fmtout.lo `test -f 'fmtout.c' || echo '$(srcdir)/'`fmtout.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmoo_la-fmtout.Tpo $(DEPDIR)/libmoo_la-fmtout.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fmtout.c' object='libmoo_la-fmtout.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-logfmt.lo `test -f 'logfmt.c' || echo '$(srcdir)/'`logfmt.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-fmtout.lo `test -f 'fmtout.c' || echo '$(srcdir)/'`fmtout.c
libmoo_la-gc.lo: gc.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-gc.lo -MD -MP -MF $(DEPDIR)/libmoo_la-gc.Tpo -c -o libmoo_la-gc.lo `test -f 'gc.c' || echo '$(srcdir)/'`gc.c

View File

@ -142,8 +142,8 @@ typedef int (*moo_fmtout_putcs_t) (
moo_oow_t len
);
typedef struct moo_fmtout_t moo_fmtout_t;
struct moo_fmtout_t
typedef struct moo_fmtout_data_t moo_fmtout_data_t;
struct moo_fmtout_data_t
{
moo_oow_t count; /* out */
moo_bitmask_t mask; /* in */
@ -151,6 +151,13 @@ struct moo_fmtout_t
moo_fmtout_putcs_t putcs; /* in */
};
typedef moo_ooi_t (*moo_outbfmt_t) (
moo_t* moo,
moo_bitmask_t mask,
const moo_bch_t* fmt,
...
);
/* ------------------------------------------------------------------------- */
/*
* Put a NUL-terminated ASCII number (base <= 36) in a buffer in reverse
@ -374,9 +381,7 @@ redo:
/* ------------------------------------------------------------------------- */
typedef moo_ooi_t (*outbfmt_t) (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...);
static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_t outbfmt)
static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, moo_outbfmt_t outbfmt)
{
if (oop == moo->_nil)
{
@ -616,35 +621,35 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
#undef FMTCHAR_IS_UCH
#undef FMTCHAR_IS_OOCH
#undef fmtchar_t
#undef logfmtv
#undef fmtoutv
#define fmtchar_t moo_bch_t
#define logfmtv __logbfmtv
#define fmtoutv __logbfmtv
#define FMTCHAR_IS_BCH
#if defined(MOO_OOCH_IS_BCH)
# define FMTCHAR_IS_OOCH
#endif
#include "logfmtv.h"
#include "fmtoutv.h"
#undef FMTCHAR_IS_BCH
#undef FMTCHAR_IS_UCH
#undef FMTCHAR_IS_OOCH
#undef fmtchar_t
#undef logfmtv
#undef fmtoutv
#define fmtchar_t moo_uch_t
#define logfmtv __logufmtv
#define fmtoutv __logufmtv
#define FMTCHAR_IS_UCH
#if defined(MOO_OOCH_IS_UCH)
# define FMTCHAR_IS_OOCH
#endif
#include "logfmtv.h"
#include "fmtoutv.h"
static int _logbfmtv (moo_t* moo, const moo_bch_t* fmt, moo_fmtout_t* data, va_list ap)
static int _logbfmtv (moo_t* moo, const moo_bch_t* fmt, moo_fmtout_data_t* data, va_list ap)
{
return __logbfmtv(moo, fmt, data, ap, moo_logbfmt);
}
static int _logufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_t* data, va_list ap)
static int _logufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_data_t* data, va_list ap)
{
return __logufmtv(moo, fmt, data, ap, moo_logbfmt);
}
@ -653,7 +658,7 @@ moo_ooi_t moo_logbfmt (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...
{
int x;
va_list ap;
moo_fmtout_t fo;
moo_fmtout_data_t fo;
if (moo->log.default_type_mask & MOO_LOG_ALL_TYPES)
{
@ -686,7 +691,7 @@ moo_ooi_t moo_logufmt (moo_t* moo, moo_bitmask_t mask, const moo_uch_t* fmt, ...
{
int x;
va_list ap;
moo_fmtout_t fo;
moo_fmtout_data_t fo;
if (moo->log.default_type_mask & MOO_LOG_ALL_TYPES)
{
@ -754,12 +759,12 @@ static int put_errcs (moo_t* moo, moo_bitmask_t mask, const moo_ooch_t* ptr, moo
static moo_ooi_t __errbfmtv (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...);
static int _errbfmtv (moo_t* moo, const moo_bch_t* fmt, moo_fmtout_t* data, va_list ap)
static int _errbfmtv (moo_t* moo, const moo_bch_t* fmt, moo_fmtout_data_t* data, va_list ap)
{
return __logbfmtv (moo, fmt, data, ap, __errbfmtv);
}
static int _errufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_t* data, va_list ap)
static int _errufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_data_t* data, va_list ap)
{
return __logufmtv (moo, fmt, data, ap, __errbfmtv);
}
@ -767,7 +772,7 @@ static int _errufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_t* data, va_l
static moo_ooi_t __errbfmtv (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...)
{
va_list ap;
moo_fmtout_t fo;
moo_fmtout_data_t fo;
fo.mask = 0; /* not used */
fo.putch = put_errch;
@ -783,7 +788,7 @@ static moo_ooi_t __errbfmtv (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fm
void moo_seterrbfmt (moo_t* moo, moo_errnum_t errnum, const moo_bch_t* fmt, ...)
{
va_list ap;
moo_fmtout_t fo;
moo_fmtout_data_t fo;
if (moo->shuterr) return;
moo->errmsg.len = 0;
@ -802,7 +807,7 @@ void moo_seterrbfmt (moo_t* moo, moo_errnum_t errnum, const moo_bch_t* fmt, ...)
void moo_seterrufmt (moo_t* moo, moo_errnum_t errnum, const moo_uch_t* fmt, ...)
{
va_list ap;
moo_fmtout_t fo;
moo_fmtout_data_t fo;
if (moo->shuterr) return;
moo->errmsg.len = 0;
@ -821,7 +826,7 @@ void moo_seterrufmt (moo_t* moo, moo_errnum_t errnum, const moo_uch_t* fmt, ...)
void moo_seterrbfmtv (moo_t* moo, moo_errnum_t errnum, const moo_bch_t* fmt, va_list ap)
{
moo_fmtout_t fo;
moo_fmtout_data_t fo;
if (moo->shuterr) return;
@ -837,7 +842,7 @@ void moo_seterrbfmtv (moo_t* moo, moo_errnum_t errnum, const moo_bch_t* fmt, va_
void moo_seterrufmtv (moo_t* moo, moo_errnum_t errnum, const moo_uch_t* fmt, va_list ap)
{
moo_fmtout_t fo;
moo_fmtout_data_t fo;
if (moo->shuterr) return;
@ -885,7 +890,7 @@ void moo_seterrufmtv (moo_t* moo, moo_errnum_t errnum, const moo_uch_t* fmt, va_
else { ch = *(fmt); (fmt)++; }\
} while(0)
static MOO_INLINE int print_formatted (moo_t* moo, moo_ooi_t nargs, moo_fmtout_t* data, moo_outbfmt_t outbfmt, int ignore_rcv)
static MOO_INLINE int print_formatted (moo_t* moo, moo_ooi_t nargs, moo_fmtout_data_t* data, moo_outbfmt_t outbfmt, int ignore_rcv)
{
const moo_ooch_t* fmt, * fmtend;
const moo_ooch_t* checkpoint, * percent;
@ -1418,7 +1423,7 @@ oops:
int moo_printfmtst (moo_t* moo, moo_ooi_t nargs)
{
moo_fmtout_t fo;
moo_fmtout_data_t fo;
MOO_MEMSET (&fo, 0, MOO_SIZEOF(fo));
fo.putch = put_prch;
fo.putcs = put_prcs;
@ -1431,7 +1436,7 @@ int moo_printfmtst (moo_t* moo, moo_ooi_t nargs)
int moo_logfmtst (moo_t* moo, moo_ooi_t nargs)
{
moo_fmtout_t fo;
moo_fmtout_data_t fo;
MOO_MEMSET (&fo, 0, MOO_SIZEOF(fo));
fo.mask = MOO_LOG_FATAL | MOO_LOG_APP;
@ -1506,13 +1511,13 @@ static int put_sprch (moo_t* moo, moo_bitmask_t mask, moo_ooch_t ch, moo_oow_t l
static moo_ooi_t __sprbfmtv (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...);
static int _sprbfmtv (moo_t* moo, const moo_bch_t* fmt, moo_fmtout_t* data, va_list ap)
static int _sprbfmtv (moo_t* moo, const moo_bch_t* fmt, moo_fmtout_data_t* data, va_list ap)
{
return __logbfmtv(moo, fmt, data, ap, __sprbfmtv);
}
/*
static int _sprufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_t* data, va_list ap)
static int _sprufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_data_t* data, va_list ap)
{
return __logufmtv (moo, fmt, data, ap, __sprbfmtv);
}*/
@ -1520,7 +1525,7 @@ static int _sprufmtv (moo_t* moo, const moo_uch_t* fmt, moo_fmtout_t* data, va_l
static moo_ooi_t __sprbfmtv(moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt, ...)
{
va_list ap;
moo_fmtout_t fo;
moo_fmtout_data_t fo;
fo.mask = mask; /* not used */
fo.putch = put_sprch;
@ -1537,7 +1542,7 @@ moo_ooi_t moo_sproutbfmt (moo_t* moo, moo_bitmask_t mask, const moo_bch_t* fmt,
{
int x;
va_list ap;
moo_fmtout_t fo;
moo_fmtout_data_t fo;
fo.mask = mask;
fo.putch = put_sprch;
@ -1555,7 +1560,7 @@ moo_ooi_t moo_sproutufmt (moo_t* moo, moo_bitmask_t mask, const moo_uch_t* fmt,
{
int x;
va_list ap;
moo_fmtout_t fo;
moo_fmtout_data_t fo;
fo.mask = mask;
fo.putch = put_sprch;
@ -1572,7 +1577,7 @@ moo_ooi_t moo_sproutufmt (moo_t* moo, moo_bitmask_t mask, const moo_uch_t* fmt,
int moo_sprintfmtst (moo_t* moo, moo_ooi_t nargs)
{
/* format a string using the receiver and arguments on the stack */
moo_fmtout_t fo;
moo_fmtout_data_t fo;
MOO_MEMSET (&fo, 0, MOO_SIZEOF(fo));
fo.putch = put_sprch;
fo.putcs = put_sprcs;

View File

@ -89,7 +89,7 @@
} \
} while (0)
static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_list ap, outbfmt_t outbfmt)
static int fmtoutv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_data_t* data, va_list ap, moo_outbfmt_t outbfmt)
{
const fmtchar_t* percent;
const fmtchar_t* checkpoint;

View File

@ -268,13 +268,6 @@
#define MOO_OOP_IS_FPDEC(moo,x) (MOO_CLASSOF(moo,x) == (moo)->_fixed_point_decimal)
#define MOO_POINTER_IS_FPDEC(moo,x) (MOO_OBJ_GET_CLASS(x) == (moo)->_fixed_point_Decimal)
typedef moo_ooi_t (*moo_outbfmt_t) (
moo_t* moo,
moo_bitmask_t mask,
const moo_bch_t* fmt,
...
);
#if defined(MOO_INCLUDE_COMPILER)
/* ========================================================================= */
@ -1474,7 +1467,7 @@ moo_oop_t moo_numtostr (
/* ========================================================================= */
/* logfmt.c */
/* fmtout.c */
/* ========================================================================= */
moo_ooi_t moo_sproutbfmt (
moo_t* moo,

View File

@ -127,10 +127,10 @@ int moo_init (moo_t* moo, moo_mmgr_t* mmgr, moo_cmgr_t* cmgr, const moo_vmprim_t
moo->log.capa = MOO_ALIGN_POW2(1, MOO_LOG_CAPA_ALIGN); /* TODO: is this a good initial size? */
/* alloate the log buffer in advance though it may get reallocated
* in put_oocs and put_ooch in logfmt.c. this is to let the logging
* in put_oocs and put_ooch in fmtout.c. this is to let the logging
* routine still function despite some side-effects when
* reallocation fails */
/* +1 required for consistency with put_oocs and put_ooch in logfmt.c */
/* +1 required for consistency with put_oocs and put_ooch in fmtout.c */
moo->log.ptr = moo_allocmem(moo, (moo->log.capa + 1) * MOO_SIZEOF(*moo->log.ptr));
if (!moo->log.ptr) goto oops;