templater: simplify parsestring
authorMatt Mackall <mpm@selenic.com>
Mon, 13 Nov 2006 13:26:57 -0600
changeset 3639 5c9a36210662
parent 3638 7b064d8bac5e
child 3640 1b2cd5dceca2
templater: simplify parsestring
mercurial/templater.py
--- a/mercurial/templater.py	Mon Nov 13 13:26:57 2006 -0600
+++ b/mercurial/templater.py	Mon Nov 13 13:26:57 2006 -0600
@@ -14,13 +14,9 @@
     '''parse a string using simple c-like syntax.
     string must be in quotes if quoted is True.'''
     if quoted:
-        first = s[0]
-        if len(s) < 2: raise SyntaxError(_('string too short'))
-        if first not in "'\"": raise SyntaxError(_('invalid quote'))
-        if s[-1] != first: raise SyntaxError(_('unmatched quotes'))
-        s = s[1:-1].decode('string_escape')
-        if first in s: raise SyntaxError(_('string ends early'))
-        return s
+        if len(s) < 2 or s[0] != s[-1]:
+            raise SyntaxError(_('unmatched quotes'))
+        return s[1:-1].decode('string_escape')
 
     return s.decode('string_escape')