Re: [xml] Coding conventions?
- From: Malcolm Tredinnick <malcolm commsecure com au>
- To: xml gnome org
- Subject: Re: [xml] Coding conventions?
- Date: Fri, 02 Jan 2004 11:12:55 +1100
On Thu, 2004-01-01 at 12:34, William M. Brack wrote:
ai2097 said:
I'm wondering if there's any standard coding convention/indent
settings
that are applied to the source for this project. If so, is there a
link
I could refer to to find out what they are? If not, am I free to
reformat code as I go and submit patches to clean things up?
Thanks,
-- Travis
There is (as far as I am aware) no document within the project files
which formally specifies a "proper" layout for the code. The vast
majority of the source has been written by Daniel, so it should be
reasonably consistent (although we all have our good days and bad
days). However, patches come from all over the world, and (to me)
the resulting logic far outweighs the format of the code. A quick
Google search of the mail archives (sorry, Daniel - the xmlsoft
search engine is still not quite in the same class ;-) gave me this
link as the best I could find for a "standard":
http://mail.gnome.org/archives/xslt/2002-May/msg00054.html
You are always more than welcome to submit proposed patches
(preferably here to the list so that all can see and discuss). Of
course, any proposed patches may or may not be accepted :-)
Rather than laboriously going through with your editor to accomplish
this, you may wish to consider recommending some program like
"indent", together with some parameters to accomplish what you think
would be better for the project.
I would really be against the idea of a large number of "just change the
indentation and formatting" patches going in. The problem is that it
really messes up the ability to track the history of various lines. The
usual (and quite valid) argument is that commands like 'cvs annotate'
command are extremely useful for trying to track down bugs and if random
lines are going to be changed just because somebody wants to change the
number of tabs in a line, that facility is going to be ruined.
If there are places where the code is genuinely difficult to read, then
they can be fixed. But otherwise, the normal rule is "do as the guy
before you did".
Example 1: Tabs/goofy indentation (xmlschemas.c:2086)
Soft tabs are your friend :)
*shrug* This is a *very* minor point and not worth the massive
disturbance to the Force .. err .. source it would cause. Maybe a line
in HACKING to say that tab stops are assumed to be eight spaces in the
source or something. But if by "soft tabs" you mean "replace tabs with
spaces", then I see no benefit.
[...]
Example 2: Ugly/confusing syntax (xmlscemas.c:2088) (generic
version)
this particular one is all over the place...
foo (ctxt->counter++ + 1);
IMHO, this seems much cleaner (and is exactly why preincrement
exists):
foo ( ++(ctxt->counter) );
Now, this one I sort of agree with. The current code looks a bit odd
(although it is consistent in the localised places it occurs, which is
not a trivial point, as Bill pointed out).
Cheers,
Malcolm
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]