Back to index

php5  5.3.10
regenc.c
Go to the documentation of this file.
00001 /**********************************************************************
00002   regenc.c -  Oniguruma (regular expression library)
00003 **********************************************************************/
00004 /*-
00005  * Copyright (c) 2002-2007  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  * 1. Redistributions of source code must retain the above copyright
00012  *    notice, this list of conditions and the following disclaimer.
00013  * 2. Redistributions in binary form must reproduce the above copyright
00014  *    notice, this list of conditions and the following disclaimer in the
00015  *    documentation and/or other materials provided with the distribution.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  */
00029 
00030 #include "regint.h"
00031 
00032 OnigEncoding OnigEncDefaultCharEncoding = ONIG_ENCODING_INIT_DEFAULT;
00033 
00034 extern int
00035 onigenc_init(void)
00036 {
00037   return 0;
00038 }
00039 
00040 extern OnigEncoding
00041 onigenc_get_default_encoding(void)
00042 {
00043   return OnigEncDefaultCharEncoding;
00044 }
00045 
00046 extern int
00047 onigenc_set_default_encoding(OnigEncoding enc)
00048 {
00049   OnigEncDefaultCharEncoding = enc;
00050   return 0;
00051 }
00052 
00053 extern UChar*
00054 onigenc_get_right_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
00055 {
00056   UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
00057   if (p < s) {
00058     p += enc_len(enc, p);
00059   }
00060   return p;
00061 }
00062 
00063 extern UChar*
00064 onigenc_get_right_adjust_char_head_with_prev(OnigEncoding enc,
00065                                const UChar* start, const UChar* s, const UChar** prev)
00066 {
00067   UChar* p = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
00068 
00069   if (p < s) {
00070     if (prev) *prev = (const UChar* )p;
00071     p += enc_len(enc, p);
00072   }
00073   else {
00074     if (prev) *prev = (const UChar* )NULL; /* Sorry */
00075   }
00076   return p;
00077 }
00078 
00079 extern UChar*
00080 onigenc_get_prev_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
00081 {
00082   if (s <= start)
00083     return (UChar* )NULL;
00084 
00085   return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1);
00086 }
00087 
00088 extern UChar*
00089 onigenc_step_back(OnigEncoding enc, const UChar* start, const UChar* s, int n)
00090 {
00091   while (ONIG_IS_NOT_NULL(s) && n-- > 0) {
00092     if (s <= start)
00093       return (UChar* )NULL;
00094 
00095     s = ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s - 1);
00096   }
00097   return (UChar* )s;
00098 }
00099 
00100 extern UChar*
00101 onigenc_step(OnigEncoding enc, const UChar* p, const UChar* end, int n)
00102 {
00103   UChar* q = (UChar* )p;
00104   while (n-- > 0) {
00105     q += ONIGENC_MBC_ENC_LEN(enc, q);
00106   }
00107   return (q <= end ? q : NULL);
00108 }
00109 
00110 extern int
00111 onigenc_strlen(OnigEncoding enc, const UChar* p, const UChar* end)
00112 {
00113   int n = 0;
00114   UChar* q = (UChar* )p;
00115   
00116   while (q < end) {
00117     q += ONIGENC_MBC_ENC_LEN(enc, q);
00118     n++;
00119   }
00120   return n;
00121 }
00122 
00123 extern int
00124 onigenc_strlen_null(OnigEncoding enc, const UChar* s)
00125 {
00126   int n = 0;
00127   UChar* p = (UChar* )s;
00128   
00129   while (1) {
00130     if (*p == '\0') {
00131       UChar* q;
00132       int len = ONIGENC_MBC_MINLEN(enc);
00133 
00134       if (len == 1) return n;
00135       q = p + 1;
00136       while (len > 1) {
00137         if (*q != '\0') break;
00138         q++;
00139         len--;
00140       }
00141       if (len == 1) return n;
00142     }
00143     p += ONIGENC_MBC_ENC_LEN(enc, p);
00144     n++;
00145   }
00146 }
00147 
00148 extern int
00149 onigenc_str_bytelen_null(OnigEncoding enc, const UChar* s)
00150 {
00151   UChar* start = (UChar* )s;
00152   UChar* p = (UChar* )s;
00153 
00154   while (1) {
00155     if (*p == '\0') {
00156       UChar* q;
00157       int len = ONIGENC_MBC_MINLEN(enc);
00158 
00159       if (len == 1) return (int )(p - start);
00160       q = p + 1;
00161       while (len > 1) {
00162         if (*q != '\0') break;
00163         q++;
00164         len--;
00165       }
00166       if (len == 1) return (int )(p - start);
00167     }
00168     p += ONIGENC_MBC_ENC_LEN(enc, p);
00169   }
00170 }
00171 
00172 #ifndef ONIG_RUBY_M17N
00173 
00174 #ifndef NOT_RUBY
00175 
00176 #define USE_APPLICATION_TO_LOWER_CASE_TABLE
00177 
00178 const unsigned short OnigEnc_Unicode_ISO_8859_1_CtypeTable[256] = {
00179   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
00180   0x2008, 0x228c, 0x2289, 0x2288, 0x2288, 0x2288, 0x2008, 0x2008,
00181   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
00182   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
00183   0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0,
00184   0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0,
00185   0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0,
00186   0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0,
00187   0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2,
00188   0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
00189   0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
00190   0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0,
00191   0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2,
00192   0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
00193   0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
00194   0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008,
00195   0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0288, 0x0008, 0x0008,
00196   0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
00197   0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
00198   0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008, 0x0008,
00199   0x0284, 0x01a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0, 0x00a0,
00200   0x00a0, 0x00a0, 0x10e2, 0x01a0, 0x00a0, 0x00a8, 0x00a0, 0x00a0,
00201   0x00a0, 0x00a0, 0x10a0, 0x10a0, 0x00a0, 0x10e2, 0x00a0, 0x01a0,
00202   0x00a0, 0x10a0, 0x10e2, 0x01a0, 0x10a0, 0x10a0, 0x10a0, 0x01a0,
00203   0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2,
00204   0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2,
00205   0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x00a0,
00206   0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x14a2, 0x10e2,
00207   0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2,
00208   0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2,
00209   0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x00a0,
00210   0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2, 0x10e2
00211 };
00212 #endif
00213 
00214 const UChar* OnigEncAsciiToLowerCaseTable = (const UChar* )0;
00215 
00216 #ifndef USE_APPLICATION_TO_LOWER_CASE_TABLE
00217 static const UChar BuiltInAsciiToLowerCaseTable[] = {
00218   '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
00219   '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
00220   '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
00221   '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
00222   '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
00223   '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
00224   '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
00225   '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
00226   '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
00227   '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
00228   '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
00229   '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
00230   '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
00231   '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
00232   '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
00233   '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
00234   '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
00235   '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
00236   '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
00237   '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
00238   '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
00239   '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
00240   '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
00241   '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
00242   '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
00243   '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
00244   '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
00245   '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
00246   '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
00247   '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
00248   '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
00249   '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
00250 };
00251 #endif /* not USE_APPLICATION_TO_LOWER_CASE_TABLE */
00252 
00253 #ifdef USE_UPPER_CASE_TABLE
00254 const UChar OnigEncAsciiToUpperCaseTable[256] = {
00255   '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
00256   '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
00257   '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
00258   '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
00259   '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
00260   '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
00261   '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
00262   '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
00263   '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
00264   '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
00265   '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
00266   '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
00267   '\140', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
00268   '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
00269   '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
00270   '\130', '\131', '\132', '\173', '\174', '\175', '\176', '\177',
00271   '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
00272   '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
00273   '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
00274   '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
00275   '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
00276   '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
00277   '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
00278   '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
00279   '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
00280   '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
00281   '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
00282   '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
00283   '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
00284   '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
00285   '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
00286   '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
00287 };
00288 #endif
00289 
00290 const unsigned short OnigEncAsciiCtypeTable[256] = {
00291   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
00292   0x2008, 0x220c, 0x2209, 0x2208, 0x2208, 0x2208, 0x2008, 0x2008,
00293   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
00294   0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008, 0x2008,
00295   0x2284, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0,
00296   0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0,
00297   0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0, 0x38b0,
00298   0x38b0, 0x38b0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x21a0,
00299   0x21a0, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x3ca2, 0x34a2,
00300   0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
00301   0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2, 0x34a2,
00302   0x34a2, 0x34a2, 0x34a2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x31a0,
00303   0x21a0, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x38e2, 0x30e2,
00304   0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
00305   0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2, 0x30e2,
00306   0x30e2, 0x30e2, 0x30e2, 0x21a0, 0x21a0, 0x21a0, 0x21a0, 0x2008,
00307 
00308   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00309   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00310   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00311   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00312   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00313   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00314   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00315   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00316   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00317   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00318   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00319   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00320   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00321   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00322   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
00323   0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
00324 };
00325 
00326 const UChar OnigEncISO_8859_1_ToLowerCaseTable[256] = {
00327   '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
00328   '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
00329   '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
00330   '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
00331   '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
00332   '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
00333   '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
00334   '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
00335   '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
00336   '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
00337   '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
00338   '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
00339   '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
00340   '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
00341   '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
00342   '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
00343   '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
00344   '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
00345   '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
00346   '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
00347   '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
00348   '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
00349   '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
00350   '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
00351   '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
00352   '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
00353   '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327',
00354   '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337',
00355   '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
00356   '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
00357   '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
00358   '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377'
00359 };
00360 
00361 #ifdef USE_UPPER_CASE_TABLE
00362 const UChar OnigEncISO_8859_1_ToUpperCaseTable[256] = {
00363   '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
00364   '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
00365   '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
00366   '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
00367   '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
00368   '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
00369   '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
00370   '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
00371   '\100', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
00372   '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
00373   '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
00374   '\130', '\131', '\132', '\133', '\134', '\135', '\136', '\137',
00375   '\140', '\101', '\102', '\103', '\104', '\105', '\106', '\107',
00376   '\110', '\111', '\112', '\113', '\114', '\115', '\116', '\117',
00377   '\120', '\121', '\122', '\123', '\124', '\125', '\126', '\127',
00378   '\130', '\131', '\132', '\173', '\174', '\175', '\176', '\177',
00379   '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
00380   '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
00381   '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
00382   '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
00383   '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
00384   '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
00385   '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
00386   '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
00387   '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
00388   '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
00389   '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327',
00390   '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337',
00391   '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307',
00392   '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317',
00393   '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\367',
00394   '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\377',
00395 };
00396 #endif
00397 
00398 extern void
00399 onigenc_set_default_caseconv_table(const UChar* table)
00400 {
00401   if (table == (const UChar* )0) {
00402 #ifndef USE_APPLICATION_TO_LOWER_CASE_TABLE
00403     table = BuiltInAsciiToLowerCaseTable;
00404 #else
00405     return ;
00406 #endif
00407   }
00408 
00409   if (table != OnigEncAsciiToLowerCaseTable) {
00410     OnigEncAsciiToLowerCaseTable = table;
00411   }
00412 }
00413 
00414 extern UChar*
00415 onigenc_get_left_adjust_char_head(OnigEncoding enc, const UChar* start, const UChar* s)
00416 {
00417   return ONIGENC_LEFT_ADJUST_CHAR_HEAD(enc, start, s);
00418 }
00419 
00420 const OnigPairAmbigCodes OnigAsciiPairAmbigCodes[] = {
00421   { 0x41, 0x61 },
00422   { 0x42, 0x62 },
00423   { 0x43, 0x63 },
00424   { 0x44, 0x64 },
00425   { 0x45, 0x65 },
00426   { 0x46, 0x66 },
00427   { 0x47, 0x67 },
00428   { 0x48, 0x68 },
00429   { 0x49, 0x69 },
00430   { 0x4a, 0x6a },
00431   { 0x4b, 0x6b },
00432   { 0x4c, 0x6c },
00433   { 0x4d, 0x6d },
00434   { 0x4e, 0x6e },
00435   { 0x4f, 0x6f },
00436   { 0x50, 0x70 },
00437   { 0x51, 0x71 },
00438   { 0x52, 0x72 },
00439   { 0x53, 0x73 },
00440   { 0x54, 0x74 },
00441   { 0x55, 0x75 },
00442   { 0x56, 0x76 },
00443   { 0x57, 0x77 },
00444   { 0x58, 0x78 },
00445   { 0x59, 0x79 },
00446   { 0x5a, 0x7a },
00447 
00448   { 0x61, 0x41 },
00449   { 0x62, 0x42 },
00450   { 0x63, 0x43 },
00451   { 0x64, 0x44 },
00452   { 0x65, 0x45 },
00453   { 0x66, 0x46 },
00454   { 0x67, 0x47 },
00455   { 0x68, 0x48 },
00456   { 0x69, 0x49 },
00457   { 0x6a, 0x4a },
00458   { 0x6b, 0x4b },
00459   { 0x6c, 0x4c },
00460   { 0x6d, 0x4d },
00461   { 0x6e, 0x4e },
00462   { 0x6f, 0x4f },
00463   { 0x70, 0x50 },
00464   { 0x71, 0x51 },
00465   { 0x72, 0x52 },
00466   { 0x73, 0x53 },
00467   { 0x74, 0x54 },
00468   { 0x75, 0x55 },
00469   { 0x76, 0x56 },
00470   { 0x77, 0x57 },
00471   { 0x78, 0x58 },
00472   { 0x79, 0x59 },
00473   { 0x7a, 0x5a }
00474 };
00475 
00476 extern int
00477 onigenc_ascii_get_all_pair_ambig_codes(OnigAmbigType flag,
00478                                        const OnigPairAmbigCodes** ccs)
00479 {
00480   if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) {
00481     *ccs = OnigAsciiPairAmbigCodes;
00482     return (sizeof(OnigAsciiPairAmbigCodes) / sizeof(OnigPairAmbigCodes));
00483   }
00484   else {
00485     return 0;
00486   }
00487 }
00488 
00489 extern int
00490 onigenc_nothing_get_all_comp_ambig_codes(OnigAmbigType flag,
00491                                          const OnigCompAmbigCodes** ccs)
00492 {
00493   return 0;
00494 }
00495 
00496 extern int
00497 onigenc_iso_8859_1_get_all_pair_ambig_codes(OnigAmbigType flag,
00498                                             const OnigPairAmbigCodes** ccs)
00499 {
00500   static const OnigPairAmbigCodes cc[] = {
00501     { 0xc0, 0xe0 },
00502     { 0xc1, 0xe1 },
00503     { 0xc2, 0xe2 },
00504     { 0xc3, 0xe3 },
00505     { 0xc4, 0xe4 },
00506     { 0xc5, 0xe5 },
00507     { 0xc6, 0xe6 },
00508     { 0xc7, 0xe7 },
00509     { 0xc8, 0xe8 },
00510     { 0xc9, 0xe9 },
00511     { 0xca, 0xea },
00512     { 0xcb, 0xeb },
00513     { 0xcc, 0xec },
00514     { 0xcd, 0xed },
00515     { 0xce, 0xee },
00516     { 0xcf, 0xef },
00517 
00518     { 0xd0, 0xf0 },
00519     { 0xd1, 0xf1 },
00520     { 0xd2, 0xf2 },
00521     { 0xd3, 0xf3 },
00522     { 0xd4, 0xf4 },
00523     { 0xd5, 0xf5 },
00524     { 0xd6, 0xf6 },
00525     { 0xd8, 0xf8 },
00526     { 0xd9, 0xf9 },
00527     { 0xda, 0xfa },
00528     { 0xdb, 0xfb },
00529     { 0xdc, 0xfc },
00530     { 0xdd, 0xfd },
00531     { 0xde, 0xfe },
00532 
00533     { 0xe0, 0xc0 },
00534     { 0xe1, 0xc1 },
00535     { 0xe2, 0xc2 },
00536     { 0xe3, 0xc3 },
00537     { 0xe4, 0xc4 },
00538     { 0xe5, 0xc5 },
00539     { 0xe6, 0xc6 },
00540     { 0xe7, 0xc7 },
00541     { 0xe8, 0xc8 },
00542     { 0xe9, 0xc9 },
00543     { 0xea, 0xca },
00544     { 0xeb, 0xcb },
00545     { 0xec, 0xcc },
00546     { 0xed, 0xcd },
00547     { 0xee, 0xce },
00548     { 0xef, 0xcf },
00549 
00550     { 0xf0, 0xd0 },
00551     { 0xf1, 0xd1 },
00552     { 0xf2, 0xd2 },
00553     { 0xf3, 0xd3 },
00554     { 0xf4, 0xd4 },
00555     { 0xf5, 0xd5 },
00556     { 0xf6, 0xd6 },
00557     { 0xf8, 0xd8 },
00558     { 0xf9, 0xd9 },
00559     { 0xfa, 0xda },
00560     { 0xfb, 0xdb },
00561     { 0xfc, 0xdc },
00562     { 0xfd, 0xdd },
00563     { 0xfe, 0xde }
00564   };
00565 
00566   if (flag == ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) {
00567     *ccs = OnigAsciiPairAmbigCodes;
00568     return (sizeof(OnigAsciiPairAmbigCodes) / sizeof(OnigPairAmbigCodes));
00569   }
00570   else if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) {
00571     *ccs = cc;
00572     return sizeof(cc) / sizeof(OnigPairAmbigCodes);
00573   }
00574   else
00575     return 0;
00576 }
00577 
00578 extern int
00579 onigenc_ess_tsett_get_all_comp_ambig_codes(OnigAmbigType flag,
00580                                            const OnigCompAmbigCodes** ccs)
00581 {
00582   static const OnigCompAmbigCodes folds[] = {
00583     { 2, 0xdf, {{ 2, { 0x53, 0x53 } }, { 2, { 0x73, 0x73} } } }
00584   };
00585 
00586   if (flag == ONIGENC_AMBIGUOUS_MATCH_NONASCII_CASE) {
00587     *ccs = folds;
00588     return sizeof(folds) / sizeof(OnigCompAmbigCodes);
00589   }
00590   else
00591     return 0;
00592 }
00593 
00594 extern int
00595 onigenc_not_support_get_ctype_code_range(int ctype,
00596                              const OnigCodePoint* sbr[], const OnigCodePoint* mbr[])
00597 {
00598   return ONIG_NO_SUPPORT_CONFIG;
00599 }
00600 
00601 extern int
00602 onigenc_is_mbc_newline_0x0a(const UChar* p, const UChar* end)
00603 {
00604   if (p < end) {
00605     if (*p == 0x0a) return 1;
00606   }
00607   return 0;
00608 }
00609 
00610 /* for single byte encodings */
00611 extern int
00612 onigenc_ascii_mbc_to_normalize(OnigAmbigType flag, const UChar** p, const UChar*end,
00613                                UChar* lower)
00614 {
00615   if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
00616     *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(**p);
00617   }
00618   else {
00619     *lower = **p;
00620   }
00621 
00622   (*p)++;
00623   return 1; /* return byte length of converted char to lower */
00624 }
00625 
00626 extern int
00627 onigenc_ascii_is_mbc_ambiguous(OnigAmbigType flag,
00628                             const UChar** pp, const UChar* end)
00629 {
00630   const UChar* p = *pp;
00631 
00632   (*pp)++;
00633   if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
00634     return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
00635   }
00636   else {
00637     return FALSE;
00638   }
00639 }
00640 
00641 extern int
00642 onigenc_single_byte_mbc_enc_len(const UChar* p)
00643 {
00644   return 1;
00645 }
00646 
00647 extern OnigCodePoint
00648 onigenc_single_byte_mbc_to_code(const UChar* p, const UChar* end)
00649 {
00650   return (OnigCodePoint )(*p);
00651 }
00652 
00653 extern int
00654 onigenc_single_byte_code_to_mbclen(OnigCodePoint code)
00655 {
00656   return 1;
00657 }
00658 
00659 extern int
00660 onigenc_single_byte_code_to_mbc_first(OnigCodePoint code)
00661 {
00662   return (code & 0xff);
00663 }
00664 
00665 extern int
00666 onigenc_single_byte_code_to_mbc(OnigCodePoint code, UChar *buf)
00667 {
00668   *buf = (UChar )(code & 0xff);
00669   return 1;
00670 }
00671 
00672 extern UChar*
00673 onigenc_single_byte_left_adjust_char_head(const UChar* start, const UChar* s)
00674 {
00675   return (UChar* )s;
00676 }
00677 
00678 extern int
00679 onigenc_always_true_is_allowed_reverse_match(const UChar* s, const UChar* end)
00680 {
00681   return TRUE;
00682 }
00683 
00684 extern int
00685 onigenc_always_false_is_allowed_reverse_match(const UChar* s, const UChar* end)
00686 {
00687   return FALSE;
00688 }
00689 
00690 extern OnigCodePoint
00691 onigenc_mbn_mbc_to_code(OnigEncoding enc, const UChar* p, const UChar* end)
00692 {
00693   int c, i, len;
00694   OnigCodePoint n;
00695 
00696   len = enc_len(enc, p);
00697   n = (OnigCodePoint )(*p++);
00698   if (len == 1) return n;
00699 
00700   for (i = 1; i < len; i++) {
00701     if (p >= end) break;
00702     c = *p++;
00703     n <<= 8;  n += c;
00704   }
00705   return n;
00706 }
00707 
00708 extern int
00709 onigenc_mbn_mbc_to_normalize(OnigEncoding enc, OnigAmbigType flag,
00710                              const UChar** pp, const UChar* end, UChar* lower)
00711 {
00712   int len;
00713   const UChar *p = *pp;
00714 
00715   if (ONIGENC_IS_MBC_ASCII(p)) {
00716     if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
00717       *lower = ONIGENC_ASCII_CODE_TO_LOWER_CASE(*p);
00718     }
00719     else {
00720       *lower = *p;
00721     }
00722     (*pp)++;
00723     return 1;
00724   }
00725   else {
00726     len = enc_len(enc, p);
00727     if (lower != p) {
00728       int i;
00729       for (i = 0; i < len; i++) {
00730        *lower++ = *p++;
00731       }
00732     }
00733     (*pp) += len;
00734     return len; /* return byte length of converted to lower char */
00735   }
00736 }
00737 
00738 extern int
00739 onigenc_mbn_is_mbc_ambiguous(OnigEncoding enc, OnigAmbigType flag,
00740                              const UChar** pp, const UChar* end)
00741 {
00742   const UChar* p = *pp;
00743 
00744   if (ONIGENC_IS_MBC_ASCII(p)) {
00745     (*pp)++;
00746     if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
00747       return ONIGENC_IS_ASCII_CODE_CASE_AMBIG(*p);
00748     }
00749     else {
00750       return FALSE;
00751     }
00752   }
00753 
00754   (*pp) += enc_len(enc, p);
00755   return FALSE;
00756 }
00757 
00758 extern int
00759 onigenc_mb2_code_to_mbclen(OnigCodePoint code)
00760 {
00761   if ((code & 0xff00) != 0) return 2;
00762   else return 1;
00763 }
00764 
00765 extern int
00766 onigenc_mb4_code_to_mbclen(OnigCodePoint code)
00767 {
00768        if ((code & 0xff000000) != 0) return 4;
00769   else if ((code & 0xff0000) != 0) return 3;
00770   else if ((code & 0xff00) != 0) return 2;
00771   else return 1;
00772 }
00773 
00774 extern int
00775 onigenc_mb2_code_to_mbc_first(OnigCodePoint code)
00776 {
00777   int first;
00778 
00779   if ((code & 0xff00) != 0) {
00780     first = (code >> 8) & 0xff;
00781   }
00782   else {
00783     return (int )code;
00784   }
00785   return first;
00786 }
00787 
00788 extern int
00789 onigenc_mb4_code_to_mbc_first(OnigCodePoint code)
00790 {
00791   int first;
00792 
00793   if ((code & 0xff000000) != 0) {
00794     first = (code >> 24) & 0xff;
00795   }
00796   else if ((code & 0xff0000) != 0) {
00797     first = (code >> 16) & 0xff;
00798   }
00799   else if ((code & 0xff00) != 0) {
00800     first = (code >>  8) & 0xff;
00801   }
00802   else {
00803     return (int )code;
00804   }
00805   return first;
00806 }
00807 
00808 extern int
00809 onigenc_mb2_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
00810 {
00811   UChar *p = buf;
00812 
00813   if ((code & 0xff00) != 0) {
00814     *p++ = (UChar )((code >>  8) & 0xff);
00815   }
00816   *p++ = (UChar )(code & 0xff);
00817 
00818 #if 1
00819   if (enc_len(enc, buf) != (p - buf))
00820     return ONIGENCERR_INVALID_WIDE_CHAR_VALUE;
00821 #endif
00822   return p - buf;
00823 }
00824 
00825 extern int
00826 onigenc_mb4_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
00827 {
00828   UChar *p = buf;
00829 
00830   if ((code & 0xff000000) != 0) {
00831     *p++ = (UChar )((code >> 24) & 0xff);
00832   }
00833   if ((code & 0xff0000) != 0 || p != buf) {
00834     *p++ = (UChar )((code >> 16) & 0xff);
00835   }
00836   if ((code & 0xff00) != 0 || p != buf) {
00837     *p++ = (UChar )((code >> 8) & 0xff);
00838   }
00839   *p++ = (UChar )(code & 0xff);
00840 
00841 #if 1
00842   if (enc_len(enc, buf) != (p - buf))
00843     return ONIGENCERR_INVALID_WIDE_CHAR_VALUE;
00844 #endif
00845   return p - buf;
00846 }
00847 
00848 extern int
00849 onigenc_mb2_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
00850                        unsigned int ctype)
00851 {
00852   if (code < 128)
00853     return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
00854   else {
00855     if ((ctype & (ONIGENC_CTYPE_WORD |
00856                   ONIGENC_CTYPE_GRAPH | ONIGENC_CTYPE_PRINT)) != 0) {
00857       return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
00858     }
00859   }
00860 
00861   return FALSE;
00862 }
00863 
00864 extern int
00865 onigenc_mb4_is_code_ctype(OnigEncoding enc, OnigCodePoint code,
00866                        unsigned int ctype)
00867 {
00868   if (code < 128)
00869     return ONIGENC_IS_ASCII_CODE_CTYPE(code, ctype);
00870   else {
00871     if ((ctype & (ONIGENC_CTYPE_WORD |
00872                   ONIGENC_CTYPE_GRAPH | ONIGENC_CTYPE_PRINT)) != 0) {
00873       return (ONIGENC_CODE_TO_MBCLEN(enc, code) > 1 ? TRUE : FALSE);
00874     }
00875   }
00876 
00877   return FALSE;
00878 }
00879 
00880 extern int
00881 onigenc_with_ascii_strncmp(OnigEncoding enc, const UChar* p, const UChar* end,
00882                            const UChar* sascii /* ascii */, int n)
00883 {
00884   int x, c;
00885 
00886   while (n-- > 0) {
00887     if (p >= end) return (int )(*sascii);
00888 
00889     c = (int )ONIGENC_MBC_TO_CODE(enc, p, end);
00890     x = *sascii - c;
00891     if (x) return x;
00892 
00893     sascii++;
00894     p += enc_len(enc, p);
00895   }
00896   return 0;
00897 }
00898 
00899 #else /* ONIG_RUBY_M17N */
00900 
00901 extern int
00902 onigenc_is_code_ctype(OnigEncoding enc, OnigCodePoint code, int ctype)
00903 {
00904   switch (ctype) {
00905   case ONIGENC_CTYPE_NEWLINE:
00906     if (code == 0x0a) return 1;
00907     break;
00908 
00909   case ONIGENC_CTYPE_ALPHA:
00910     return m17n_isalpha(enc, code);
00911     break;
00912   case ONIGENC_CTYPE_BLANK:
00913     return ONIGENC_IS_CODE_BLANK(enc, (int )(code));
00914     break;
00915   case ONIGENC_CTYPE_CNTRL:
00916     return m17n_iscntrl(enc, code);
00917     break;
00918   case ONIGENC_CTYPE_DIGIT:
00919     return m17n_isdigit(enc, code);
00920     break;
00921   case ONIGENC_CTYPE_GRAPH:
00922     return ONIGENC_IS_CODE_GRAPH(enc, (int )(code));
00923     break;
00924   case ONIGENC_CTYPE_LOWER:
00925     return m17n_islower(enc, code);
00926     break;
00927   case ONIGENC_CTYPE_PRINT:
00928     return m17n_isprint(enc, code);
00929     break;
00930   case ONIGENC_CTYPE_PUNCT:
00931     return m17n_ispunct(enc, code);
00932     break;
00933   case ONIGENC_CTYPE_SPACE:
00934     return m17n_isspace(enc, code);
00935     break;
00936   case ONIGENC_CTYPE_UPPER:
00937     return m17n_isupper(enc, code);
00938     break;
00939   case ONIGENC_CTYPE_XDIGIT:
00940     return m17n_isxdigit(enc, code);
00941     break;
00942   case ONIGENC_CTYPE_WORD:
00943     return m17n_iswchar(enc, code);
00944     break;
00945   case ONIGENC_CTYPE_ASCII:
00946     return (code < 128 ? TRUE : FALSE);
00947     break;
00948   case ONIGENC_CTYPE_ALNUM:
00949     return m17n_isalnum(enc, code);
00950     break;
00951   default:
00952     break;
00953   }
00954 
00955   return 0;
00956 }
00957 
00958 extern int
00959 onigenc_code_to_mbc(OnigEncoding enc, OnigCodePoint code, UChar *buf)
00960 {
00961   int c, len;
00962 
00963   m17n_mbcput(enc, code, buf);
00964   c = m17n_firstbyte(enc, code);
00965   len = enc_len(enc, c);
00966   return len;
00967 }
00968 
00969 extern int
00970 onigenc_mbc_to_lower(OnigEncoding enc, UChar* p, UChar* buf)
00971 {
00972   unsigned int c, low;
00973 
00974   c   = m17n_codepoint(enc, p, p + enc_len(enc, *p));
00975   low = m17n_tolower(enc, c);
00976   m17n_mbcput(enc, low, buf);
00977 
00978   return m17n_codelen(enc, low);
00979 }
00980 
00981 extern int
00982 onigenc_is_mbc_ambiguous(OnigEncoding enc, OnigAmbigType flag,
00983                          UChar** pp, UChar* end)
00984 {
00985   int len;
00986   unsigned int c;
00987   UChar* p = *pp;
00988 
00989   len = enc_len(enc, *p);
00990   (*pp) += len;
00991   c = m17n_codepoint(enc, p, p + len);
00992 
00993   if ((flag & ONIGENC_AMBIGUOUS_MATCH_ASCII_CASE) != 0) {
00994     if (m17n_isupper(enc, c) || m17n_islower(enc, c))
00995       return TRUE;
00996   }
00997 
00998   return FALSE;
00999 }
01000 
01001 extern UChar*
01002 onigenc_get_left_adjust_char_head(OnigEncoding enc, UChar* start, UChar* s)
01003 {
01004   UChar *p;
01005   int len;
01006 
01007   if (s <= start) return s;
01008   p = s;
01009 
01010   while (!m17n_islead(enc, *p) && p > start) p--;
01011   while (p + (len = enc_len(enc, *p)) < s) {
01012     p += len;
01013   }
01014   if (p + len == s) return s;
01015   return p;
01016 }
01017 
01018 extern int
01019 onigenc_is_allowed_reverse_match(OnigEncoding enc,
01020                              const UChar* s, const UChar* end)
01021 {
01022   return ONIGENC_IS_SINGLEBYTE(enc);
01023 }
01024 
01025 extern void
01026 onigenc_set_default_caseconv_table(UChar* table) { }
01027 
01028 #endif /* ONIG_RUBY_M17N */