Commit 017d63cd authored by Emden R. Gansner's avatar Emden R. Gansner

Fix bug in split function

parent 88057b7b
......@@ -713,16 +713,20 @@ exsplit(Expr_t * ex, register Exnode_t * expr, void *env)
v.integer = 0;
while (*str) {
sz = strspn (str, seps);
for (i = 0; i < sz; i++) {
addItem (arr, v, "");
v.integer++;
if (sz) {
if (v.integer == 0) { /* initial separator => empty field */
addItem (arr, v, "");
v.integer++;
}
for (i = 1; i < sz; i++) {
addItem (arr, v, "");
v.integer++;
}
}
str += sz;
if (*str == '\0') {
if (v.integer == sz) { /* only separators */
addItem (arr, v, "");
v.integer++;
}
if (*str == '\0') { /* terminal separator => empty field */
addItem (arr, v, "");
v.integer++;
break;
}
sz = strcspn (str, seps);
......
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