From cf7fdec792a75f93be55d7a4a81933f961a5516a Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 15 Mar 2018 22:08:29 -0400 Subject: [PATCH] initialize oniguruma --- main.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/main.cc b/main.cc index 7ccdc48..f1d995c 100644 --- a/main.cc +++ b/main.cc @@ -1,5 +1,25 @@ #include +#include int main(int argc, char * argv[]) { + static OnigEncoding encodings[] = { + ONIG_ENCODING_ASCII, + ONIG_ENCODING_UTF8, + ONIG_ENCODING_UTF16_BE, + ONIG_ENCODING_UTF16_LE, + ONIG_ENCODING_UTF32_BE, + ONIG_ENCODING_UTF32_LE, + }; + int rc = onig_initialize(encodings, sizeof(encodings) / sizeof(encodings[0])); + if (rc != ONIG_NORMAL) + { + OnigErrorInfo einfo; + OnigUChar s[ONIG_MAX_ERROR_MESSAGE_LEN]; + onig_error_code_to_str(s, rc, &einfo); + fprintf(stderr, "Error: %s\n", s); + return 1; + } + + return 0; }