Problem with ghc on Windows ME
Carsten Schultz
carsten at codimi.de
Thu Jan 29 16:42:16 EST 2004
On Thu, Jan 29, 2004 at 02:53:21PM -0000, Simon Marlow wrote:
> After Googling around a bit, I found this description of exactly how
> Windows interprets command lines in the C runtime:
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng
> /htm/progs_12.asp
>
> As you can see, the rules are indeed very strange,
Very strange indeed.
> 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)
>
Neat. If I understand the specs correctly, the following should also
work.
translate str = '"' : foldr escape ('"':[]) str
where escape '"' t = '\\':'"':t
escape '\\' t = '\\':'\\':'"':'"':t
escape c t = c:t
Who is going to write the unit test for that?
And assuming both of our solutions satisfy the specs, which one will
work for more versions of Windows? :-)
Greetings,
Carsten
--
Carsten Schultz (2:38, 33:47), FB Mathematik, FU Berlin
http://carsten.codimi.de/
PGP/GPG key on the pgp.net key servers,
fingerprint on my home page.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://haskell.org/pipermail/glasgow-haskell-users/attachments/20040129/9ea7cba8/attachment.bin
More information about the Glasgow-haskell-users
mailing list