summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/common
diff options
context:
space:
mode:
authorFelix Kuehling <[email protected]>2005-04-12 20:58:34 +0000
committerFelix Kuehling <[email protected]>2005-04-12 20:58:34 +0000
commitad0dbe6b04f5d6d580a0a5dfe2018027f986acbd (patch)
tree9b94bee1954d3e71c0e6de0c349b7717efb87929 /src/mesa/drivers/dri/common
parent41bddcfa7bbc65bcd2fc60ada9761d3065e71388 (diff)
Changed escaping of double quotes.
Diffstat (limited to 'src/mesa/drivers/dri/common')
-rw-r--r--src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py b/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py
index 11e24b1332e..7398c4cd0b2 100644
--- a/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py
+++ b/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py
@@ -10,21 +10,25 @@ languages = sys.argv[1:]
# Escape special characters in C strings
def escapeCString (s):
escapeSeqs = {'\a' : '\\a', '\b' : '\\b', '\f' : '\\f', '\n' : '\\n',
- '\r' : '\\r', '\t' : '\\t', '\v' : '\\v',
- '"' : "''", '\\' : '\\\\'}
+ '\r' : '\\r', '\t' : '\\t', '\v' : '\\v', '\\' : '\\\\'}
# " -> '' is a hack. Quotes (") aren't possible in XML attributes.
# Better use Unicode characters for typographic quotes in option
# descriptions and translations.
i = 0
r = ''
while i < len(s):
- if escapeSeqs.has_key(s[i]):
- if s[i] == '"':
- sys.stderr.write (
- "Warning: Double quotes don't work in XML attributes. "
- "Escaping with ''.\n"
- "Consider using typographic quotes (\\u201c-\\u201f) "
- "instead.\n%s\n" % repr(s))
+ # Special case: escape double quote with \u201c or \u201d, depending
+ # on whether it's an open or close quote. This is needed because plain
+ # double quotes are not possible in XML attributes.
+ if s[i] == '"':
+ if i == len(s)-1 or s[i+1].isspace():
+ # close quote
+ q = u'\u201c'
+ else:
+ # open quote
+ q = u'\u201d'
+ r = r + q
+ elif escapeSeqs.has_key(s[i]):
r = r + escapeSeqs[s[i]]
else:
r = r + s[i]