[Openmcl-devel] pathname problem with open-shared-library?

Gary Byers gb at clozure.com
Mon Nov 22 16:38:23 UTC 2004



On Mon, 22 Nov 2004, Rick Taube wrote:

> Directory seems to add "\\" to pathnames when there is more than one
> dot in the pathname but then this causes problems when you attempt to
> pass that string programmatically to open-shared-library:
> ------------------------------------------------
> Welcome to OpenMCL Version (Beta: Darwin) 0.14.1-p1!
>
> ? (setq l (directory "/sw/lib/libgtk-x11-2.*.dylib"))
> (#P"/sw/lib/libgtk-x11-2\\.0\\.0\\.200\\.4.dylib")
>
> ? (open-shared-library (namestring (car l)))
>  > Error in process listener(1): Error opening shared library
> "/sw/lib/libgtk-x11-2\\.0\\.0\\.200\\.4.dylib": dyld: /Lisp/ccl/dppccl
> can't open library: /sw/lib/libgtk-x11-2\.0\.0\.200\.4.dylib  (No such
> file or directory, errno = 2)
>  >
>  > While executing: OPEN-SHARED-LIBRARY
>  > Type :POP to abort.
> Type :? for other options.
> 1 > :pop
> ------------------------------------------------
>
> However, probe-file can deal with quoted multi-dots:
>
> (probe-file #P"/sw/lib/libgtk-x11-2\\.0\\.0\\.200\\.4.dylib")
> #P"/sw/lib/libgtk-x11-2\\.0\\.0\\.200\\.4.dylib"
>
> AND open-shared-library can handle the unquoted multi-dot version:
>
> ? (open-shared-library "/sw/lib/libgtk-x11-2.0.0.200.4.dylib")
> #<SHLIB /sw/lib/libgtk-x11-2.0.0.200.4.dylib #x5396426>
>
> AND pathname-type can deal with multiple dots!:
>
> ? (pathname-type "/sw/bin/libgtk-x11-2.0.0.dylib")
>
> What is the correct way for me to deal with such pathnames? Actually, I
> dont really understand why directory gets all nervous about multi-dots
> in the first place, it seems that other openmcl funcions either dont
> need them or can handlle them.

The way that most other functions handle overly-aggressive escaping
is to use CCL::NATIVE-TRANSLATED-NAMESTRING instead of NAMESTRING:

? (namestring "/usr/lib/libltdl.3.1.0.dylib")
"/usr/lib/libltdl\\.3\\.1\\.0.dylib"
? (ccl::native-translated-namestring "/usr/lib/libltdl.3.1.0.dylib")
"/usr/lib/libltdl.3.1.0.dylib"

OPEN-SHARED-LIBRARY just blindly passes its argument to the OS.  It
could probably be made a little more pathname-aware than it is.  (Part
of the reason that it isn't is that it's supposed to support "logical
library names" as well as pathnames, though this may be more meaningful
on Linux than on OSX.)

When physical pathnames are involved, I'm not sure that escaping
dots is that helpful.  It's probably happening in code that's
shared between the logical- and physical-pathname parsing cases,
and it makes a little more sense in the logical case (a logical pathname
namestring is supposed to contain at most one dot, but this is the
real world ...)



More information about the Openmcl-devel mailing list