Skip to content
Snippets Groups Projects
Commit fb974709 authored by Henrik (Grubba) Grubbström's avatar Henrik (Grubba) Grubbström
Browse files

Fixed a few bugs in String.SplitIterator.

Rev: src/iterators.cmod:1.6
parent fda2e1cb
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
\*/ \*/
/**/ /**/
#include "global.h" #include "global.h"
RCSID("$Id: iterators.cmod,v 1.5 2001/05/17 16:49:22 grubba Exp $"); RCSID("$Id: iterators.cmod,v 1.6 2001/05/17 18:31:18 grubba Exp $");
#include "main.h" #include "main.h"
#include "object.h" #include "object.h"
#include "mapping.h" #include "mapping.h"
...@@ -465,6 +465,10 @@ PIKECLASS string_split_iterator ...@@ -465,6 +465,10 @@ PIKECLASS string_split_iterator
} }
if (offset >= ssi->buffer->len) { if (offset >= ssi->buffer->len) {
if (ssi->feed.type == T_INT) { if (ssi->feed.type == T_INT) {
if (!ssi->flags) {
MAKE_CONSTANT_SHARED_STRING(ssi->current, "");
ssi->index++;
}
free_string(ssi->buffer); free_string(ssi->buffer);
ssi->buffer = NULL; ssi->buffer = NULL;
ssi->offset = 0; ssi->offset = 0;
...@@ -532,6 +536,10 @@ PIKECLASS string_split_iterator ...@@ -532,6 +536,10 @@ PIKECLASS string_split_iterator
ssi->offset = end+1; ssi->offset = end+1;
ssi->current = Pike_sp[-1].u.string; ssi->current = Pike_sp[-1].u.string;
Pike_sp--; Pike_sp--;
if ((!THIS->flags) && (ssi->offset > ssi->buffer->len)) {
free_string(THIS->buffer);
THIS->buffer = 0;
}
} }
PIKEFUN string value() PIKEFUN string value()
...@@ -668,8 +676,7 @@ PIKECLASS string_split_iterator ...@@ -668,8 +676,7 @@ PIKECLASS string_split_iterator
fatal("Unsupported size shift!\n"); fatal("Unsupported size shift!\n");
} }
} }
off++; /* Skip the end split character. */ if ((!THIS->flags) && (off == THIS->buffer->len-1)) {
if ((!THIS->flags) && (off == THIS->buffer->len)) {
/* Ends with an empty segment. */ /* Ends with an empty segment. */
res++; res++;
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment