From 728df1517a518b06ed44bb072ba60beb58bd415d Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 4 May 2023 17:34:27 -0700 Subject: [PATCH] verify fields.txt forms' field separators ('|') line up with headers' --- openpower/isatables/fields.text | 4 ++-- src/openpower/decoder/power_fields.py | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/openpower/isatables/fields.text b/openpower/isatables/fields.text index 451fb57d..89ad7530 100644 --- a/openpower/isatables/fields.text +++ b/openpower/isatables/fields.text @@ -140,7 +140,7 @@ # 1.6.7.1 DCT-FORM - |0 |6 |11 |16 |21 |26 |31 | + |0 |6 |11 |16 |21 |26 |31 | | PO | FRT | FRA | FRB | // | XO | Rc | # 1.6.8 XL-FORM @@ -212,7 +212,7 @@ | PO | RT | IT | CVM | FRB | OE | XO | Rc | # 1.6.17 A-FORM - |0 |6 |11 |16 |21 |26 |31 | + |0 |6 |11 |16 |21 |26 |31 | | PO | FRT | FRA | FRB | FRC | XO |Rc | | PO | FRT | FRA | FRB | /// | XO |Rc | | PO | FRT | FRA | /// | FRC | XO |Rc | diff --git a/src/openpower/decoder/power_fields.py b/src/openpower/decoder/power_fields.py index b0f17909..892af1d8 100644 --- a/src/openpower/decoder/power_fields.py +++ b/src/openpower/decoder/power_fields.py @@ -489,7 +489,7 @@ class DecodeFields: #print ("decode", txt) forms = {} reading_data = False - for l in txt: + for lineno, l in enumerate(txt): l = l.strip() if len(l) == 0: continue @@ -497,7 +497,20 @@ class DecodeFields: if l[0] == '#': reading_data = False else: - forms[heading].append(l) + form = forms[heading] + form.append(l) + if len(form) <= 1: + continue + for i, ch in enumerate(l): + if ch != '|': + continue + if i >= len(form[0]) or form[0][i] != '|': + col = len(txt[lineno]) - len(txt[lineno].lstrip()) + col += i + 1 + raise SyntaxError( + "form line field separator ('|') " + "with no corresponding separator in header", + (self.fname, lineno + 1, col, txt[lineno])) if not reading_data: assert l[0] == '#' heading = l[1:].strip() -- 2.30.2