Skip to content

Commit afa8e2a

Browse files
committed
test
1 parent 7fc571b commit afa8e2a

140 files changed

Lines changed: 19981 additions & 92 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

core/pom.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
jar 'com.github.jnr:jffi:${jffi.version}:native'
5353

5454
jar 'org.jruby.joni:joni:2.2.4'
55-
jar 'org.jruby.jcodings:jcodings:1.0.62'
55+
# jar 'org.jruby.jcodings:jcodings:1.0.62'
5656
jar 'org.jruby:dirgra:0.3'
5757

5858
jar 'com.headius:invokebinder:1.13'

core/pom.xml

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ DO NOT MODIFY - GENERATED CODE
8181
<version>1.2.0</version>
8282
<exclusions>
8383
<exclusion>
84-
<groupId>com.github.jnr</groupId>
8584
<artifactId>jnr-ffi</artifactId>
85+
<groupId>com.github.jnr</groupId>
8686
</exclusion>
8787
</exclusions>
8888
</dependency>
@@ -92,8 +92,8 @@ DO NOT MODIFY - GENERATED CODE
9292
<version>0.32.18</version>
9393
<exclusions>
9494
<exclusion>
95-
<groupId>com.github.jnr</groupId>
9695
<artifactId>jnr-ffi</artifactId>
96+
<groupId>com.github.jnr</groupId>
9797
</exclusion>
9898
</exclusions>
9999
</dependency>
@@ -103,8 +103,8 @@ DO NOT MODIFY - GENERATED CODE
103103
<version>0.38.23</version>
104104
<exclusions>
105105
<exclusion>
106-
<groupId>com.github.jnr</groupId>
107106
<artifactId>jnr-ffi</artifactId>
107+
<groupId>com.github.jnr</groupId>
108108
</exclusion>
109109
</exclusions>
110110
</dependency>
@@ -114,8 +114,8 @@ DO NOT MODIFY - GENERATED CODE
114114
<version>3.1.20</version>
115115
<exclusions>
116116
<exclusion>
117-
<groupId>com.github.jnr</groupId>
118117
<artifactId>jnr-ffi</artifactId>
118+
<groupId>com.github.jnr</groupId>
119119
</exclusion>
120120
</exclusions>
121121
</dependency>
@@ -125,8 +125,8 @@ DO NOT MODIFY - GENERATED CODE
125125
<version>0.10.4</version>
126126
<exclusions>
127127
<exclusion>
128-
<groupId>com.github.jnr</groupId>
129128
<artifactId>jnr-ffi</artifactId>
129+
<groupId>com.github.jnr</groupId>
130130
</exclusion>
131131
</exclusions>
132132
</dependency>
@@ -151,11 +151,6 @@ DO NOT MODIFY - GENERATED CODE
151151
<artifactId>joni</artifactId>
152152
<version>2.2.4</version>
153153
</dependency>
154-
<dependency>
155-
<groupId>org.jruby.jcodings</groupId>
156-
<artifactId>jcodings</artifactId>
157-
<version>1.0.62</version>
158-
</dependency>
159154
<dependency>
160155
<groupId>org.jruby</groupId>
161156
<artifactId>dirgra</artifactId>
@@ -222,8 +217,8 @@ DO NOT MODIFY - GENERATED CODE
222217
<version>0.4.1</version>
223218
<exclusions>
224219
<exclusion>
225-
<groupId>org.ow2.asm</groupId>
226220
<artifactId>asm-all</artifactId>
221+
<groupId>org.ow2.asm</groupId>
227222
</exclusion>
228223
</exclusions>
229224
</dependency>
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
/*
2+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
3+
* this software and associated documentation files (the "Software"), to deal in
4+
* the Software without restriction, including without limitation the rights to
5+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
6+
* of the Software, and to permit persons to whom the Software is furnished to do
7+
* so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all
10+
* copies or substantial portions of the Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
* SOFTWARE.
19+
*/
20+
package org.jcodings;
21+
22+
import org.jcodings.ascii.AsciiTables;
23+
import org.jcodings.constants.PosixBracket;
24+
import org.jcodings.exception.CharacterPropertyException;
25+
import org.jcodings.exception.EncodingError;
26+
27+
abstract class AbstractEncoding extends Encoding {
28+
29+
private final short CTypeTable[];
30+
31+
protected AbstractEncoding(String name, int minLength, int maxLength, short[]CTypeTable) {
32+
super(name, minLength, maxLength);
33+
this.CTypeTable = CTypeTable;
34+
}
35+
36+
/** CTYPE_TO_BIT
37+
*/
38+
private static int CTypeToBit(int ctype) {
39+
return 1 << ctype;
40+
}
41+
42+
/** ONIGENC_IS_XXXXXX_CODE_CTYPE
43+
*/
44+
protected final boolean isCodeCTypeInternal(int code, int ctype) {
45+
return (CTypeTable[code] & CTypeToBit(ctype)) != 0;
46+
}
47+
48+
/** onigenc_is_mbc_newline_0x0a / used also by multibyte encodings
49+
*
50+
*/
51+
@Override
52+
public boolean isNewLine(byte[]bytes, int p, int end) {
53+
return p < end ? bytes[p] == Encoding.NEW_LINE : false;
54+
}
55+
56+
protected final int asciiMbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]lower) {
57+
lower[0] = AsciiTables.ToLowerCaseTable[bytes[pp.value] & 0xff];
58+
pp.value++;
59+
return 1;
60+
}
61+
62+
/** onigenc_ascii_mbc_case_fold
63+
*/
64+
@Override
65+
public int mbcCaseFold(int flag, byte[]bytes, IntHolder pp, int end, byte[]lower) {
66+
return asciiMbcCaseFold(flag, bytes, pp, end, lower);
67+
}
68+
69+
protected final void asciiApplyAllCaseFold(int flag, ApplyAllCaseFoldFunction fun, Object arg) {
70+
int[]code = new int[]{0};
71+
72+
for (int i=0; i<AsciiTables.LowerMap.length; i++) {
73+
code[0] = AsciiTables.LowerMap[i][1];
74+
fun.apply(AsciiTables.LowerMap[i][0], code, 1, arg);
75+
76+
code[0] = AsciiTables.LowerMap[i][0];
77+
fun.apply(AsciiTables.LowerMap[i][1], code, 1, arg);
78+
}
79+
}
80+
81+
/** onigenc_ascii_apply_all_case_fold / used also by multibyte encodings
82+
*/
83+
@Override
84+
public void applyAllCaseFold(int flag, ApplyAllCaseFoldFunction fun, Object arg) {
85+
asciiApplyAllCaseFold(flag, fun, arg);
86+
}
87+
88+
protected final CaseFoldCodeItem[]asciiCaseFoldCodesByString(int flag, byte[]bytes, int p, int end) {
89+
int b = bytes[p] & 0xff;
90+
91+
if (0x41 <= b && b <= 0x5a) {
92+
return new CaseFoldCodeItem[]{CaseFoldCodeItem.create(1, b + 0x20)};
93+
} else if (0x61 <= b && b <= 0x7a) {
94+
return new CaseFoldCodeItem[]{CaseFoldCodeItem.create(1, b - 0x20)};
95+
} else {
96+
return CaseFoldCodeItem.EMPTY_FOLD_CODES;
97+
}
98+
}
99+
100+
/** onigenc_ascii_get_case_fold_codes_by_str / used also by multibyte encodings
101+
*/
102+
@Override
103+
public CaseFoldCodeItem[]caseFoldCodesByString(int flag, byte[]bytes, int p, int end) {
104+
return asciiCaseFoldCodesByString(flag, bytes, p, end);
105+
}
106+
107+
/** onigenc_ascii_only_case_map / onigenc_single_byte_ascii_only_case_map
108+
*/
109+
int asciiOnlyCaseMap(IntHolder flagP, byte[]bytes, IntHolder pp, int end, byte[]to, int toP, int toEnd) {
110+
int toStart = toP;
111+
int flags = flagP.value;
112+
113+
while (pp.value < end && toP < toEnd) {
114+
// specialize for singlebyte ?
115+
int length = length(bytes, pp.value, end);
116+
if (length < 0) return length;
117+
int code = mbcToCode(bytes, pp.value, end);
118+
pp.value += length;
119+
120+
if (code >= 'a' && code <= 'z' && ((flags & Config.CASE_UPCASE) != 0)) {
121+
flags |= Config.CASE_MODIFIED;
122+
code += 'A' - 'a';
123+
} else if (code >= 'A' && code <= 'Z' && ((flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0)) {
124+
flags |= Config.CASE_MODIFIED;
125+
code += 'a' - 'A';
126+
}
127+
toP += codeToMbc(code, to, toP);
128+
if ((flags & Config.CASE_TITLECASE) != 0) {
129+
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
130+
}
131+
}
132+
flagP.value = flags;
133+
return toP - toStart;
134+
}
135+
136+
int singleByteAsciiOnlyCaseMap(IntHolder flagP, byte[]bytes, IntHolder pp, int end, byte[]to, int toP, int toEnd) {
137+
int toStart = toP;
138+
int flags = flagP.value;
139+
140+
while (pp.value < end && toP < toEnd) {
141+
int code = bytes[pp.value++] & 0xff;
142+
143+
if (code >= 'a' && code <= 'z' && ((flags & Config.CASE_UPCASE) != 0)) {
144+
flags |= Config.CASE_MODIFIED;
145+
code += 'A' - 'a';
146+
} else if (code >= 'A' && code <= 'Z' && ((flags & (Config.CASE_DOWNCASE | Config.CASE_FOLD)) != 0)) {
147+
flags |= Config.CASE_MODIFIED;
148+
code += 'a' - 'A';
149+
}
150+
to[toP++] = (byte)code;
151+
if ((flags & Config.CASE_TITLECASE) != 0) {
152+
flags ^= (Config.CASE_UPCASE | Config.CASE_DOWNCASE | Config.CASE_TITLECASE);
153+
}
154+
}
155+
flagP.value = flags;
156+
return toP - toStart;
157+
}
158+
159+
/** onigenc_minimum_property_name_to_ctype
160+
* notably overridden by unicode encodings
161+
*/
162+
@Override
163+
public int propertyNameToCType(byte[]bytes, int p, int end) {
164+
Integer ctype = PosixBracket.PBSTableUpper.get(bytes, p, end);
165+
if (ctype != null) return ctype;
166+
throw new CharacterPropertyException(EncodingError.ERR_INVALID_CHAR_PROPERTY_NAME, bytes, p, end - p);
167+
}
168+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
3+
* this software and associated documentation files (the "Software"), to deal in
4+
* the Software without restriction, including without limitation the rights to
5+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
6+
* of the Software, and to permit persons to whom the Software is furnished to do
7+
* so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all
10+
* copies or substantial portions of the Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
* SOFTWARE.
19+
*/
20+
package org.jcodings;
21+
22+
public interface ApplyAllCaseFoldFunction {
23+
public void apply(int from, int[]to, int toLength, Object o);
24+
}
25+
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
3+
* this software and associated documentation files (the "Software"), to deal in
4+
* the Software without restriction, including without limitation the rights to
5+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
6+
* of the Software, and to permit persons to whom the Software is furnished to do
7+
* so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all
10+
* copies or substantial portions of the Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
* SOFTWARE.
19+
*/
20+
package org.jcodings;
21+
22+
public abstract class CanBeTrailTableEncoding extends MultiByteEncoding {
23+
24+
protected final boolean[] CanBeTrailTable;
25+
26+
protected CanBeTrailTableEncoding(String name, int minLength, int maxLength, int[]EncLen, int[][]Trans, short[]CTypeTable, boolean[]CanBeTrailTable) {
27+
super(name, minLength, maxLength, EncLen, Trans, CTypeTable);
28+
this.CanBeTrailTable = CanBeTrailTable;
29+
}
30+
31+
@Override
32+
public int leftAdjustCharHead(byte[]bytes, int p, int s, int end) {
33+
if (s <= p) return s;
34+
35+
int p_ = s;
36+
37+
if (CanBeTrailTable[bytes[p_] & 0xff]) {
38+
while (p_ > p) {
39+
if (!(EncLen[bytes[--p_] & 0xff] > 1)) {
40+
p_++;
41+
break;
42+
}
43+
}
44+
}
45+
int len = length(bytes, p_, end);
46+
if (p_ + len > s) return p_;
47+
p_ += len;
48+
return p_ + ((s - p_) & ~1);
49+
}
50+
51+
@Override
52+
public boolean isReverseMatchAllowed(byte[]bytes, int p, int end) {
53+
return !CanBeTrailTable[bytes[p] & 0xff];
54+
}
55+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Permission is hereby granted, free of charge, to any person obtaining a copy of
3+
* this software and associated documentation files (the "Software"), to deal in
4+
* the Software without restriction, including without limitation the rights to
5+
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
6+
* of the Software, and to permit persons to whom the Software is furnished to do
7+
* so, subject to the following conditions:
8+
*
9+
* The above copyright notice and this permission notice shall be included in all
10+
* copies or substantial portions of the Software.
11+
*
12+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
* SOFTWARE.
19+
*/
20+
package org.jcodings;
21+
22+
public final class CaseFoldCodeItem {
23+
public static final CaseFoldCodeItem[] EMPTY_FOLD_CODES = new CaseFoldCodeItem[]{};
24+
25+
public final int byteLen;
26+
public final int code[];
27+
28+
private CaseFoldCodeItem(int byteLen, int[]code) {
29+
this.byteLen = byteLen;
30+
this.code = code;
31+
}
32+
33+
public static CaseFoldCodeItem create(int byteLen, int code1) {
34+
return new CaseFoldCodeItem(byteLen, new int[] {code1});
35+
}
36+
37+
public static CaseFoldCodeItem create(int byteLen, int code1, int code2) {
38+
return new CaseFoldCodeItem(byteLen, new int[] {code1, code2});
39+
}
40+
41+
public static CaseFoldCodeItem create(int byteLen, int code1, int code2, int code3) {
42+
return new CaseFoldCodeItem(byteLen, new int[] {code1, code2, code3});
43+
}
44+
}

0 commit comments

Comments
 (0)