#include <errno.h>
#include <iconv.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
/* The various invalid sequences can be inferred from the table of
*/
int test_iconv_open_supports_suffix(const char* suffix) {
const char* fromcode = "ASCII";
- char tocode[64] = "ASCII";
+ char* tocode = malloc(strlen(fromcode) + strlen(suffix) + 1);
+ strcat(tocode, fromcode);
strcat(tocode, suffix);
printf("iconv_open() supports %s suffix...", suffix);
iconv_t cd = iconv_open(tocode, fromcode);
+ free(tocode);
if (cd == (iconv_t)(-1)) {
switch (errno) {
case EINVAL:
- printf("OK (EINVAL, not supported)\n");
+ printf("no\n");
return UNSUPPORTED;
default:
printf("FAIL (errno=%d, unexpected error)\n", errno);