From: Adam Dickmeiss Date: Mon, 16 Feb 2009 22:05:31 +0000 (+0100) Subject: Dont assume error if fgets returns NULL X-Git-Tag: v3.0.44~3 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=442f9815fa99344367af117cba29f2c0e209a0cf;p=yaz-moved-to-github.git Dont assume error if fgets returns NULL --- diff --git a/client/client.c b/client/client.c index 5126d97..93741ca 100644 --- a/client/client.c +++ b/client/client.c @@ -3547,16 +3547,12 @@ int cmd_source(const char* arg, int echo ) return -1; } - while (!feof(includeFile)) { - memset(line, 0, sizeof(line)); - if (!fgets(line, sizeof(line), includeFile)) - { - perror("fgets"); - break; - } - - if (strlen(line) < 2) continue; - if (line[0] == '#') continue; + while (fgets(line, sizeof(line), includeFile)) + { + if (strlen(line) < 2) + continue; + if (line[0] == '#') + continue; if ((cp = strrchr(line, '\n'))) *cp = '\0';