diff mbox

fwts/generate-fwts-olog: Fix regex matches to allow more printf formats

Message ID 1466411966-15160-1-git-send-email-jk@ozlabs.org
State Accepted
Headers show

Commit Message

Jeremy Kerr June 20, 2016, 8:39 a.m. UTC
We currently aren't handling the 'll' length modifier, or widths
starting with zero (eg %016x). The former is becase we have the shorter
'l' match in the group first (so borking on the second l). The latter is
because we don't allow a leading zero on width matches.

This change fixes those issues.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
---
 external/fwts/generate-fwts-olog | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stewart Smith June 21, 2016, 3:53 a.m. UTC | #1
Jeremy Kerr <jk@ozlabs.org> writes:
> We currently aren't handling the 'll' length modifier, or widths
> starting with zero (eg %016x). The former is becase we have the shorter
> 'l' match in the group first (so borking on the second l). The latter is
> because we don't allow a leading zero on width matches.
>
> This change fixes those issues.
>
> Signed-off-by: Jeremy Kerr <jk@ozlabs.org>

thanks, I even tested with FWTS and things are looking good.

Merged to master at ff42a814deaf55691b037f15d01f3f218fcaf1a8
diff mbox

Patch

diff --git a/external/fwts/generate-fwts-olog b/external/fwts/generate-fwts-olog
index c9d8259..7663d34 100755
--- a/external/fwts/generate-fwts-olog
+++ b/external/fwts/generate-fwts-olog
@@ -109,9 +109,9 @@  def message_to_pattern(loc, msg):
     # Somewhat-simplified match for a %-template
     template_re = re.compile(
             '%(?P<flag>[-#0 +]*)'
-            '(?P<width>(?:[1-9][0-9]*|\*))?'
+            '(?P<width>(?:[0-9]*|\*))?'
             '(?P<precision>\.*(?:[1-9][0-9]*|\*))?'
-            '(?:hh|h|l|ll|L|j|z|t)?'
+            '(?:hh|h|ll|l|L|j|z|t)?'
             '(?P<conversion>[a-zA-Z%])')
     global is_regex
     is_regex = False