summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2007-10-25 16:36:48 +0000
committerZac Medico <zmedico@gentoo.org>2007-10-25 16:36:48 +0000
commitb5dc4f9364189134570da426ce34a05eabd339ce (patch)
tree0b67b372ce0b388bbb715869a01f3ea2a4f4dcfb /pym
parent32c0cb6cb155d1be20d3a768f10412051affff44 (diff)
downloadportage-b5dc4f9364189134570da426ce34a05eabd339ce.tar.gz
portage-b5dc4f9364189134570da426ce34a05eabd339ce.tar.bz2
portage-b5dc4f9364189134570da426ce34a05eabd339ce.zip
Handle multiple consecutive spaces in filenames as per
bug #196836#c6. svn path=/main/trunk/; revision=8291
Diffstat (limited to 'pym')
-rw-r--r--pym/portage/dbapi/vartree.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py
index a306f8267..32e04f436 100644
--- a/pym/portage/dbapi/vartree.py
+++ b/pym/portage/dbapi/vartree.py
@@ -824,6 +824,13 @@ class dblink(object):
import re
_normalize_needed = re.compile(r'.*//.*|^[^/]|.+/$|(^|.*/)\.\.?(/.*|$)')
+ _contents_split_counts = {
+ "dev": 1,
+ "dir": 1,
+ "fif": 1,
+ "obj": 4,
+ "sym": 5
+ }
def __init__(self, cat, pkg, myroot, mysettings, treetype=None,
vartree=None):
@@ -949,6 +956,7 @@ class dblink(object):
myc.close()
null_byte = "\0"
normalize_needed = self._normalize_needed
+ contents_split_counts = self._contents_split_counts
myroot = self.myroot
if myroot == os.path.sep:
myroot = None
@@ -962,6 +970,20 @@ class dblink(object):
noiselevel=-1)
continue
mydat = line.split()
+ correct_split_count = contents_split_counts.get(mydat[0])
+ if correct_split_count and len(mydat) != correct_split_count:
+ if mydat[0] == "obj" and \
+ len(mydat) > contents_split_counts["obj"]:
+ # File name contains spaces. Use field widths to infer the
+ # start and end points so that even multiple consecutive
+ # spaces are parsed correctly.
+ newsplit = ["obj"]
+ filename_start = len(mydat[0]) + 1
+ filename_end = len(line.rstrip()) - \
+ len(mydat[-1]) - len(mydat[-2]) - 2
+ newsplit.append(line[filename_start:filename_end])
+ newsplit.extend(mydat[-2:])
+ mydat = newsplit
# we do this so we can remove from non-root filesystems
# (use the ROOT var to allow maintenance on other partitions)
try: