diff --git a/libguile/fports.c b/libguile/fports.c index 148e71a5a..18cdef03e 100644 --- a/libguile/fports.c +++ b/libguile/fports.c @@ -416,6 +416,16 @@ local_fgets (SCM port, int *len) pre_read (port); + /* If this is a socket port or something where we can't rely on + ftell to determine how much we've read, then call the generic + function. We could use a separate scm_ptobfuns table with + scm_generic_fgets, but then we'd have to change SCM_FPORTP, etc. + Ideally, it should become something that means "this port has a + file descriptor"; sometimes we reject sockets when we shouldn't. + But I'm too stupid at the moment to do that right. */ + if (SCM_CAR (port) & SCM_NOFTELL) + return scm_generic_fgets (port, len); + f = (FILE *) SCM_STREAM (port); if (feof (f)) return NULL; diff --git a/libguile/ports.h b/libguile/ports.h index a74f14248..46972790c 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -83,6 +83,7 @@ extern int scm_port_table_size; /* Number of ports in scm_port_table. */ #define SCM_RDNG (2L<<16) /* Is it a readable port? */ #define SCM_WRTNG (4L<<16) /* Is it writable? */ #define SCM_BUF0 (8L<<16) +#define SCM_NOFTELL (16L<<16) /* Does ftell work on this? Yuck! */ #define SCM_CRDY (32L<<16) /* Should char-ready? return #t? */ /* A mask used to clear the char-ready port flag. */ diff --git a/libguile/socket.c b/libguile/socket.c index 6e35b9909..9b5f20497 100644 --- a/libguile/socket.c +++ b/libguile/socket.c @@ -107,6 +107,7 @@ scm_socket (family, style, proto) SCM_DEFER_INTS; fd = socket (SCM_INUM (family), SCM_INUM (style), SCM_INUM (proto)); result = scm_sock_fd_to_port (fd, s_socket); + SCM_SETOR_CAR (result, SCM_NOFTELL); SCM_ALLOW_INTS; return result; }