]> pd.if.org Git - pdclib/blobdiff - functions/string/strndup.c
RegTest gives warning about implicitly declared functions. Fixed.
[pdclib] / functions / string / strndup.c
index e50f419ded982705b0e9e5530299f080c0a40f54..15c44be27f23dc717acc718dd8dddb60f7e28bdf 100644 (file)
@@ -4,6 +4,10 @@
    Permission is granted to use, modify, and / or redistribute at will.\r
 */\r
 \r
+#ifdef REGTEST\r
+#define _POSIX_C_SOURCE 200809L\r
+#endif\r
+\r
 #include <string.h>\r
 #include <stdlib.h>\r
 \r
@@ -37,16 +41,16 @@ int main( void )
     const char *teststr2 = "\xFE\x8C\n";\r
     char *testres, *testres2;\r
 \r
-    TESTCASE(testres  = strndup(teststr, 5));\r
-    TESTCASE(testres2 = strndup(teststr2, 1));\r
+    TESTCASE((testres  = strndup(teststr, 5)) != NULL);\r
+    TESTCASE((testres2 = strndup(teststr2, 1)) != NULL);\r
     TESTCASE(strcmp(testres, teststr) != 0);\r
     TESTCASE(strncmp(testres, teststr, 5) == 0);\r
     TESTCASE(strcmp(testres2, teststr2) != 0);\r
     TESTCASE(strncmp(testres2, teststr2, 1) == 0);\r
     free(testres);\r
     free(testres2);\r
-    TESTCASE(testres  = strndup(teststr, 20));\r
-    TESTCASE(testres2 = strndup(teststr2, 5));\r
+    TESTCASE((testres  = strndup(teststr, 20)) != NULL);\r
+    TESTCASE((testres2 = strndup(teststr2, 5)) != NULL);\r
     TESTCASE(strcmp(testres, teststr) == 0);\r
     TESTCASE(strcmp(testres2, teststr2) == 0);\r
     free(testres);\r