diff --git a/lib/hcl.h b/lib/hcl.h index 9491b80..9ae0ae8 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -1589,10 +1589,10 @@ HCL_EXPORT hcl_ooi_t hcl_logbfmt ( ... ); -HCL_EXPORT hcl_ooi_t hcl_logoofmt ( - hcl_t* hcl, - hcl_oow_t mask, - const hcl_ooch_t* fmt, +HCL_EXPORT hcl_ooi_t hcl_logufmt ( + hcl_t* hcl, + hcl_oow_t mask, + const hcl_uch_t* fmt, ... ); @@ -1796,10 +1796,10 @@ HCL_EXPORT int hcl_equalobjs ( # define hcl_convootobcstr(hcl,oocs,oocslen,bcs,bcslen) hcl_convutobcstr(hcl,oocs,oocslen,bcs,bcslen) # define hcl_convbtooocstr(hcl,bcs,bcslen,oocs,oocslen) hcl_convbtoucstr(hcl,bcs,bcslen,oocs,oocslen) #else -# define hcl_convootouchars(hcl,oocs,oocslen,bcs,bcslen) hcl_convbtouchars(hcl,oocs,oocslen,bcs,bcslen) -# define hcl_convutooochars(hcl,bcs,bcslen,oocs,oocslen) hcl_convutobchars(hcl,bcs,bcslen,oocs,oocslen) -# define hcl_convootoucstr(hcl,oocs,oocslen,bcs,bcslen) hcl_convbtoucstr(hcl,oocs,oocslen,bcs,bcslen) -# define hcl_convutooocstr(hcl,bcs,bcslen,oocs,oocslen) hcl_convutobcstr(hcl,bcs,bcslen,oocs,oocslen) +# define hcl_convootouchars(hcl,oocs,oocslen,ucs,ucslen) hcl_convbtouchars(hcl,oocs,oocslen,ucs,ucslen) +# define hcl_convutooochars(hcl,ucs,ucslen,oocs,oocslen) hcl_convutobchars(hcl,ucs,ucslen,oocs,oocslen) +# define hcl_convootoucstr(hcl,oocs,oocslen,ucs,ucslen) hcl_convbtoucstr(hcl,oocs,oocslen,ucs,ucslen) +# define hcl_convutooocstr(hcl,ucs,ucslen,oocs,oocslen) hcl_convutobcstr(hcl,ucs,ucslen,oocs,oocslen) #endif HCL_EXPORT int hcl_convbtouchars ( diff --git a/lib/logfmtv.h b/lib/logfmtv.h index 6f36dd1..1126b9b 100644 --- a/lib/logfmtv.h +++ b/lib/logfmtv.h @@ -100,6 +100,7 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis int n, base, neg, sign; hcl_ooi_t tmp, width, precision; hcl_ooch_t ch, padc; + fmtchar_t fch; int lm_flag, lm_dflag, flagc, numlen; hcl_uintmax_t num = 0; int stop = 0; @@ -137,23 +138,29 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis } PUT_OOCS (checkpoint, fmt - checkpoint - 1); #else - while ((ch = *fmt++) != '%' || stop) + while ((fch = *fmt++) != '%' || stop) { - if (ch == '\0') goto done; - - #if defined(HCL_OOCH_IS_UCH) - /* ooch is uch. fmtchar is bch */ - /* TODO: convert bch to uch */ - #else - /* ooch is bch. fmtchar is uch */ - /* TODO: convert uch to bch */ - #endif + #if defined(HCL_OOCH_IS_UCH) + if (fch == '\0') goto done; + /* ooch is uch. fmtchar is bch */ + /* TODO: convert bch to uch */ PUT_OOCH (ch, 1); + #else + hcl_bch_t bcsbuf[HCL_MBLEN_MAX + 1]; + hcl_oow_t ucslen, bcslen; + + if (fch == '\0') goto done; + + /* ooch is bch. fmtchar is uch */ + ucslen = 1; + bcslen = 1; + if (hcl_convutooochars (hcl, &fch, &ucslen, bcsbuf, &bcslen) <= -1) goto oops; + PUT_OOCS (bcsbuf, bcslen); + #endif } #endif percent = fmt - 1; - padc = ' '; width = 0; precision = 0; neg = 0; sign = 0;