- /*
- * TODO: Implement parsing like for CSI when required.
- * Format: ESC type cmd ';' arg0 [';' argn] ESC \
- */
- int narg = 0;
- char *start = strescseq.buf, *end = start + strescseq.len;
- strescseq.args[0] = start;
- while(start < end && narg < LEN(strescseq.args)) {
- start = memchr(start, ';', end - start);
- if(!start)
- break;
- *start++ = '\0';
- if(start < end) {
- strescseq.args[++narg] = start;
- }
+ char *p = strescseq.buf, *sp;
+
+ strescseq.buf[strescseq.len] = '\0';
+ for(p = strtok_r(p, ";", &sp); p; p = strtok_r(NULL, ";", &sp)) {
+ if(strescseq.narg == STR_ARG_SIZ)
+ return;
+ strescseq.args[strescseq.narg++] = p;