octave-maintainers
[Top][All Lists]
Advanced

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

Re: Problem with "yes_or_no" and newline character


From: John W. Eaton
Subject: Re: Problem with "yes_or_no" and newline character
Date: Wed, 4 Apr 2007 16:07:18 -0400

On  4-Apr-2007, Michael Goffioul wrote:

| On 4/4/07, John W. Eaton <address@hidden> wrote:
| > On  4-Apr-2007, Michael Goffioul wrote:
| >
| > | When executing
| > |
| > |     eval('yes_or_no("Close ? ")')
| > |
| > | the "yes_or_no" never terminates, because the newline character
| > | is appended to the string returned by interactive_input, which is not
| > | expected by yes_or_no. When doing the call within "eval", "line_editing"
| > | is set to false, resulting in "gnu_readline" calling "octave_fgets" 
instead
| > | of "command_editor::readline". The problem is that "octave_fgets" includes
| > | the newline character, while "command_editor::readline" does not.
| > |
| > | Using "octave_fgetl" would probably solve the problem (cannot test for
| > | the moment).
| >
| > How about the following patch?
| 
| This would solve the problem I have. But this doesn't change the fact
| that in gnu_readline function, the 2 possible cases ('"if" statement)
| return different results. This is IMO a bad idea.

Having the gnu_readline function call octave_fgetl instead of
octave_fgets won't work because the parser needs the newline
characters when input is coming from a file.

I don't see a simple fix for this problem right now.  The code in
input.cc could use some cleaning up.  There are currently too many
cases and at this point it is not clear how or why each exists.

BTW, why do you need to eval 'yes_or_no("Close ? ")'?

jwe


reply via email to

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