The bleadperl build currently fails using Compaq C V6.5-001 on OpenVMS
Alpha V7.3-1 because there are lots of signed/unsigned mismatch warnings
in pp_pack.c. The attached patch adds a bunch of casts to make explicit
the assumption that as long as we shovel 8 bits at a time to the right
place, we don't care about signedness. I don't know enough about the
UTF-8 conversion routines to know if that assumption is really true,
i.e., that we never manipulate the contents of those bytes in such a way
that sign would matter. The patch does get the build to succeed and
t/op/pack.t also succeeds.
--- pp_pack.c;-0 Mon Feb 14 15:32:17 2005
+++ pp_pack.c Thu Feb 17 17:04:08 2005
@@no-spam -503,7 +503,7 @@no-spam
UV val;
STRLEN retlen;
val =
- UNI_TO_NATIVE(utf8n_to_uvuni(*s, end-*s, &retlen,
+ UNI_TO_NATIVE(utf8n_to_uvuni((U8*)*s, end-*s, &retlen,
ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY));
/* We try to process malformed UTF-8 as much as possible (preferrably with
warnings), but these two mean we make no progress in the string and
@@no-spam -535,7 +535,7 @@no-spam
UTF8_CHECK_ONLY : (UTF8_CHECK_ONLY | UTF8_ALLOW_ANY);
for (;buf_len > 0; buf_len--) {
if (from >= end) return FALSE;
- val = UNI_TO_NATIVE(utf8n_to_uvuni(from, end-from, &retlen, flags));
+ val = UNI_TO_NATIVE(utf8n_to_uvuni((U8*)from, end-from, &retlen, flags));
if (retlen == (STRLEN) -1 || retlen == 0) {
from += UTF8SKIP(from);
bad |= 1;
@@no-spam -554,7 +554,7 @@no-spam
flags = ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY;
for (ptr = *s; ptr < from; ptr += UTF8SKIP(ptr)) {
if (ptr >= end) break;
- utf8n_to_uvuni(ptr, end-ptr, &retlen, flags);
+ utf8n_to_uvuni((U8*)ptr, end-ptr, &retlen, flags);
}
if (from > end) from = end;
}
@@no-spam -572,7 +572,7 @@no-spam
UV val;
STRLEN retlen;
char *from = *s;
- val = UNI_TO_NATIVE(utf8n_to_uvuni(*s, end-*s, &retlen, UTF8_CHECK_ONLY));
+ val = UNI_TO_NATIVE(utf8n_to_uvuni((U8*)*s, end-*s, &retlen, UTF8_CHECK_ONLY));
if (val >= 0x100 || !ISUUCHAR(val) ||
retlen == (STRLEN) -1 || retlen == 0) {
*out = 0;
@@no-spam -974,7 +974,7 @@no-spam
/* We probably should try to avoid this in case a scalar context call
wouldn't get to the "U0" */
STRLEN len = strend - s;
- s = bytes_to_utf8(s, &len);
+ s = (char*)bytes_to_utf8((U8*)s, &len);
SAVEFREEPV(s);
strend = s + len;
flags |= FLAG_UNPACK_DO_UTF8;
@@no-spam -1009,7 +1009,7 @@no-spam
/* We probably should try to avoid this in case a scalar context call
wouldn't get to the "U0" */
STRLEN len = strend - s;
- s = bytes_to_utf8(s, &len);
+ s = (char*)bytes_to_utf8((U8*)s, &len);
SAVEFREEPV(s);
strend = s + len;
flags |= FLAG_UNPACK_DO_UTF8;
@@no-spam -1403,7 +1403,7 @@no-spam
UV val;
STRLEN retlen;
val =
- UNI_TO_NATIVE(utf8n_to_uvuni(s, strend-s, &retlen,
+ UNI_TO_NATIVE(utf8n_to_uvuni((U8*)s, strend-s, &retlen,
ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY));
if (retlen == (STRLEN) -1 || retlen == 0)
Perl_croak(aTHX_ "Malformed UTF-8 string in unpack");
@@no-spam -1452,10 +1452,10 @@no-spam
ptr = s;
/* Bug: warns about bad utf8 even if we are short on bytes
and will break out of the loop */
- if (!next_uni_bytes(aTHX_ &ptr, strend, result, 1))
+ if (!next_uni_bytes(aTHX_ &ptr, strend, (char*)result, 1))
break;
len = UTF8SKIP(result);
- if (!next_uni_bytes(aTHX_ &ptr, strend, &result[1], len-1))
+ if (!next_uni_bytes(aTHX_ &ptr, strend, (char*)&result[1], len-1))
break;
auv = utf8n_to_uvuni(result, len, &retlen, ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANYUV);
s = ptr;
[plaintext pp_pack_casts.patch]
In article <42160CFC.3080304@no-spam>,
"Craig A. Berry" <craigberry@no-spam> writes:
> --------------000104090403040902010805
> Content-Type: text/plain; charset=us-ascii; format=flowed
> Content-Transfer-Encoding: 7bit
>
> The bleadperl build currently fails using Compaq C V6.5-001 on OpenVMS
> Alpha V7.3-1 because there are lots of signed/unsigned mismatch warnings
> in pp_pack.c. The attached patch adds a bunch of casts to make explicit
> the assumption that as long as we shovel 8 bits at a time to the right
> place, we don't care about signedness. I don't know enough about the
> UTF-8 conversion routines to know if that assumption is really true,
> i.e., that we never manipulate the contents of those bytes in such a way
> that sign would matter. The patch does get the build to succeed and
> t/op/pack.t also succeeds.
>
Yes, these routines should be used in a U8* style. The patch is good
and ought to be applied I think. I'll try to see if i can make the
declarations in my pack neutrality effort such that we'll need less casts,
but I won't have to time to do more work on it for about a week.