[Top][All Lists]

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

[Axiom-developer] RE: [Gcl-devel] Axiom on Windows GCL problems

From: Mike Thomas
Subject: [Axiom-developer] RE: [Gcl-devel] Axiom on Windows GCL problems
Date: Thu, 13 Jan 2005 15:05:52 +1000

Hi Bill.

| I presume that you have been extraordinarily busy (as usual)
| but with other things since I haven't seen your email lately
| on the Axiom list. I hope you had a pleasant holiday season
| in spite of the work. :)

Thanks for the wishes and also to yourself!  I suspect I'm going to be a
distant cousin for a while longer I'm afraid.

| You are probably reading the axiom mailing lists anyway, so
| you know that things are progressing at a good pace

Yes.  At some stage (not this fortnight) I am going to have to compare
detailed setup notes with you as I failed miserably in setting up arch last


| notice how the command line arguments to gcc are mangled
| because they contain spaces and are not properly escaped. If
| I copy the gcc command and insert delimiters as follows:
| gcc -c -g -Wall -DVOL=volatile -fsigned-char -pipe
| -fno-zero-initialized-in-bss -mms-bitfields -g -mcpu=i386
| -march=i386  -IC:/msys/1.0/home/bpage/axiom-build/mnt/windows/bin/../h
| -c -w "C:/Documents and Settings/bpage/My Documents/PPF.NRLIB/code.c"
| -o "C:/Documents and Settings/bpage/My Documents/PPF.NRLIB/code.o"
| and then paste it into a command window, gcc runs and produces
| a object file normally. So I know everything else is ok. And of
| course this also works if Axiom and GCL are installed in
| directories so that the paths do not contain spaces.
| --------
| So, I was wondering if you might be able to quickly point
| me in the right direction to fix this problem. I know that
| at some point GCL is going to convert so-called path
| expressions like #P"c:xxxx yyy zzz" into actual command line
| arguments. I think that what is happening is that this
| conversion is removing the "quotes" but that these should
| remain especially on the windows platform - but maybe under
| linux as well even though users much less frequently employ
| paths with spaces under linux.

It sounds like you have a more clear idea of what the Lisp code will be
doing than I, but here is where I believe that it all happens in GCL:

   1.  The starting point seems to be the call out to gcc in
"cmpnew/gcl_cmpmain.lsp" at the function "compiler-cc" which in turn calls
"compiler-command", at which point the command line is constructed.

   2.  That command line is executed by the function "safe-system" in the
same file.

   3.  If you need to look at the underlying C code used on Windows you may
need to look at "fix_filename()" in "o/mingfile.c" and other stuff in

   4.  The "system" function resides in "o/unixsys.c" and unfortunately I
believe it is a major trap regarding cross-Windows-version compatibility
specifically regarding quotation rules - not to mention Unix.  I've attached
an email from Simon Marlow to one of the GHC mailing lists which includes a
link on the topic.

I wish you well!

Mike Thomas.
--- Begin Message --- Subject: RE: Problem with ghc on Windows ME Date: Fri, 30 Jan 2004 00:53:21 +1000
After Googling around a bit, I found this description of exactly how
Windows interprets command lines in the C runtime:

As you can see, the rules are indeed very strange, but they are
invertible.  I think this code should do the trick:

translate :: String -> String
translate str = '"' : snd (foldr escape (True,"\"") str)
  where escape '"'  (_,     str) = (True,  '\\' : '"'  : str)
        escape '\\' (True,  str) = (True,  '\\' : '\\' : str)
        escape '\\' (False, str) = (False, '\\' : str)
        escape c    (_,     str) = (False, c : str)


> -----Original Message-----
> From: address@hidden 
> [mailto:address@hidden On Behalf 
> Of Simon Marlow
> Sent: 29 January 2004 11:31
> To: Claus Reinke; Simon Peyton-Jones; 
> address@hidden
> Subject: RE: Problem with ghc on Windows ME
> > So does that mean functionality has been lost in the move from
> > ghc-6.0.1?
> No, the behaviour is improved in 6.2 because we're now 
> careful to escape
> quotes before passing the command-line to the operating system.
> I think confusion has arisen because Simon pointed out that there's no
> way, on Windows, to pass this sequence of characters as an 
> argument to a
> command:
>    \"
> This is not entirely true, I just discovered that the 
> sequence \\\" will
> turn into \".  But in general, the sequence \\ does not turn into \.
> Windows' command-line quoting rules are highly mysterious, to say the
> least.
> So the patch I posted is not complete.  It looks like rawSystem should
> additionally translate \" as \\\".
> > Because that (on win98) happily accepts such useful
> > contraptions as
> > 
> >     System.Cmd.rawSystem "\"c:\\silly 
> > space\\Vim\\vim62\\gvim.exe\" --servername GVIM --remote-send
> > \":echo \\\"hi \\\\\\\" there\\\"<cr>\"" >>= print
> The idea is that you should pass to rawSystem *exactly* the 
> command and
> arguments you want to run, with no quoting except that required by the
> Haskell lexical syntax.  You'll notice that rawSystem now takes the
> command and list of arguments separately in 6.2.  The 
> implementation of
> rawSystem will attempt to compensate for the internal translation that
> Windows does on the command-line; on Unix no translation is necessary.
> So clients of rawSystem should be more portable, because they 
> don't have
> to know about quoting that happens under the hood.
> Your example will probably work once it's reformulated for 
> 6.2's version
> of rawSystem, and once we fix rawSystem in light of the \\\" hack I
> discovered above.
> Cheers,
>       Simon
> _______________________________________________
> Glasgow-haskell-users mailing list
> address@hidden
Glasgow-haskell-users mailing list

--- End Message ---

reply via email to

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