Changeset 3345

Show
Ignore:
Timestamp:
08/27/06 18:33:11 (2 years ago)
Author:
timothy
Message:

Fix many incorrect uses of strncmp.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Models/JVChatEvent.m

    r3247 r3345  
    5252 
    5353                do { 
    54                         if( subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 6 ) ) { 
     54                        if( subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) { 
    5555                                _message = [[NSTextStorage allocWithZone:[self zone]] initWithXHTMLTree:subNode baseURL:nil defaultAttributes:nil]; 
    5656                                break; 
     
    7070 
    7171                do { 
    72                         if( subNode -> type == XML_ELEMENT_NODE && strncmp( "message", (char *) subNode -> name, 6 ) ) { // everything but "message" 
     72                        if( subNode -> type == XML_ELEMENT_NODE && strcmp( "message", (char *) subNode -> name ) ) { // everything but "message" 
    7373                                NSMutableDictionary *properties = [NSMutableDictionary dictionary]; 
    7474                                xmlAttrPtr prop = NULL; 
  • trunk/Models/JVChatTranscript.m

    r3259 r3345  
    204204                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    205205                do { 
    206                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     206                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    207207                                xmlNode *subNode = node -> children; 
    208208                                do { 
    209                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) 
     209                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) 
    210210                                                count++; 
    211211                                } while( subNode && ( subNode = subNode -> next ) ); 
     
    223223                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    224224                do { 
    225                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "session", (char *) node -> name, 7 ) ) 
     225                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "session", (char *) node -> name ) ) 
    226226                                count++; 
    227227                } while( node && ( node = node -> next ) ); 
     
    237237                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    238238                do { 
    239                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     239                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    240240                                xmlNode *subNode = node -> children; 
    241241                                do { 
    242                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) 
     242                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) 
    243243                                                count++; 
    244244                                } while( subNode && ( subNode = subNode -> next ) ); 
     
    256256                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    257257                do { 
    258                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "event", (char *) node -> name, 5 ) ) 
     258                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "event", (char *) node -> name ) ) 
    259259                                count++; 
    260260                } while( node && ( node = node -> next ) ); 
     
    290290                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    291291                do { 
    292                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     292                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    293293                                xmlNode *subNode = node -> children; 
    294294                                do { 
    295                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) { 
     295                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) { 
    296296                                                if( NSLocationInRange( i, range ) ) { 
    297297                                                        JVChatMessage *msg = [[JVChatMessage allocWithZone:nil] _initWithNode:subNode andTranscript:self]; 
     
    303303                                        } 
    304304                                } while( subNode && ( subNode = subNode -> next ) ); 
    305                         } else if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "session", (char *) node -> name, 7 ) ) { 
     305                        } else if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "session", (char *) node -> name ) ) { 
    306306                                if( NSLocationInRange( i, range ) ) { 
    307307                                        JVChatSession *session = [[JVChatSession allocWithZone:nil] _initWithNode:node andTranscript:self]; 
     
    311311 
    312312                                if( ++i > ( range.location + range.length ) ) goto done; 
    313                         } else if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "event", (char *) node -> name, 5 ) ) { 
     313                        } else if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "event", (char *) node -> name ) ) { 
    314314                                if( NSLocationInRange( i, range ) ) { 
    315315                                        JVChatEvent *event = [[JVChatEvent allocWithZone:nil] _initWithNode:node andTranscript:self]; 
     
    335335                xmlNode *node = xmlGetLastChild( xmlDocGetRootElement( _xmlLog ) ); 
    336336                do { 
    337                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     337                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    338338                                xmlNode *subNode = xmlGetLastChild( node ); 
    339339                                do { 
    340                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) 
     340                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) 
    341341                                                return [[[JVChatMessage allocWithZone:nil] _initWithNode:subNode andTranscript:self] autorelease]; 
    342342                                } while( subNode && ( subNode = subNode -> prev ) ); 
    343                         } else if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "session", (char *) node -> name, 7 ) ) { 
     343                        } else if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "session", (char *) node -> name ) ) { 
    344344                                return [[[JVChatSession allocWithZone:nil] _initWithNode:node andTranscript:self] autorelease]; 
    345                         } else if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "event", (char *) node -> name, 5 ) ) { 
     345                        } else if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "event", (char *) node -> name ) ) { 
    346346                                return [[[JVChatEvent allocWithZone:nil] _initWithNode:node andTranscript:self] autorelease]; 
    347347                        } 
     
    405405                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    406406                do { 
    407                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     407                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    408408                                xmlNode *subNode = node -> children; 
    409409                                do { 
    410                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) { 
     410                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) { 
    411411                                                if( NSLocationInRange( i, range ) ) { 
    412412                                                        if( [_messages count] > i && [[_messages objectAtIndex:i] isKindOfClass:[JVChatMessage class]] ) { 
     
    463463                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    464464                do { 
    465                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     465                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    466466                                xmlNode *subNode = node -> children; 
    467467                                do { 
    468                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) { 
     468                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) { 
    469469                                                xmlChar *prop = xmlGetProp( subNode, (xmlChar *) "id" ); 
    470470                                                if( prop && ! strcmp( (char *) prop, ident ) ) foundNode = subNode; 
     
    486486 
    487487                do { 
    488                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     488                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    489489                                xmlNode *subNode = xmlGetLastChild( node ); 
    490490                                do { 
    491                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) { 
     491                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) { 
    492492                                                foundNode = subNode; 
    493493                                                break; 
     
    513513 
    514514                do { 
    515                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     515                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    516516                                xmlNode *subNode = node -> children; 
    517517                                do { 
    518                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) { 
     518                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) { 
    519519                                                xmlChar *prop = xmlGetProp( subNode, (xmlChar *) "id" ); 
    520520                                                if( prop && ! strcmp( (char *) prop, ident ) ) found = YES; 
     
    547547                        // check if the last node is an envelope by the same sender (and maybe source), if so append this message to that envelope 
    548548                        xmlNode *lastChild = xmlGetLastChild( xmlDocGetRootElement( _xmlLog ) ); 
    549                         if( lastChild && lastChild -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) lastChild -> name, 8 ) ) { 
     549                        if( lastChild && lastChild -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) lastChild -> name ) ) { 
    550550                                NSString *msgSource = [[message source] absoluteString]; 
    551551 
     
    557557                                        xmlNode *subNode = lastChild -> children; 
    558558                                        do { 
    559                                                 if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "sender", (char *) subNode -> name, 6 ) ) { 
     559                                                if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "sender", (char *) subNode -> name ) ) { 
    560560                                                        NSString *identifier = [message senderIdentifier]; 
    561561                                                        NSString *nickname = [message senderNickname]; 
     
    599599 
    600600                        do { 
    601                                 if( ! strncmp( "sender", (char *) subNode -> name, 6 ) ) break; 
     601                                if( ! strcmp( "sender", (char *) subNode -> name ) ) break; 
    602602                        } while( subNode && ( subNode = subNode -> next ) ); 
    603603 
     
    664664                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    665665                do { 
    666                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "session", (char *) node -> name, 7 ) ) { 
     666                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "session", (char *) node -> name ) ) { 
    667667                                if( NSLocationInRange( i, range ) ) { 
    668668                                        JVChatSession *session = [[JVChatSession allocWithZone:nil] _initWithNode:node andTranscript:self]; 
     
    688688                xmlNode *node = xmlGetLastChild( xmlDocGetRootElement( _xmlLog ) ); 
    689689                do { 
    690                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "session", (char *) node -> name, 7 ) ) 
     690                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "session", (char *) node -> name ) ) 
    691691                                return [[[JVChatSession allocWithZone:nil] _initWithNode:node andTranscript:self] autorelease]; 
    692692                } while( node && ( node = node -> prev ) ); 
     
    729729                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    730730                do { 
    731                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "event", (char *) node -> name, 5 ) ) { 
     731                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "event", (char *) node -> name ) ) { 
    732732                                if( NSLocationInRange( i, range ) ) { 
    733733                                        JVChatEvent *event = [[JVChatEvent allocWithZone:nil] _initWithNode:node andTranscript:self]; 
     
    753753                xmlNode *node = xmlGetLastChild( xmlDocGetRootElement( _xmlLog ) ); 
    754754                do { 
    755                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "event", (char *) node -> name, 5 ) ) 
     755                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "event", (char *) node -> name ) ) 
    756756                                return [[[JVChatEvent allocWithZone:nil] _initWithNode:node andTranscript:self] autorelease]; 
    757757                } while( node && ( node = node -> prev ) ); 
     
    773773 
    774774                do { 
    775                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "event", (char *) node -> name, 5 ) ) { 
     775                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "event", (char *) node -> name ) ) { 
    776776                                xmlChar *prop = xmlGetProp( node, (xmlChar *) "id" ); 
    777777                                if( prop && ! strcmp( (char *) prop, ident ) ) found = YES; 
     
    978978                xmlNode *node = xmlDocGetRootElement( _xmlLog ) -> children; 
    979979                do { 
    980                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "envelope", (char *) node -> name, 8 ) ) { 
     980                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "envelope", (char *) node -> name ) ) { 
    981981                                xmlNode *subNode = node -> children; 
    982982                                BOOL removedAllMessages = YES; 
    983983 
    984984                                do { 
    985                                         if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) subNode -> name, 7 ) ) { 
     985                                        if( subNode && subNode -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) subNode -> name ) ) { 
    986986                                                if( total > 0 ) { 
    987987                                                        tmp = subNode -> prev; 
     
    10041004                                        node = ( tmp ? tmp : xmlDocGetRootElement( _xmlLog ) -> children ); 
    10051005                                } 
    1006                         } else if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "session", (char *) node -> name, 7 ) ) { 
     1006                        } else if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "session", (char *) node -> name ) ) { 
    10071007                                tmp = node -> prev; 
    10081008                                xmlUnlinkNode( node ); 
     
    10101010                                node = ( tmp ? tmp : xmlDocGetRootElement( _xmlLog ) -> children ); 
    10111011                                total--; 
    1012                         } else if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "event", (char *) node -> name, 5 ) ) { 
     1012                        } else if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "event", (char *) node -> name ) ) { 
    10131013                                tmp = node -> prev; 
    10141014                                xmlUnlinkNode( node ); 
     
    13391339 
    13401340                do { 
    1341                         if( node && node -> type == XML_ELEMENT_NODE && ! strncmp( "message", (char *) node -> name, 7 ) ) { 
     1341                        if( node && node -> type == XML_ELEMENT_NODE && ! strcmp( "message", (char *) node -> name ) ) { 
    13421342                                if( node == _node ) break; 
    13431343                                _consecutiveOffset++; 
     
    13561356 
    13571357                do { 
    1358                         if( subNode -> type == XML_ELEMENT_NODE && ! strncmp( "sender", (char *) subNode -> name, 6 ) ) { 
     1358                        if( subNode -> type == XML_ELEMENT_NODE && ! strcmp( "sender", (char *) subNode -> name ) ) { 
    13591359                                xmlChar *prop = xmlNodeGetContent( subNode ); 
    13601360                                id old = _senderName; 
  • trunk/Models/JVSQLChatTranscript.m

    r3259 r3345  
    187187        NSString *identifier = [[NSString allocWithZone:nil] initWithUTF8String:fields[1]]; 
    188188 
    189         if( ! strncmp( "message", fields[0], 7 ) ) { 
     189        if( ! strcmp( "message", fields[0] ) ) { 
    190190                JVChatMessage *message = [[JVChatMessage allocWithZone:nil] _initWithSQLIdentifier:identifier andTranscript:data -> transcript]; 
    191191                if( message ) [data -> results addObject:message]; 
    192192                [message release]; 
    193         } else if( ! strncmp( "event", fields[0], 5 ) ) { 
     193        } else if( ! strcmp( "event", fields[0] ) ) { 
    194194                JVChatEvent *event = [[JVChatEvent allocWithZone:nil] _initWithSQLIdentifier:identifier andTranscript:data -> transcript]; 
    195195                if( event ) [data -> results addObject:event];