Commit 7e056b83 authored by Marius Wachtler's avatar Marius Wachtler

Handle sperator empty case. And reformat code.

parent 32cd891e
...@@ -353,16 +353,18 @@ Box* strSplit2(BoxedString* self, BoxedString* sep) { ...@@ -353,16 +353,18 @@ Box* strSplit2(BoxedString* self, BoxedString* sep) {
BoxedList* rtn = new BoxedList(); BoxedList* rtn = new BoxedList();
if (sep->cls == str_cls) if (sep->cls == str_cls) {
{ if (!sep->s.empty()) {
llvm::SmallVector<llvm::StringRef, 16> parts; llvm::SmallVector<llvm::StringRef, 16> parts;
llvm::StringRef(self->s).split(parts, sep->s); llvm::StringRef(self->s).split(parts, sep->s);
for (const auto &s : parts) for (const auto &s : parts)
listAppendInternal(rtn, boxString(s.str())); listAppendInternal(rtn, boxString(s.str()));
} } else {
else fprintf(stderr, "ValueError: empty separator\n");
{ raiseExc();
}
} else {
fprintf(stderr, "TypeError: expected a character buffer object\n"); fprintf(stderr, "TypeError: expected a character buffer object\n");
raiseExc(); raiseExc();
} }
......
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