bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSAttributedString (Foundation) bug


From: Pascal Bourguignon
Subject: Re: NSAttributedString (Foundation) bug
Date: Sat, 8 Dec 2001 01:25:48 +0100 (CET)

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;
    }else if(condition){  /* Always put the { even for only one statement !!! */
        statement;
    }else{                /* Always put the { even for only one statement !!! */
        statement;
    }


    while(condition){  /* Always put the { even for only one statement !!! */
        statement;
    }


    switch(expression){
    case constant1:
        statement;
        break;
    case constant2:
        statement;
        break;
    default::
        statement;
        break;
    }


    for(init;cond;incr){  /* Always put the { even for only one statement !!! */
        statement;
    }



Any other style is propicious to bugs like that one.


-- 
__Pascal_Bourguignon__              (o_ Software patents are endangering
()  ASCII ribbon against html email //\ the computer industry all around
/\  and Microsoft attachments.      V_/ the world http://lpf.ai.mit.edu/
1962:DO20I=1.100  2001:my($f)=`fortune`;  http://petition.eurolinux.org/

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/IT d? s++:++(+++)>++ a C+++  UB+++L++++$S+X++++>$ P- L+++ E++ W++
N++ o-- K- w------ O- M++$ V PS+E++ Y++ PGP++ t+ 5? X+ R !tv b++(+)
DI+++ D++ G++ e+++ h+(++) r? y---? UF++++
------END GEEK CODE BLOCK------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]