On Mon, Nov 05, 2007 at 02:09:20PM +1800, Bo Peng wrote:
> Dear all,
> 
> It is not always easy to write code that conforms to lyx' coding rules
> so I have been searching for an open-source code beautifier. I have
> tried bcpp, greatcode, astyle, indent etc, but none of them is
> powerful enough. I tried again yesterday and found that uncrustify
> (http://uncrustify.sourceforge.net/ ) has achieved a useful level. I
> think it is now possible to standardize lyx source file format in
> terms of a uncrusitify configuration file so that uncrustify can be
> applied before patches are generated.
> 
> I have attached a draft configuration file that is close to our coding
> rules. More adjustment can be made using universalindentgui
> (http://universalindent.sourceforge.net/).  Once we agree on a
> standard configuration file, it would be good to apply it to all
> source files and result in a uniform format.
> 
> What do you think?

I'd use it as recommendation at best, not as the governing tool.

It does catch a few 'problems' in the current code, but there are 
also a few false positives:

>From a quick run:

It currently replaces


 ASpell::ASpell(BufferParams const &, string const & lang)

by

 ASpell::ASpell(BufferParams const & , string const & lang)


I think I prefer the original version.


Same for

76c78
<       BOOST_ASSERT(unsigned(id) < authors_.size());
---
>       BOOST_ASSERT(unsigned (id) < authors_.size());


BiblioInfo.cpp:
79,80c81
<       docstring const familyName(docstring const & name)
<       {
---
>       docstring const familyName(docstring const & name) {


312c316
<       for (vector<docstring>::size_type i = 0; i != vec.size(); ++i) {
---
>       for (vector < docstring > ::size_type i = 0; i != vec.size();
>       ++i) {


550,551c558,559
< } // namespace biblio
< } // namespace lyx
---
> }       // namespace biblio
> }       // namespace lyx

BranchList.cpp:
86c86,87
<       return it == list.end() ? 0 : &*it;
---
> 
>       return it == list.end() ? 0 : & * it;
94c95,96
<       return it == list.end() ? 0 : &*it;
---
> 
>       return it == list.end() ? 0 : & * it;


Buffer.cpp:
663c666
<               std::ofstream os(name.toFilesystemEncoding().c_str());
---
>               std::ofstream os(name.toFilesystemEncoding ().c_str());



There are also 'real' problems as in:

Buffer.cpp:

< # define fork() -1
---
>  #define fork() - 1

Preprocessor stuff has to have its '#' in the first column. A conforming
preprocessor is not required to accept anything else (Even if most do.
The last one requiring it I saw was some kind of aCC ~1998)

So, as I said: Checking patches with it is nice, but as it stands I
would not like to see it ruling our style.


Andre'

Reply via email to