[petsc-dev] pretty printing PETSc source code

Barry Smith bsmith at mcs.anl.gov
Tue Sep 18 21:54:48 CDT 2012


  As those who watch the petsc-dev RSS feed know (by the way, get a life; surely George Takei's Facebook feeds are more enlightening ) I have been monkeying with using uncrustify for pretty printing PETSc source code and am tempted to start using it on PETSc (yes, I am anal about source code formatting). It is not perfect, and doesn't do everything exactly PETSc style but its pretty good, and by using ignore for some options it leaves our "correct" formatting alone.  In any directory with source code do make uncrustify; for i in *.c; do diff ${i} ${i}.uncrustify ; done | more and you can see how it formats differently (better) than our unruly source code.

   Anyways, rather than jumping in too deep a water I propose I uncrustify the files in src/ts/examples/tutorials and commit those as a test. Does anyone object to this?

   Why TS? We'll I want to improve the usability curve of PETSc and focus on the parts we want more people using so to make usage as clean and easy as possible.

   Barry

 Yes, I have dreamed for many years that upon committing files to petsc-dev it would automatically trigger appropriate formatting tools so people cannot commit/push badly formatted source code. Unfortunately the llvm boys and girls have let me down and I still cannot find a tool better than uncrustify.  With a little ambition we could add a set of rules in addition to uncrustify that reject non-standard PETSc source code from being committed/pushed (like the absolutely perverse sizeof something that Jed is so damn fond of).

   In my ideal world, PETSc developers could trigger automatically their favorite pretty printer on update so that they could have their crazy if(xx) and sizeof something in their editors and it would automatically go back to the correct form on committing but sadly these pretty printers are not powerful enough to be fully reversible so you are largely stuck with my style.






More information about the petsc-dev mailing list