diff options
author | Christoph Lohmann <20h@r-36.net> | 2013-02-25 13:36:40 +0100 |
---|---|---|
committer | Christoph Lohmann <20h@r-36.net> | 2013-02-25 13:36:40 +0100 |
commit | 7cb0d95509d1b2837e4fa7d131f497800b20d22c (patch) | |
tree | 3ea070f2e2982de33a6e842c69887e178b94b5c8 | |
parent | 37863356b00cd41c24e10243121649473b98824f (diff) | |
download | st-patched-7cb0d95509d1b2837e4fa7d131f497800b20d22c.tar.bz2 st-patched-7cb0d95509d1b2837e4fa7d131f497800b20d22c.tar.xz st-patched-7cb0d95509d1b2837e4fa7d131f497800b20d22c.zip |
Using strtok_r for the string parsing.
-rw-r--r-- | st.c | 32 |
1 files changed, 14 insertions, 18 deletions
@@ -1300,8 +1300,10 @@ csiparse(void) { | |||
1300 | long int v; | 1300 | long int v; |
1301 | 1301 | ||
1302 | csiescseq.narg = 0; | 1302 | csiescseq.narg = 0; |
1303 | if(*p == '?') | 1303 | if(*p == '?') { |
1304 | csiescseq.priv = 1, p++; | 1304 | csiescseq.priv = 1; |
1305 | p++; | ||
1306 | } | ||
1305 | 1307 | ||
1306 | while(p < csiescseq.buf+csiescseq.len) { | 1308 | while(p < csiescseq.buf+csiescseq.len) { |
1307 | np = NULL; | 1309 | np = NULL; |
@@ -1928,23 +1930,17 @@ strhandle(void) { | |||
1928 | 1930 | ||
1929 | void | 1931 | void |
1930 | strparse(void) { | 1932 | strparse(void) { |
1931 | /* | 1933 | char *p = strescseq.buf, *np, *sp; |
1932 | * TODO: Implement parsing like for CSI when required. | 1934 | |
1933 | * Format: ESC type cmd ';' arg0 [';' argn] ESC \ | 1935 | strescseq.narg = 0; |
1934 | */ | 1936 | np = strtok_r(strescseq.buf, ";", &sp); |
1935 | int narg = 0; | 1937 | while(p < strescseq.buf+strescseq.len && np != NULL) { |
1936 | char *start = strescseq.buf, *end = start + strescseq.len; | 1938 | strescseq.args[strescseq.narg++] = p; |
1937 | strescseq.args[0] = start; | 1939 | |
1938 | while(start < end && narg < LEN(strescseq.args)) { | 1940 | np = strtok_r(NULL, ";", &sp); |
1939 | start = memchr(start, ';', end - start); | 1941 | if(np != NULL) |
1940 | if(!start) | 1942 | p = np; |
1941 | break; | ||
1942 | *start++ = '\0'; | ||
1943 | if(start < end) { | ||
1944 | strescseq.args[++narg] = start; | ||
1945 | } | ||
1946 | } | 1943 | } |
1947 | strescseq.narg = narg + 1; | ||
1948 | } | 1944 | } |
1949 | 1945 | ||
1950 | void | 1946 | void |