]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/news.cpp
First update in a while... added a couple includes to news.cpp and hash.cpp for picky...
[irc/gameservirc.git] / gameserv / news.cpp
index 2040d2de1b64e918a082fa9dfe2749798a19363b..3aff621f319a348a44725c3ebaeeb5c2cdc3e2fe 100644 (file)
@@ -1,5 +1,6 @@
 #include "extern.h"
 #include <fstream>
+#include <stdio.h>
 
 using std::ofstream;
 using std::ifstream;
@@ -76,11 +77,9 @@ void showNews(char *nick, List<myString> &news)
 
 void saveNews(char *filename, List<myString> &news)
 {
-    if (news.isEmpty())
-       return;
-
     ofstream outfile;
     outfile.open(filename);
+
     if (outfile.fail())
     {
        log("Error opening %s", filename);
@@ -125,6 +124,11 @@ void loadNews(char *filename, List<myString> &news)
 
     while (infile.getline(buf, 1024, '\n'))
     {
+       if (buf[0] == '\0' || buf[0] == '\n')
+       {
+           delete [] buf;
+           return;
+       }
        string = new myString(buf);
        news.insertAtBack(string);
        delete string;