Skip to content

Commit 5064b54

Browse files
committed
Added special case for [split "foobar" ""] and test.
1 parent 0c6f318 commit 5064b54

File tree

17 files changed

+27
-10
lines changed

17 files changed

+27
-10
lines changed

android/build.xml

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@
201201
<target name="dex" depends="hecl-android-jar">
202202
<echo>Converting compiled files and external libraries into ${outdir}/${dex-file}...</echo>
203203
<apply executable="${dx}" failonerror="true" parallel="true">
204+
<arg value="-JXmx512m" />
204205
<arg value="--dex" />
205206
<arg value="--output=${intermediate-dex-ospath}" />
206207
<arg path="android/Hecl.jar" />

core/org/hecl/ListCmds.java

+18-6
Original file line numberDiff line numberDiff line change
@@ -176,13 +176,25 @@ public Thing operate(int cmd, Interp interp, Thing[] argv) throws HeclException
176176
splitstr = " ";
177177
}
178178

179-
idx = str.indexOf(splitstr);
180-
while (idx >= 0) {
181-
result.addElement(new Thing(str.substring(last, idx)));
182-
last = idx + splitstr.length();
183-
idx = str.indexOf(splitstr, last);
179+
int splitstringlen = splitstr.length();
180+
181+
if (splitstringlen > 0) {
182+
idx = str.indexOf(splitstr);
183+
while (idx >= 0) {
184+
result.addElement(new Thing(str.substring(last, idx)));
185+
last = idx + splitstringlen;
186+
idx = str.indexOf(splitstr, last);
187+
}
188+
result.addElement(new Thing(str.substring(last, str.length())));
189+
} else {
190+
/* This is a special case: when the splitstring is
191+
* an empty string "". */
192+
for(int i = 0; i < str.length(); i++) {
193+
char[] c = new char[1];
194+
c[0] = str.charAt(i);
195+
result.addElement(new Thing(new String(c)));
196+
}
184197
}
185-
result.addElement(new Thing(str.substring(last, str.length())));
186198
return ListThing.create(result);
187199

188200
default:

jars/AndroidBuilder.jar

78 Bytes
Binary file not shown.

jars/AppletTweak.jar

0 Bytes
Binary file not shown.

jars/HeclBuilder.jar

258 Bytes
Binary file not shown.

jars/JarHack.jar

0 Bytes
Binary file not shown.

jars/applet/cldc1.0-midp1.0/Hecl.jar

89 Bytes
Binary file not shown.

jars/applet/cldc1.1-midp2.0/Hecl.jar

87 Bytes
Binary file not shown.

jars/cldc1.0-midp1.0/Hecl.jad

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MIDlet-Jar-URL: Hecl.jar
2-
MIDlet-Jar-Size: 74994
2+
MIDlet-Jar-Size: 75086
33
MIDlet-Name: Hecl
44
MIDlet-Vendor: dedasys.com
55
MIDlet-Version: 1.1

jars/cldc1.0-midp1.0/Hecl.jar

92 Bytes
Binary file not shown.

jars/cldc1.1-midp2.0/Hecl.jad

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MIDlet-Jar-URL: Hecl.jar
2-
MIDlet-Jar-Size: 149953
2+
MIDlet-Jar-Size: 150045
33
MIDlet-Name: Hecl
44
MIDlet-Vendor: dedasys.com
55
MIDlet-Version: 1.1

jars/cldc1.1-midp2.0/Hecl.jar

92 Bytes
Binary file not shown.

jars/j2se/Hecl.jar

6.83 KB
Binary file not shown.

jars/j2se/HeclApplet.jar

11.4 KB
Binary file not shown.

jars/mwt/Mwtgui.jad

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MIDlet-Jar-URL: Mwtgui.jar
2-
MIDlet-Jar-Size: 187590
2+
MIDlet-Jar-Size: 187682
33
MIDlet-Name: Hecl
44
MIDlet-Vendor: dedasys.com
55
MIDlet-Version: 1.1

jars/mwt/Mwtgui.jar

92 Bytes
Binary file not shown.

tests/split.hcl

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ test split-2 {
77
split "aaa bbb ccc"
88
} {aaa bbb ccc}
99

10-
test split-2 {
10+
test split-3 {
1111
split "aaaxbbbycccxyddd" "xy"
1212
} {aaaxbbbyccc ddd}
1313

14+
test split-4 {
15+
split "abcdefg" ""
16+
} {a b c d e f g}
17+

0 commit comments

Comments
 (0)