/[emacs]/emacs/lib-src/update-game-score.c
ViewVC logotype

Diff of /emacs/lib-src/update-game-score.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by walters, Fri Apr 5 08:53:37 2002 UTC revision 1.3 by walters, Fri Apr 5 09:18:57 2002 UTC
# Line 189  read_score(FILE *f, struct score_entry * Line 189  read_score(FILE *f, struct score_entry *
189      ;      ;
190    if (c == EOF)    if (c == EOF)
191      return -1;      return -1;
192      ungetc(c, f);
193  #ifdef HAVE_GETDELIM  #ifdef HAVE_GETDELIM
194    {    {
195      int count = 0;      int count = 0;
# Line 200  read_score(FILE *f, struct score_entry * Line 201  read_score(FILE *f, struct score_entry *
201    {    {
202      int unameread = 0;      int unameread = 0;
203      int unamelen = 30;      int unamelen = 30;
204      char *username;      char *username = malloc(unamelen);
205        if (!username)
206          return -1;
207            
208      while ((c = getc(f)) != EOF      while ((c = getc(f)) != EOF
209             && !isspace(c))             && !isspace(c))
# Line 213  read_score(FILE *f, struct score_entry * Line 216  read_score(FILE *f, struct score_entry *
216          username[unameread] = c;          username[unameread] = c;
217          unameread++;          unameread++;
218        }        }
219        if (c == EOF)    
220          return -1;
221        username[unameread] = '\0';
222      score->username = username;      score->username = username;
223    }    }
224  #endif  #endif
# Line 231  read_score(FILE *f, struct score_entry * Line 237  read_score(FILE *f, struct score_entry *
237      char *buf = malloc(len);      char *buf = malloc(len);
238      if (!buf)      if (!buf)
239        return -1;        return -1;
240      while ((c = getc(f)) != EOF)      while ((c = getc(f)) != EOF
241               && c != '\n')
242        {        {
243          if (cur >= len-1)          if (cur >= len-1)
244            {            {
# Line 242  read_score(FILE *f, struct score_entry * Line 249  read_score(FILE *f, struct score_entry *
249          cur++;          cur++;
250        }        }
251      score->data = buf;      score->data = buf;
     score->data[cur+1] = '\0';  
252    }    }
253  #endif  #endif
254    /* Trim the newline */    /* Trim the newline */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26