fixed %js handling in the formatting funtions

This commit is contained in:
hyung-hwan 2022-01-24 07:30:14 +00:00
parent e5d7bba381
commit 601707ab40
2 changed files with 22 additions and 5 deletions

View File

@ -134,6 +134,12 @@ static const qse_wchar_t* w_hex2ascii =
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
/* char_t a normal character type for the format
* ochar_t is an opposite type to char_t
* uchar_t is a normal unsigned character type */
/* ------------------------------------------------------------------ */
#undef char_t #undef char_t
#undef uchar_t #undef uchar_t
#undef ochar_t #undef ochar_t
@ -147,12 +153,12 @@ static const qse_wchar_t* w_hex2ascii =
#undef fmtout #undef fmtout
#define char_t qse_mchar_t #define char_t qse_mchar_t
#define uchar_t qse_mchar_t #define uchar_t qse_mchau_t
#define ochar_t qse_wchar_t #define ochar_t qse_wchar_t
#define T(x) QSE_MT(x) #define T(x) QSE_MT(x)
#define OT(x) QSE_WT(x) #define OT(x) QSE_WT(x)
#define CONV_MAX QSE_MBLEN_MAX #define CONV_MAX QSE_MBLEN_MAX
#define toupper QSE_TOUPPER #define toupper QSE_TOMUPPER
#define sprintn m_sprintn #define sprintn m_sprintn
#define fmtout_t qse_mfmtout_t #define fmtout_t qse_mfmtout_t
#define fmtout qse_mfmtout #define fmtout qse_mfmtout
@ -176,7 +182,7 @@ static const qse_wchar_t* w_hex2ascii =
#undef fmtout #undef fmtout
#define char_t qse_wchar_t #define char_t qse_wchar_t
#define uchar_t qse_wchar_t #define uchar_t qse_wchau_t
#define ochar_t qse_mchar_t #define ochar_t qse_mchar_t
#define T(x) QSE_WT(x) #define T(x) QSE_WT(x)
#define OT(x) QSE_MT(x) #define OT(x) QSE_MT(x)

View File

@ -442,6 +442,8 @@ reswitch:
if (flagc & FLAGC_ZEROPAD) padc = T(' '); if (flagc & FLAGC_ZEROPAD) padc = T(' ');
if (((lm_flag & LF_H) && (QSE_SIZEOF(char_t) > QSE_SIZEOF(ochar_t))) || if (((lm_flag & LF_H) && (QSE_SIZEOF(char_t) > QSE_SIZEOF(ochar_t))) ||
((lm_flag & LF_L) && (QSE_SIZEOF(char_t) < QSE_SIZEOF(ochar_t)))) goto uppercase_c; ((lm_flag & LF_L) && (QSE_SIZEOF(char_t) < QSE_SIZEOF(ochar_t)))) goto uppercase_c;
/* check qse_char_t(not char_t) against ochar_t */
if ((lm_flag & LF_J) && QSE_SIZEOF(qse_char_t) == QSE_SIZEOF(ochar_t)) goto uppercase_c;
lowercase_c: lowercase_c:
ach = QSE_SIZEOF(char_t) < QSE_SIZEOF(int)? va_arg(ap, int): va_arg(ap, char_t); ach = QSE_SIZEOF(char_t) < QSE_SIZEOF(int)? va_arg(ap, int): va_arg(ap, char_t);
@ -464,6 +466,8 @@ reswitch:
if (flagc & FLAGC_ZEROPAD) padc = T(' '); if (flagc & FLAGC_ZEROPAD) padc = T(' ');
if (((lm_flag & LF_H) && (QSE_SIZEOF(char_t) < QSE_SIZEOF(ochar_t))) || if (((lm_flag & LF_H) && (QSE_SIZEOF(char_t) < QSE_SIZEOF(ochar_t))) ||
((lm_flag & LF_L) && (QSE_SIZEOF(char_t) > QSE_SIZEOF(ochar_t)))) goto lowercase_c; ((lm_flag & LF_L) && (QSE_SIZEOF(char_t) > QSE_SIZEOF(ochar_t)))) goto lowercase_c;
/* check qse_char_t(not char_t) against ochar_t */
if ((lm_flag & LF_J) && QSE_SIZEOF(qse_char_t) == QSE_SIZEOF(char_t)) goto lowercase_s;
uppercase_c: uppercase_c:
oach = QSE_SIZEOF(ochar_t) < QSE_SIZEOF(int)? va_arg(ap, int): va_arg(ap, ochar_t); oach = QSE_SIZEOF(ochar_t) < QSE_SIZEOF(int)? va_arg(ap, int): va_arg(ap, ochar_t);
@ -508,6 +512,12 @@ reswitch:
if (flagc & FLAGC_ZEROPAD) padc = T(' '); if (flagc & FLAGC_ZEROPAD) padc = T(' ');
if (((lm_flag & LF_H) && (QSE_SIZEOF(char_t) > QSE_SIZEOF(ochar_t))) || if (((lm_flag & LF_H) && (QSE_SIZEOF(char_t) > QSE_SIZEOF(ochar_t))) ||
((lm_flag & LF_L) && (QSE_SIZEOF(char_t) < QSE_SIZEOF(ochar_t)))) goto uppercase_s; ((lm_flag & LF_L) && (QSE_SIZEOF(char_t) < QSE_SIZEOF(ochar_t)))) goto uppercase_s;
/* check qse_char_t(not char_t) against ochar_t */
if ((lm_flag & LF_J) && QSE_SIZEOF(qse_char_t) == QSE_SIZEOF(ochar_t)) goto uppercase_s;
/* falls down here if lm_flag & LF_J */
lowercase_s: lowercase_s:
sp = va_arg(ap, char_t*); sp = va_arg(ap, char_t*);
if (sp == QSE_NULL) p = T("(null)"); if (sp == QSE_NULL) p = T("(null)");
@ -540,8 +550,9 @@ reswitch:
if (flagc & FLAGC_ZEROPAD) padc = T(' '); if (flagc & FLAGC_ZEROPAD) padc = T(' ');
if (((lm_flag & LF_H) && (QSE_SIZEOF(char_t) < QSE_SIZEOF(ochar_t))) || if (((lm_flag & LF_H) && (QSE_SIZEOF(char_t) < QSE_SIZEOF(ochar_t))) ||
((lm_flag & LF_L) && (QSE_SIZEOF(char_t) > QSE_SIZEOF(ochar_t)))) goto lowercase_s; ((lm_flag & LF_L) && (QSE_SIZEOF(char_t) > QSE_SIZEOF(ochar_t)))) goto lowercase_s;
/* check qse_char_t(not char_t) against ochar_t */
if ((lm_flag & LF_J) && QSE_SIZEOF(qse_char_t) == QSE_SIZEOF(char_t)) goto lowercase_s;
uppercase_s: uppercase_s:
osp = va_arg (ap, ochar_t*); osp = va_arg (ap, ochar_t*);
if (osp == QSE_NULL) osp = OT("(null)"); if (osp == QSE_NULL) osp = OT("(null)");