|
From: Bruno H. <br...@cl...> - 2005-06-03 16:56:56
|
David Tolpin wrote in c.l.l:
> This does not save from hacking, unfortunately; CLISP always calls
> fresh-line on standard output, and never sets argv_verbose to zero if
> used as a script interpreter. I've just had to fix spvw.d to make it
> work (that is, to regard -q set twice despite of scripts etc., and to
> not print newline on stdout on exit if argv_verbose is 0).
- About argv_verbose: Did you try using
#!/usr/bin/env clisp -q
or similar in your script, to reduce the verbosity? See the section
"Quickstarting delivery with CLISP" in the impnotes.html.
- About the newline: Can you let us reproduce the problem? When I do
$ LC_ALL=C clisp -q foo3.lisp
where foo3.lisp contains just a nop form, no output is sent to stdout
at all.
Bruno
|
|
From: David T. <dv...@da...> - 2005-06-03 17:15:40
|
Hi Bruno,
> David Tolpin wrote in c.l.l:
>> This does not save from hacking, unfortunately; CLISP always calls
>> fresh-line on standard output, and never sets argv_verbose to zero if
>> used as a script interpreter. I've just had to fix spvw.d to make it
>> work (that is, to regard -q set twice despite of scripts etc., and to
>> not print newline on stdout on exit if argv_verbose is 0).
>
> - About argv_verbose: Did you try using
> #!/usr/bin/env clisp -q
> or similar in your script, to reduce the verbosity? See the section
> "Quickstarting delivery with CLISP" in the impnotes.html.
Yes, I even set it twice, -q -q, and then patched spvw.d, see below, to
not fresh-line if argv_verbose. It along did not help because spvw.d
2922 # Perform the main actions as specified by the command-line
arguments.
2923 local inline void main_actions (struct argv_actions *p) {
2924 /* print greeting: */
2925 if (!nullpSv(quiet)) /* SYS::*QUIET* /= NIL ? */
2926 { p->argv_verbose = 1; } /* prevents the greeting */
2927 if (p->argv_execute_file != NULL) /* batch-mode ? */
2928 { p->argv_verbose = 1; } /* prevents the greeting */
opposite to what the documentation says, argv_verbose does not become
0, because it is reset to 1.
Changed it to if(p->argv_verbose) p->argv_verbose = 1;
to make it work.
(Actually, I was changing the last stable version, clisp-2.33.2, but it
is almost the same with the current CVS branch).
> - About the newline: Can you let us reproduce the problem? When I do
> $ LC_ALL=C clisp -q foo3.lisp
> where foo3.lisp contains just a nop form, no output is sent to stdout
> at all.
Yes, because it is freshline, not newline. From spvw.d
3370 /* when running as a script, i.e. "clisp lisp-file",
3371 *standard-input* is /dev/fd/0
3372 *standard-output* is /dev/fd/1
3373 *error-output* is /dev/fd/2
3374 and *terminal-io* is an #<IO TERMINAL-STREAM>,
3375 so they all need to be terminated individually */
3376 funcall(L(fresh_line),0); # (FRESH-LINE [*standard-output*])
3377 pushSTACK(var_stream(S(error_output),strmflags_wr_ch_B));
3378 funcall(L(fresh_line),1); /* (FRESH-LINE *error-output*)
*/
3379 pushSTACK(Symbol_value(S(terminal_io)));
3380 funcall(L(fresh_line),1); /* (FRESH-LINE *terminal-io*) */
3381 if (argv2.argv_verbose >= 2) {
3382 pushSTACK(CLSTEXT("Bye.")); funcall(L(write_line),1);
3383 }
Line 3376 always sends fresh-line to stdout.
David
|
|
From: Bruno H. <br...@cl...> - 2005-06-03 18:15:46
|
David Tolpin wrote:
> 2925 if (!nullpSv(quiet)) /* SYS::*QUIET* /= NIL ? */
> 2926 { p->argv_verbose = 1; } /* prevents the greeting */
> 2927 if (p->argv_execute_file != NULL) /* batch-mode ? */
> 2928 { p->argv_verbose = 1; } /* prevents the greeting */
>
> opposite to what the documentation says, argv_verbose does not become
> 0, because it is reset to 1.
Thanks for explaining. I'm fixing this now.
> Yes, because it is freshline, not newline. From spvw.d
>
> 3370 /* when running as a script, i.e. "clisp lisp-file",
> 3371 *standard-input* is /dev/fd/0
> 3372 *standard-output* is /dev/fd/1
> 3373 *error-output* is /dev/fd/2
> 3374 and *terminal-io* is an #<IO TERMINAL-STREAM>,
> 3375 so they all need to be terminated individually */
> 3376 funcall(L(fresh_line),0); # (FRESH-LINE [*standard-output*])
> 3377 pushSTACK(var_stream(S(error_output),strmflags_wr_ch_B));
> 3378 funcall(L(fresh_line),1); /* (FRESH-LINE *error-output*) */
> 3379 pushSTACK(Symbol_value(S(terminal_io)));
> 3380 funcall(L(fresh_line),1); /* (FRESH-LINE *terminal-io*) */
> 3381 if (argv2.argv_verbose >= 2) {
> 3382 pushSTACK(CLSTEXT("Bye.")); funcall(L(write_line),1);
> 3383 }
>
> Line 3376 always sends fresh-line to stdout.
Yes. And this is needed to ensure that after clisp terminated, the next
prompt comes in a fresh line or, if the output went to a file, the last
line of the file is correctly terminated. In your case, you will probably
need to call FRESH-LINE on the output stream before you switch it to
binary, if you want no newline after the binary part.
Bruno
|
|
From: David T. <dv...@da...> - 2005-06-03 18:24:39
|
> Yes. And this is needed to ensure that after clisp terminated, the next > prompt comes in a fresh line or, if the output went to a file, the last > line of the file is correctly terminated. In your case, you will > probably > need to call FRESH-LINE on the output stream before you switch it to > binary, if you want no newline after the binary part. Hi Bruno, under Mac OS X I cannot 'switch to binary', /dev/stdout is locked (by setting it to ------) once it is open, and when I close *standard-output* from CLISP, I cannot re-open it. But let's leave this issue alone; I am not going to convince you that there is indeed a character with code 13 in Latin-1 encoding. I just want to send as many characters (well, bytes in fact, but let's assume they are characters) to the output stream, no more, no less. This should not be different from closing any file. When I close a file, CLISP (as well as any other lisp implementation available to me) does not fresh-line it. Where in the standard it is written that the last line to *standard-output* (redirected to a pipe going to a browser through an http server) must be properly terminated by calling fresh-line? I just want to get what I asked to. I just don't want any program to do things I didn't ask it to. (That's why I don't use Emacs, by the way). David |