mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Added ScriptRuntime.splitSC
This commit is contained in:
parent
bb5d66ddc1
commit
0a5b59efe7
@ -2225,6 +2225,30 @@ public class ScriptRuntime {
|
||||
return Context.reportRuntimeError1(msg, val.getClass().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Split string into array of strings using semicolon as string terminator
|
||||
* (; after the last string is required).
|
||||
*/
|
||||
static String[] splitSC(String s)
|
||||
{
|
||||
int count = 0;
|
||||
for (int cursor = 0; ;) {
|
||||
cursor = s.indexOf(';', cursor) + 1;
|
||||
if (cursor <= 0) { break; }
|
||||
++count;
|
||||
}
|
||||
String[] array = new String[count];
|
||||
count = 0;
|
||||
for (int cursor = 0; ;) {
|
||||
int next = s.indexOf(';', cursor);
|
||||
if (next < 0) { break; }
|
||||
array[count] = s.substring(cursor, next);
|
||||
++count;
|
||||
cursor = next + 1;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public static final Object[] emptyArgs = new Object[0];
|
||||
public static final String[] emptyStrings = new String[0];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user