| 1 | /********************************************************************** |
| 2 | regext.c - Onigmo (Oniguruma-mod) (regular expression library) |
| 3 | **********************************************************************/ |
| 4 | /*- |
| 5 | * Copyright (c) 2002-2008 K.Kosako <sndgk393 AT ybb DOT ne DOT jp> |
| 6 | * Copyright (c) 2011-2016 K.Takata <kentkt AT csc DOT jp> |
| 7 | * All rights reserved. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * |
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
| 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 21 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE |
| 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 28 | * SUCH DAMAGE. |
| 29 | */ |
| 30 | |
| 31 | #include "regint.h"cxx . . $ `<file>/vendor/onigmo-source/regint.h`/ |
| 32 | |
| 33 | static void |
| 34 | conv_ext0be32cxx . . $ conv_ext0be32(9d5454c624d2238e).(const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* s, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* end, UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* conv) |
| 35 | { |
| 36 | while (s < end) { |
| 37 | *conv++ = '\0'; |
| 38 | *conv++ = '\0'; |
| 39 | *conv++ = '\0'; |
| 40 | *conv++ = *s++; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | static void |
| 45 | conv_ext0le32cxx . . $ conv_ext0le32(9d5454c624d2238e).(const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* s, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* end, UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* conv) |
| 46 | { |
| 47 | while (s < end) { |
| 48 | *conv++ = *s++; |
| 49 | *conv++ = '\0'; |
| 50 | *conv++ = '\0'; |
| 51 | *conv++ = '\0'; |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | static void |
| 56 | conv_ext0becxx . . $ conv_ext0be(9d5454c624d2238e).(const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* s, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* end, UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* conv) |
| 57 | { |
| 58 | while (s < end) { |
| 59 | *conv++ = '\0'; |
| 60 | *conv++ = *s++; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | static void |
| 65 | conv_ext0lecxx . . $ conv_ext0le(9d5454c624d2238e).(const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* s, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* end, UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* conv) |
| 66 | { |
| 67 | while (s < end) { |
| 68 | *conv++ = *s++; |
| 69 | *conv++ = '\0'; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | static void |
| 74 | conv_swap4bytescxx . . $ conv_swap4bytes(9d5454c624d2238e).(const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* s, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* end, UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* conv) |
| 75 | { |
| 76 | while (s < end) { |
| 77 | *conv++ = s[3]; |
| 78 | *conv++ = s[2]; |
| 79 | *conv++ = s[1]; |
| 80 | *conv++ = s[0]; |
| 81 | s += 4; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | static void |
| 86 | conv_swap2bytescxx . . $ conv_swap2bytes(9d5454c624d2238e).(const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* s, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* end, UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* conv) |
| 87 | { |
| 88 | while (s < end) { |
| 89 | *conv++ = s[1]; |
| 90 | *conv++ = s[0]; |
| 91 | s += 2; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | static int |
| 96 | conv_encodingcxx . . $ conv_encoding(ee639dc78b5652e4).(OnigEncodingcxx . . $ OnigEncoding# from, OnigEncodingcxx . . $ OnigEncoding# to, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* s, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* end, |
| 97 | UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!** conv, UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!** conv_end) |
| 98 | { |
| 99 | ptrdiff_t len = end - s; |
| 100 | |
| 101 | if (to == ONIG_ENCODING_UTF16_BEcxx . . $ `vendor/onigmo-source/onigmo.h:275:10`!) { |
| 102 | if (from == ONIG_ENCODING_ASCIIcxx . . $ `vendor/onigmo-source/onigmo.h:225:9`! || from == ONIG_ENCODING_ISO_8859_1cxx . . $ `vendor/onigmo-source/onigmo.h:227:10`!) { |
| 103 | *conv = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )xmalloccxx . . $ `vendor/onigmo-source/regint.h:143:10`!(len * 2); |
| 104 | CHECK_NULL_RETURN_MEMERRcxx . . $ `vendor/onigmo-source/regint.h:301:9`!(*conv); |
| 105 | *conv_end = *conv + (len * 2); |
| 106 | conv_ext0becxx . . $ conv_ext0be(9d5454c624d2238e).(s, end, *conv); |
| 107 | return 0; |
| 108 | } |
| 109 | else if (from == ONIG_ENCODING_UTF16_LEcxx . . $ `vendor/onigmo-source/onigmo.h:276:10`!) { |
| 110 | swap16: |
| 111 | *conv = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )xmalloccxx . . $ `vendor/onigmo-source/regint.h:143:10`!(len); |
| 112 | CHECK_NULL_RETURN_MEMERRcxx . . $ `vendor/onigmo-source/regint.h:301:9`!(*conv); |
| 113 | *conv_end = *conv + len; |
| 114 | conv_swap2bytescxx . . $ conv_swap2bytes(9d5454c624d2238e).(s, end, *conv); |
| 115 | return 0; |
| 116 | } |
| 117 | } |
| 118 | else if (to == ONIG_ENCODING_UTF16_LEcxx . . $ `vendor/onigmo-source/onigmo.h:276:10`!) { |
| 119 | if (from == ONIG_ENCODING_ASCIIcxx . . $ `vendor/onigmo-source/onigmo.h:225:9`! || from == ONIG_ENCODING_ISO_8859_1cxx . . $ `vendor/onigmo-source/onigmo.h:227:10`!) { |
| 120 | *conv = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )xmalloccxx . . $ `vendor/onigmo-source/regint.h:143:10`!(len * 2); |
| 121 | CHECK_NULL_RETURN_MEMERRcxx . . $ `vendor/onigmo-source/regint.h:301:9`!(*conv); |
| 122 | *conv_end = *conv + (len * 2); |
| 123 | conv_ext0lecxx . . $ conv_ext0le(9d5454c624d2238e).(s, end, *conv); |
| 124 | return 0; |
| 125 | } |
| 126 | else if (from == ONIG_ENCODING_UTF16_BEcxx . . $ `vendor/onigmo-source/onigmo.h:275:10`!) { |
| 127 | goto swap16; |
| 128 | } |
| 129 | } |
| 130 | if (to == ONIG_ENCODING_UTF32_BEcxx . . $ `vendor/onigmo-source/onigmo.h:277:10`!) { |
| 131 | if (from == ONIG_ENCODING_ASCIIcxx . . $ `vendor/onigmo-source/onigmo.h:225:9`! || from == ONIG_ENCODING_ISO_8859_1cxx . . $ `vendor/onigmo-source/onigmo.h:227:10`!) { |
| 132 | *conv = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )xmalloccxx . . $ `vendor/onigmo-source/regint.h:143:10`!(len * 4); |
| 133 | CHECK_NULL_RETURN_MEMERRcxx . . $ `vendor/onigmo-source/regint.h:301:9`!(*conv); |
| 134 | *conv_end = *conv + (len * 4); |
| 135 | conv_ext0be32cxx . . $ conv_ext0be32(9d5454c624d2238e).(s, end, *conv); |
| 136 | return 0; |
| 137 | } |
| 138 | else if (from == ONIG_ENCODING_UTF32_LEcxx . . $ `vendor/onigmo-source/onigmo.h:278:10`!) { |
| 139 | swap32: |
| 140 | *conv = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )xmalloccxx . . $ `vendor/onigmo-source/regint.h:143:10`!(len); |
| 141 | CHECK_NULL_RETURN_MEMERRcxx . . $ `vendor/onigmo-source/regint.h:301:9`!(*conv); |
| 142 | *conv_end = *conv + len; |
| 143 | conv_swap4bytescxx . . $ conv_swap4bytes(9d5454c624d2238e).(s, end, *conv); |
| 144 | return 0; |
| 145 | } |
| 146 | } |
| 147 | else if (to == ONIG_ENCODING_UTF32_LEcxx . . $ `vendor/onigmo-source/onigmo.h:278:10`!) { |
| 148 | if (from == ONIG_ENCODING_ASCIIcxx . . $ `vendor/onigmo-source/onigmo.h:225:9`! || from == ONIG_ENCODING_ISO_8859_1cxx . . $ `vendor/onigmo-source/onigmo.h:227:10`!) { |
| 149 | *conv = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )xmalloccxx . . $ `vendor/onigmo-source/regint.h:143:10`!(len * 4); |
| 150 | CHECK_NULL_RETURN_MEMERRcxx . . $ `vendor/onigmo-source/regint.h:301:9`!(*conv); |
| 151 | *conv_end = *conv + (len * 4); |
| 152 | conv_ext0le32cxx . . $ conv_ext0le32(9d5454c624d2238e).(s, end, *conv); |
| 153 | return 0; |
| 154 | } |
| 155 | else if (from == ONIG_ENCODING_UTF32_BEcxx . . $ `vendor/onigmo-source/onigmo.h:277:10`!) { |
| 156 | goto swap32; |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | return ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATIONcxx . . $ `vendor/onigmo-source/onigmo.h:692:9`!; |
| 161 | } |
| 162 | |
| 163 | extern int |
| 164 | onig_new_deluxecxx . . $ onig_new_deluxe(2c93dbf66fe84630).(regex_tcxx . . $ regex_t#** reg, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* pattern, const UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* pattern_end, |
| 165 | OnigCompileInfocxx . . $ OnigCompileInfo#* ci, OnigErrorInfocxx . . $ OnigErrorInfo#* einfo) |
| 166 | { |
| 167 | int r; |
| 168 | UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`! *cpat, *cpat_end; |
| 169 | |
| 170 | if (IS_NOT_NULLcxx . . $ `vendor/onigmo-source/regint.h:299:9`!(einfo)) einfo->parcxx . . $ $anonymous_type_d8a9e63ad63ca5ad_3#par. = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 171 | |
| 172 | if (ci->pattern_enccxx . . $ $anonymous_type_d8a9e63ad63ca5ad_5#pattern_enc. != ci->target_enccxx . . $ $anonymous_type_d8a9e63ad63ca5ad_5#target_enc.) { |
| 173 | r = conv_encodingcxx . . $ conv_encoding(ee639dc78b5652e4).(ci->pattern_enccxx . . $ $anonymous_type_d8a9e63ad63ca5ad_5#pattern_enc., ci->target_enccxx . . $ $anonymous_type_d8a9e63ad63ca5ad_5#target_enc., pattern, pattern_end, |
| 174 | &cpat, &cpat_end); |
| 175 | if (r) return r; |
| 176 | } |
| 177 | else { |
| 178 | cpat = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )pattern; |
| 179 | cpat_end = (UCharcxx . . $ `vendor/onigmo-source/onigmo.h:76:10`!* )pattern_end; |
| 180 | } |
| 181 | |
| 182 | *reg = (regex_tcxx . . $ regex_t#* )xmalloccxx . . $ `vendor/onigmo-source/regint.h:143:10`!(sizeof(regex_tcxx . . $ regex_t#)); |
| 183 | if (IS_NULLcxx . . $ `vendor/onigmo-source/regint.h:298:9`!(*reg)) { |
| 184 | r = ONIGERR_MEMORYcxx . . $ `vendor/onigmo-source/onigmo.h:629:9`!; |
| 185 | goto err2; |
| 186 | } |
| 187 | |
| 188 | r = onig_reg_initcxx . . $ onig_reg_init(28921ffecbffafbf).(*reg, ci->optioncxx . . $ $anonymous_type_d8a9e63ad63ca5ad_5#option., ci->case_fold_flagcxx . . $ $anonymous_type_d8a9e63ad63ca5ad_5#case_fold_flag., ci->target_enccxx . . $ $anonymous_type_d8a9e63ad63ca5ad_5#target_enc., |
| 189 | ci->syntaxcxx . . $ $anonymous_type_d8a9e63ad63ca5ad_5#syntax.); |
| 190 | if (r) goto err; |
| 191 | |
| 192 | r = onig_compilecxx . . $ onig_compile(c081430bb1efff2d).(*reg, cpat, cpat_end, einfo); |
| 193 | if (r) { |
| 194 | err: |
| 195 | onig_freecxx . . $ onig_free(b1814a8fd6af504b).(*reg); |
| 196 | *reg = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 197 | } |
| 198 | |
| 199 | err2: |
| 200 | if (cpat != pattern) xfreecxx . . $ `vendor/onigmo-source/regint.h:146:10`!(cpat); |
| 201 | |
| 202 | return r; |
| 203 | } |