[760] in Athena Bugs
/paris/source/4.3/usr.athena/print9700.c
daemon@ATHENA.MIT.EDU (probe@ATHENA.MIT.EDU)
Fri Sep 2 10:17:13 1988
From: <probe@ATHENA.MIT.EDU>
Date: Fri, 2 Sep 88 10:16:39 EDT
To: bugs@ATHENA.MIT.EDU, jik@ATHENA.MIT.EDU
Reply-To: Richard Basch <probe@ATHENA.MIT.EDU>
The problem in the original proposed fix is that a null string can be
entered and it will be interpreted as an EOF.
Here is another proposed fix. This should take care of the EOF problem
and it also solves a problem of when you enter a null string (or at
least it seems to do a more logical thing... prompt again, saying type
"quit" if you want to exit).
Does anyone see anything wrong with this?
Henry, do you approve of the second change? If so, I will go ahead and
change the sources and add this program to /srvd/patch.
-Richard
*** /paris/source/4.3/usr.athena/print9700.c Sat Dec 20 21:19:20 1986
--- ./print9700.c Fri Sep 2 10:10:09 1988
***************
*** 102,112 ****
if (!first_time || !filename_in_arg_list) {
get_response("What file would you like to print?",
filename);
}
first_time = 0;
! if (access(filename, R_OK)) {
printf("Cannot access \"%s\".\n", filename);
printf("Please enter the name again or type \"quit\" to abort\n");
}
else got_filename = 1;
}
--- 102,112 ----
if (!first_time || !filename_in_arg_list) {
get_response("What file would you like to print?",
filename);
}
first_time = 0;
! if (! *filename || access(filename, R_OK)) {
printf("Cannot access \"%s\".\n", filename);
printf("Please enter the name again or type \"quit\" to abort\n");
}
else got_filename = 1;
}
***************
*** 407,417 ****
{
char buffer[100];
int i = 0;
input:
printf("\n%s ", question);
! gets(buffer);
while (buffer[i] == ' ')
i++;
if (!strcmp(&buffer[i], "quit") || !strcmp(&buffer[i], "exit")) {
if (askyn("Do you really want to exit?")) {
printf("Exiting...\n");
--- 407,420 ----
{
char buffer[100];
int i = 0;
input:
printf("\n%s ", question);
! if (gets(buffer) == NULL && feof(stdin)) {
! fprintf(stderr,"\nUnexpected EOF... exiting.\n");
! exit(1);
! }
while (buffer[i] == ' ')
i++;
if (!strcmp(&buffer[i], "quit") || !strcmp(&buffer[i], "exit")) {
if (askyn("Do you really want to exit?")) {
printf("Exiting...\n");