A small bug fix, providing a small sample of both code and bug-handling comments.
This part of KDE is under the Gnu GPL (code) and Gnu GFDL (documentation); only two short excerpts are reproduced here.
Bug overview
Link to Debian's bug tracking system
KDE has a standard text-field component. The search-and-replace function could lock up in a infinite-loop, forcing the user to kill the application and lose any unsaved changes.
When handling a replacement string containing an escaped backslash followed by a number, such as "\\0", the old code first found the "\0", then checked for a preceeding backslash, and became stuck if there was one.
A two-part fix, the first part being to decide and document how it should handle escape sequences.
Documentation addition
- Use Placeholders
- If selected, the replacement string may use backreferences (see Regular Expressions). Backslashes, newlines and tabs may be inserted with the sequences "\\", "\n" and "\t" respectively.
Code change
The code is using Qt's QtString class, which handles ref-counting and deallocation of the underlying character arrays
The existing code that follows the changed section checked for and handled the addition of newlines, which is why I added support for "\n" in the replacement string.