00001 #ifndef ONIGURUMA_REGENC_H
00002 #define ONIGURUMA_REGENC_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef REGINT_H
00033 #ifndef RUBY_EXTERN
00034 #include "ruby/config.h"
00035 #include "ruby/defines.h"
00036 #endif
00037 #ifdef ONIG_ESCAPE_UCHAR_COLLISION
00038 #undef ONIG_ESCAPE_UCHAR_COLLISION
00039 #endif
00040 #endif
00041 #include "ruby/oniguruma.h"
00042
00043 RUBY_SYMBOL_EXPORT_BEGIN
00044
00045 typedef struct {
00046 OnigCodePoint from;
00047 OnigCodePoint to;
00048 } OnigPairCaseFoldCodes;
00049
00050
00051 #ifndef NULL
00052 #define NULL ((void* )0)
00053 #endif
00054
00055 #ifndef TRUE
00056 #define TRUE 1
00057 #endif
00058
00059 #ifndef FALSE
00060 #define FALSE 0
00061 #endif
00062
00063 #ifndef ARG_UNUSED
00064 #if defined(__GNUC__)
00065 # define ARG_UNUSED __attribute__ ((unused))
00066 #else
00067 # define ARG_UNUSED
00068 #endif
00069 #endif
00070
00071 #define ONIG_IS_NULL(p) (((void*)(p)) == (void*)0)
00072 #define ONIG_IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
00073 #define ONIG_CHECK_NULL_RETURN(p) if (ONIG_IS_NULL(p)) return NULL
00074 #define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val)
00075
00076 #define enclen(enc,p,e) ((enc->max_enc_len == enc->min_enc_len) ? enc->min_enc_len : ONIGENC_MBC_ENC_LEN(enc,p,e))
00077
00078
00079 #define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE)
00080 #define BIT_CTYPE_ALPHA (1<< ONIGENC_CTYPE_ALPHA)
00081 #define BIT_CTYPE_BLANK (1<< ONIGENC_CTYPE_BLANK)
00082 #define BIT_CTYPE_CNTRL (1<< ONIGENC_CTYPE_CNTRL)
00083 #define BIT_CTYPE_DIGIT (1<< ONIGENC_CTYPE_DIGIT)
00084 #define BIT_CTYPE_GRAPH (1<< ONIGENC_CTYPE_GRAPH)
00085 #define BIT_CTYPE_LOWER (1<< ONIGENC_CTYPE_LOWER)
00086 #define BIT_CTYPE_PRINT (1<< ONIGENC_CTYPE_PRINT)
00087 #define BIT_CTYPE_PUNCT (1<< ONIGENC_CTYPE_PUNCT)
00088 #define BIT_CTYPE_SPACE (1<< ONIGENC_CTYPE_SPACE)
00089 #define BIT_CTYPE_UPPER (1<< ONIGENC_CTYPE_UPPER)
00090 #define BIT_CTYPE_XDIGIT (1<< ONIGENC_CTYPE_XDIGIT)
00091 #define BIT_CTYPE_WORD (1<< ONIGENC_CTYPE_WORD)
00092 #define BIT_CTYPE_ALNUM (1<< ONIGENC_CTYPE_ALNUM)
00093 #define BIT_CTYPE_ASCII (1<< ONIGENC_CTYPE_ASCII)
00094
00095 #define CTYPE_TO_BIT(ctype) (1<<(ctype))
00096 #define CTYPE_IS_WORD_GRAPH_PRINT(ctype) \
00097 ((ctype) == ONIGENC_CTYPE_WORD || (ctype) == ONIGENC_CTYPE_GRAPH ||\
00098 (ctype) == ONIGENC_CTYPE_PRINT)
00099
00100
00101 typedef struct {
00102 const UChar *name;
00103 int ctype;
00104 short int len;
00105 } PosixBracketEntryType;
00106
00107 #define PosixBracketEntryInit(name, ctype) {(const UChar *)name, ctype, (short int)(sizeof(name) - 1)}
00108
00109 #define USE_CRNL_AS_LINE_TERMINATOR
00110 #define USE_UNICODE_PROPERTIES
00111
00112
00113
00114
00115 #define ONIG_ENCODING_INIT_DEFAULT ONIG_ENCODING_ASCII
00116
00117
00118 ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
00119 ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[], OnigEncoding enc));
00120 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));
00121 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[]));
00122 ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], OnigEncoding enc));
00123 ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end, OnigEncoding enc));
00124
00125
00126
00127 ONIG_EXTERN int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower, OnigEncoding enc));
00128 ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p, const UChar* e, OnigEncoding enc));
00129 ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end, OnigEncoding enc));
00130 ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc));
00131 ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf, OnigEncoding enc));
00132 ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s, const OnigUChar* end, OnigEncoding enc));
00133 ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end, OnigEncoding enc));
00134 ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end, OnigEncoding enc));
00135 ONIG_EXTERN int onigenc_ascii_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
00136
00137
00138 ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end));
00139 ONIG_EXTERN int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));
00140 ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc));
00141 ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
00142 ONIG_EXTERN int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));
00143 ONIG_EXTERN int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));
00144 ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
00145 ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc));
00146 ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
00147 ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
00148
00149
00150
00151 ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
00152 ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[], OnigEncoding enc));
00153 ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));
00154 ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
00155 ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));
00156 ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
00157
00158
00159 #define UTF16_IS_SURROGATE_FIRST(c) (((c) & 0xfc) == 0xd8)
00160 #define UTF16_IS_SURROGATE_SECOND(c) (((c) & 0xfc) == 0xdc)
00161
00162 #define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
00163 OnigEncISO_8859_1_ToLowerCaseTable[c]
00164 #define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
00165 OnigEncISO_8859_1_ToUpperCaseTable[c]
00166
00167 ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[];
00168 ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[];
00169
00170 ONIG_EXTERN int
00171 onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii , int n));
00172 ONIG_EXTERN int
00173 onigenc_with_ascii_strnicmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii , int n));
00174 ONIG_EXTERN UChar*
00175 onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));
00176
00177
00178 extern int onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));
00179
00180 ONIG_EXTERN OnigEncoding OnigEncDefaultCharEncoding;
00181 ONIG_EXTERN const UChar OnigEncAsciiToLowerCaseTable[];
00182 ONIG_EXTERN const UChar OnigEncAsciiToUpperCaseTable[];
00183 ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
00184
00185 #define ONIGENC_IS_ASCII_CODE(code) ((code) < 0x80)
00186 #define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c]
00187 #define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c]
00188 #define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \
00189 ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
00190 #define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \
00191 (ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\
00192 ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER))
00193
00194
00195 #define ONIGENC_IS_IN_RANGE(code, from, to) \
00196 ((OnigCodePoint )((code) - (from)) <= (OnigCodePoint )((to) - (from)))
00197
00198
00199 #ifdef ONIG_ENC_REGISTER
00200 extern int ONIG_ENC_REGISTER(const char *, OnigEncodingType*);
00201 #define OnigEncodingName(n) encoding_##n
00202 #define OnigEncodingDeclare(n) static OnigEncodingType OnigEncodingName(n)
00203 #define OnigEncodingDefine(f,n) \
00204 OnigEncodingDeclare(n); \
00205 void Init_##f(void) { \
00206 ONIG_ENC_REGISTER(OnigEncodingName(n).name, \
00207 &OnigEncodingName(n)); \
00208 } \
00209 OnigEncodingDeclare(n)
00210 #else
00211 #define OnigEncodingName(n) OnigEncoding##n
00212 #define OnigEncodingDeclare(n) OnigEncodingType OnigEncodingName(n)
00213 #define OnigEncodingDefine(f,n) OnigEncodingDeclare(n)
00214 #endif
00215
00216
00217 #define ENC_REPLICATE(name, orig)
00218 #define ENC_ALIAS(name, orig)
00219 #define ENC_DUMMY(name)
00220
00221 RUBY_SYMBOL_EXPORT_END
00222
00223 #endif
00224