aboutsummaryrefslogtreecommitdiffstats
path: root/st.c
diff options
context:
space:
mode:
authorChristoph Lohmann <20h@r-36.net>2013-02-26 21:43:40 +0100
committerChristoph Lohmann <20h@r-36.net>2013-02-26 21:43:40 +0100
commitc6b89f23e7546c30dea42a3c49f99682c5818190 (patch)
treedc2f411410882c2c8b2abc95189ecc830704d09e /st.c
parent1c1621da699adae49a4344b145f856dacb57270c (diff)
downloadst-c6b89f23e7546c30dea42a3c49f99682c5818190.tar.gz
Using strsep and fixing null termination in csiparse.
Thanks for the hint from Alexander Sedov <alex0player@gmail.com>!
Diffstat (limited to 'st.c')
-rw-r--r--st.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/st.c b/st.c
index 8b5ba64..fc9ed70 100644
--- a/st.c
+++ b/st.c
@@ -1,5 +1,4 @@
/* See LICENSE for licence details. */
-#define _XOPEN_SOURCE 600
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
@@ -1304,6 +1303,7 @@ csiparse(void) {
p++;
}
+ csiescseq.buf[csiescseq.len] = '\0';
while(p < csiescseq.buf+csiescseq.len) {
np = NULL;
v = strtol(p, &np, 10);
@@ -1925,14 +1925,12 @@ strhandle(void) {
void
strparse(void) {
- char *p = strescseq.buf, *sp;
+ char *p = strescseq.buf;
+ strescseq.narg = 0;
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;
- }
+ while(p && strescseq.narg < STR_ARG_SIZ)
+ strescseq.args[strescseq.narg++] = strsep(&p, ";");
}
void
@@ -2109,7 +2107,8 @@ tputc(char *c, int len) {
if(term.esc & ESC_CSI) {
csiescseq.buf[csiescseq.len++] = ascii;
if(BETWEEN(ascii, 0x40, 0x7E)
- || csiescseq.len >= ESC_BUF_SIZ) {
+ || csiescseq.len >= \
+ sizeof(csiescseq.buf)-1) {
term.esc = 0;
csiparse();
csihandle();
remember that computers suck.