Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: <Joerg-Cyril.Hoehle <at> t-systems.com>
Subject: Re: using pathnames containing wildcard characters
Newsgroups: gmane.lisp.clisp.general
Date: Friday 10th February 2012 13:35:18 UTC (over 5 years ago)
Hi,

Don Cohen wrote:
>So I see no way to use only ansi standard functions in clisp that can
>distinguish between files with names containing CR's and LF's.

Use custom:*pathname-encoding* as iso-8859-1 to work with strings.

>You mean read the file as bytes and then convert to string?
>That does seem to preserve the difference between CR and LF

As you've verified, that encoding is truly 1:1.  It's only
with character streams that funny things happen.

One extra idea would be to have DIRECTORY, EXT:DIR
and Sam's POSIX:FILE-TREE-WALK function
http://clisp.podval.org/impnotes/syscalls.html#file-tree-walk
accept an extra ENCODING keyword.
&keyword (encoding custom:*pathname-encoding*)

:ENCODING NIL => deliver a byte array

You'd use :ENCODING as iso-8859-1 to work with strings.
As you've verified, that encoding is truly 1:1.  It's only
with character streams that funny things happen.

Then the directory traversal code must be made robust (not leak memory)
w.r.t. the :INPUT-ERROR-ACTION of MAKE-ENCODING.

The key is not to accept custom:*pathname-encoding* being NIL as that
would break too many expectations.

Well, that's only dir traversal.  No solution for rename-file etc.
but having custom:*pathname-encoding* be iso-8859-1 in your program.

With byte arrays, I'd use
(let* ((chars (ext:convert-string-from-bytes bytes
               (ext:make-encoding charset:utf-8 :input-error-action
:ignore)))
       (bytes2 (ext:convert-string-to-bytes chars
                (ext:make-encoding charset:utf-8 :output-error-action
:ignore))))
  (if (equalp byte bytes2) chars #| round trip check passed |# bytes))
This would produce either printable UTF-8 strings or byte arrays on my
system.
(actually, I'd write this code using custom:*pathname-encoding*, but you
 might have rebound that to iso-8859-1, which does not match my
LANG/LC_MESSAGES).

If you have bound custom:*pathname-encoding* to iso-8859-1, you can still
apply a triple conversion trick with custom:*terminal-encoding* before
printing such names or saving them to a file (using byte arrays if
unprintable).

Regards,
	Jörg Höhle
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list
 
CD: 4ms