Index ¦ Archives ¦ RSS

Sanitizing member variable names in LibreOffice Writer

Estimated read time: 1 minutes

Robinson just branched off libreoffice-5-1 from master in LibreOffice’s core.git repository, so time to talk about what happened behind the scenes in the 5.0 → 5.1 development cycle from my side.

One stylistic detail that annoyed me for a while was the inconsistency around naming class member variables. In new code it’s common to give them an m_ (or at least an m) prefix, but in older code that wasn’t that common, and various custom hacks were invented to differentiate between pointers which point to the same memory address, but one being a parameter of a member function, and the other being a member variable.

Probably the worst scenario is when one was an abbreviation of the other, like pTable and pTbl or pCursor and pCrsr. I took this as an opportunity to play with Clang’s LibTooling, and I wrote two tools back during the Cambridge hackfest to automate the process of finding and fixing missing prefixes.

To scope the renaming, I changed all classes in the sw module having more than 20 unprefixed members to follow the above convention, hopefully this nicely improves code readability, together with the mass-rename of pointless abbreviations, also done before the branch-off, so affecting both libreoffice-5-1 and master. :-)

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.