From 6750eca1da5cf1cd8859a2f21c658b34555190ba Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Fri, 25 Dec 2020 10:32:41 -0700 Subject: [PATCH 1/2] MAINT: crackfortran regex simplify * remove extraneous character class markers used in `crackline_re_1`: `\w` and `=` on their own have no benefit to character class `[]` inclusion * `name_match` has a character class that can be simplified because `\w` metacharacter already encompasses the digit metacharacter and the underscore --- numpy/f2py/crackfortran.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 2e95e45969e5..2177c97cd93c 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -636,7 +636,7 @@ def _simplifyargs(argsline): a.append(n) return ','.join(a) -crackline_re_1 = re.compile(r'\s*(?P\b[a-z]+[\w]*\b)\s*[=].*', re.I) +crackline_re_1 = re.compile(r'\s*(?P\b[a-z]+\w*\b)\s*=.*', re.I) def crackline(line, reset=0): @@ -2605,7 +2605,7 @@ def analyzevars(block): params = get_parameters(vars, get_useparameters(block)) dep_matches = {} - name_match = re.compile(r'\w[\w\d_$]*').match + name_match = re.compile(r'\w[\w$]*').match for v in list(vars.keys()): m = name_match(v) if m: From c181a403d5d36b13c6f8c4e65537a25c4436ca71 Mon Sep 17 00:00:00 2001 From: Tyler Reddy Date: Sat, 26 Dec 2020 16:04:26 -0700 Subject: [PATCH 2/2] MAINT: PR 18072 revisions * `name_match` regular expression now starts by matching a letter only, based on reviewer feedback --- numpy/f2py/crackfortran.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpy/f2py/crackfortran.py b/numpy/f2py/crackfortran.py index 2177c97cd93c..733336032a60 100755 --- a/numpy/f2py/crackfortran.py +++ b/numpy/f2py/crackfortran.py @@ -2605,7 +2605,7 @@ def analyzevars(block): params = get_parameters(vars, get_useparameters(block)) dep_matches = {} - name_match = re.compile(r'\w[\w$]*').match + name_match = re.compile(r'[A-Za-z][\w$]*').match for v in list(vars.keys()): m = name_match(v) if m: