From: kosako Date: Tue, 19 Apr 2016 08:44:15 +0000 (+0900) Subject: allow the case that initialization function is not invited. But it is unfavorable. X-Git-Tag: v6.0.0^2~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3b1a3b524adb744633830239ffe93ad568a6d42a;p=onig allow the case that initialization function is not invited. But it is unfavorable. --- diff --git a/src/regcomp.c b/src/regcomp.c index 0a3584b..b48977e 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -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;