]> granicus.if.org Git - onig/commitdiff
set default value 1 for (*ONLY(n))
authorK.Kosako <kosako@sofnec.co.jp>
Tue, 27 Feb 2018 04:15:56 +0000 (13:15 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Tue, 27 Feb 2018 04:15:56 +0000 (13:15 +0900)
src/ascii.c
src/regint.h

index 556f4f99c7f2ff628411f3ebc175846faa9711b2..d83f3c04e57cdb52bdaec89356b3a8fb59587ad8 100644 (file)
@@ -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 */
 
index 637e0c9c58dd572727fe9d5d922f2e394259b0c8..2c783b5c83a072b7c449bb6b93d83a13ebf04aca 100644 (file)
@@ -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 */