simonowen / pyz80

pyz80 - a Z80 cross assembler
GNU General Public License v2.0
18 stars 8 forks source link

if defined( symbol ) does not work due to whitespace #14

Closed stefandrissen closed 5 years ago

stefandrissen commented 5 years ago
if defined(symbol) ; works
if defined( symbol) ; works
if defined( symbol ) ; does not work

The regexp on line 442 is incorrect, the (.*) is gobbling the trailing space and adding it to the symbol, resulting in the symbol not being found.

match = re.search('defined\s*\(\s*(.*)\s*\)', arg, re.IGNORECASE)
simonowen commented 5 years ago

Interesting find! Changing the .* to .*? should hopefully fix it, if the re module support that syntax for non-greedy matching.

stefandrissen commented 5 years ago

Fix works!

Both Python 2 and Python 3 documentation contain an example with non-greedy matching.

simonowen commented 5 years ago

Thanks for confirming. I've cherry-picked your commit with a small edit as it conflicted with the raw string change in 28bfde2f04e234cefc2b1ca0f46eb478.

stefandrissen commented 5 years ago

Thanks - I'm pretty clueless on git commits - I'll see if I can rebase or so.