1

Re: substitution in C# hangs VS2008

Here is the selected code:
                Build.a_nacha_record()
                    .that_starts_with_a_record_type_field_code_of(8)
                    .then_has_a_field_containing(service_class_code())
                    .then_has_a_numeric_field_of_length(6).containing(entry_count)
                    .then_has_a_numeric_field_of_length(10).containing(entry_hash)
                    .then_has_a_numeric_field_of_length(12).containing(debit_total)
                    .then_has_a_numeric_field_of_length(12).containing(credit_total)
                    .then_has_a_field_containing(company_identification)
                    .then_has_a_field_containing(new string(' ', 19)) // message authentication code -- leave blank
                    .then_has_a_field_containing(new string(' ', 6)) // reserved -- leave blank
                    .then_has_a_field_containing(originating_dfi_id)
                    .then_has_a_numeric_field_of_length(7).containing(batch_number)
                    .and_return_a_string;

Here is what I'm trying to do:
:'<,'>s/then_has_a_\(field\|numeric_field\)/then_has_a<mandatory>().\1/g

This crashes VS every time -- well, the four times I tried it, anyway, including with :%s instead of :'<,'>s.

2

Re: substitution in C# hangs VS2008

Jay, congratulations, you've found a bug in the ViEmu regex engine!

It hasn't been easy to find and it hasn't been easy to fix, but I got it now. I had to delve back into the regex parser and compiler, and in the regex matching engine itself. The problem was that the internal code generation for the \| operator was declaring a full match too early. It worked when \| expressions were used in the toplevel, but if used insided a submatch between \( and \), the internal submatch markers weren't set correctly. After this, the EvalReplacement code in the :subst command implementation got caught in an infinite loop.

I can't release it right now, because I'm midway through the new licensing-system implementation, but the next release of ViEmu will definitely have this fixed. Meanwhile, please don't use expressions like:

  \(a\|b\)

in the :s command, please do the two substitutions in two steps:

:'<,'>s/then_has_a_\(field\)/then_has_a<mandatory>().\1/g
:'<,'>s/then_has_a_\(numeric_field\)/then_has_a<mandatory>().\1/g

Regards,

  -- Jon