From d4450b478c979b138fd3a2ffee3180a3f4cbbbec Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Tue, 27 Feb 2018 13:15:56 +0900 Subject: [PATCH] set default value 1 for (*ONLY(n)) --- src/ascii.c | 9 ++++++--- src/regint.h | 9 +++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ascii.c b/src/ascii.c index 556f4f9..d83f3c0 100644 --- a/src/ascii.c +++ b/src/ascii.c @@ -38,10 +38,11 @@ init(void) #ifdef USE_CALLOUT int id; - OnigType t_int; - OnigType t_long; OnigEncoding enc; char* name; + OnigType t_int; + OnigType t_long; + OnigValue opts[4]; enc = ONIG_ENCODING_ASCII; t_int = ONIG_TYPE_INT; @@ -53,7 +54,9 @@ init(void) name = "ERROR"; BC1_P(name, error, &t_int); name = "COUNT"; BC0_P(name, count); name = "FAIL_COUNT"; BC0_R(name, count); - name = "ONLY"; BC1_B(name, only, &t_long); + + name = "ONLY"; opts[0].l = 1L; + BC1_B_O(name, only, &t_long, opts); #endif /* USE_CALLOUT */ diff --git a/src/regint.h b/src/regint.h index 637e0c9..2c783b5 100644 --- a/src/regint.h +++ b/src/regint.h @@ -864,6 +864,15 @@ extern CalloutListEntry* onig_reg_callout_list_at(regex_t* reg, int num); if (id < 0) return id;\ } while(0) +#define BC1_B_O(name, func, ts, opts) do {\ + int len = onigenc_str_bytelen_null(enc, (UChar* )name);\ + id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,\ + (UChar* )(name), (UChar* )((name) + len),\ + ONIG_CALLOUT_IN_BOTH,\ + onig_builtin_ ## func, 0, 1, (ts), 1, opts);\ + if (id < 0) return id;\ +} while(0) + #endif /* USE_CALLOUT */ -- 2.40.0