]> granicus.if.org Git - onig/commitdiff
add onig_get_callout_num_from_tag_name()
authorK.Kosako <kkosako0@gmail.com>
Sun, 25 Feb 2018 08:46:39 +0000 (17:46 +0900)
committerK.Kosako <kkosako0@gmail.com>
Sun, 25 Feb 2018 08:46:39 +0000 (17:46 +0900)
src/oniguruma.h
src/regparse.c

index 6045c586a94b070b9715fbfbb5fb7159d0846d92..db52d0ae0ed01e28d003bed68d60c7c7479b876c 100644 (file)
@@ -944,6 +944,8 @@ ONIG_EXTERN
 int onig_set_callout_of_name P_((OnigEncoding enc, OnigCalloutType type, OnigUChar* name, OnigUChar* name_end, int callout_in, OnigCalloutFunc callout, OnigCalloutFunc end_callout, int arg_num, OnigType arg_types[], int optional_arg_num, OnigValue opt_defaults[])); /* name: single-byte string */
 ONIG_EXTERN
 OnigUChar* onig_get_callout_name_from_name_id P_((int id));
+ONIG_EXTERN
+int onig_get_callout_num_from_tag_name P_((OnigRegex reg, const UChar* name, const UChar* name_end));
 
 /* used in callout functions */
 ONIG_EXTERN
index 0830a455f454b81062d68d838165ff984126840f..a8c2a593984f8bc87a0213d9cc7540006e733935 100644 (file)
@@ -1685,6 +1685,23 @@ onig_callout_tag_table_free(void* table)
   return 0;
 }
 
+extern int
+onig_get_callout_num_from_tag_name(regex_t* reg,
+                                  const UChar* name, const UChar* name_end)
+{
+  int r;
+  RegexExt* ext;
+  CalloutTagVal e;
+
+  ext = REG_EXTP(reg);
+  if (IS_NULL(ext) || IS_NULL(ext->tag_table)) return -1;
+
+  r = onig_st_lookup_strend(ext->tag_table, name, name_end,
+                           (HashDataType* )((void* )(&e)));
+  if (r == 0) return -1;
+  return (int )e;
+}
+
 static CalloutTagVal
 callout_tag_find(CalloutTagTable* t, const UChar* name, const UChar* name_end)
 {