From dd95aad0a184fc4f2ab4cd13323a70c9833acc2b Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 1 Nov 2004 23:09:46 +0000 Subject: [PATCH] Knows how to use LINES now. --- TODO | 2 -- sst.c | 11 ++++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 8062cb1..142160b 100644 --- a/TODO +++ b/TODO @@ -2,8 +2,6 @@ * Remove the assumption that sst.doc lives in the current directory. -* Have it read the value of LINES rather than assumong a 24-line terminal. - * Do a manual page. * Improve the internal pager. diff --git a/sst.c b/sst.c index b06a82f..b3a0202 100644 --- a/sst.c +++ b/sst.c @@ -11,6 +11,7 @@ int getch(void); static char line[128], *linep = line; static int linecount; /* for paging */ +static int screenheight = 24; static void clearscreen(void); @@ -163,8 +164,8 @@ static void helpme(void) { while (fgets(linebuf, sizeof(linebuf),fp)) { if (strstr(linebuf, "******")) break; - linebuf[strlen(linebuf)-1] = '\0'; // No \n at end - prout(linebuf); + /* use fputs here to avoid % expansion */ + fputs(linebuf, stdout); } fclose(fp); } @@ -355,6 +356,10 @@ int main(int argc, char **argv) { int hitme; char ch; prelim(); + char *LINES = getenv("LINES"); + + if (LINES) + screenheight = atoi(LINES); if (argc > 1) { fromcommandline = 1; @@ -577,7 +582,7 @@ void pause(int i) { void skip(int i) { while (i-- > 0) { linecount++; - if (linecount >= 23) + if (linecount >= screenheight) pause(0); else putchar('\n'); -- 2.31.1