X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrcmp.c;h=5202771a67d52f266000746cf63c7608cd9b7682;hp=42ed51c01c86d5b96a9a62270d35015185694179;hb=393020b6e48719d27699dea6b29e53025bbd5123;hpb=f408c1fd633015089d2a0fc6bc31c9f61eeae0a9 diff --git a/functions/string/strcmp.c b/functions/string/strcmp.c index 42ed51c..5202771 100644 --- a/functions/string/strcmp.c +++ b/functions/string/strcmp.c @@ -17,7 +17,7 @@ int strcmp( const char * s1, const char * s2 ) ++s1; ++s2; } - return ( *s1 - *s2 ); + return ( *(unsigned char *)s1 - *(unsigned char *)s2 ); } #endif @@ -28,12 +28,14 @@ int strcmp( const char * s1, const char * s2 ) int main( void ) { char cmpabcde[] = "abcde"; + char cmpabcd_[] = "abcd\xfc"; char empty[] = ""; TESTCASE( strcmp( abcde, cmpabcde ) == 0 ); TESTCASE( strcmp( abcde, abcdx ) < 0 ); TESTCASE( strcmp( abcdx, abcde ) > 0 ); TESTCASE( strcmp( empty, abcde ) < 0 ); TESTCASE( strcmp( abcde, empty ) > 0 ); + TESTCASE( strcmp( abcde, cmpabcd_ ) < 0 ); return TEST_RESULTS; } #endif