mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-01 01:09:03 +03:00
Escape backslashes when outputting filenames to chez
This commit is contained in:
parent
99f407f1ab
commit
5d77de178e
@ -55,11 +55,13 @@ findLibs ds
|
||||
then Just (trim (substr 3 (length d) d))
|
||||
else Nothing
|
||||
|
||||
escapeQuotes : String -> String
|
||||
escapeQuotes s = pack $ foldr escape [] $ unpack s
|
||||
|
||||
escapeString : String -> String
|
||||
escapeString s = pack $ foldr escape [] $ unpack s
|
||||
where
|
||||
escape : Char -> List Char -> List Char
|
||||
escape '"' cs = '\\' :: '\"' :: cs
|
||||
escape '\\' cs = '\\' :: '\\' :: cs
|
||||
escape c cs = c :: cs
|
||||
|
||||
schHeader : String -> List String -> String
|
||||
@ -71,7 +73,7 @@ schHeader chez libs
|
||||
" [(i3osx ti3osx a6osx ta6osx) (load-shared-object \"libc.dylib\")]\n" ++
|
||||
" [(i3nt ti3nt a6nt ta6nt) (load-shared-object \"msvcrt.dll\")]\n" ++
|
||||
" [else (load-shared-object \"libc.so\")])\n\n" ++
|
||||
showSep "\n" (map (\x => "(load-shared-object \"" ++ escapeQuotes x ++ "\")") libs) ++ "\n\n" ++
|
||||
showSep "\n" (map (\x => "(load-shared-object \"" ++ escapeString x ++ "\")") libs) ++ "\n\n" ++
|
||||
"(let ()\n"
|
||||
|
||||
schFooter : String
|
||||
@ -181,7 +183,7 @@ cCall appdir fc cfn clib args ret
|
||||
copyLib (appdir ++ dirSep ++ fname, fullname)
|
||||
put Loaded (clib :: loaded)
|
||||
pure $ "(load-shared-object \""
|
||||
++ escapeQuotes fname
|
||||
++ escapeString fname
|
||||
++ "\")\n"
|
||||
argTypes <- traverse (\a => cftySpec fc (snd a)) args
|
||||
retType <- cftySpec fc ret
|
||||
|
Loading…
Reference in New Issue
Block a user