From 3fce1dfa37e923c052179188adf2ff582b185146 Mon Sep 17 00:00:00 2001 From: Roland Lutz Date: Wed, 18 Sep 2019 14:45:02 +0200 Subject: [PATCH] python: Accept same kind of whitespace in files as libgeda does --- src/gaf/plainread.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gaf/plainread.py b/src/gaf/plainread.py index 0880a8806..56b063ef4 100644 --- a/src/gaf/plainread.py +++ b/src/gaf/plainread.py @@ -131,13 +131,19 @@ def sscanf(s, fmt): if s.endswith('\n'): raise ValueError - # gEDA/gaf ignores trailing spaces and, in some older versions, - # wrote them for text objects - s = s.rstrip(' ') + # str.split without an argument treats any whitespace character as + # a separator and removes empty strings from the result + stok = s.split() + # but gEDA/gaf doesn't allow trailing whitespace + if stok and stok[0][0] != s[0]: + raise ValueError - stok = s.split(' ') fmttok = fmt.split(' ') + # gEDA/gaf ignores extra fields + if len(stok) > len(fmttok): + del stok[len(fmttok):] + if len(stok) != len(fmttok): raise ValueError -- 2.11.4.GIT