OSC 52 - copy to clipboard: don't limit to 382 bytes (7a018b)

This commit is contained in:
bakkeby 2020-03-24 14:25:10 +01:00
parent 0d5ea3a3f2
commit 2de79ac677
1 changed files with 11 additions and 4 deletions

13
st.c
View File

@ -159,7 +159,8 @@ typedef struct {
/* ESC type [[ [<priv>] <arg> [;]] <mode>] ESC '\' */
typedef struct {
char type; /* ESC type ... */
char buf[STR_BUF_SIZ]; /* raw string */
char *buf; /* allocated raw string */
size_t siz; /* allocation size */
size_t len; /* raw string length */
char *args[STR_ARG_SIZ];
int narg; /* nb of args */
@ -2073,7 +2074,10 @@ strdump(void)
void
strreset(void)
{
memset(&strescseq, 0, sizeof(strescseq));
strescseq = (STREscape){
.buf = xrealloc(strescseq.buf, STR_BUF_SIZ),
.siz = STR_BUF_SIZ,
};
}
void
@ -2463,7 +2467,7 @@ tputc(Rune u)
if (term.esc&ESC_DCS && strescseq.len == 0 && u == 'q')
term.mode |= MODE_SIXEL;
if (strescseq.len+len >= sizeof(strescseq.buf)) {
if (strescseq.len+len >= strescseq.siz) {
/*
* Here is a bug in terminals. If the user never sends
* some code to stop the str or esc command, then st
@ -2477,7 +2481,10 @@ tputc(Rune u)
* term.esc = 0;
* strhandle();
*/
if (strescseq.siz > (SIZE_MAX - UTF_SIZ) / 2)
return;
strescseq.siz *= 2;
strescseq.buf = xrealloc(strescseq.buf, strescseq.siz);
}
memmove(&strescseq.buf[strescseq.len], c, len);