/* hdr.h: included by c advent files */
#include <sys/types.h>
+#include <stdio.h>
int datfd; /* message file descriptor */
int delhit;
#define TAB 011
#define LF 012
-#define FLUSHLINE while (getchar()!='\n')
+#define FLUSHLINE do { int c; while ((c = getchar()) != EOF && c != '\n'); } while (0)
#define FLUSHLF while (next()!=LF)
int loc,newloc,oldloc,oldlc2,wzdark,gaveup,kq,k,k2;
*s=0;
return;
}
+ case EOF:
+ printf("user closed input stream, quitting...\n");
+ exit(0);
default:
if (++numch>=MAXSTR) /* string too long */
{ printf("Give me a break!!\n");
confirm(mesg) /* confirm irreversible action */
char *mesg;
{ register int result;
+ register int c;
printf("%s",mesg); /* tell him what he did */
- if (getchar()=='y') /* was his first letter a 'y'? */
+ if ((c = getchar())=='y') /* was his first letter a 'y'? */
result=1;
- else result=0;
+ else if (c == EOF) {
+ printf("user closed input stream, quitting...\n");
+ exit(0);
+ } else result=0;
FLUSHLINE;
return(result);
}
yes(x,y,z) /* confirm with rspeak */
int x,y,z;
{ register int result;
- register char ch;
+ register int ch;
for (;;)
{ rspeak(x); /* tell him what we want*/
if ((ch=getchar())=='y')
result=TRUE;
else if (ch=='n') result=FALSE;
+ else if (ch == EOF) {
+ printf("user closed input stream, quitting...\n");
+ exit(0);
+ }
FLUSHLINE;
if (ch=='y'|| ch=='n') break;
printf("Please answer the question.\n");
if ((ch=getchar())=='y')
result=TRUE;
else if (ch=='n') result=FALSE;
+ else if (ch == EOF) {
+ printf("user closed input stream, quitting...\n");
+ exit(0);
+ }
FLUSHLINE;
if (ch=='y'|| ch=='n') break;
printf("Please answer the question.\n");
printf("What would you like to call the saved version?\n");
for (c=fname;; c++)
- if ((*c=getchar())=='\n') break;
+ if ((*c=getchar())=='\n' || *c == EOF) break;
*c=0;
if (save(fname) != 0) return; /* Save failed */
printf("To resume, say \"adventure %s\".\n", fname);