summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-04-03 21:15:58 +0200
committerBram Moolenaar <Bram@vim.org>2019-04-03 21:15:58 +0200
commit5da04ef1b4126cc997e38b58faa5325e7cb83e4f (patch)
tree32bd387880cd1ed57c61af8aed68a1b0f29a985b
parent796cc42d3a4fc7a940da87831a111eeb6b7a5cf3 (diff)
patch 8.1.1105: long escape sequences may be split upv8.1.1105
Problem: Long escape sequences may be split up. Solution: Assume esccape sequences can be up to 80 bytes long. (Nobuhiro Takasaki, closes #4196)
-rw-r--r--src/term.c22
-rw-r--r--src/version.c2
2 files changed, 17 insertions, 7 deletions
diff --git a/src/term.c b/src/term.c
index ffc988483c..d114be9781 100644
--- a/src/term.c
+++ b/src/term.c
@@ -2538,12 +2538,18 @@ termcapinit(char_u *name)
}
/*
- * the number of calls to ui_write is reduced by using the buffer "out_buf"
+ * The number of calls to ui_write is reduced by using "out_buf".
*/
#define OUT_SIZE 2047
- /* Add one to allow mch_write() in os_win32.c to append a NUL */
+
+// add one to allow mch_write() in os_win32.c to append a NUL
static char_u out_buf[OUT_SIZE + 1];
-static int out_pos = 0; /* number of chars in out_buf */
+
+static int out_pos = 0; // number of chars in out_buf
+
+// Since the maximum number of SGR parameters shown as a normal value range is
+// 16, the escape sequence length can be 4 * 16 + lead + tail.
+#define MAX_ESC_SEQ_LEN 80
/*
* out_flush(): flush the output buffer
@@ -2660,12 +2666,14 @@ out_char_nf(unsigned c)
void
out_str_nf(char_u *s)
{
- if (out_pos > OUT_SIZE - 20) /* avoid terminal strings being split up */
+ // avoid terminal strings being split up
+ if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN)
out_flush();
+
while (*s)
out_char_nf(*s++);
- /* For testing we write one string at a time. */
+ // For testing we write one string at a time.
if (p_wd)
out_flush();
}
@@ -2694,7 +2702,7 @@ out_str_cf(char_u *s)
return;
}
#endif
- if (out_pos > OUT_SIZE - 20)
+ if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN)
out_flush();
#ifdef HAVE_TGETENT
for (p = s; *s; ++s)
@@ -2762,7 +2770,7 @@ out_str(char_u *s)
}
#endif
/* avoid terminal strings being split up */
- if (out_pos > OUT_SIZE - 20)
+ if (out_pos > OUT_SIZE - MAX_ESC_SEQ_LEN)
out_flush();
#ifdef HAVE_TGETENT
tputs((char *)s, 1, TPUTSFUNCAST out_char_nf);
diff --git a/src/version.c b/src/version.c
index 3f8d347b49..08e2394cb4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -772,6 +772,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1105,
+/**/
1104,
/**/
1103,