X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=functions%2Fstring%2Fstrdup.c;h=bbd1e93be1c0485f6b61be1b312f4b09c0540d17;hp=6ed0f832feef21b29ec9871c622c6661c75a7b4b;hb=da0f3f353d417fed71f358a48d5d5394145e460d;hpb=1cc4363093c919f79eafac209bb5c41548d3f88f diff --git a/functions/string/strdup.c b/functions/string/strdup.c index 6ed0f83..bbd1e93 100644 --- a/functions/string/strdup.c +++ b/functions/string/strdup.c @@ -1,9 +1,13 @@ -/* [XSI] char* strdup(const char *) +/* [XSI] char * strdup( const char * ) This file is part of the Public Domain C Library (PDCLib). Permission is granted to use, modify, and / or redistribute at will. */ +#ifdef REGTEST +#define _POSIX_C_SOURCE 200809L +#endif + #include #include @@ -24,7 +28,7 @@ char *strdup(const char *s) #endif #ifdef TEST -#include <_PDCLIB_test.h> +#include "_PDCLIB_test.h" int main( void ) { @@ -32,13 +36,13 @@ int main( void ) const char *teststr2 = "An alternative test string with non-7-bit characters \xFE\x8C\n"; char *testres, *testres2; - TESTCASE(testres = strdup(teststr)); - TESTCASE(testres2 = strdup(teststr2)); + TESTCASE((testres = strdup(teststr)) != NULL); + TESTCASE((testres2 = strdup(teststr2)) != NULL); TESTCASE(strcmp(testres, teststr) == 0); TESTCASE(strcmp(testres2, teststr2) == 0); free(testres); free(testres2); - + return TEST_RESULTS; }