tools/pas2c.hs
changeset 6921 e6033fe39b7f
parent 6902 7d4e5ce73b98
child 6923 d2405a6a86f5
--- a/tools/pas2c.hs	Tue Apr 24 06:53:39 2012 +0200
+++ b/tools/pas2c.hs	Tue Apr 24 16:11:07 2012 +0400
@@ -46,10 +46,16 @@
     
 addStringConst :: String -> State RenderState Doc
 addStringConst str = do
-    i <- getUniq
-    let sn = "__str" ++ show i
-    modify (\s -> s{lastType = BTString, stringConsts = (sn, str) : stringConsts s})
-    return $ text sn
+    strs <- gets stringConsts
+    let a = find ((==) str . snd) strs
+    if isJust a then
+        return . text . fst . fromJust $ a
+    else
+        do
+        i <- getUniq
+        let sn = "__str" ++ show i
+        modify (\s -> s{lastType = BTString, stringConsts = (sn, str) : strs})
+        return $ text sn
     
 escapeStr :: String -> String
 escapeStr = foldr escapeChar []