Browse Source

Using strtok_r for the string parsing.

master
Christoph Lohmann 12 years ago
parent
commit
7cb0d95509
1 changed files with 14 additions and 18 deletions
  1. +14
    -18
      st.c

+ 14
- 18
st.c View File

@ -1300,8 +1300,10 @@ csiparse(void) {
long int v; long int v;
csiescseq.narg = 0; csiescseq.narg = 0;
if(*p == '?') if(*p == '?') {
csiescseq.priv = 1, p++; csiescseq.priv = 1;
p++;
}
while(p < csiescseq.buf+csiescseq.len) { while(p < csiescseq.buf+csiescseq.len) {
np = NULL; np = NULL;
@ -1928,23 +1930,17 @@ strhandle(void) {
void void
strparse(void) { strparse(void) {
/* char *p = strescseq.buf, *np, *sp;
* TODO: Implement parsing like for CSI when required. strescseq.narg = 0;
* Format: ESC type cmd ';' arg0 [';' argn] ESC \ np = strtok_r(strescseq.buf, ";", &sp);
*/ while(p < strescseq.buf+strescseq.len && np != NULL) {
int narg = 0; strescseq.args[strescseq.narg++] = p;
char *start = strescseq.buf, *end = start + strescseq.len; np = strtok_r(NULL, ";", &sp);
strescseq.args[0] = start; if(np != NULL)
while(start < end && narg < LEN(strescseq.args)) { p = np;
start = memchr(start, ';', end - start);
if(!start)
break;
*start++ = '\0';
if(start < end) {
strescseq.args[++narg] = start;
}
} }
strescseq.narg = narg + 1;
} }
void void


|||||||
x
 
000:0
Loading…
Cancel
Save