📄 regenc.c
字号:
int c, i, len; OnigCodePoint n; len = enc_len(enc, p); n = (OnigCodePoint )(*p++); if (len == 1) return n; for (i = 1; i < len; i++) { if (p >= end) break; c = *p++; n <<= 8; n += c; } return n;}extern intonigenc_mbn_mbc_to_normalize(OnigEncoding enc, OnigAmbigType flag, const UChar** pp, const UChar* end, UChar* lower){ int len; const UChar *p = *pp; if (ONIGENC_IS_MBC_ASCII(p)) { if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p); } else { *lower = *p; } (*pp)++; return 1; } else { len = enc_len(enc, p); if (lower != p) { int i; for (i = 0; i < len; i++) { *lower++ = *p++; } } (*pp) += len; return len; /* return byte length of converted to lower char */ }}extern intonigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigAmbigType flag, const UChar** pp, const UChar* end){ const UChar* p = *pp; if (ONIGENC_IS_MBC_ASCII(p)) { (*pp)++; if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p); } else { return FALSE; } } (*pp) += enc_len(enc, p); return FALSE;}extern intonigenc_mb2_code_to_mbclen(OnigCodePoint code){ if ((code & 0xff00) != 0) return 2; else return 1;}extern intonigenc_mb4_code_to_mbclen(OnigCodePoint code){ if ((code & 0xff000000) != 0) return 4; else if ((code & 0xff0000) != 0) return 3; else if ((code & 0xff00) != 0) return 2; else return 1;}extern intonigenc_mb2_code_to_mbc_first(OnigCodePoint code){ int first; if ((code & 0xff00) != 0) { first = (code >> 8) & 0xff; } else { return (int )code; } return first;}extern intonigenc_mb4_code_to_mbc_first(OnigCodePoint code){ int first; if ((code & 0xff000000) != 0) { first = (code >> 24) & 0xff; } else if ((code & 0xff0000) != 0) { first = (code >> 16) & 0xff; } else if ((code & 0xff00) != 0) { first = (code >> 8) & 0xff; } else { return (int )code; } return first;}extern intonigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf){ UChar *p = buf; if ((code & 0xff00) != 0) { *p++ = (UChar )((code >> 8) & 0xff); } *p++ = (UChar )(code & 0xff);#if 1 if (enc_len(enc, buf) != (p - buf)) return ONIGENCERR_INVALID_WIDE_CHAR_VALUE;#endif return p - buf;}extern intonigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf){ UChar *p = buf; if ((code & 0xff000000) != 0) { *p++ = (UChar )((code >> 24) & 0xff); } if ((code & 0xff0000) != 0) { *p++ = (UChar )((code >> 16) & 0xff); } if ((code & 0xff00) != 0) { *p++ = (UChar )((code >> 8) & 0xff); } *p++ = (UChar )(code & 0xff);#if 1 if (enc_len(enc, buf) != (p - buf)) return ONIGENCERR_INVALID_WIDE_CHAR_VALUE;#endif return p - buf;}extern intonigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code, unsigned int ctype){ if ((ctype & ONIGENC_CTYPE_WORD) != 0) { if (code < 128) return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); else return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE); ctype &= ~ONIGENC_CTYPE_WORD; if (ctype == 0) return FALSE; } if (code < 128) return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); else return FALSE;}extern intonigenc_mb4_is_code_ctype(OnigEncoding enc, OnigCodePoint code, unsigned int ctype){ if ((ctype & ONIGENC_CTYPE_WORD) != 0) { if (code < 128) return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); else return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE); ctype &= ~ONIGENC_CTYPE_WORD; if (ctype == 0) return FALSE; } if (code < 128) return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype); else return FALSE;}extern intonigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n){ int x, c; while (n-- > 0) { if (p >= end) return (int )(*sascii); c = (int )ONIGENC_MBC_TO_CODE(enc, p, end); x = *sascii - c; if (x) return x; sascii++; p += enc_len(enc, p); } return 0;}#else /* ONIG_RUBY_M17N */extern intonigenc_is_code_ctype(OnigEncoding enc, OnigCodePoint code, int ctype){ switch (ctype) { case ONIGENC_CTYPE_NEWLINE: if (code == 0x0a) return 1; break; case ONIGENC_CTYPE_ALPHA: return m17n_isalpha(enc, code); break; case ONIGENC_CTYPE_BLANK: return ONIGENC_IS_CODE_BLANK(enc, (int )(code)); break; case ONIGENC_CTYPE_CNTRL: return m17n_iscntrl(enc, code); break; case ONIGENC_CTYPE_DIGIT: return m17n_isdigit(enc, code); break; case ONIGENC_CTYPE_GRAPH: return ONIGENC_IS_CODE_GRAPH(enc, (int )(code)); break; case ONIGENC_CTYPE_LOWER: return m17n_islower(enc, code); break; case ONIGENC_CTYPE_PRINT: return m17n_isprint(enc, code); break; case ONIGENC_CTYPE_PUNCT: return m17n_ispunct(enc, code); break; case ONIGENC_CTYPE_SPACE: return m17n_isspace(enc, code); break; case ONIGENC_CTYPE_UPPER: return m17n_isupper(enc, code); break; case ONIGENC_CTYPE_XDIGIT: return m17n_isxdigit(enc, code); break; case ONIGENC_CTYPE_WORD: return m17n_iswchar(enc, code); break; case ONIGENC_CTYPE_ASCII: return (code < 128 ? TRUE : FALSE); break; case ONIGENC_CTYPE_ALNUM: return m17n_isalnum(enc, code); break; default: break; } return 0;}extern intonigenc_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf){ int c, len; m17n_mbcput(enc, code, buf); c = m17n_firstbyte(enc, code); len = enc_len(enc, c); return len;}extern intonigenc_mbc_to_lower(OnigEncoding enc, UChar* p, UChar* buf){ unsigned int c, low; c = m17n_codepoint(enc, p, p + enc_len(enc, *p)); low = m17n_tolower(enc, c); m17n_mbcput(enc, low, buf); return m17n_codelen(enc, low);}extern intonigenc_is_mbc_ambiguous(OnigEncoding enc, OnigAmbigType flag, UChar** pp, UChar* end){ int len; unsigned int c; UChar* p = *pp; len = enc_len(enc, *p); (*pp) += len; c = m17n_codepoint(enc, p, p + len); if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) { if (m17n_isupper(enc, c) || m17n_islower(enc, c)) return TRUE; } return FALSE;}extern UChar*onigenc_get_left_adjust_char_head(OnigEncoding enc, UChar* start, UChar* s){ UChar *p; int len; if (s <= start) return s; p = s; while (!m17n_islead(enc, *p) && p > start) p--; while (p + (len = enc_len(enc, *p)) < s) { p += len; } if (p + len == s) return s; return p;}extern intonigenc_is_allowed_reverse_match(OnigEncoding enc, const UChar* s, const UChar* end){ return ONIGENC_IS_SINGLEBYTE(enc);}extern voidonigenc_set_default_caseconv_table(UChar* table) { }#endif /* ONIG_RUBY_M17N */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -