return 0;
}
-static int
-exec(OnigEncoding enc, OnigOptionType options,
- char* apattern, char* apattern_end, char* astr, char* astr_end)
-{
- int r;
- regex_t* reg;
- OnigErrorInfo einfo;
- UChar* pattern = (UChar* )apattern;
- UChar* str = (UChar* )astr;
- UChar* pattern_end = (UChar* )apattern_end;
- unsigned char *end = (unsigned char* )astr_end;
-
- onig_initialize(&enc, 1);
- onig_set_retry_limit_in_match(DEFAULT_LIMIT);
- onig_set_parse_depth_limit(DEFAULT_LIMIT);
-
- r = onig_new(®, pattern, pattern_end,
- options, enc, ONIG_SYNTAX_DEFAULT, &einfo);
- if (r != ONIG_NORMAL) {
- char s[ONIG_MAX_ERROR_MESSAGE_LEN];
- onig_error_code_to_str((UChar* )s, r, &einfo);
- fprintf(stdout, "ERROR: %s\n", s);
- onig_end();
- return -1;
- }
-
- r = search(reg, str, end);
-
- onig_free(reg);
- onig_end();
- return 0;
-}
-
static OnigCaseFoldType CF = ONIGENC_CASE_FOLD_MIN;
static int
unsigned char *pattern_end;
unsigned char *str_null_end;
-
- size_t remaining_size = Size;
- unsigned char *data = (unsigned char *)(Data);
+ size_t remaining_size;
+ unsigned char *data;
// pull off one byte to switch off
- unsigned char encoding_choice = data[0];
+#if !defined(UTF16_BE) && !defined(UTF16_LE)
+ OnigEncodingType *encodings[] = {
+ ONIG_ENCODING_SJIS,
+ ONIG_ENCODING_EUC_JP,
+ ONIG_ENCODING_CP1251,
+ ONIG_ENCODING_ISO_8859_1,
+ ONIG_ENCODING_UTF8,
+ ONIG_ENCODING_KOI8_R,
+ ONIG_ENCODING_BIG5
+ };
+
+ unsigned char encoding_choice;
+#endif
+
+ remaining_size = Size;
+ data = (unsigned char* )(Data);
+
+#if !defined(UTF16_BE) && !defined(UTF16_LE)
+ encoding_choice = data[0];
+#endif
+
data++;
remaining_size--;
str_null_end = str + remaining_size;
int r;
- OnigEncodingType *encodings[] = {
- ONIG_ENCODING_SJIS,
- ONIG_ENCODING_EUC_JP,
- ONIG_ENCODING_CP1251,
- ONIG_ENCODING_ISO_8859_1,
- ONIG_ENCODING_UTF8,
- ONIG_ENCODING_KOI8_R,
- ONIG_ENCODING_BIG5
- };
-
OnigEncodingType *enc;
#ifdef UTF16_BE