From 5b3ca9bd2d02b41401e7b5d06478199c5c60466e Mon Sep 17 00:00:00 2001 From: James Vega Date: Wed, 18 Jan 2006 00:19:31 +0000 Subject: [PATCH] src/registry.py, test/test_registry.py: Better handling of backslashes in config values. --- src/registry.py | 15 ++++++++++----- test/test_registry.py | 10 ++++++++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/registry.py b/src/registry.py index 569b3924f..5ceafad3b 100644 --- a/src/registry.py +++ b/src/registry.py @@ -68,13 +68,18 @@ def open(filename, clear=False): _fd = file(filename) fd = utils.file.nonCommentNonEmptyLines(_fd) acc = '' + slashEnd = re.compile(r'\\*$') for line in fd: line = line.rstrip('\r\n') # XXX There should be some way to determine whether or not we're # starting a new variable or not. As it is, if there's a backslash # at the end of every line in a variable, it won't be read, and # worse, the error will pass silently. - if line.endswith('\\'): + # + # If the line ends in an odd number of backslashes, then there is a + # line-continutation. + m = slashEnd.search(line) + if m and len(m.group(0)) % 2: acc += line[:-1] continue else: @@ -82,7 +87,7 @@ def open(filename, clear=False): try: (key, value) = re.split(r'(?