- * we are either at the end of the string, or the
- * terminator found has been found, so finish up.
- */
- if (!c || brkany (c, brkterm)) {
- *s = '\0';
- broken[i] = NULL;
- return broken;
+ ** scan string, replacing separators with zeroes
+ ** and enter start addresses in "broken".
+ */
+ s = str;
+ for (i = 0;; i++) {
+ /* enlarge pointer array, if necessary */
+ if (i >= len) {
+ len += NUMBROKEN;
+ broken = mh_xrealloc(broken,
+ (size_t)(len * sizeof(*broken)));
+ }
+
+ /* handle separators */
+ while (strchr(brksep, c = *s)) {
+ *s++ = '\0';
+ }
+
+ /*
+ ** we are either at the end of the string, or the
+ ** terminator found has been found, so finish up.
+ */
+ if (!c || strchr(brkterm, c)) {
+ *s = '\0';
+ broken[i] = NULL;
+ return broken;
+ }
+
+ /* set next start addr and walk over word */
+ broken[i] = s;
+ while ((c=*++s) && !strchr(brksep, c) && !strchr(brkterm, c)) {
+ continue;
+ }