|
44 | 44 | #undef iconv |
45 | 45 | #endif |
46 | 46 |
|
| 47 | +#if defined(__NetBSD__) |
| 48 | +// unfortunately, netbsd has still the old non posix conformant signature |
| 49 | +// libiconv tends to match the eventual system's iconv too. |
| 50 | +#define ICONV_CONST const |
| 51 | +#else |
| 52 | +#define ICONV_CONST |
| 53 | +#endif |
| 54 | + |
47 | 55 | #include "zend_smart_str.h" |
48 | 56 | #include "ext/standard/base64.h" |
49 | 57 | #include "ext/standard/quot_print.h" |
@@ -360,7 +368,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l, |
360 | 368 |
|
361 | 369 | out_p = ZSTR_VAL((d)->s) + ZSTR_LEN((d)->s); |
362 | 370 |
|
363 | | - if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { |
| 371 | + if (iconv(cd, (ICONV_CONST char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { |
364 | 372 | switch (errno) { |
365 | 373 | case EINVAL: |
366 | 374 | return PHP_ICONV_ERR_ILLEGAL_CHAR; |
@@ -456,7 +464,7 @@ PHP_ICONV_API php_iconv_err_t php_iconv_string(const char *in_p, size_t in_len, |
456 | 464 | out_p = ZSTR_VAL(out_buf); |
457 | 465 |
|
458 | 466 | while (in_left > 0) { |
459 | | - result = iconv(cd, (char **) &in_p, &in_left, (char **) &out_p, &out_left); |
| 467 | + result = iconv(cd, (ICONV_CONST char **) &in_p, &in_left, (char **) &out_p, &out_left); |
460 | 468 | out_size = bsz - out_left; |
461 | 469 | if (result == (size_t)(-1)) { |
462 | 470 | if (ignore_ilseq && errno == EILSEQ) { |
@@ -576,7 +584,7 @@ static php_iconv_err_t _php_iconv_strlen(size_t *pretval, const char *str, size_ |
576 | 584 |
|
577 | 585 | more = in_left > 0; |
578 | 586 |
|
579 | | - iconv(cd, more ? (char **)&in_p : NULL, more ? &in_left : NULL, (char **) &out_p, &out_left); |
| 587 | + iconv(cd, more ? (ICONV_CONST char **)&in_p : NULL, more ? &in_left : NULL, (char **) &out_p, &out_left); |
580 | 588 | if (out_left == sizeof(buf)) { |
581 | 589 | break; |
582 | 590 | } else { |
@@ -683,7 +691,7 @@ static php_iconv_err_t _php_iconv_substr(smart_str *pretval, |
683 | 691 |
|
684 | 692 | more = in_left > 0 && len > 0; |
685 | 693 |
|
686 | | - iconv(cd1, more ? (char **)&in_p : NULL, more ? &in_left : NULL, (char **) &out_p, &out_left); |
| 694 | + iconv(cd1, more ? (ICONV_CONST char **)&in_p : NULL, more ? &in_left : NULL, (char **) &out_p, &out_left); |
687 | 695 | if (out_left == sizeof(buf)) { |
688 | 696 | break; |
689 | 697 | } |
@@ -805,7 +813,7 @@ static php_iconv_err_t _php_iconv_strpos(size_t *pretval, |
805 | 813 |
|
806 | 814 | more = in_left > 0; |
807 | 815 |
|
808 | | - iconv_ret = iconv(cd, more ? (char **)&in_p : NULL, more ? &in_left : NULL, (char **) &out_p, &out_left); |
| 816 | + iconv_ret = iconv(cd, more ? (ICONV_CONST char **)&in_p : NULL, more ? &in_left : NULL, (char **) &out_p, &out_left); |
809 | 817 | if (out_left == sizeof(buf)) { |
810 | 818 | break; |
811 | 819 | } |
@@ -1012,7 +1020,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn |
1012 | 1020 |
|
1013 | 1021 | out_left = out_size - out_reserved; |
1014 | 1022 |
|
1015 | | - if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { |
| 1023 | + if (iconv(cd, (ICONV_CONST char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { |
1016 | 1024 | switch (errno) { |
1017 | 1025 | case EINVAL: |
1018 | 1026 | err = PHP_ICONV_ERR_ILLEGAL_CHAR; |
@@ -1096,7 +1104,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn |
1096 | 1104 | out_p = buf; |
1097 | 1105 | out_left = out_size; |
1098 | 1106 |
|
1099 | | - if (iconv(cd, (char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { |
| 1107 | + if (iconv(cd, (ICONV_CONST char **)&in_p, &in_left, (char **) &out_p, &out_left) == (size_t)-1) { |
1100 | 1108 | switch (errno) { |
1101 | 1109 | case EINVAL: |
1102 | 1110 | err = PHP_ICONV_ERR_ILLEGAL_CHAR; |
@@ -2365,7 +2373,7 @@ static int php_iconv_stream_filter_append_bucket( |
2365 | 2373 | tcnt = self->stub_len; |
2366 | 2374 |
|
2367 | 2375 | while (tcnt > 0) { |
2368 | | - if (iconv(self->cd, &pt, &tcnt, &pd, &ocnt) == (size_t)-1) { |
| 2376 | + if (iconv(self->cd, (ICONV_CONST char **)&pt, &tcnt, &pd, &ocnt) == (size_t)-1) { |
2369 | 2377 | switch (errno) { |
2370 | 2378 | case EILSEQ: |
2371 | 2379 | php_error_docref(NULL, E_WARNING, "iconv stream filter (\"%s\"=>\"%s\"): invalid multibyte sequence", self->from_charset, self->to_charset); |
@@ -2431,7 +2439,7 @@ static int php_iconv_stream_filter_append_bucket( |
2431 | 2439 |
|
2432 | 2440 | while (icnt > 0) { |
2433 | 2441 | if ((ps == NULL ? iconv(self->cd, NULL, NULL, &pd, &ocnt): |
2434 | | - iconv(self->cd, (char **)&ps, &icnt, &pd, &ocnt)) == (size_t)-1) { |
| 2442 | + iconv(self->cd, (ICONV_CONST char **)&ps, &icnt, &pd, &ocnt)) == (size_t)-1) { |
2435 | 2443 | switch (errno) { |
2436 | 2444 | case EILSEQ: |
2437 | 2445 | php_error_docref(NULL, E_WARNING, "iconv stream filter (\"%s\"=>\"%s\"): invalid multibyte sequence", self->from_charset, self->to_charset); |
|
0 commit comments