bug-apl
[Top][All Lists]
Advanced

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

Re: [Bug-apl] Is this output incorrect?


From: Juergen Sauermann
Subject: Re: [Bug-apl] Is this output incorrect?
Date: Sun, 01 Jun 2014 14:00:30 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130330 Thunderbird/17.0.5

Hi Peter,

almost correct. The first comment should be "// may point to an optional string typically containing 6 spaces".
prompt can be 0 and then no prompt is printed. Otherwise the function pushes the prompt (backwards)
back into stdin. Whether that works is a matter of the underlying operating system. The man page
of ungetc() says that only 1 ungetc() char is guaranteed but we push 6. Another question is whether
an ungetc() into stdin will occur on C++ cin?

The main use case for this were scripts where it does not matter too much if a prompt is printed
or not. Note also that pushing chars back into stdin has a different effect than just printing the prompt
- there are  cases where the prompt should be editable (⍞ I believe).

/// Jürgen


On 06/01/2014 04:22 AM, Peter Teeson wrote:
Hi Jürgen:
Well please help me properly understand the no_readline function in Input.cc.
Because it's called instead of the readline library because of the --rawCIN.
I've made comments of my interpretation of the code but am probably wrong.
So I'd appreciate any contribution to my very rusty C++.

no_readline(const UCS_string * prompt)
{
   if (prompt) // points at 6 spaces x'20'
      {
        CIN << '\r' << *prompt << flush; // CIN is an ostream see Output.cc
        UTF8_string prompt_utf(*prompt);
        loop(p, prompt_utf.size()) // ungets those spaces from stdin
           {
             const int cc = prompt_utf[prompt_utf.size() - p - 1];
             ungetc(cc & 0xFF, stdin);
           }
      }
etc

Much appreciated and

respect…

Peter

On 2014-05-31, at 11:13 AM, Juergen Sauermann <address@hidden> wrote:
Hi Peter,

looks OK to me. (Note: as of recently apl -s does the same as your command line options).

--rawCIN reads directly from the file (stdin in this case) without outputting any prompts.
The line numbers in the ∇-editor count as prompts and are therefore suppressed as well.

However when you display the function with [⎕] then the line numbers are not prompts
but output of the editor.

/// Jürgen



reply via email to

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