aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorColin Walters2002-04-05 09:18:57 +0000
committerColin Walters2002-04-05 09:18:57 +0000
commitf5bceaf89b3b88f42da85cbce98cadf9429c3974 (patch)
tree6881f631867fbfb7c2ba374886275d7451bb06b8 /lib-src
parentcd553ffbf3c5eae5d6edb492ff62ce3fb6e7e6b8 (diff)
downloademacs-f5bceaf89b3b88f42da85cbce98cadf9429c3974.tar.gz
emacs-f5bceaf89b3b88f42da85cbce98cadf9429c3974.zip
Actually make previous changes work (oops).
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/update-game-score.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib-src/update-game-score.c b/lib-src/update-game-score.c
index e713d732fef..084b54fdb32 100644
--- a/lib-src/update-game-score.c
+++ b/lib-src/update-game-score.c
@@ -189,6 +189,7 @@ read_score(FILE *f, struct score_entry *score)
189 ; 189 ;
190 if (c == EOF) 190 if (c == EOF)
191 return -1; 191 return -1;
192 ungetc(c, f);
192#ifdef HAVE_GETDELIM 193#ifdef HAVE_GETDELIM
193 { 194 {
194 int count = 0; 195 int count = 0;
@@ -200,7 +201,9 @@ read_score(FILE *f, struct score_entry *score)
200 { 201 {
201 int unameread = 0; 202 int unameread = 0;
202 int unamelen = 30; 203 int unamelen = 30;
203 char *username; 204 char *username = malloc(unamelen);
205 if (!username)
206 return -1;
204 207
205 while ((c = getc(f)) != EOF 208 while ((c = getc(f)) != EOF
206 && !isspace(c)) 209 && !isspace(c))
@@ -213,6 +216,9 @@ read_score(FILE *f, struct score_entry *score)
213 username[unameread] = c; 216 username[unameread] = c;
214 unameread++; 217 unameread++;
215 } 218 }
219 if (c == EOF)
220 return -1;
221 username[unameread] = '\0';
216 score->username = username; 222 score->username = username;
217 } 223 }
218#endif 224#endif
@@ -231,7 +237,8 @@ read_score(FILE *f, struct score_entry *score)
231 char *buf = malloc(len); 237 char *buf = malloc(len);
232 if (!buf) 238 if (!buf)
233 return -1; 239 return -1;
234 while ((c = getc(f)) != EOF) 240 while ((c = getc(f)) != EOF
241 && c != '\n')
235 { 242 {
236 if (cur >= len-1) 243 if (cur >= len-1)
237 { 244 {
@@ -242,7 +249,6 @@ read_score(FILE *f, struct score_entry *score)
242 cur++; 249 cur++;
243 } 250 }
244 score->data = buf; 251 score->data = buf;
245 score->data[cur+1] = '\0';
246 } 252 }
247#endif 253#endif
248 /* Trim the newline */ 254 /* Trim the newline */