;
if (c == EOF)
return -1;
+ ungetc(c, f);
#ifdef HAVE_GETDELIM
{
int count = 0;
{
int unameread = 0;
int unamelen = 30;
- char *username;
+ char *username = malloc(unamelen);
+ if (!username)
+ return -1;
while ((c = getc(f)) != EOF
&& !isspace(c))
username[unameread] = c;
unameread++;
}
+ if (c == EOF)
+ return -1;
+ username[unameread] = '\0';
score->username = username;
}
#endif
char *buf = malloc(len);
if (!buf)
return -1;
- while ((c = getc(f)) != EOF)
+ while ((c = getc(f)) != EOF
+ && c != '\n')
{
if (cur >= len-1)
{
cur++;
}
score->data = buf;
- score->data[cur+1] = '\0';
}
#endif
/* Trim the newline */