[poppler] Source code beautifiers

Carlos Garcia Campos carlosgc at gnome.org
Tue Jun 28 05:59:50 UTC 2016


William Bader <williambader at hotmail.com> writes:

> 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.

That's right, but in the end we always had to manually apply all
changes, at least in the 3.02 and 3.03 merges. It's not really possible
to apply the patch and fix merge conflicts, so I think it's time to stop any
progress because of diverging from xpdf code.

> 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
>  		 	   		  
> _______________________________________________
> poppler mailing list
> poppler at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/poppler

-- 
Carlos Garcia Campos
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x523E6462
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 180 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/poppler/attachments/20160628/4e6a6917/attachment.sig>


More information about the poppler mailing list