]> granicus.if.org Git - onig/commitdiff
allow the case that initialization function is not invited. But it is unfavorable.
authorkosako <kosako@sofnec.co.jp>
Tue, 19 Apr 2016 08:44:15 +0000 (17:44 +0900)
committerkosako <kosako@sofnec.co.jp>
Tue, 19 Apr 2016 08:44:15 +0000 (17:44 +0900)
src/regcomp.c

index 0a3584b4c81208441bf424e4934a98c4dbfdb62a..b48977ed1591f5533eb4a8dbc89ab9ed1a60de44 100644 (file)
@@ -5416,10 +5416,23 @@ onig_reg_init(regex_t* reg, OnigOptionType option,
              OnigCaseFoldType case_fold_flag,
              OnigEncoding enc, OnigSyntaxType* syntax)
 {
+  int r;
+
   xmemset(reg, 0, sizeof(*reg));
 
-  if (onig_inited == 0)
+  if (onig_inited == 0) {
+#if 0
     return ONIGERR_LIBRARY_IS_NOT_INITIALIZED;
+#else
+    r = onig_initialize(NULL, 0);
+    if (r != 0)
+      return ONIGERR_FAIL_TO_INITIALIZE;
+
+    r = onig_initialize_encoding(enc);
+    if (r != 0)
+      return ONIGERR_FAIL_TO_INITIALIZE;
+#endif
+  }
 
   if (IS_NULL(reg))
     return ONIGERR_INVALID_ARGUMENT;