Changeset 331 for EcnlProtoTool/trunk/onigmo-6.1.3/src/regenc.h
- Timestamp:
- Jan 21, 2018, 12:10:09 AM (6 years ago)
- Location:
- EcnlProtoTool/trunk/onigmo-6.1.3
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
EcnlProtoTool/trunk/onigmo-6.1.3/src/regenc.h
r321 r331 1 #ifndef REGENC_H2 #define REGENC_H1 #ifndef ONIGMO_REGENC_H 2 #define ONIGMO_REGENC_H 3 3 /********************************************************************** 4 4 regenc.h - Onigmo (Oniguruma-mod) (regular expression library) … … 6 6 /*- 7 7 * Copyright (c) 2002-2008 K.Kosako <sndgk393 AT ybb DOT ne DOT jp> 8 * Copyright (c) 2011 8 * Copyright (c) 2011-2016 K.Takata <kentkt AT csc DOT jp> 9 9 * All rights reserved. 10 10 * … … 31 31 */ 32 32 33 #ifndef PACKAGE 33 #if !defined(RUBY) && (defined(RUBY_EXPORT) || defined(ONIG_ENC_REGISTER)) 34 # define RUBY 35 #endif 36 #ifdef RUBY 37 # ifndef ONIGMO_REGINT_H 38 # ifndef RUBY_EXTERN 39 # include "ruby/config.h" 40 # include "ruby/defines.h" 41 # endif 42 # endif 43 #else /* RUBY */ 44 # ifndef PACKAGE 34 45 /* PACKAGE is defined in config.h */ 35 #include "config.h" 36 #endif 46 # include "config.h" 47 # endif 48 #endif /* RUBY */ 37 49 38 50 #ifdef ONIG_ESCAPE_UCHAR_COLLISION 39 #undef ONIG_ESCAPE_UCHAR_COLLISION 40 #endif 41 42 #include "oniguruma.h" 51 # undef ONIG_ESCAPE_UCHAR_COLLISION 52 #endif 53 54 #ifdef RUBY 55 # include "ruby/onigmo.h" 56 #else 57 # include "onigmo.h" 58 #endif 59 60 RUBY_SYMBOL_EXPORT_BEGIN 43 61 44 62 typedef struct { … … 49 67 50 68 #ifndef NULL 51 # define NULL ((void* )0)69 # define NULL ((void* )0) 52 70 #endif 53 71 54 72 #ifndef TRUE 55 # define TRUE 173 # define TRUE 1 56 74 #endif 57 75 58 76 #ifndef FALSE 59 # define FALSE 077 # define FALSE 0 60 78 #endif 61 79 62 80 #ifndef ARG_UNUSED 63 # if defined(__GNUC__)81 # if defined(__GNUC__) 64 82 # define ARG_UNUSED __attribute__ ((unused)) 65 # else83 # else 66 84 # define ARG_UNUSED 67 # endif85 # endif 68 86 #endif 69 87 … … 73 91 #define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val) 74 92 75 #define enclen(enc,p ) ONIGENC_MBC_ENC_LEN(enc,p)93 #define enclen(enc,p,e) ((enc->max_enc_len == enc->min_enc_len) ? enc->min_enc_len : ONIGENC_MBC_ENC_LEN(enc,p,e)) 76 94 77 95 /* character types bit flag */ … … 99 117 100 118 typedef struct { 101 const UChar *name; 119 short int len; 120 const UChar name[6]; 102 121 int ctype; 103 short int len;104 122 } PosixBracketEntryType; 105 123 106 124 #define POSIX_BRACKET_ENTRY_INIT(name, ctype) \ 107 {( const UChar* )(name), (ctype), (short int )(sizeof(name) - 1)}125 {(short int )(sizeof(name) - 1), (name), (ctype)} 108 126 109 127 #ifndef numberof 110 # define numberof(array) (int )(sizeof(array) / sizeof((array)[0]))128 # define numberof(array) (int )(sizeof(array) / sizeof((array)[0])) 111 129 #endif 112 130 … … 119 137 120 138 121 #define ONIG_ENCODING_INIT_DEFAULT ONIG_ENCODING_ UTF8139 #define ONIG_ENCODING_INIT_DEFAULT ONIG_ENCODING_ASCII 122 140 123 141 /* for encoding system implementation (internal) */ 124 ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg)); 125 ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])); 126 ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg)); 127 ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[])); 128 ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[])); 129 ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end)); 142 ONIG_EXTERN int onigenc_ascii_apply_all_case_fold(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc); 143 ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str(OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[], OnigEncoding enc); 144 ONIG_EXTERN int onigenc_apply_all_case_fold_with_map(int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg); 145 ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map(int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]); 146 ONIG_EXTERN int onigenc_not_support_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], OnigEncoding enc); 147 ONIG_EXTERN int onigenc_is_mbc_newline_0x0a(const UChar* p, const UChar* end, OnigEncoding enc); 148 ONIG_EXTERN int onigenc_single_byte_ascii_only_case_map(OnigCaseFoldType* flagP, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to, OnigUChar* to_end, const struct OnigEncodingTypeST* enc); 130 149 131 150 132 151 /* methods for single byte encoding */ 133 ONIG_EXTERN int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));134 ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p));135 ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end));136 ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code));137 ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf));138 ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s));139 ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end));140 ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end));141 ONIG_EXTERN int onigenc_ascii_is_code_ctype P_((OnigCodePoint code, unsigned int ctype));152 ONIG_EXTERN int onigenc_ascii_mbc_case_fold(OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower, OnigEncoding enc); 153 ONIG_EXTERN int onigenc_single_byte_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc); 154 ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code(const UChar* p, const UChar* end, OnigEncoding enc); 155 ONIG_EXTERN int onigenc_single_byte_code_to_mbclen(OnigCodePoint code, OnigEncoding enc); 156 ONIG_EXTERN int onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf, OnigEncoding enc); 157 ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head(const UChar* start, const UChar* s, const OnigUChar* end, OnigEncoding enc); 158 ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match(const UChar* s, const UChar* end, OnigEncoding enc); 159 ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match(const UChar* s, const UChar* end, OnigEncoding enc); 160 ONIG_EXTERN int onigenc_ascii_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc); 142 161 143 162 /* methods for multi byte encoding */ 144 ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end)); 145 ONIG_EXTERN int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower)); 146 ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code)); 147 ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf)); 148 ONIG_EXTERN int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end)); 149 ONIG_EXTERN int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end)); 150 ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype)); 151 ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code)); 152 ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf)); 153 ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype)); 163 ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end); 164 ONIG_EXTERN int onigenc_mbn_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower); 165 ONIG_EXTERN int onigenc_mb2_code_to_mbclen(OnigCodePoint code, OnigEncoding enc); 166 ONIG_EXTERN int onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf); 167 ONIG_EXTERN int onigenc_minimum_property_name_to_ctype(OnigEncoding enc, const UChar* p, const UChar* end); 168 ONIG_EXTERN int onigenc_unicode_property_name_to_ctype(OnigEncoding enc, const UChar* p, const UChar* end); 169 ONIG_EXTERN int onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code, unsigned int ctype); 170 ONIG_EXTERN int onigenc_mb4_code_to_mbclen(OnigCodePoint code, OnigEncoding enc); 171 ONIG_EXTERN int onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf); 172 ONIG_EXTERN int onigenc_mb4_is_code_ctype(OnigEncoding enc, OnigCodePoint code, unsigned int ctype); 173 174 ONIG_EXTERN int onigenc_unicode_case_map(OnigCaseFoldType* flagP, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to, OnigUChar* to_end, const struct OnigEncodingTypeST* enc); 154 175 155 176 156 177 /* in enc/unicode.c */ 157 ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype));158 ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[]));159 ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));160 ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));161 ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));162 ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));178 ONIG_EXTERN int onigenc_unicode_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc); 179 ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range(OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[], OnigEncoding enc); 180 ONIG_EXTERN int onigenc_unicode_ctype_code_range(int ctype, const OnigCodePoint* ranges[]); 181 ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str(OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]); 182 ONIG_EXTERN int onigenc_unicode_mbc_case_fold(OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold); 183 ONIG_EXTERN int onigenc_unicode_apply_all_case_fold(OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc); 163 184 164 185 165 186 #define UTF16_IS_SURROGATE_FIRST(c) (((c) & 0xfc) == 0xd8) 166 187 #define UTF16_IS_SURROGATE_SECOND(c) (((c) & 0xfc) == 0xdc) 188 #define UTF16_IS_SURROGATE(c) (((c) & 0xf8) == 0xd8) 189 #define UNICODE_VALID_CODEPOINT_P(c) ( \ 190 ((c) <= 0x10ffff) && \ 191 !((c) < 0x10000 && UTF16_IS_SURROGATE((c) >> 8))) 167 192 168 193 #define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \ … … 175 200 176 201 ONIG_EXTERN int 177 onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));202 onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n); 178 203 ONIG_EXTERN int 179 onigenc_with_ascii_strnicmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));204 onigenc_with_ascii_strnicmp(OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n); 180 205 ONIG_EXTERN UChar* 181 onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));206 onigenc_step(OnigEncoding enc, const UChar* p, const UChar* end, int n); 182 207 183 208 /* defined in regexec.c, but used in enc/xxx.c */ 184 extern int onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));209 extern int onig_is_in_code_range(const UChar* p, OnigCodePoint code); 185 210 186 211 ONIG_EXTERN OnigEncoding OnigEncDefaultCharEncoding; … … 203 228 204 229 205 #endif /* REGENC_H */ 230 #ifdef ONIG_ENC_REGISTER 231 extern int ONIG_ENC_REGISTER(const char *, OnigEncoding); 232 # define OnigEncodingName(n) encoding_##n 233 # define OnigEncodingDeclare(n) static const OnigEncodingType OnigEncodingName(n) 234 # define OnigEncodingDefine(f,n) \ 235 OnigEncodingDeclare(n); \ 236 void Init_##f(void) { \ 237 ONIG_ENC_REGISTER(OnigEncodingName(n).name, \ 238 &OnigEncodingName(n)); \ 239 } \ 240 OnigEncodingDeclare(n) 241 #else 242 # define OnigEncodingName(n) OnigEncoding##n 243 # define OnigEncodingDeclare(n) const OnigEncodingType OnigEncodingName(n) 244 # define OnigEncodingDefine(f,n) OnigEncodingDeclare(n) 245 #endif 246 247 /* macros for define replica encoding and encoding alias */ 248 #define ENC_REPLICATE(name, orig) 249 #define ENC_ALIAS(name, orig) 250 #define ENC_DUMMY(name) 251 252 RUBY_SYMBOL_EXPORT_END 253 254 #endif /* ONIGMO_REGENC_H */
Note:
See TracChangeset
for help on using the changeset viewer.