changeset 34581:dba158d9b986

Simplify end-of-file detection. Don't double-check foef() and fgetstr(), because fgetstr() already reports EOF.
author ib
date Thu, 09 Feb 2012 14:26:12 +0000
parents 065029b847e5
children d0617776d506
files gui/cfg.c
diffstat 1 files changed, 3 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/gui/cfg.c	Thu Feb 09 14:14:39 2012 +0000
+++ b/gui/cfg.c	Thu Feb 09 14:26:12 2012 +0000
@@ -273,12 +273,9 @@
     file  = fopen(fname, "rt");
 
     if (file) {
-        while (!feof(file)) {
+        while (fgetstr(line, sizeof(line), file)) {
             plItem *item;
 
-            if (fgetstr(line, sizeof(line), file) == NULL)
-                continue;
-
             item       = calloc(1, sizeof(plItem));
             item->path = strdup(line);
             fgetstr(line, sizeof(line), file);
@@ -297,12 +294,9 @@
     file  = fopen(fname, "rt");
 
     if (file) {
-        while (!feof(file)) {
+        while (fgetstr(line, sizeof(line), file)) {
             urlItem *item;
 
-            if (fgetstr(line, sizeof(line), file) == NULL)
-                continue;
-
             item      = calloc(1, sizeof(urlItem));
             item->url = strdup(line);
             listSet(gtkAddURLItem, item);
@@ -321,12 +315,8 @@
     if (file) {
         int i = 0;
 
-        while (!feof(file)) {
-            if (fgetstr(line, sizeof(line), file) == NULL)
-                continue;
-
+        while (fgetstr(line, sizeof(line), file))
             fsHistory[i++] = gstrdup(line);
-        }
 
         fclose(file);
     }