[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSAttributedString (Foundation) bug
From: |
Richard Frith-Macdonald |
Subject: |
Re: NSAttributedString (Foundation) bug |
Date: |
Sat, 8 Dec 2001 07:29:43 +0000 |
On Saturday, December 8, 2001, at 12:25 AM, Pascal Bourguignon wrote:
Ludovic Marcotte <ludovic@Sophos.ca> wrote:
Hi,
In NSAttributedString: -initWithCoder we have:
...
m = [m initWithString: string attributes: nil];
[m setAttributes: attrs range: r];
while (index < length);
{
[aDecoder decodeValueOfObjCType: @encode(unsigned int)
at: &index];
...
we should remove the ; after while (index < length), otherwise, it'll
endlessly loop if the attributed string has been archived with
different
attributes.
Ludo
That kind of bugs can be avoided easily adopting a style resembling
the syntax of more advanced languages like MODULA-3:
if(condition){ /* Always put the { even for only one
statement !!! */
statement;
Nice try ... by demonstrably untrue.
For the case in point, a '{' *was* there, and code like
'if(condition);{some-code-here}'
is perfectly legal in C.
While I'm strongly in favour of using braces around even a single
statement in any
control structure, that's to improve readability and lessen the chances
of mistaking
each statements are associated with a conditional - not because I think
it will
help me spot extra semicolons in the code (it doesn't).
We have a simple rule for GNUstep ... stick to the GNU coding standards
so that
everyone ifs familiar with the style (a pretty good one), and can read
it easily.
Whether or not to use braces for a single statement is not covered in
the GNU
coding style (I say, yes we should), but how to use them *is* -
if (condition)
{
statement;
}
*NOT*
if(condition){statement;}