fgets(3) returns a pointer, so compare against NULL, not integer 0.
This commit is contained in:
parent
ab80dcdb1c
commit
a3a2bf4b67
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=230044
@ -89,7 +89,7 @@ edit1(int *msgvec, int type)
|
||||
char *p;
|
||||
|
||||
printf("Edit message %d [ynq]? ", msgvec[i]);
|
||||
if (fgets(buf, sizeof(buf), stdin) == 0)
|
||||
if (fgets(buf, sizeof(buf), stdin) == NULL)
|
||||
break;
|
||||
for (p = buf; *p == ' ' || *p == '\t'; p++)
|
||||
;
|
||||
|
@ -734,7 +734,7 @@ command(void)
|
||||
history(hist, &he, H_ENTER, bp);
|
||||
} else {
|
||||
line[0] = 0;
|
||||
if (fgets(line, sizeof line , stdin) == 0) {
|
||||
if (fgets(line, sizeof line , stdin) == NULL) {
|
||||
if (feof(stdin)) {
|
||||
exit(txrx_error);
|
||||
} else {
|
||||
|
@ -422,7 +422,7 @@ handle_existing_file(char **path)
|
||||
fprintf(stderr,
|
||||
"replace %s? [y]es, [n]o, [A]ll, [N]one, [r]ename: ",
|
||||
*path);
|
||||
if (fgets(buf, sizeof(buf), stdin) == 0) {
|
||||
if (fgets(buf, sizeof(buf), stdin) == NULL) {
|
||||
clearerr(stdin);
|
||||
printf("NULL\n(EOF or read error, "
|
||||
"treating as \"[N]one\"...)\n");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1993, 19801990
|
||||
* Copyright (c) 1980, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -154,7 +154,7 @@ makefile(void)
|
||||
fprintf(ofp, "PROFLEVEL=%d\n", profiling);
|
||||
if (*srcdir != '\0')
|
||||
fprintf(ofp,"S=%s\n", srcdir);
|
||||
while (fgets(line, BUFSIZ, ifp) != 0) {
|
||||
while (fgets(line, BUFSIZ, ifp) != NULL) {
|
||||
if (*line != '%') {
|
||||
fprintf(ofp, "%s", line);
|
||||
continue;
|
||||
@ -204,7 +204,7 @@ makehints(void)
|
||||
ifp = fopen(hint->hint_name, "r");
|
||||
if (ifp == NULL)
|
||||
err(1, "%s", hint->hint_name);
|
||||
while (fgets(line, BUFSIZ, ifp) != 0) {
|
||||
while (fgets(line, BUFSIZ, ifp) != NULL) {
|
||||
/* zap trailing CR and/or LF */
|
||||
while ((s = strrchr(line, '\n')) != NULL)
|
||||
*s = '\0';
|
||||
@ -266,7 +266,7 @@ makeenv(void)
|
||||
fprintf(ofp, "int envmode = %d;\n", envmode);
|
||||
fprintf(ofp, "char static_env[] = {\n");
|
||||
if (ifp) {
|
||||
while (fgets(line, BUFSIZ, ifp) != 0) {
|
||||
while (fgets(line, BUFSIZ, ifp) != NULL) {
|
||||
/* zap trailing CR and/or LF */
|
||||
while ((s = strrchr(line, '\n')) != NULL)
|
||||
*s = '\0';
|
||||
|
@ -188,7 +188,7 @@ cmdscanner(void)
|
||||
history(hist, &he, H_ENTER, bp);
|
||||
|
||||
} else {
|
||||
if (fgets(cmdline, MAX_CMDLINE, stdin) == 0)
|
||||
if (fgets(cmdline, MAX_CMDLINE, stdin) == NULL)
|
||||
quit(0, NULL);
|
||||
if (cmdline[0] == 0 || cmdline[0] == '\n')
|
||||
break;
|
||||
|
@ -105,7 +105,7 @@ main(argc, argv)
|
||||
printf("timedc> ");
|
||||
(void) fflush(stdout);
|
||||
}
|
||||
if (fgets(cmdline, sizeof(cmdline), stdin) == 0)
|
||||
if (fgets(cmdline, sizeof(cmdline), stdin) == NULL)
|
||||
quit();
|
||||
if (cmdline[0] == 0)
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user