Commit c44dfc56 authored by Marius Wachtler's avatar Marius Wachtler

Implement string.split(None)

parent 7e056b83
......@@ -351,25 +351,25 @@ Box* strSplit1(BoxedString* self) {
Box* strSplit2(BoxedString* self, BoxedString* sep) {
assert(self->cls == str_cls);
BoxedList* rtn = new BoxedList();
if (sep->cls == str_cls) {
if (!sep->s.empty()) {
llvm::SmallVector<llvm::StringRef, 16> parts;
llvm::StringRef(self->s).split(parts, sep->s);
BoxedList* rtn = new BoxedList();
for (const auto &s : parts)
listAppendInternal(rtn, boxString(s.str()));
return rtn;
} else {
fprintf(stderr, "ValueError: empty separator\n");
raiseExc();
}
} else if (sep->cls == none_cls) {
return strSplit1(self);
} else {
fprintf(stderr, "TypeError: expected a character buffer object\n");
raiseExc();
}
return rtn;
}
......
......@@ -8,4 +8,5 @@ print repr("'\"")
print "hello world\tmore\nwords\va\fb\ao".split()
print " test ".split()
print " test ".split(' ')
print " test ".split(None)
print "1<>2<>3".split('<>')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment