summaryrefslogtreecommitdiff
path: root/src/GF/Source
diff options
context:
space:
mode:
Diffstat (limited to 'src/GF/Source')
-rw-r--r--src/GF/Source/PrintGF.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/GF/Source/PrintGF.hs b/src/GF/Source/PrintGF.hs
index 2774246bf..88b20308e 100644
--- a/src/GF/Source/PrintGF.hs
+++ b/src/GF/Source/PrintGF.hs
@@ -66,12 +66,13 @@ instance Print Double where
prt _ x = doc (shows x)
instance Print Char where
- prt _ s = doc (showChar '\'' . mkEsc s . showChar '\'')
- prtList s = doc (showChar '"' . concatS (map mkEsc s) . showChar '"')
+ prt _ s = doc (showChar '\'' . mkEsc '\'' s . showChar '\'')
+ prtList s = doc (showChar '"' . concatS (map (mkEsc '"') s) . showChar '"')
-mkEsc :: Char -> ShowS
-mkEsc s = case s of
- _ | elem s "\\\"" -> showChar '\\' . showChar s -- H (don't escape ')
+mkEsc :: Char -> Char -> ShowS
+mkEsc q s = case s of
+ _ | s == q -> showChar '\\' . showChar s
+ '\\'-> showString "\\\\"
'\n' -> showString "\\n"
'\t' -> showString "\\t"
_ -> showChar s