Re: [Widelands-public] Sourcecode beautification
Status: Beta
Brought to you by:
sirver
From: Florian W. <Flo...@pf...> - 2006-01-09 23:29:16
|
Am Donnerstag, 1. Januar 1970 00:59 schrieb Philipp Niemann: > | static Building_Descr* create_from_dir(Tribe_Descr* tribe, > |- const char* directory, const EncodeData* encdata); > |+ const char* directory, const > OLD: Two tabs in front of line continued > NEW: ONE tab and lots of spaces in front of line continued > Seems like astyle wants the open parenthesis to be continued on the same > column in the next line. This is indeed what is happening. And I think it's the right thing to do, f= rom=20 the viewpoint of indentation and disregarding line length. > time to time I do use 80 char width terminals, the above example is a > strong "no" to automatic use of astyle. 80 characters is, another formatting problem we currently face and I agree = it=20 has to be addressed - preferrably at the same time as indentation. (cf. las= t=20 paragraph for software 'solutions') Two "but"s: 1. Notice that, in your example, the un-astyled line is <80characters only= =20 because the author manually made it so. An already reindented line can be=20 treated the same way, once it is found. 2. There already is a measure of code that has this problem (ex.: bob.h::vo= id=20 start_task_movepath). Addressing #1: Provided one does use astyle and breaks annoying lines manually, both party= s=20 could probably be happy: * people with big screens will have relatively big indents (say, 8sp).=20 Nevertheless, they break the lines at 80characters. Any smaller indent t= han=20 theirs (say, 3sp) will display correctly, only a few characters at the e= nd=20 don't get used * the other way around, nobody cares. Big screens are big, even 130char lin= es are no problem. So reindenting is "only" a matter of introducing additional long lines;=20 probably not that many. I'm not saying we shouldn't care - but it's not muc= h=20 additional trouble. (I can't quantify that yet, will test tomorrow) > indentation handling. But I hate programs messing up my thoughtfully > written things. =2E.. and, in this case, doing so because you yourself ordered it. ;-) > What bothers me is that I miss the meaning of a patch for hundreds of > lines of indentation changes or trailing spaces removement. But still I My opinion is that reformatting patches should contain nothing else and vic= e=20 versa. Yes, I'm painfully aware that I've acted differently time and time again. := =2D( Mostly because of "Oops, my editor lost that setting _again_. But I'm too l= azy=20 to clean the patch, I want it out _now_ and go to bed." =20 > About to read its manpage. I couldn't find a way to solve the problem. The only program that does fold= ing=20 for long lines is gnu indent (and some very expensive commercial ones). But= =20 indent doesn't understand C++. So it's either spend money or fold manually. To lessen the impact, one might: 1. use --max-instatement-indent=3D5. This way the additional indentation wo= uld=20 be 5 spaces max. (or any other n) 2. use --force-indent=3Dtab=3D8 instead of --indent=3Dtab=3D3. This uses as= many tabs=20 as possible (assuming the given width) to still get the same indentatio= n=20 as with spaces. If your local tabwidth is less, stuff moves to the left= =20 much more. #1 is crap, IMHO. I suggest you try #2 and see how it looks. We might also find a way to first break long lines with indent, then do a n= ice=20 formatting with astyle. This will take a lot of fiddling with indent=20 parameters. The downside: it will still very likely touch the sourcecode in= =20 ways we won't like. There is no way to make indent _not_ change braces and= =20 such (and barf immensely at some C++ constructs). astyle, even if we found= =20 the perfect parameters, probably couldn't undo the damage indent did. I definitely wouldn't like that solution, and I guess I'm not alone with th= e=20 sentiment. >cover some files >step by step beforehand to get an idea of the quirks of astyle. As from The current state of sound_handler.* is: write-->astyle-->manually break to 80chars-->astyle. =46inal indentation was done with the parameters you used in your trial. So have a first look to see what it could be like. :-) =2D-=20 Mit freundlichen Gr=FC=DFen, =46lorian Weber PGP key id: A34C32F9 |