Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The change in mio_new_mio() exposed a problem in yacc parser where epilogue parsing didn't work correctly and the reason it worked was only thanks to the strange mio_new_mio() semantics. First, in runYaccParser() the line shouldn't be read because this is the first (and possibly last) line of epilogue and this way it gets ignored and offsets for the promise API aren't calculated for it. Because of this change, we have to add 1 to c_start and c_source_start inside make_promise_for_epilogue() so we get real start of epilogue. Second, the loop while ((tmp = readLineFromInputFile ())) last = tmp; didn't do what the author thought it was doing. The idea behind it probably was to "remember" the last line and subsequently to compute its length. This however doesn't work this way - because readLineFromInputFile() returns a const pointer into an internal buffer inside ctags main, the last time readLineFromInputFile() is called and when it returns NULL this value is cleared so no matter what the "last" variable contained, it would always be an empty string after the loop finishes. This patch just moves the calculation of endCharOffset inside the loop where the line value is still valid. It means some unnecessary strlen() calculation of all lines in the epilogue but I don't think it has a big overall impact on the performance. The unfortunate side-effect of this patch is that if a tag appears on the last line of the file, we can't say whether the line ends with \n or not because readLineFromInputFile() silently discards them. This means that the test in which there's a tag at the last line doesn't contain $ in the pattern. This problem didn't appear before the change in MIO because thanks to the various bugs in the yacc parser, the start line was equal to the end line and both offsets were 0 so the size for mio_new_mio() was 0 and it was created till the end of the file.
- Loading branch information