Conditions followed by single EOL failed to be processed
- Dominant language
- No language data
- Stars
- 1.7k
- Forks
- 399
- Avg merge
- 3d 5h
- Merged PRs (30d)
- 39
Description
Examples:
```
string value = @"Hello
#if (1.2 > 2.5)
#endif
";
string expected = @"Hello
";
byte[] valueBytes = Encoding.UTF8.GetBytes(value);
MemoryStream input = new MemoryStream(valueBytes);
MemoryStream output = new MemoryStream();
VariableCollection vc = new VariableCollection();
IProcessor processor = SetupCStyleNoCommentsProcessor(vc);
//Changes should be made
bool changed = processor.Run(input, output, 50);
Verify(Encoding.UTF8, output, changed, value, expected);
Expected: Hello\r\n
Actual: Hello\r\n#endif\r\n
```
```
string value = @"Hello
";
string expected = @"Hello
";
byte[] valueBytes = Encoding.UTF8.GetBytes(value);
MemoryStream input = new MemoryStream(valueBytes);
MemoryStream output = new MemoryStream();
VariableCollection vc = new VariableCollection();
IProcessor processor = SetupXmlStyleProcessor(vc);
//Changes should be made
bool changed = processor.Run(input, output, 50);
Verify(Encoding.UTF8, output, changed, value, expected);;
Expected: Hello\r\n
Actual: Hello\r\n#endif -->\r\n
```
Some notes:
The case happens when condition is false and ends with empty line.
Then in `ProcessorState.Run` during `HandleMatch` for condition the buffer is moved to the end, however not `OldestRequiredSequenceNumber` for `TrieEvaluation.`
Due to this, buffer advancing logic proceeds only to`OldestRequiredSequenceNumber` with offset which is after `if condition`.
The `endif` is getting processed once again as unbalanced condition and gets output.
The fix is potentially "accepting" or "finalizes matches" after `HandleMatch` is done, so last known sequence number is updated and double processing does not happen. Then buffer will be updated to the end and processing stops. After "false" condition branch anyway doesn't make sense to process the open tries. As section is skipped, they won't be matched.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.