X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=st.c;h=fc9ed70d435c03434e5a1fb64898a667d5b4caeb;hb=82494f248d778e1195a9eabfac916ce08c52b6da;hp=9f5793c5865056735821303634b4513c89fc48f2;hpb=7d32471efffa825f52d24930b5ee617105f9c83e;p=st.git diff --git a/st.c b/st.c index 9f5793c..fc9ed70 100644 --- a/st.c +++ b/st.c @@ -1,5 +1,4 @@ /* See LICENSE for licence details. */ -#define _XOPEN_SOURCE 600 #include #include #include @@ -796,7 +795,7 @@ selcopy(void) { } /* \n at the end of every selected line except for the last one */ if(is_selected && y < sel.e.y) - *ptr++ = '\n'; + *ptr++ = '\r'; } *ptr = 0; } @@ -1295,7 +1294,6 @@ tnewline(int first_col) { void csiparse(void) { - /* int noarg = 1; */ char *p = csiescseq.buf, *np; long int v; @@ -1305,10 +1303,12 @@ csiparse(void) { p++; } + csiescseq.buf[csiescseq.len] = '\0'; while(p < csiescseq.buf+csiescseq.len) { + np = NULL; v = strtol(p, &np, 10); if(np == p) - break; + v = 0; if(v == LONG_MAX || v == LONG_MIN) v = -1; csiescseq.arg[csiescseq.narg++] = v; @@ -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();