bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

3 readline bugs: source positions, readline-options, endless loop on err


From: Martin Grabmueller
Subject: 3 readline bugs: source positions, readline-options, endless loop on error
Date: Thu, 25 Jan 2001 10:12:38 +0100

Hello,

`readline-options' and the corresponding `*-enable' and `*-disable'
procedures do not work:

guile> (readline-options )
ERROR: Unbound variable: readline-options-interface
ABORT: (unbound-variable)
guile> (readline-enable 'history-file)
ERROR: Unbound variable: readline-options-interface
ABORT: (unbound-variable)

Seems like `readline-options-interface' is not exported properly.
Unfortunately, I do not feel like at home with the module system yet,
so I cannot provide a fix for this.


The next problem is that with readline, you don't get source positions
in error messages.  The reason is that the readline port created by
`make-readline-port' (readline.scm) is not given a file name.  The
following patch fixes the problem for simple cases, but not when
calling `set-readline-input-port!', which should also copy the
filename; but I am not sure how to test this procedure.

Maybe this problem is not worth fixing anyway, because the filename is
always `standard input'.

Index: readline.scm
===================================================================
RCS file: /cvs/guile/guile-core/guile-readline/readline.scm,v
retrieving revision 1.8
diff -u -r1.8 readline.scm
--- readline.scm        2001/01/19 09:00:05     1.8
+++ readline.scm        2001/01/25 09:13:42
@@ -82,9 +82,11 @@
                  (let ((res (string-ref read-string string-index)))
                    (set! string-index (+ 1 string-index))
                    res))))))         
-      (make-soft-port
-       (vector #f #f #f get-character #f)
-       "r"))))
+      (let ((rl-port (make-soft-port
+                     (vector #f #f #f get-character #f)
+                     "r")))
+       (set-port-filename! rl-port (port-filename input-port))
+       rl-port))))
 
 ;;; We only create one readline port.  There's no point in having
 ;;; more, since they would all share the tty and history ---

Another bug I found: when using `set-readline-input-port!' with an
invalid argument, Guile goes into an endless loop printing:

...
ERROR: In procedure %readline:
ERROR: Input port is not open or not a file port
ABORT: (misc-error)
ERROR: In procedure %readline:
ERROR: Input port is not open or not a file port
ABORT: (misc-error)
...

and must be kill'ed -9, because C-c is blocked.  The reason is that
`%readline' throws an error because of the wrong type argument, the
repl catches the error and calls `readline', which in turn calls
`%readline' and so on...

Two possible fixes came to my mind:

- Check the argument in `set-readline-input-port!' and only accept
  valid open input ports.
- When the argument check in `%readline' fails, reset the current
  input port to the standard input file port.

I think the first is preferable.

Thx,
  'Martin
-- 
Martin Grabmueller              address@hidden
http://www.pintus.de/mgrabmue/  address@hidden on EFnet



reply via email to

[Prev in Thread] Current Thread [Next in Thread]