+static void
+Check_strlcat(void)
+{
+ char str[5];
+
+ if (strlcpy(str, "12", sizeof(str)) != 2)
+ Panic("strlcpy for strlcat");
+ if (strlcat(str, "1234567890", sizeof(str)) != 12)
+ Panic("strlcat return code");
+ if (str[4] != '\0')
+ Panic("strlcat NULL byte");
+ if (strlen(str) != 4)
+ Panic("strlcat string length");
+}
+
+static void
+Check_strtok_r(void)
+{
+ char *ptr, *last;
+
+ ptr = strdup("12,abc");
+
+ ptr = strtok_r(ptr, ",", &last);
+ if (!ptr)
+ Panic("strtok_r result #1");
+ if (strcmp(ptr, "12") != 0)
+ Panic("strtok_r token #1");
+
+ ptr = strtok_r(NULL, ",", &last);
+ if (!ptr)
+ Panic("strtok_r result #2");
+ if (strcmp(ptr, "abc") != 0)
+ Panic("strtok_r token #2");
+
+ ptr = strtok_r(NULL, ",", &last);
+ if (ptr)
+ Panic("strtok_r result #3");
+}
+
+#ifdef PROTOTYPES
+static void
+Check_vsnprintf(const int Len, const char *Format, ...)
+#else
+static void
+Check_vsnprintf(Len, Format, va_alist)
+const int Len;
+const char *Format;
+va_dcl
+#endif
+{
+ char str[5];
+ va_list ap;
+ int r;
+
+#ifdef PROTOTYPES
+ va_start(ap, Format);
+#else
+ va_start(ap);
+#endif
+ r = vsnprintf(str, sizeof(str), Format, ap);
+ va_end(ap);
+ if (r != Len) {
+ /* C99 states that vsnprintf() "returns the number of
+ * characters that would have been printed if the n were
+ * unlimited", but according to the Linux manual page "glibc
+ * until 2.0.6 would return -1 when the output was truncated",
+ * and other implementations (libUTIL on A/UX) even return the
+ * number of characters processed ... so we only test our own
+ * implementation and warn on errors otherwise :-/ */
+#ifdef HAVE_VSNPRINTF
+ fprintf(stderr,
+ "\n ** WARNING: The vsnprintf() function of this system isn't standard\n");
+ fprintf(stderr,
+ " ** conformant and returns a WRONG result: %d (should be %d)! The test\n",
+ r, Len);
+ fprintf(stderr,
+ " ** result has been ignored but may lead to errors during execution!\n\n");
+#else
+ Panic("vsnprintf return code");
+#endif
+ }
+ if (str[4] != '\0')
+ Panic("vsnprintf NULL byte");
+ if (strlen(str) != 4)
+ Panic("vsnprintf string length");
+}
+
+GLOBAL int
+main(void)