Mercurial > hg
changeset 3639:5c9a36210662
templater: simplify parsestring
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 13 Nov 2006 13:26:57 -0600 |
parents | 7b064d8bac5e |
children | 1b2cd5dceca2 |
files | mercurial/templater.py |
diffstat | 1 files changed, 3 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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')