extern int onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s) { UChar* start = (UChar* )s; UChar* p = (UChar* )s; UChar* e; while (1) { if (*p == '\0') { UChar* q; int len = ONIGENC_MBC_MINLEN(enc); if (len == 1) return (int )(p - start); q = p + 1; while (len > 1) { if (*q != '\0') break; q++; len--; } if (len == 1) return (int )(p - start); } e = p + ONIGENC_MBC_MAXLEN(enc); p += ONIGENC_MBC_ENC_LEN(enc, p, e); } }
extern int re_adjust_startpos(regex_t* reg, const char* string, int size, int startpos, int range) { if (startpos > 0 && ONIGENC_MBC_MAXLEN(reg->enc) != 1 && startpos < size) { UChar *p; UChar *s = (UChar* )string + startpos; if (range > 0) { p = onigenc_get_right_adjust_char_head(reg->enc, (UChar* )string, s); } else { p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(reg->enc, (UChar* )string, s); } return p - (UChar* )string; } return startpos; }