summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2021-03-07 10:49:54 +0200
committerToomas Soome <tsoome@me.com>2021-03-12 09:01:35 +0200
commitba2848d4cb17292e88f04f6a47e0b3305f17efa7 (patch)
tree4e1e5593df9debec4661852595ba3baa390847c0
parenta11d78d661ddb4b26a53fad39aba982d2bb5a63b (diff)
downloadillumos-joyent-ba2848d4cb17292e88f04f6a47e0b3305f17efa7.tar.gz
13607 loader: tem should use dynamic array for tab stops
Reviewed by: Yuri Pankov <yuripv@yuripv.dev> Approved by: Dan McDonald <danmcd@joyent.com>
-rw-r--r--usr/src/boot/Makefile.version2
-rw-r--r--usr/src/boot/sys/boot/common/tem.c18
-rw-r--r--usr/src/boot/sys/sys/tem_impl.h6
3 files changed, 16 insertions, 10 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version
index fc79093fee..32d625d23a 100644
--- a/usr/src/boot/Makefile.version
+++ b/usr/src/boot/Makefile.version
@@ -34,4 +34,4 @@ LOADER_VERSION = 1.1
# Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes.
# The version is processed from left to right, the version number can only
# be increased.
-BOOT_VERSION = $(LOADER_VERSION)-2021.02.13.1
+BOOT_VERSION = $(LOADER_VERSION)-2021.03.07.1
diff --git a/usr/src/boot/sys/boot/common/tem.c b/usr/src/boot/sys/boot/common/tem.c
index ebb3ae48f8..0ceb83c72a 100644
--- a/usr/src/boot/sys/boot/common/tem.c
+++ b/usr/src/boot/sys/boot/common/tem.c
@@ -214,6 +214,11 @@ tem_internal_init(struct tem_vt_state *ptem,
if (ptem->tvs_outbuf == NULL)
panic("out of memory in tem_internal_init()\n");
+ ptem->tvs_maxtab = width / 8;
+ ptem->tvs_tabs = calloc(ptem->tvs_maxtab, sizeof (*ptem->tvs_tabs));
+ if (ptem->tvs_tabs == NULL)
+ panic("out of memory in tem_internal_init()\n");
+
tem_reset_display(ptem, clear_screen, init_color);
ptem->tvs_utf8_left = 0;
@@ -294,6 +299,9 @@ tem_free_buf(struct tem_vt_state *tem)
free(tem->tvs_screen_buf);
tem->tvs_screen_buf = NULL;
+
+ free(tem->tvs_tabs);
+ tem->tvs_tabs = NULL;
}
static int
@@ -2399,7 +2407,7 @@ tem_back_tab(struct tem_vt_state *tem)
static void
tem_tab(struct tem_vt_state *tem)
{
- int i;
+ size_t i;
screen_pos_t tabstop;
tabstop = tems.ts_c_dimension.width - 1;
@@ -2417,10 +2425,9 @@ tem_tab(struct tem_vt_state *tem)
static void
tem_set_tab(struct tem_vt_state *tem)
{
- int i;
- int j;
+ size_t i, j;
- if (tem->tvs_ntabs == TEM_MAXTAB)
+ if (tem->tvs_ntabs == tem->tvs_maxtab)
return;
if (tem->tvs_ntabs == 0 ||
tem->tvs_tabs[tem->tvs_ntabs] < tem->tvs_c_cursor.col) {
@@ -2443,8 +2450,7 @@ tem_set_tab(struct tem_vt_state *tem)
static void
tem_clear_tabs(struct tem_vt_state *tem, int action)
{
- int i;
- int j;
+ size_t i, j;
switch (action) {
case 3: /* clear all tabs */
diff --git a/usr/src/boot/sys/sys/tem_impl.h b/usr/src/boot/sys/sys/tem_impl.h
index 6764475695..2afcb5df0a 100644
--- a/usr/src/boot/sys/sys/tem_impl.h
+++ b/usr/src/boot/sys/sys/tem_impl.h
@@ -66,7 +66,6 @@ typedef uint32_t tem_char_t; /* 32bit char to support UTF-8 */
#define TEM_ATTR_ISSET(c, a) ((TEM_CHAR_ATTR(c) & (a)) == (a))
#define TEM_MAXPARAMS 5 /* maximum number of ANSI paramters */
-#define TEM_MAXTAB 40 /* maximum number of tab stops */
#define TEM_MAXFKEY 30 /* max length of function key with <ESC>Q */
#define MAX_TEM 2 /* max number of loadable terminal emulators */
@@ -172,8 +171,9 @@ struct tem_vt_state {
int tvs_curparam; /* current param # of output esc seq */
int tvs_paramval; /* value of current param */
int tvs_params[TEM_MAXPARAMS]; /* parameters of output esc seq */
- screen_pos_t tvs_tabs[TEM_MAXTAB]; /* tab stops */
- int tvs_ntabs; /* number of tabs used */
+ screen_pos_t *tvs_tabs; /* tab stops */
+ size_t tvs_maxtab; /* maximum number of tab stops */
+ size_t tvs_ntabs; /* number of tabs used */
int tvs_nscroll; /* number of lines to scroll */
struct tem_char_pos tvs_s_cursor; /* start cursor position */