X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;ds=sidebyside;f=sst.c;h=b06a82fade956d28bd2b9b4f6b32a250d39db369;hb=4df73495bbade3ebd8b03d68f838f67dd717db8f;hp=653e06be826b8a71d4950682fa2ad04fb78f1267;hpb=7d27c8befdb5de9a50ff4af88e764c8336bc1797;p=super-star-trek.git diff --git a/sst.c b/sst.c index 653e06b..b06a82f 100644 --- a/sst.c +++ b/sst.c @@ -103,7 +103,7 @@ static void listCommands(int x) { static void helpme(void) { int i, j; - char cmdbuf[32]; + char cmdbuf[32], *cp; char linebuf[132]; FILE *fp; /* Give help on commands */ @@ -130,9 +130,9 @@ static void helpme(void) { strcpy(cmdbuf, " ABBREV"); } else { - strcpy(cmdbuf, " Mnemonic: "); - j = 0; - while ((cmdbuf[j+13] = toupper(commands[i][j])) != 0) j++; + for (j = 0; commands[i][j]; j++) + cmdbuf[j] = toupper(commands[i][j]); + cmdbuf[j] = '\0'; } fp = fopen("sst.doc", "r"); if (fp == NULL) { @@ -141,26 +141,31 @@ static void helpme(void) { prout(" current directory.\""); return; } - i = strlen(cmdbuf); - do { - if (fgets(linebuf, 132, fp) == NULL) { + for (;;) { + if (fgets(linebuf, sizeof(linebuf), fp) == NULL) { prout("Spock- \"Captain, there is no information on that command.\""); fclose(fp); return; } - } while (strncmp(linebuf, cmdbuf, i) != 0); + if (linebuf[0] == '%' && linebuf[1] == '%'&& linebuf[2] == ' ') { + for (cp = linebuf+3; isspace(*cp); cp++) + continue; + linebuf[strlen(linebuf)-1] = '\0'; + if (strcmp(cp, cmdbuf) == 0) + break; + } + } skip(1); prout("Spock- \"Captain, I've found the following information:\""); skip(1); - do { - if (linebuf[0]!=12) { // ignore page break lines - linebuf[strlen(linebuf)-1] = '\0'; // No \n at end - prout(linebuf); - } - fgets(linebuf,132,fp); - } while (strstr(linebuf, "******")==NULL); + while (fgets(linebuf, sizeof(linebuf),fp)) { + if (strstr(linebuf, "******")) + break; + linebuf[strlen(linebuf)-1] = '\0'; // No \n at end + prout(linebuf); + } fclose(fp); } @@ -677,7 +682,7 @@ void debugme(void) { case FSCMOVE: proutn("SC Move "); break; case FSCDBAS: proutn("SC Base Destroy "); break; } - proutn("%82.2f", future[i]-game.state.date); + proutn("%.2f", future[i]-game.state.date); chew(); proutn(" ?"); key = scan();