tUsing strtok_r for the string parsing. - st - [fork] customized build of st, t… | |
git clone git://src.adamsgaard.dk/st | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 7cb0d95509d1b2837e4fa7d131f497800b20d22c | |
parent 37863356b00cd41c24e10243121649473b98824f | |
Author: Christoph Lohmann <[email protected]> | |
Date: Mon, 25 Feb 2013 13:36:40 +0100 | |
Using strtok_r for the string parsing. | |
Diffstat: | |
M st.c | 32 ++++++++++++++---------------… | |
1 file changed, 14 insertions(+), 18 deletions(-) | |
--- | |
diff --git a/st.c b/st.c | |
t@@ -1300,8 +1300,10 @@ csiparse(void) { | |
long int v; | |
csiescseq.narg = 0; | |
- if(*p == '?') | |
- csiescseq.priv = 1, p++; | |
+ if(*p == '?') { | |
+ csiescseq.priv = 1; | |
+ p++; | |
+ } | |
while(p < csiescseq.buf+csiescseq.len) { | |
np = NULL; | |
t@@ -1928,23 +1930,17 @@ strhandle(void) { | |
void | |
strparse(void) { | |
- /* | |
- * 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, *np, *sp; | |
+ | |
+ strescseq.narg = 0; | |
+ np = strtok_r(strescseq.buf, ";", &sp); | |
+ while(p < strescseq.buf+strescseq.len && np != NULL) { | |
+ strescseq.args[strescseq.narg++] = p; | |
+ | |
+ np = strtok_r(NULL, ";", &sp); | |
+ if(np != NULL) | |
+ p = np; | |
} | |
- strescseq.narg = narg + 1; | |
} | |
void |