X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=sst.c;h=ae209e2cb373ed7cf7ad8a156e1fbf01b55bc092;hp=b06a82fade956d28bd2b9b4f6b32a250d39db369;hb=404aca234d55a8d9ba7b6573b3c100c940b42fe8;hpb=4df73495bbade3ebd8b03d68f838f67dd717db8f diff --git a/sst.c b/sst.c index b06a82f..ae209e2 100644 --- a/sst.c +++ b/sst.c @@ -6,11 +6,16 @@ #include #endif #include + +#ifndef SSTDOC +#define SSTDOC "sst.doc" +#endif int getch(void); static char line[128], *linep = line; static int linecount; /* for paging */ +static int screenheight = 24; static void clearscreen(void); @@ -134,7 +139,7 @@ static void helpme(void) { cmdbuf[j] = toupper(commands[i][j]); cmdbuf[j] = '\0'; } - fp = fopen("sst.doc", "r"); + fp = fopen(SSTDOC, "r"); if (fp == NULL) { prout("Spock- \"Captain, that information is missing from the"); prout(" computer. You need to find SST.DOC and put it in the"); @@ -163,8 +168,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 +360,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 +586,7 @@ void pause(int i) { void skip(int i) { while (i-- > 0) { linecount++; - if (linecount >= 23) + if (linecount >= screenheight) pause(0); else putchar('\n');