222 |
222 |
223 if (result) { |
223 if (result) { |
224 sstr_t curpos = s; |
224 sstr_t curpos = s; |
225 ssize_t j = 1; |
225 ssize_t j = 1; |
226 while (1) { |
226 while (1) { |
227 sstr_t match = sstrstr(curpos, d); |
227 sstr_t match; |
|
228 /* optimize for one byte delimiters */ |
|
229 if (d.length == 1) { |
|
230 match = curpos; |
|
231 for (size_t i = 0 ; i < curpos.length ; i++) { |
|
232 if (curpos.ptr[i] == *(d.ptr)) { |
|
233 match.ptr = curpos.ptr + i; |
|
234 break; |
|
235 } |
|
236 match.length--; |
|
237 } |
|
238 } else { |
|
239 match = sstrstr(curpos, d); |
|
240 } |
228 if (match.length > 0) { |
241 if (match.length > 0) { |
229 /* is this our last try? */ |
242 /* is this our last try? */ |
230 if (nmax == 0 || j < nmax) { |
243 if (nmax == 0 || j < nmax) { |
231 /* copy the current string to the array */ |
244 /* copy the current string to the array */ |
232 sstr_t item = sstrn(curpos.ptr, match.ptr - curpos.ptr); |
245 sstr_t item = sstrn(curpos.ptr, match.ptr - curpos.ptr); |