Page 1 of 1

exec in newlisp 10.7.1/Windows

Posted: Fri Feb 17, 2017 6:29 pm
by Cyril
Seems like exec in newlisp 10.7.1/Windows opens it's second argument in text (as opposed to binary) mode. Test:

Code: Select all

(exec "od -b" "hello\r\nworld\r\n")
Output with newlisp 10.6.2

Code: Select all

0000000 150 145 154 154 157 015 012 167 157 162 154 144 015 012
Output with newlisp 10.7.1

Code: Select all

0000000 150 145 154 154 157 015 015 012 167 157 162 154 144 015 015 012
I suppose this is a side effect of the change to a newer MinGW. But still confusing - "binary mode everywhere" policy was consistent so far.

Re: exec in newlisp 10.7.1/Windows

Posted: Mon Feb 20, 2017 12:05 am
by Lutz
The translation from “\n” to “\r\n” happens in the newer MINGW development system call popen() or _popen(). Both do the same text translation in current MINGW versions used.

In newLISP popen() is used only in the exec function and when writing CGI output in newLISP builtin web server (nl-web.c).

When using text just use the UNIX “\n” line-feed format as input on both UNIX and Windows. When you need strictly binary format on Windows then convert data to a binary file first then use exec on that:

Code: Select all

> (write-file "binfile" "\n\n\n")
3
> (exec "od -b binfile")
("0000000   012 012 012" "0000003")
> 
and it will not do the Windows linefeed text translation.