A bug on Windows

Machine-specific discussion
Unix, Linux, OS X, OS/2, Windows, ..?
Locked
linli
Posts: 8
Joined: Tue Sep 01, 2009 3:13 pm

A bug on Windows

Post by linli »

I had the following problem:

Code: Select all

> (change-dir "h:")
true
> (real-path)
"H:\\"
> (change-dir "c:\\a\\b")
true
> (real-path)
"c:\\a\\b"
> (change-dir "h:")
true
> (real-path)
"H:\\"
> (change-dir "c:")
true
> (real-path)
"c:\\a\\b"
In the last step, I was trying to change the dir to c:\, but it remains in c:\a\b

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: A bug on Windows

Post by Lutz »

With C: without the slash, you only change the drive and to the directory which was current on C: before. If you want to change to root of C: do "C:\\" or "C:/". This is standard MS Windows behavior.

bjo
Posts: 2
Joined: Sat Nov 21, 2009 11:54 am

Re: A bug on Windows

Post by bjo »

On Windows (Vista) the (file?) built-in does not seem to look in any or all PATHs:

Code: Select all

> (file? "libgmp-3.dll")
nil
> (import "libgmp-3.dll" "__gmpz_mul")
__gmpz_mul <1000D880>

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Re: A bug on Windows

Post by cormullion »

The manual suggests that import uses search paths: "If the library is not located in the normal library search path, str-lib-name must contain the full path name." but that file? just checks for file/directory existence.

bjo
Posts: 2
Joined: Sat Nov 21, 2009 11:54 am

Re: A bug on Windows

Post by bjo »

The problem is that the gmp module depends on (import)'s behaviour when using (file?) to determine which file to use:

Code: Select all

(set 'files '(
    "/usr/lib/libgmp.dylib" ; Mac OSX
    [...]
    "libgmp-3.dll" ; Win32 in Path))

(set 'library (files (or 
  (find true (map file? files)) 
    (begin (println "cannot find GMP library") (exit)))))
On windows this piece of code will always fail.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: A bug on Windows

Post by Lutz »

'file?' must have the full path-name specified. At least on Windows XP libgmp-3.dll is not installed by default and because of this, the full path-name has not been specified for libgmp-3.dll in the source of the gmp.lsp module.

You can either put libgmp-3.dll into the current directory to make the 'file?' statement in the module work on it, or you can change the path in the module to whatever location the DLL is installed on your machine.

A sentence has been added to the documentation clarifying this:

http://www.newlisp.org/code/modules/gmp.lsp.html


ps: welcome to newLISP

Locked