From: Aaron Brown
Subject: CLISP (Cygwin) defaults to :DOS instead of :UNIX
Date: 
Message-ID: <1163826585.552254.121620@b28g2000cwb.googlegroups.com>
Unlike a few other recent messages with "clisp" in the
subject, this one is actually about CLISP!

I'm using version 2.36 as downloaded from a Cygwin mirror,
and my *default-file-encoding* uses dos-style line
terminators

  [1]> *default-file-encoding*
  #<ENCODING CHARSET:ASCII :DOS>

even though my Cygwin installation is set to use unix ones.
I poked around in the source, but couldn't figure out when
or how CLISP decides what to set this to.  How do I get it
to use :UNIX?

Thanks,

-- 
Aaron
http://www.amazon.com/gp/product/0470069171/

From: Pascal Bourguignon
Subject: Re: CLISP (Cygwin) defaults to :DOS instead of :UNIX
Date: 
Message-ID: <87ac2p6u04.fsf@thalassa.informatimago.com>
"Aaron Brown" <········@hotmail.com> writes:

> Unlike a few other recent messages with "clisp" in the
> subject, this one is actually about CLISP!
>
> I'm using version 2.36 as downloaded from a Cygwin mirror,
> and my *default-file-encoding* uses dos-style line
> terminators
>
>   [1]> *default-file-encoding*
>   #<ENCODING CHARSET:ASCII :DOS>
>
> even though my Cygwin installation is set to use unix ones.
> I poked around in the source, but couldn't figure out when
> or how CLISP decides what to set this to.  How do I get it
> to use :UNIX?

(In clisp-2.41) it's in encoding.d, line 2535: (encoding_from_name and
init_dependent_encodings).  If you don't specify a -E or -Efile
option, it'll be taken from the locale, and it selects the
line-terminator so:

 #if defined(WIN32) || (defined(UNIX) && (O_BINARY != 0))
  pushSTACK(S(Kdos));           /* :line-terminator */
 #else
  pushSTACK(S(Kunix));          /* :line-terminator */
 #endif


So it seems that Cygwin is not considered a UNIX at compilation
time...

On the other hand, it appears we cannot specify a line terminator from
the command line, so there remains two ways to handle the situation:

Start with:

clisp -x '(setf custom:default-file-encoding (ext:make-encoding :charset charset:iso-8859-1 :line-terminator :unix))' ...

or put:

(setf custom:default-file-encoding (ext:make-encoding :charset charset:iso-8859-1
                                                      :line-terminator :unix))

in '~/.clisprc'.



You can do that with:

clisp -x '
(with-open-file (out (make-pathname :name ".clisprc" :type nil :version nil
                                    :defaults (user-homedir-pathname))
                     :external-format (ext:make-encoding :charset charset:iso-8859-1
                                                         :line-terminator :unix)
                     :direction :output
                     :if-does-not-exist :create
                     :if-exists :append)
   (pprint  '(setf custom:default-file-encoding
                   (ext:make-encoding :charset charset:iso-8859-1
                                      :line-terminator :unix)) out))
'


http://clisp.cons.org/impnotes/encoding.html

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

ATTENTION: Despite any other listing of product contents found
herein, the consumer is advised that, in actuality, this product
consists of 99.9999999999% empty space.
From: Wolfram Fenske
Subject: Re: CLISP (Cygwin) defaults to :DOS instead of :UNIX
Date: 
Message-ID: <1163843769.880098.183710@k70g2000cwa.googlegroups.com>
Pascal Bourguignon <···@informatimago.com> writes:

> "Aaron Brown" <········@hotmail.com> writes:

[...]

>> I'm using version 2.36 as downloaded from a Cygwin mirror,
>> and my *default-file-encoding* uses dos-style line
>> terminators
>>
>>   [1]> *default-file-encoding*
>>   #<ENCODING CHARSET:ASCII :DOS>

[...]

> or put:
>
> (setf custom:default-file-encoding (ext:make-encoding :charset charset:iso-8859-1
>                                                       :line-terminator :unix))
>
> in '~/.clisprc'.

Just a tiny mistake that I stumbled over when I tried this: the symbol
is called `custom:*default-file-encoding*', not
`custom:default-file-encoding'.

--
Wolfram Fenske

