diff options
author | Karl Williamson <khw@cpan.org> | 2018-02-09 10:10:47 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2018-02-09 10:19:12 -0700 |
commit | e0280e4921cf0b53edc3e4790ff6f201046adcbc (patch) | |
tree | 7efc0b0198899b9758d0dc02473cc6a57c2e1c6a /ext | |
parent | 0a9f8f95112ff40e13406b3e5aab49c01487f045 (diff) | |
download | perl-e0280e4921cf0b53edc3e4790ff6f201046adcbc.tar.gz |
APItest: Fix C++ compiles
0a9f8f95112ff40e13406b3e5aab49c01487f045 introduced failures on C++
compilations. This is a better patch, suggested by ilmari.
The issue was in cases where the pointer size is 32 bits and the word
size was 64, a (STRLEN) -1 returned as an error was getting turned into
0xFFFFFFFF instead of -1.
Diffstat (limited to 'ext')
-rw-r--r-- | ext/XS-APItest/APItest.xs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/XS-APItest/APItest.xs b/ext/XS-APItest/APItest.xs index 842b6281f6..794ab403bb 100644 --- a/ext/XS-APItest/APItest.xs +++ b/ext/XS-APItest/APItest.xs @@ -1380,18 +1380,22 @@ bytes_cmp_utf8(bytes, utf8) RETVAL AV * -test_utf8_to_bytes(bytes, lenp) +test_utf8_to_bytes(bytes, len) unsigned char * bytes - ssize_t lenp + STRLEN len PREINIT: char * ret; CODE: RETVAL = newAV(); sv_2mortal((SV*)RETVAL); - ret = (char *) utf8_to_bytes(bytes, &lenp); + ret = (char *) utf8_to_bytes(bytes, &len); av_push(RETVAL, newSVpv(ret, 0)); - av_push(RETVAL, newSViv(lenp)); + + /* utf8_to_bytes uses (STRLEN)-1 to signal errors, and we want to + * return that as -1 to perl, so cast to SSize_t in case + * sizeof(IV) > sizeof(STRLEN) */ + av_push(RETVAL, newSViv((SSize_t)len)); av_push(RETVAL, newSVpv((const char *) bytes, 0)); OUTPUT: |