Re: [xml] Coding conventions?
- From: "William M. Brack" <wbrack mmm com hk>
- To: "ai2097" <ai2097 yahoo com>
- Cc: xml gnome org
- Subject: Re: [xml] Coding conventions?
- Date: Thu, 1 Jan 2004 09:34:22 +0800 (HKT)
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.
Example 1: Tabs/goofy indentation (xmlschemas.c:2086)
Soft tabs are your friend :)
<snip>
I'm afraid my mail client must have messed this part up - I can't be
certain of what you are trying to point out. Again from a personal
point of view, soft tabs and me are not particularly on very
friendly terms, but that relationship is historic (from the days of
100 baud teletype machines [with program source stored on paper
tape], 300 baud modems, and 360kb disks, where a tab was only 1/8
the size of a string of 8 spaces).
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) );
or even
ctxt->counter++;
foo (ctxt->counter);
Yes, I will certainly have to agree that (in general) the expression
"(foo->counter++ +1)" can be more concisely expressed in way you
mentioned. However, I would take issue with "ugly and confusing" (I
wouldn't call it beautiful, but I'm certainly not confused), and
your general statement about it happening "all over the place":
bill billsuper xmltest $ grep -l "++ + 1" *.c
xmlschemas.c
bill billsuper xmltest $ grep "++ + 1" xmlschemas.c | wc -l
18
i.e. it only occurs in the module xmlschemas.c, and those are 18
snprintf statements (out of 6,380 lines of code). Also note that,
even with a minimal optimisation level on the compiler, the
generated code will be the same, so we are only concerned with
aesthetics.
Thanks for your interest - and best wishes for the New Year.
Bill
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]