mirror of
https://github.com/alrayyes/st.git
synced 2024-11-23 03:36:21 +00:00
Using strtok_r for the string parsing.
This commit is contained in:
parent
37863356b0
commit
7cb0d95509
1 changed files with 14 additions and 18 deletions
32
st.c
32
st.c
|
@ -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,24 +1930,18 @@ strhandle(void) {
|
||||||
|
|
||||||
void
|
void
|
||||||
strparse(void) {
|
strparse(void) {
|
||||||
/*
|
char *p = strescseq.buf, *np, *sp;
|
||||||
* TODO: Implement parsing like for CSI when required.
|
|
||||||
* Format: ESC type cmd ';' arg0 [';' argn] ESC \
|
strescseq.narg = 0;
|
||||||
*/
|
np = strtok_r(strescseq.buf, ";", &sp);
|
||||||
int narg = 0;
|
while(p < strescseq.buf+strescseq.len && np != NULL) {
|
||||||
char *start = strescseq.buf, *end = start + strescseq.len;
|
strescseq.args[strescseq.narg++] = p;
|
||||||
strescseq.args[0] = start;
|
|
||||||
while(start < end && narg < LEN(strescseq.args)) {
|
np = strtok_r(NULL, ";", &sp);
|
||||||
start = memchr(start, ';', end - start);
|
if(np != NULL)
|
||||||
if(!start)
|
p = np;
|
||||||
break;
|
|
||||||
*start++ = '\0';
|
|
||||||
if(start < end) {
|
|
||||||
strescseq.args[++narg] = start;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
strescseq.narg = narg + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
strdump(void) {
|
strdump(void) {
|
||||||
|
|
Loading…
Reference in a new issue