mirror of
https://github.com/simh/simh.git
synced 2026-05-16 10:09:12 +00:00
Symptom
After one regex match with more capture groups, a later regex match with
fewer groups could leave stale _EXPECT_MATCH_GROUP_n values behind from
the earlier match.
Example:
1) A first match exports:
- _EXPECT_MATCH_GROUP_0=ab42
- _EXPECT_MATCH_GROUP_1=4
- _EXPECT_MATCH_GROUP_2=2
2) A later match with only one subgroup exports:
- _EXPECT_MATCH_GROUP_0=cd7
- _EXPECT_MATCH_GROUP_1=7
3) _EXPECT_MATCH_GROUP_2 incorrectly remained "2" instead of
being cleared or blanked.
Cause
sim_exp_check() tracked the prior regex state in a static
sim_exp_match_sub_count, but it updated that count incorrectly after a
successful match.
It stored the wrong bound for later cleanup, so the loop that blanked
stale _EXPECT_MATCH_GROUP_n entries did not run far enough.
718 KiB
718 KiB