Changeset 22fe2438b98e2d041b4481c0c8706096a8f160ce

Show
Ignore:
Timestamp:
05/24/08 11:40:57 (3 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1211622057 +0300
git-parent:

[05cfa654a872bd3b6dc8123cc736110d3d022b20]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1211622057 +0300
Message:

Simplify, fix and inline strcasecmp and strncasecmp

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_common.h

    r287081c r22fe243  
    729729VLC_EXPORT( int, vlc_alphasort, ( const struct dirent **a, const struct dirent **b ) ); 
    730730 
    731 VLC_EXPORT( int, vlc_strcasecmp, ( const char *s1, const char *s2 ) ); 
    732 VLC_EXPORT( int, vlc_strncasecmp, ( const char *s1, const char *s2, size_t n ) ); 
    733731VLC_EXPORT( char *, vlc_strcasestr, ( const char *s1, const char *s2 ) ); 
    734732 
  • include/vlc_fixups.h

    r287081c r22fe243  
    118118#ifndef HAVE_STRCASECMP 
    119119# ifndef HAVE_STRICMP 
    120 #  define strcasecmp vlc_strcasecmp 
     120#  include <ctype.h> 
     121static inline int strcasecmp (const char *s1, const char *s2) 
     122
     123    for (size_t i = 0;; i++) 
     124    { 
     125        int d = tolower (s1[i]) - tolower (s2[i]); 
     126        if (d) return d; 
     127    } 
     128    return 0; 
     129
    121130# else 
    122131#  define strcasecmp stricmp 
     
    126135#ifndef HAVE_STRNCASECMP 
    127136# ifndef HAVE_STRNICMP 
    128 #  define strncasecmp vlc_strncasecmp 
     137#  include <ctype.h> 
     138static inline int strncasecmp (const char *s1, const char *s2, size_t n) 
     139
     140    for (size_t i = 0; i < n; i++) 
     141    { 
     142        int d = tolower (s1[i]) - tolower (s2[i]); 
     143        if (d) return d; 
     144    } 
     145    return 0; 
     146
    129147# else 
    130148#  define strncasecmp strnicmp 
  • src/extras/libc.c

    r287081c r22fe243  
    7575#endif 
    7676 
    77 /***************************************************************************** 
    78  * strcasecmp: compare two strings ignoring case 
    79  *****************************************************************************/ 
    80 #if !defined( HAVE_STRCASECMP ) && !defined( HAVE_STRICMP ) 
    81 int vlc_strcasecmp( const char *s1, const char *s2 ) 
    82 { 
    83     int c1, c2; 
    84     if( !s1 || !s2 ) return  -1; 
    85  
    86     while( *s1 && *s2 ) 
    87     { 
    88         c1 = tolower(*s1); 
    89         c2 = tolower(*s2); 
    90  
    91         if( c1 != c2 ) return (c1 < c2 ? -1 : 1); 
    92         s1++; s2++; 
    93     } 
    94  
    95     if( !*s1 && !*s2 ) return 0; 
    96     else return (*s1 ? 1 : -1); 
    97 } 
    98 #endif 
    99  
    100 /***************************************************************************** 
    101  * strncasecmp: compare n chars from two strings ignoring case 
    102  *****************************************************************************/ 
    103 #if !defined( HAVE_STRNCASECMP ) && !defined( HAVE_STRNICMP ) 
    104 int vlc_strncasecmp( const char *s1, const char *s2, size_t n ) 
    105 { 
    106     int c1, c2; 
    107     if( !s1 || !s2 ) return  -1; 
    108  
    109     while( n > 0 && *s1 && *s2 ) 
    110     { 
    111         c1 = tolower(*s1); 
    112         c2 = tolower(*s2); 
    113  
    114         if( c1 != c2 ) return (c1 < c2 ? -1 : 1); 
    115         s1++; s2++; n--; 
    116     } 
    117  
    118     if( !n || (!*s1 && !*s2) ) return 0; 
    119     else return (*s1 ? 1 : -1); 
    120 } 
    121 #endif 
    122  
    12377/****************************************************************************** 
    12478 * strcasestr: find a substring (little) in another substring (big) 
  • src/libvlccore.sym

    r287081c r22fe243  
    439439vlc_sdp_Start 
    440440vlc_sendmsg 
    441 vlc_strcasecmp 
    442441vlc_strcasestr 
    443442vlc_strlcpy 
    444 vlc_strncasecmp 
    445443vlc_strtoll 
    446444vlc_submodule_create