X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=functions%2Fstdlib%2Fqsort.c;h=084cd3ca4cf07675cca839812a5e4526283550da;hb=b42a534f135f12fe47a6bc343bb6cc2c0e973198;hp=8941e6db7a187e73aee6fcc03668396bcd63f8fc;hpb=8d7981ddc09a9f37513b57f20c89876a33bb4627;p=pdclib.old diff --git a/functions/stdlib/qsort.c b/functions/stdlib/qsort.c index 8941e6d..084cd3c 100644 --- a/functions/stdlib/qsort.c +++ b/functions/stdlib/qsort.c @@ -1,7 +1,5 @@ /* $Id$ */ -/* Release $Name$ */ - /* qsort( void *, size_t, size_t, int(*)( const void *, const void * ) ) This file is part of the Public Domain C Library (PDCLib). @@ -21,7 +19,7 @@ */ /* Wrapper for _PDCLIB_memswp protects against multiple argument evaluation. */ -static inline void memswp( char * i, char * j, unsigned int size ) +static inline void memswp( char * i, char * j, size_t size ) { _PDCLIB_memswp( i, j, size ); } @@ -133,18 +131,17 @@ void qsort( void * base, size_t nmemb, size_t size, int (*compar)( const void *, #include #include -int compare( const void * left, const void * right ) +static int compare( const void * left, const void * right ) { return *( (unsigned char *)left ) - *( (unsigned char *)right ); } -int main() +int main( void ) { char presort[] = { "shreicnyjqpvozxmbt" }; char sorted1[] = { "bcehijmnopqrstvxyz" }; char sorted2[] = { "bticjqnyozpvreshxm" }; char s[19]; - BEGIN_TESTS; strcpy( s, presort ); qsort( s, 18, 1, compare ); TESTCASE( strcmp( s, sorted1 ) == 0 ); @@ -154,8 +151,12 @@ int main() strcpy( s, presort ); qsort( s, 1, 1, compare ); TESTCASE( strcmp( s, presort ) == 0 ); +#if __BSD_VISIBLE + puts( "qsort.c: Skipping test #4 for BSD as it goes into endless loop here." ); +#else qsort( s, 100, 0, compare ); TESTCASE( strcmp( s, presort ) == 0 ); +#endif return TEST_RESULTS; }