X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fportab%2Fportabtest.c;h=3602feecf25819a882b7655a6cfba88bf2600322;hp=9e6bd228bae0df847ab6d32fc52401d9bfc0aa37;hb=e747fe92775f577a38f8dd681f7a58f751348f5e;hpb=f024a4992a9a38d64d0fd63283cd0c484bdec683;ds=sidebyside diff --git a/src/portab/portabtest.c b/src/portab/portabtest.c index 9e6bd228..3602feec 100644 --- a/src/portab/portabtest.c +++ b/src/portab/portabtest.c @@ -24,6 +24,8 @@ #include "exp.h" +int allow_severity = 0, deny_severity = 0; + static void Panic(char *Reason) { @@ -139,16 +141,35 @@ va_dcl { char str[5]; va_list ap; + int r; #ifdef PROTOTYPES va_start(ap, Format); #else va_start(ap); #endif - if (vsnprintf(str, sizeof(str), Format, ap) != Len) - Panic("vsnprintf return code"); + 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)