/* * Initialize from environment variables. */ void init_line(void) { end_ansi_chars = lgetenv("LESSANSIENDCHARS"); if (end_ansi_chars == NULL || *end_ansi_chars == '\0') end_ansi_chars = "m"; mid_ansi_chars = lgetenv("LESSANSIMIDCHARS"); if (mid_ansi_chars == NULL || *mid_ansi_chars == '\0') mid_ansi_chars = "0123456789;[?!\"'#%()*+ "; linebuf = ecalloc(LINEBUF_SIZE, sizeof (char)); attr = ecalloc(LINEBUF_SIZE, sizeof (char)); size_linebuf = LINEBUF_SIZE; }
/* * Define the printing format for control (or binary utf) chars. */ static void setbinfmt(char *e, const char **fmtvarptr, const char *default_fmt) { const char *s; if (((s = lgetenv(e)) == NULL) || (*s == 0)) { s = default_fmt; goto attr; } if (s != NULL && *s != 0) { if (checkfmt(s) < 0) { s = default_fmt; goto attr; } } /* * Select the attributes if it starts with "*". */ attr: if (*s == '*') { switch (s[1]) { case 'd': binattr = AT_BOLD; break; case 'k': binattr = AT_BLINK; break; case 's': binattr = AT_STANDOUT; break; case 'u': binattr = AT_UNDERLINE; break; default: binattr = AT_NORMAL; break; } s += 2; } *fmtvarptr = s; }