[poppler] Source code beautifiers
William Bader
williambader at hotmail.com
Mon Jun 27 17:57:59 UTC 2016
I think that the poppler maintainers have tried to avoid changes that would unnecessarily complicate merging xpdf changes into poppler.
Even though poppler has diverged from xpdf, it is still often possible to apply small xpdf diffs to poppler, and I think that there are a number of xpdf-3.04 changes that still need to be merged.
The qt frontends are not in xpdf, so reformatting them would probably be less of an issue.
Regards, William
> From: jakubkucharski97 at gmail.com
> To: poppler at lists.freedesktop.org
> Date: Mon, 27 Jun 2016 19:09:33 +0200
> Subject: [poppler] Source code beautifiers
>
> Hello, everyone!
>
> Poppler has a very diverse codebase if it comes to coding style. In
> some places it gets really weird, e.g. the qt frontends, where we have
> code like this ("▸---" marks a tab):
>
> bool Document::unlock(const QByteArray &ownerPassword,
> ▸---▸---▸--- const QByteArray &userPassword)
> {
> ▸---if (m_doc->locked) {
> ▸--- /* racier then it needs to be */
> ▸--- DocumentData *doc2;
> ▸--- if (!m_doc->fileContents.isEmpty())
> ▸--- {
> ▸---▸---doc2 = new DocumentData(m_doc->fileContents,
> ▸---▸---▸---▸---▸---new GooString(ownerPassword.data()),
> ▸---▸---▸---▸---▸---new GooString(userPassword.data()));
> ▸--- }
> ▸--- else
> ▸--- {
> ▸---▸---doc2 = new DocumentData(m_doc->m_filePath,
> ▸---▸---▸---▸---▸---new GooString(ownerPassword.data()),
> ▸---▸---▸---▸---▸---new GooString(userPassword.data()));
> ▸--- }
> ▸--- if (!doc2->doc->isOk()) {
> ▸---▸---delete doc2;
> ▸--- } else {
> ▸---▸---delete m_doc;
> ▸---▸---m_doc = doc2;
> ▸---▸---m_doc->locked = false;
> ▸---▸---m_doc->fillMembers();
> ▸--- }
> ▸---}
> ▸---return m_doc->locked;
> }
>
> With code like this I just end up copy-pasting things hoping that I
> manage to guess the right way to format the code. So I've thought we
> could make things easier by using a source code beautifier and
> providing config files for it. We could either unify the coding style
> or we could have different config files for core, goo, qt etc. (I'd be
> in favor of unification.)
>
> Two source code beautifiers that I know of are Uncrustify[1] and
> ClangFormat[2]. For the second one there is a web page[3] which makes
> its configuration a piece of cake and there is a python script making
> it easy to integrate it with vim or any other highly configurable
> editor. However Uncrustify seems to be more configurable. Flatpak devs
> have a useful shell script making it easier to invoke Uncrustify[4].
>
> What do you think?
>
> Jakub
>
> [1] http://uncrustify.sourceforge.net/
> [2] http://clang.llvm.org/docs/ClangFormat.html
> [3] http://clangformat.com/
> [4] https://github.com/flatpak/flatpak/blob/master/uncrustify.sh
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/poppler
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/poppler/attachments/20160627/5dc7af82/attachment-0001.html>
More information about the poppler
mailing list