Ticket #915: handle-eof-in-read-string.diff

File handle-eof-in-read-string.diff, 689 bytes (added by felix winkelmann, 9 years ago)

Possible fix

  • library.scm

    diff --git a/library.scm b/library.scm
    index 76eb046..6fe4735 100644
    a b fast_read_string_from_file(C_word dest, C_word port, C_word len, C_word pos) 
    106106  char * buf = ((char *)C_data_pointer (dest) + C_unfix (pos));
    107107  C_FILEPTR fp = C_port_file (port);
    108108
     109  if(feof(fp)) return C_SCHEME_END_OF_FILE;
     110
    109111  size_t m = fread (buf, sizeof (char), n, fp);
    110112
    111113  if(m == EOF && errno == EINTR) {
    fast_read_string_from_file(C_word dest, C_word port, C_word len, C_word pos) 
    114116  }
    115117  else if (m < n) {
    116118    if (feof (fp)) {
    117       clearerr (fp);
    118119      if (0 == m)
    119120        return C_SCHEME_END_OF_FILE;
    120121    } else if (ferror (fp)) {