gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Gcl-devel] Re: Axiom on Windows


From: Mike Thomas
Subject: RE: [Gcl-devel] Re: Axiom on Windows
Date: Thu, 17 Jun 2004 11:07:39 +1000

Hi Michael

Thanks for the information.

| > (probe-file "./") on Windows GCL *(CLtL1) gives nil which is, I think,
| > invalid.  LispWorks gives the current working directory which I believe
| > would be the correct result - or perhaps "./"?
|
|   >(probe-file "./")
|   #P"/bakunin/home/kraehe/"             ; on Unix
|   #P"C:/Documents and Settings/miketh/" ; should be on windows
|
|   >(namestring nil)
|      NIL is not of type PATHNAME.        ; NIL does not mean "NIL" !
|
| > Likewise, (namestring nil) returns the string "nil" which I
| also think is
| > invalid - LispWorks raises an error which, again, I think would be the
| > correct response.
|
|   (namestring nil) -> "NIL" had been without my patch, iirc
|
|   >(namestring (probe-file "./"))
|   "/bakunin/home/kraehe/"
|
|   what happens to those functions, if you apply the pathname patch from
|   www.copyleft.de/lisp/ ?

GCL refuses to work; the opther day and after some mucking around got to
this (I haven't the time to chase this yet):

-----------------------------------------------------------------------
Building symbol table for c:/cvs/head/gcl/unixport/raw_pre_gcl.exe ..
rsym_nt: c:/cvs/head/gcl/unixport/raw_pre_gcl.exe rsym3488 loading
c:/cvs/head/gcl/unixport/../lsp/gcl_export.lsp
loading c:/cvs/head/gcl/unixport/../lsp/gcl_defmacro.lsp
loading c:/cvs/head/gcl/unixport/../lsp/gcl_evalmacros.lsp
loading c:/cvs/head/gcl/unixport/../lsp/gcl_top.lsp
loading c:/cvs/head/gcl/unixport/../lsp/gcl_module.lsp
loading c:/cvs/head/gcl/unixport/../lsp/gcl_autoload.lsp

Error: Cannot coerce NIL to PATHNAME namestring.
Error signalled by NAMESTRING.

Error: The variable + is unbound.
Error signalled by LET*.

Error: The variable + is unbound.
Error signalled by LET*.

Error: The variable + is unbound.
Error signalled by LET*.
-----------------------------------------------------------------------


|
|   Probefile might still not work - we need some #ifdef in o/unixfsys.c,
|   if this is the case for file_exists - try :
|
| #define MAXPATHLEN 4096
| #include <sys/stat.h>
| main()
| {   struct stat filestatus;
|     char current_directory[MAXPATHLEN];
|     char *p;
|     getwd(current_directory);
|     printf("getwd %s\n",current_directory);
|     if (stat("C:/Documents and Settings/miketh/", &filestatus) < 0)
|               printf("stat failed for miketh !\n");
|     for (p=current_directory; (p-current_directory<4069) && *p; p++)
|       if (*p=='\\') *p=='/';
|     printf("what about getwd %s\n",current_directory);
|     if (stat(current_directory, &filestatus) < 0)
|               printf("stat failed for cwd ?\n");
|     if (p==current_directory)
|       { *p='/'; p[1]=0; }
|     else
|     if (p[-1]!='/')
|       { *p='/'; p[1]=0; }
|     printf("what about getwd %s\n",current_directory);
|     if (stat(current_directory, &filestatus) < 0)
|               printf("stat failed for cwd ?\n");
| }
|
|   probe_file calls truename after checking file_exists, and there
| you might
|   need to map the \\ windows directory seperators into / unix directory,
|   before truename calls coerce_to_pathname.

Replacing getwd() with GetCurrentDirectory() (no getwd on Windows and it's a
fairly dangerous function), fixing a couple of bugs and adding a few extra
tests:

#define MAXPATHLEN 4096
#include <windows.h>
#include <stdio.h>
#include <sys/stat.h>
main()
{   struct stat filestatus;
    char current_directory[MAXPATHLEN];
    char *p;
    DWORD GetCD_size = GetCurrentDirectory(MAXPATHLEN,current_directory);
    if ( 0 == GetCD_size ) {
        fprintf ( stderr, "Can't get current directory.\n" );
    } else {
        if ( MAXPATHLEN < GetCD_size ) {
            fprintf ( stderr, "Need more space for current directory.\n" );
        } else {
            printf("GetCurrentDirectory %s\n",current_directory);
            if ( stat ( "C:/Documents and Settings/miketh/", &filestatus )
== -1 )
                printf ( "stat failed for miketh1 !\n" );
            if ( stat ( "C:/Documents and Settings/miketh", &filestatus )
== -1 )
                printf ( "stat failed for miketh2 !\n" );
            if ( stat ( "C:\\Documents and Settings\\miketh\\",
&filestatus ) == -1 )
                printf ( "stat failed for miketh3 !\n" );
            if ( stat ( "C:\\Documents and Settings\\miketh", &filestatus )
== -1 )
                printf ( "stat failed for miketh4 !\n" );
            if ( stat ( "./", &filestatus ) == -1 )
                printf ( "stat failed for ./ !\n" );
            if ( stat ( ".", &filestatus ) == -1 )
                printf ( "stat failed for . !\n" );
            if ( stat ( ".\\", &filestatus ) == -1 )
                printf ( "stat failed for .\\ !\n" );
            if ( stat ( "../", &filestatus ) == -1 )
                printf ( "stat failed for ../ !\n" );
            if ( stat ( "..", &filestatus ) == -1 )
                printf ( "stat failed for .. !\n" );
            if ( stat ( "..\\", &filestatus ) == -1 )
                printf ( "stat failed for ..\\ !\n" );
            for ( p = current_directory; ( p-current_directory <
MAXPATHLEN ) && *p; p++ )
                if ( *p == '\\' ) *p ='/';
            printf("what about GetCurrentDirectory %s\n",current_directory);
            if ( stat ( current_directory, &filestatus ) < 0 )
                printf ( "stat failed for %s ?\n", current_directory );
            if ( p == current_directory )
                { *p='/'; p[1]=0; }
            else
                if ( p[-1] !='/' )
                    { *p='/'; p[1]=0; }
            printf("what about GetCurrentDirectory %s\n",current_directory);
            if ( stat ( current_directory, &filestatus ) < 0 )
                printf ( "stat failed for %s ?\n", current_directory );
        }
    }
}


$ ./mktest
GetCurrentDirectory c:\cvs\head\gcl
stat failed for miketh1 !
stat failed for miketh3 !
stat failed for ./ !
stat failed for .\ !
stat failed for ../ !
stat failed for ..\ !
what about GetCurrentDirectory c:/cvs/head/gcl
what about GetCurrentDirectory c:/cvs/head/gcl/
stat failed for c:/cvs/head/gcl/ ?

Cheers

Mike Thomas.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]