sprintf(buf, format, *val);
printf("%30s [%s] ", prompt, buf);
- fgets(buf, sizeof(buf), stdin);
+ if (!fgets(buf, sizeof(buf), stdin))
+ return;
if (buf[strlen (buf) - 1] == '\n')
buf[strlen (buf) - 1] = '\0';
if (!buf[0])
sprintf(buf, format, *val);
printf("%30s [%s] ", prompt, buf);
- fgets(buf, sizeof(buf), stdin);
+ if (!fgets(buf, sizeof(buf), stdin))
+ return;
if (buf[strlen (buf) - 1] == '\n')
buf[strlen (buf) - 1] = '\0';
if (!buf[0])
sprintf(buf, format, *val);
printf("%30s [%s] ", prompt, buf);
- fgets(buf, sizeof(buf), stdin);
+ if (!fgets(buf, sizeof(buf), stdin))
+ return;
if (buf[strlen (buf) - 1] == '\n')
buf[strlen (buf) - 1] = '\0';
if (!buf[0])
if (!(f = fopen("/proc/swaps", "r")))
return 0;
/* Skip the first line */
- fgets(buf, sizeof(buf), f);
- while (!feof(f)) {
- if (!fgets(buf, sizeof(buf), f))
- break;
+ if (fgets(buf, sizeof(buf), f))
+ while (fgets(buf, sizeof(buf), f)) {
if ((cp = strchr(buf, ' ')) != NULL)
*cp = 0;
if ((cp = strchr(buf, '\t')) != NULL)
fflush(stderr);
fputs(_("Proceed anyway? (y,n) "), stdout);
buf[0] = 0;
- fgets(buf, sizeof(buf), stdin);
- if (strchr(short_yes, buf[0]) == 0)
+ if (!fgets(buf, sizeof(buf), stdin) ||
+ strchr(short_yes, buf[0]) == 0)
exit(1);
}