mirror of
https://github.com/corda/corda.git
synced 2025-01-22 04:18:31 +00:00
Merge branch 'master' of oss.readytalk.com:/var/local/git/avian into openjdk
This commit is contained in:
commit
64100d17c7
@ -31,6 +31,7 @@ public class PrintStream extends OutputStream {
|
||||
public synchronized void print(String s) {
|
||||
try {
|
||||
out.write(s.getBytes());
|
||||
if (autoFlush) flush();
|
||||
} catch (IOException e) { }
|
||||
}
|
||||
|
||||
|
@ -115,23 +115,34 @@ public class Pattern {
|
||||
List<CharSequence> list = new LinkedList();
|
||||
int index = 0;
|
||||
int trailing = 0;
|
||||
while (index < input.length() && list.size() < limit) {
|
||||
int i = indexOf(input, pattern, index);
|
||||
int patternLength = pattern.length();
|
||||
while (index < input.length() && list.size() < limit - 1) {
|
||||
int i;
|
||||
if (patternLength == 0) {
|
||||
if (list.size() == 0) {
|
||||
i = 0;
|
||||
} else {
|
||||
i = index + 1;
|
||||
}
|
||||
} else {
|
||||
i = indexOf(input, pattern, index);
|
||||
}
|
||||
|
||||
if (i >= 0) {
|
||||
if (i == index) {
|
||||
if (patternLength != 0 && i == index) {
|
||||
++ trailing;
|
||||
} else {
|
||||
trailing = 0;
|
||||
}
|
||||
|
||||
list.add(input.subSequence(index, i));
|
||||
index = i + pattern.length();
|
||||
index = i + patternLength;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (strip && index == input.length()) {
|
||||
if (strip && index > 0 && index == input.length()) {
|
||||
++ trailing;
|
||||
} else {
|
||||
trailing = 0;
|
||||
|
@ -1677,62 +1677,6 @@ jumpC(Context* c, unsigned size UNUSED, Assembler::Constant* target)
|
||||
emit(c, b(0));
|
||||
}
|
||||
|
||||
void
|
||||
jumpIfEqualC(Context* c, unsigned size UNUSED, Assembler::Constant* target)
|
||||
{
|
||||
assert(c, size == BytesPerWord);
|
||||
|
||||
appendOffsetTask(c, target->value, offset(c), true);
|
||||
emit(c, beq(0));
|
||||
}
|
||||
|
||||
void
|
||||
jumpIfNotEqualC(Context* c, unsigned size UNUSED, Assembler::Constant* target)
|
||||
{
|
||||
assert(c, size == BytesPerWord);
|
||||
|
||||
appendOffsetTask(c, target->value, offset(c), true);
|
||||
emit(c, bne(0));
|
||||
}
|
||||
|
||||
void
|
||||
jumpIfGreaterC(Context* c, unsigned size UNUSED, Assembler::Constant* target)
|
||||
{
|
||||
assert(c, size == BytesPerWord);
|
||||
|
||||
appendOffsetTask(c, target->value, offset(c), true);
|
||||
emit(c, bgt(0));
|
||||
}
|
||||
|
||||
void
|
||||
jumpIfGreaterOrEqualC(Context* c, unsigned size UNUSED,
|
||||
Assembler::Constant* target)
|
||||
{
|
||||
assert(c, size == BytesPerWord);
|
||||
|
||||
appendOffsetTask(c, target->value, offset(c), true);
|
||||
emit(c, bge(0));
|
||||
}
|
||||
|
||||
void
|
||||
jumpIfLessC(Context* c, unsigned size UNUSED, Assembler::Constant* target)
|
||||
{
|
||||
assert(c, size == BytesPerWord);
|
||||
|
||||
appendOffsetTask(c, target->value, offset(c), true);
|
||||
emit(c, blt(0));
|
||||
}
|
||||
|
||||
void
|
||||
jumpIfLessOrEqualC(Context* c, unsigned size UNUSED,
|
||||
Assembler::Constant* target)
|
||||
{
|
||||
assert(c, size == BytesPerWord);
|
||||
|
||||
appendOffsetTask(c, target->value, offset(c), true);
|
||||
emit(c, ble(0));
|
||||
}
|
||||
|
||||
void
|
||||
return_(Context* c)
|
||||
{
|
||||
@ -2198,6 +2142,12 @@ class MyAssembler: public Assembler {
|
||||
}
|
||||
|
||||
virtual void saveFrame(unsigned stackOffset, unsigned) {
|
||||
Register returnAddress(0);
|
||||
emit(&c, mflr(returnAddress.low));
|
||||
|
||||
Memory returnAddressDst(StackRegister, 8);
|
||||
moveRM(&c, BytesPerWord, &returnAddress, BytesPerWord, &returnAddressDst);
|
||||
|
||||
Register stack(StackRegister);
|
||||
Memory stackDst(ThreadRegister, stackOffset);
|
||||
moveRM(&c, BytesPerWord, &stack, BytesPerWord, &stackDst);
|
||||
|
@ -3,6 +3,24 @@ public class Strings {
|
||||
if (! v) throw new RuntimeException();
|
||||
}
|
||||
|
||||
private static boolean equal(Object a, Object b) {
|
||||
return a == b || (a != null && a.equals(b));
|
||||
}
|
||||
|
||||
private static boolean arraysEqual(Object[] a, Object[] b) {
|
||||
if (a.length != b.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < a.length; ++i) {
|
||||
if (! equal(a[i], b[i])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
expect(new String(new byte[] { 99, 111, 109, 46, 101, 99, 111, 118, 97,
|
||||
116, 101, 46, 110, 97, 116, 46, 98, 117,
|
||||
@ -13,6 +31,31 @@ public class Strings {
|
||||
expect(months.split("\u00ae").length == 3);
|
||||
expect(months.replaceAll("\u00ae", ".").equals("Jan.Feb.Mar."));
|
||||
|
||||
expect(arraysEqual
|
||||
("xyz".split("", 0), new String[] { "", "x", "y", "z" }));
|
||||
expect(arraysEqual
|
||||
("xyz".split("", 1), new String[] { "xyz" }));
|
||||
expect(arraysEqual
|
||||
("xyz".split("", 2), new String[] { "", "xyz" }));
|
||||
expect(arraysEqual
|
||||
("xyz".split("", 3), new String[] { "", "x", "yz" }));
|
||||
expect(arraysEqual
|
||||
("xyz".split("", 4), new String[] { "", "x", "y", "z" }));
|
||||
expect(arraysEqual
|
||||
("xyz".split("", 5), new String[] { "", "x", "y", "z", "" }));
|
||||
expect(arraysEqual
|
||||
("xyz".split("", 6), new String[] { "", "x", "y", "z", "" }));
|
||||
expect(arraysEqual
|
||||
("xyz".split("", -1), new String[] { "", "x", "y", "z", "" }));
|
||||
|
||||
expect(arraysEqual("".split("xyz", 0), new String[] { "" }));
|
||||
expect(arraysEqual("".split("xyz", 1), new String[] { "" }));
|
||||
expect(arraysEqual("".split("xyz", -1), new String[] { "" }));
|
||||
|
||||
expect(arraysEqual("".split("", 0), new String[] { "" }));
|
||||
expect(arraysEqual("".split("", 1), new String[] { "" }));
|
||||
expect(arraysEqual("".split("", -1), new String[] { "" }));
|
||||
|
||||
expect("foo_foofoo__foo".replaceAll("_", "__")
|
||||
.equals("foo__foofoo____foo"));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user