diff options
author | K.Kosako <kkosako0@gmail.com> | 2022-10-10 13:34:11 +0900 |
---|---|---|
committer | K.Kosako <kkosako0@gmail.com> | 2022-10-10 13:34:11 +0900 |
commit | 0be69456f20278740a0db8418ba45c1a08e15a2f (patch) | |
tree | 798149c7b0e33cbf763a6617ce05c62eea4666b6 | |
parent | 811c0fb5bf1f9f4276d8b70acca36f8586a227b0 (diff) | |
download | oniguruma-0be69456f20278740a0db8418ba45c1a08e15a2f.zip oniguruma-0be69456f20278740a0db8418ba45c1a08e15a2f.tar.gz oniguruma-0be69456f20278740a0db8418ba45c1a08e15a2f.tar.bz2 |
change output format in print_enc_string()
-rw-r--r-- | src/regcomp.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/regcomp.c b/src/regcomp.c index 7b23239..d67a747 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -7021,8 +7021,9 @@ clear_optimize_info(regex_t* reg) #if defined(ONIG_DEBUG_PARSE) || defined(ONIG_DEBUG_MATCH) || \ defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) -static void print_enc_string(FILE* fp, OnigEncoding enc, - const UChar *s, const UChar *end) +static void +print_enc_string(FILE* fp, OnigEncoding enc, + const UChar *s, const UChar *end) { if (ONIGENC_MBC_MINLEN(enc) > 1) { const UChar *p; @@ -7043,7 +7044,17 @@ static void print_enc_string(FILE* fp, OnigEncoding enc, } else { while (s < end) { - fputc((int )*s, fp); + if (ONIGENC_MBC_MAXLEN(enc) == 1) { + if (*s >= 0x80) { + fprintf(fp, "\\x%02x", (unsigned int )*s); + } + else { + fputc((int )*s, fp); + } + } + else { /* for UTF-8 */ + fputc((int )*s, fp); + } s++; } } |