This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

port-line bug details & patch question.



It seems like port-line works for read-char but not for read-line:

   guile> (define p (open-input-file "ports.c"))
   guile> (read-char p)
   #\/
   guile> (do ((i 0 (1+ i))) ((> i 300)) (read-char p))
   guile> (port-line p)
   5
   guile> (define p (open-input-file "ports.c"))
   guile> (read-line p)
   "/*	Copyright (C) 1995,1996,1997 Free Software Foundation, Inc."
   guile> (read-line p)
   " * "
   guile> (read-line p)
   " * This program is free software; you can redistribute it and/or modify"
   guile> (read-line p)
   " * it under the terms of the GNU General Public License as published by"
   guile> (port-line p)
   0
   guile> 

Checking the code, I see that SCM_INCLINE is called on the port by
scm_getc, but not by any of the readline code (which doesn't go
through scm_getc).

My questions are:

1. Where should it be called for line reading?  The options, as far as
I can tell are:

   scm_do_read_line

or

   scm_fgets & scm_generic_fgets?

The latter seems to parallel its usage in scm_getc better.  The former
is simpler, and keeps the calls to SCM_INCLINE in the one file -
scm_getc & scm_do_readline are both defined in ioext.c, scm_fgets &
scm_generic_fgets are in fports.c.

2. Would one or the other cover all appropriate entry points?  The
code is sufficiently byzantine that it's not at all clear to me that
either one covers all possibilities.

If someone can answer these questions, great - that person could do a
better patch than I could.  If not, I'll make my best guess & submit a
patch.

Thanks,

Harvey J. Stein
BFM Financial Research
hjstein@bfr.co.il