| 127 | } |
| 128 | |
| 129 | int V_strnicmp( const char *s1, const char *s2, int n ) |
| 130 | { |
| 131 | Assert( n >= 0 ); |
| 132 | Assert( n == 0 || s1 != NULL ); |
| 133 | Assert( n == 0 || s2 != NULL ); |
| 134 | |
| 135 | while ( n-- > 0 ) |
| 136 | { |
| 137 | int c1 = *s1++; |
| 138 | int c2 = *s2++; |
| 139 | |
| 140 | if ( c1 != c2 ) |
| 141 | { |
| 142 | if ( c1 >= 'a' && c1 <= 'z' ) |
| 143 | c1 -= ('a' - 'A'); |
| 144 | if ( c2 >= 'a' && c2 <= 'z' ) |
| 145 | c2 -= ( 'a' - 'A' ); |
| 146 | if ( c1 != c2 ) |
| 147 | return c1 < c2 ? -1 : 1; |
| 148 | } |
| 149 | if ( c1 == '\0' ) |
| 150 | return 0; // null terminator hit - strings the same |
| 151 | } |
| 152 | |
| 153 | return 0; // n characters compared the same |
| 154 | } |
| 155 | |
| 156 | //----------------------------------------------------------------------------- |
| 157 | // Finds a string in another string with a case insensitive test |
no outgoing calls