A: Yes.
>Q: Are you sure?
>>A: Because it reverses the logical flow of conversation.
>>>Q: Why is top posting frowned upon?
From: Pascal Bourguignon
Subject: Re: CLISP (Cygwin) defaults to :DOS instead of :UNIX
Date: 
Message-ID: <87d57l59a7.fsf@thalassa.informatimago.com>
"Wolfram Fenske" <·····@gmx.net> writes:

> Pascal Bourguignon <···@informatimago.com> writes:
>
>> "Aaron Brown" <········@hotmail.com> writes:
>
> [...]
>
>>> I'm using version 2.36 as downloaded from a Cygwin mirror,
>>> and my *default-file-encoding* uses dos-style line
>>> terminators
>>>
>>>   [1]> *default-file-encoding*
>>>   #<ENCODING CHARSET:ASCII :DOS>
>
> [...]
>
>> or put:
>>
>> (setf custom:default-file-encoding (ext:make-encoding :charset charset:iso-8859-1
>>                                                       :line-terminator :unix))
>>
>> in '~/.clisprc'.
>
> Just a tiny mistake that I stumbled over when I tried this: the symbol
> is called `custom:*default-file-encoding*', not
> `custom:default-file-encoding'.

Of course.  Sorry for the confusion.

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"You can tell the Lisp programmers.  They have pockets full of punch
 cards with close parentheses on them." --> http://tinyurl.com/8ubpf
From: Aaron Brown
Subject: Re: CLISP (Cygwin) defaults to :DOS instead of :UNIX
Date: 
Message-ID: <1163863928.330439.127760@b28g2000cwb.googlegroups.com>
Pascal Bourguignon wrote:

> (In clisp-2.41) it's in encoding.d, line 2535:
> (encoding_from_name and init_dependent_encodings).  If you
> don't specify a -E or -Efile option, it'll be taken from
> the locale, and it selects the line-terminator so:
>
>  #if defined(WIN32) || (defined(UNIX) && (O_BINARY != 0))
>   pushSTACK(S(Kdos));           /* :line-terminator */
>  #else
>   pushSTACK(S(Kunix));          /* :line-terminator */
>  #endif

Aha!

Before my original post, I tried setting *default-file-encoding*
from .clisprc as you described.  This works for files opened
by me, but not for standard output (presumably because its
line terminator is set before .clisprc or similar code is
run -- there's no way to update an already-open stream's
:external-format, is there?).

I'm going to

1. Hand-hack the above lines to force the use of Kunix, and
   recompile.
2. Find out what needs to be done to CLISP's Cygwin version
   so that it uses the line terminator that Cygwin has been
   configured to use.

Thanks to both you and Wolfram for your help.

-- 
Aaron
http://www.amazon.com/gp/product/0470069171/
From: Rob Thorpe
Subject: Re: CLISP (Cygwin) defaults to :DOS instead of :UNIX
Date: 
Message-ID: <1163876769.992091.197350@h54g2000cwb.googlegroups.com>
Aaron Brown wrote:
> Pascal Bourguignon wrote:
>
> > (In clisp-2.41) it's in encoding.d, line 2535:
> > (encoding_from_name and init_dependent_encodings).  If you
> > don't specify a -E or -Efile option, it'll be taken from
> > the locale, and it selects the line-terminator so:
> >
> >  #if defined(WIN32) || (defined(UNIX) && (O_BINARY != 0))
> >   pushSTACK(S(Kdos));           /* :line-terminator */
> >  #else
> >   pushSTACK(S(Kunix));          /* :line-terminator */
> >  #endif

This is something that clisp should not do in order to be considered a
cygwin package.
It should take the terminator it uses from cygwin, in which it is a
setup option.

It is probably best to report it as a bug to both the developers of
clisp and the cygwin packager of it.  (Even though it can be fixed).
From: Aaron Brown
Subject: Re: CLISP (Cygwin) defaults to :DOS instead of :UNIX
Date: 
Message-ID: <1179499807_409@qrz.fr>
I wrote:

> I'm using version 2.36 [of CLISP] as downloaded from a
> Cygwin mirror, and my *default-file-encoding* uses
> dos-style line terminators [...] even though my Cygwin
> installation is set to use unix ones.

> How do I get it to use :UNIX?

For the benefit of anyone who has this problem and finds
this thread in a search, the problem is fixed in version
2.41-2:

  http://cygwin.com/ml/cygwin/2007-04/msg00201.html

Thanks to denizens of comp.lang.lisp and the Cygwin list for
their help and to Reini Urban for doing the fix.

-- 
Aaron
http://arundelo.com