]> granicus.if.org Git - onig/commitdiff
onig_set_callout_of_name() returns id value
authorK.Kosako <kkosako0@gmail.com>
Fri, 9 Feb 2018 12:06:39 +0000 (21:06 +0900)
committerK.Kosako <kkosako0@gmail.com>
Fri, 9 Feb 2018 12:06:39 +0000 (21:06 +0900)
sample/callout.c
src/regexec.c
src/regparse.c

index 4f17ff6026b26ed4ca6241f145cd5edf3c90cb8d..0ec6d6945e6ed826423c1ea43da6495f23938b08 100644 (file)
@@ -131,6 +131,7 @@ test(char* in_pattern, char* in_str)
 extern int main(int argc, char* argv[])
 {
   int r;
+  int id;
   UChar* name;
   OnigEncoding use_encs[1];
 
@@ -143,10 +144,11 @@ extern int main(int argc, char* argv[])
   if (r != ONIG_NORMAL) return -r;
 
   name = (UChar* )"foo";
-  r = onig_set_callout_of_name(name, name + strlen((char* )name),
+  id = onig_set_callout_of_name(name, name + strlen((char* )name),
                               foo, retraction_foo);
-  if (r != ONIG_NORMAL) {
+  if (id < 0) {
     fprintf(stderr, "ERROR: fail to set callout of name: %s\n", name);
+    //return -1;
   }
 
   (void)onig_set_callout_of_code(progress_callout_func);
index 531ee414b8686ba4e3a9ffea1b438e8c0a9b2f4b..b50d299d9648ad71bfd70be3ed1a7288a579ba6f 100644 (file)
@@ -4910,12 +4910,12 @@ onig_initialize_builtin_callouts(void)
 #else
 
 #define B1(name, func)  do {\
-  r = onig_set_callout_of_name((UChar* )#name, (UChar* )(#name + strlen(#name)),\
+  id = onig_set_callout_of_name((UChar* )#name, (UChar* )(#name + strlen(#name)),\
                                onig_builtin_ ## func, 0);\
-  if (r != ONIG_NORMAL) return r;\
+  if (id < 0) return id;\
 } while(0)
 
-  int r;
+  int id;
 
   B1(FAIL,    fail);
   B1(SUCCESS, success);
index 3ccbf240f7af1d5b9898324a2765931f2ae0a7c5..69c8ac6844990bf345a50f741f33dafe9862568a 100644 (file)
@@ -1425,10 +1425,11 @@ set_callout_of_name_with_enc(OnigEncoding enc, UChar* name, UChar* name_end,
     goto end;
   }
 
-  r = callout_name_entry(&e, name, name_end, callout, retraction_callout);
-  if (r < 0) goto end;
-
-  id = r;
+  id = callout_name_entry(&e, name, name_end, callout, retraction_callout);
+  if (id < 0) {
+    r = id;
+    goto end;
+  }
 
   r = ONIG_NORMAL;
   if (IS_NULL(CalloutNameFuncList)) {
@@ -1444,6 +1445,7 @@ set_callout_of_name_with_enc(OnigEncoding enc, UChar* name, UChar* name_end,
   CalloutNameFuncList->v[id].callout            = callout;
   CalloutNameFuncList->v[id].retraction_callout = retraction_callout;
   CalloutNameFuncList->v[id].name               = e->name;
+  r = id; // return id
 
  end:
   if (save_name != name) xfree(name);