diff --git a/cop.h b/cop.h index 33463a0ab27a..fd0e12a84a15 100644 --- a/cop.h +++ b/cop.h @@ -885,7 +885,7 @@ struct block_loop { * Note the contrast with CvLVALUE(), which is a property of the sub * rather than the call site. */ -#define CxLVAL(c) (0 + ((c)->blk_u16 & 0xff)) +#define CxLVAL(c) (0 + ((U8)((c)->blk_u16))) diff --git a/dist/Storable/Storable.pm b/dist/Storable/Storable.pm index 27c9cf54c345..c1c94f04c197 100644 --- a/dist/Storable/Storable.pm +++ b/dist/Storable/Storable.pm @@ -28,7 +28,7 @@ our @EXPORT_OK = qw( our ($canonical, $forgive_me); BEGIN { - our $VERSION = '3.23'; + our $VERSION = '3.24'; } our $recursion_limit; diff --git a/dist/Storable/Storable.xs b/dist/Storable/Storable.xs index 70dddf3f100c..30fd69fbece0 100644 --- a/dist/Storable/Storable.xs +++ b/dist/Storable/Storable.xs @@ -1247,7 +1247,7 @@ static const char byteorderstr_56[] = {BYTEORDER_BYTES_56, 0}; # define Sntohl(x) (x) # else static U32 Sntohl(U32 x) { - return ((x & 0xFF) << 24) + ((x * 0xFF00) << 8) + return (((U8) x) << 24) + ((x * 0xFF00) << 8) + ((x & 0xFF0000) >> 8) + ((x & 0xFF000000) >> 24); } # endif diff --git a/dist/Unicode-Normalize/Normalize.pm b/dist/Unicode-Normalize/Normalize.pm index fd6f1cb700fb..918c4d832e35 100644 --- a/dist/Unicode-Normalize/Normalize.pm +++ b/dist/Unicode-Normalize/Normalize.pm @@ -16,7 +16,7 @@ use Carp; no warnings 'utf8'; -our $VERSION = '1.28'; +our $VERSION = '1.29'; our $PACKAGE = __PACKAGE__; our @EXPORT = qw( NFC NFD NFKC NFKD ); diff --git a/dist/Unicode-Normalize/Normalize.xs b/dist/Unicode-Normalize/Normalize.xs index 0c151b71b0cb..2695f8394124 100644 --- a/dist/Unicode-Normalize/Normalize.xs +++ b/dist/Unicode-Normalize/Normalize.xs @@ -139,8 +139,8 @@ static U8* dec_canonical(UV uv) plane = (U8***)UNF_canon[uv >> 16]; if (! plane) return NULL; - row = plane[(uv >> 8) & 0xff]; - return row ? row[uv & 0xff] : NULL; + row = plane[(U8) (uv >> 8)]; + return row ? row[(U8) uv] : NULL; } static U8* dec_compat(UV uv) @@ -151,8 +151,8 @@ static U8* dec_compat(UV uv) plane = (U8***)UNF_compat[uv >> 16]; if (! plane) return NULL; - row = plane[(uv >> 8) & 0xff]; - return row ? row[uv & 0xff] : NULL; + row = plane[(U8) (uv >> 8)]; + return row ? row[(U8) uv] : NULL; } static UV composite_uv(UV uv, UV uv2) @@ -175,10 +175,10 @@ static UV composite_uv(UV uv, UV uv2) plane = UNF_compos[uv >> 16]; if (! plane) return 0; - row = plane[(uv >> 8) & 0xff]; + row = plane[(U8) (uv >> 8)]; if (! row) return 0; - cell = row[uv & 0xff]; + cell = row[(U8) uv]; if (! cell) return 0; for (i = cell; i->nextchar; i++) { @@ -196,8 +196,8 @@ static U8 getCombinClass(UV uv) plane = (U8**)UNF_combin[uv >> 16]; if (! plane) return 0; - row = plane[(uv >> 8) & 0xff]; - return row ? row[uv & 0xff] : 0; + row = plane[(U8) (uv >> 8)]; + return row ? row[(U8) uv] : NULL; } static U8* pv_cat_decompHangul(pTHX_ U8* d, UV uv) diff --git a/doop.c b/doop.c index e179c0f83557..f359aab1303d 100644 --- a/doop.c +++ b/doop.c @@ -363,7 +363,8 @@ S_do_trans_count_invmap(pTHX_ SV * const sv, AV * const invmap) SSize_t i; STRLEN s_len; - /* Get the code point of the next character in the string */ + /* remove from loop; look for all INVARIANT calls in the code; should be replaceable + * Get the code point of the next character in the string */ if (! SvUTF8(sv) || UTF8_IS_INVARIANT(*s)) { from = *s; s_len = 1; diff --git a/dump.c b/dump.c index a72accddb3bf..a939c3ff5649 100644 --- a/dump.c +++ b/dump.c @@ -181,7 +181,7 @@ Perl_pv_escape( pTHX_ SV *dsv, char const * const str, for ( ; (pv < end && (!max || (wrote < max))) ; pv += readsize ) { const UV u= (isuni) ? utf8_to_uvchr_buf((U8*)pv, (U8*) end, &readsize) : (U8)*pv; - const U8 c = (U8)u & 0xFF; + const U8 c = (U8)u; if ( ( u > 255 ) || (flags & PERL_PV_ESCAPE_ALL) diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs index f574ca2cd7a2..3923386a117a 100644 --- a/ext/Opcode/Opcode.xs +++ b/ext/Opcode/Opcode.xs @@ -68,7 +68,7 @@ op_names_init(pTHX) bitmap = (U8*)SvPV(opset_all, len); memset(bitmap, 0xFF, len-1); /* deal with last byte specially, see below */ /* Take care to set the right number of bits in the last byte */ - bitmap[len-1] = (PL_maxo & 0x07) ? ((~(0xFF << (PL_maxo & 0x07))) & 0xFF) + bitmap[len-1] = (PL_maxo & 0x07) ? ((U8) (~(0xFF << (PL_maxo & 0x07)))) : 0xFF; put_op_bitspec(aTHX_ STR_WITH_LEN(":all"), opset_all); /* don't mortalise */ } diff --git a/ext/POSIX/POSIX.xs b/ext/POSIX/POSIX.xs index 27ba2dc45919..c26651016994 100644 --- a/ext/POSIX/POSIX.xs +++ b/ext/POSIX/POSIX.xs @@ -1678,7 +1678,7 @@ static const struct lconv_offset lconv_integers[] = { * in the first place, though. -- Ingo Weinhold */ #if defined(__HAIKU__) -# define WMUNGE(x) (((x) & 0xFF00) >> 8 | ((x) & 0x00FF) << 8) +# define WMUNGE(x) (((x) & 0xFF00) >> 8 | (((U8) (x)) << 8)) #else # define WMUNGE(x) (x) #endif diff --git a/ext/POSIX/lib/POSIX.pm b/ext/POSIX/lib/POSIX.pm index 8305c3014a60..918dd9a73efb 100644 --- a/ext/POSIX/lib/POSIX.pm +++ b/ext/POSIX/lib/POSIX.pm @@ -4,7 +4,7 @@ use warnings; our ($AUTOLOAD, %SIGRT); -our $VERSION = '1.98'; +our $VERSION = '1.99'; require XSLoader; diff --git a/inline.h b/inline.h index 55b26e0d7810..e540e832cf9d 100644 --- a/inline.h +++ b/inline.h @@ -667,6 +667,7 @@ Perl_is_utf8_invariant_string_loc(const U8* const s, STRLEN len, const U8 ** ep) #ifndef EBCDIC PERL_STATIC_INLINE unsigned int +/* rename to pos */ Perl_variant_byte_number(PERL_UINTMAX_T word) { diff --git a/perl.h b/perl.h index 4acb23aefc15..2e72ce9f0910 100644 --- a/perl.h +++ b/perl.h @@ -1224,18 +1224,18 @@ Use L to declare variables of the maximum usable size on this platform. /* byte-swapping functions for big-/little-endian conversion */ # define _swab_16_(x) ((U16)( \ - (((U16)(x) & UINT16_C(0x00ff)) << 8) | \ - (((U16)(x) & UINT16_C(0xff00)) >> 8) )) + (((U16)(U8) (x) ) << 8) | \ + (((U16) (x) & UINT16_C(0xff00)) >> 8) )) # define _swab_32_(x) ((U32)( \ - (((U32)(x) & UINT32_C(0x000000ff)) << 24) | \ + (((U32)(U8)(x) ) << 24) | \ (((U32)(x) & UINT32_C(0x0000ff00)) << 8) | \ (((U32)(x) & UINT32_C(0x00ff0000)) >> 8) | \ (((U32)(x) & UINT32_C(0xff000000)) >> 24) )) # ifdef HAS_QUAD # define _swab_64_(x) ((U64)( \ - (((U64)(x) & UINT64_C(0x00000000000000ff)) << 56) | \ + (((U64)(U8)(x) ) << 56) | \ (((U64)(x) & UINT64_C(0x000000000000ff00)) << 40) | \ (((U64)(x) & UINT64_C(0x0000000000ff0000)) << 24) | \ (((U64)(x) & UINT64_C(0x00000000ff000000)) << 8) | \ @@ -3512,7 +3512,7 @@ EXTERN_C int perl_tsa_mutex_unlock(perl_mutex* mutex) if (MY_POSIX_EXIT) { \ if (evalue <= 0xFF00) { \ if (evalue > 0xFF) \ - evalue = (evalue >> child_offset_bits) & 0xFF; \ + evalue = ((U8) (evalue >> child_offset_bits)); \ PL_statusvalue_vms = \ (C_FAC_POSIX | (evalue << 3 ) | \ ((evalue == 1) ? (STS$K_ERROR | STS$M_INHIB_MSG) : 1)); \ @@ -4220,11 +4220,11 @@ my_swap16(const U16 x) { # define htovl(x) vtohl(x) # define htovs(x) vtohs(x) #elif BYTEORDER == 0x4321 || BYTEORDER == 0x87654321 -# define vtohl(x) ((((x)&0xFF)<<24) \ - +(((x)>>24)&0xFF) \ +# define vtohl(x) ((((U8) (x)) << 24) \ + +((U8) ((x) >> 24)) \ +(((x)&0x0000FF00)<<8) \ +(((x)&0x00FF0000)>>8) ) -# define vtohs(x) ((((x)&0xFF)<<8) + (((x)>>8)&0xFF)) +# define vtohs(x) ((((U8) (x)) << 8) + ((U8) ((x) >> 8))) # define htovl(x) vtohl(x) # define htovs(x) vtohs(x) #else diff --git a/pp_pack.c b/pp_pack.c index 27b0a7116243..60cbfa529b2f 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -223,7 +223,7 @@ S_mul128(pTHX_ SV *sv, U8 m) #define TYPE_IS_PACK 0x800 #define TYPE_ENDIANNESS_MASK (TYPE_IS_BIG_ENDIAN|TYPE_IS_LITTLE_ENDIAN) #define TYPE_MODIFIERS(t) ((t) & ~0xFF) -#define TYPE_NO_MODIFIERS(t) ((t) & 0xFF) +#define TYPE_NO_MODIFIERS(t) ((U8) (t)) # define TYPE_ENDIANNESS(t) ((t) & TYPE_ENDIANNESS_MASK) # define TYPE_NO_ENDIANNESS(t) ((t) & ~TYPE_ENDIANNESS_MASK) @@ -263,7 +263,7 @@ utf8_to_byte(pTHX_ const char **s, const char *end, I32 datumtype) Perl_ck_warner(aTHX_ packWARN(WARN_UNPACK), "Character in '%c' format wrapped in unpack", (int) TYPE_NO_MODIFIERS(datumtype)); - val &= 0xff; + val = (U8) val; } *s += retlen; return (U8)val; @@ -296,7 +296,7 @@ S_utf8_to_bytes(pTHX_ const char **s, const char *end, const char *buf, SSize_t } else from += retlen; if (val >= 0x100) { bad |= 2; - val &= 0xff; + val = (U8) val; } if (UNLIKELY(needs_swap)) *(U8 *)--buf = (U8)val; @@ -2573,7 +2573,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) if ((-128 > aiv || aiv > 127)) Perl_ck_warner(aTHX_ packWARN(WARN_PACK), "Character in 'c' format wrapped in pack"); - PUSH_BYTE(utf8, cur, (U8)(aiv & 0xff)); + PUSH_BYTE(utf8, cur, (U8)aiv); } break; case 'C': @@ -2588,7 +2588,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) if ((0 > aiv || aiv > 0xff)) Perl_ck_warner(aTHX_ packWARN(WARN_PACK), "Character in 'C' format wrapped in pack"); - PUSH_BYTE(utf8, cur, (U8)(aiv & 0xff)); + PUSH_BYTE(utf8, cur, (U8)aiv); } break; case 'W': { @@ -2628,7 +2628,7 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist ) } Perl_ck_warner(aTHX_ packWARN(WARN_PACK), "Character in 'W' format wrapped in pack"); - auv &= 0xff; + auv = (U8) auv; } if (cur >= end) { *cur = '\0'; diff --git a/regcomp.h b/regcomp.h index b92a08820f97..22847ca6b292 100644 --- a/regcomp.h +++ b/regcomp.h @@ -592,7 +592,7 @@ struct regnode_ssc { * are cautioned about its shared nature */ #define ANYOF_SHARED_d_MATCHES_ALL_NON_UTF8_NON_ASCII_non_d_WARN_SUPER 0x80 -#define ANYOF_FLAGS_ALL (0xff & ~0x10) +#define ANYOF_FLAGS_ALL ((U8) ~0x10) #define ANYOF_LOCALE_FLAGS (ANYOFL_FOLD | ANYOF_MATCHES_POSIXL) diff --git a/t/op/vec.t b/t/op/vec.t index 0e8b5cee954a..c875bd92a2f9 100644 --- a/t/op/vec.t +++ b/t/op/vec.t @@ -6,12 +6,15 @@ BEGIN { set_up_inc('../lib'); } +use warnings; +use strict; use Config; plan(tests => 78); my $exception_134139 = "Use of strings with code points over 0xFF as arguments to vec is forbidden"; +my $foo; is(vec($foo,0,1), 0); is(length($foo), undef); vec($foo,0,1) = 1; @@ -29,11 +32,14 @@ is(vec($foo,1,8), 0xf1); is((unpack('C',substr($foo,1,1)) & 255), 0xf1); is(vec($foo,2,4), 1);; is(vec($foo,3,4), 15); + +my $Vec; vec($Vec, 0, 32) = 0xbaddacab; is($Vec, "\xba\xdd\xac\xab"); is(vec($Vec, 0, 32), 3135089835); # ensure vec() handles numericalness correctly +my ($bar, $baz); $foo = $bar = $baz = 0; vec($foo = 0,0,1) = 1; vec($bar = 0,1,1) = 1; @@ -44,7 +50,7 @@ ok("$foo $bar $baz" eq "1 2 3"); # error cases -$x = eval { vec $foo, 0, 3 }; +my $x = eval { vec $foo, 0, 3 }; like($@, qr/^Illegal number of bits in vec/); $@ = undef; $x = eval { vec $foo, 0, 0 }; @@ -67,7 +73,7 @@ is(vec($x, 0, 8), 255); $@ = undef; { local $@; - eval { vec($foo, 1, 8) }; + eval { my $foo = vec($foo, 1, 8) }; like($@, qr/$exception_134139/, "Caught exception: code point over 0xFF used as argument to vec"); $@ = undef; @@ -236,7 +242,7 @@ like($@, qr/^Modification of a read-only value attempted at /, like($@, qr/Negative offset to vec in lvalue context/, "RT131083 lval -1"); $off = ~0; - my $v = RT131083(0, vec($s, $off, 8)); + $v = RT131083(0, vec($s, $off, 8)); is($v, 0, "RT131083 rval ~0"); $v = eval { RT131083(1, vec($s, $off, 8)); }; like($@, qr/Out of memory!/, "RT131083 lval ~0"); @@ -247,7 +253,7 @@ like($@, qr/^Modification of a read-only value attempted at /, local $@; my $foo = "\x{100}" . "\xff\xfe"; - eval { vec($foo, 1, 8) }; + eval { my $bar = vec($foo, 1, 8) }; like($@, qr/$exception_134139/, "RT 134139: Use of strings with code points over 0xFF as arguments to 'vec' is now forbidden"); } diff --git a/toke.c b/toke.c index 18e342efd52b..e6f7a3a42fd7 100644 --- a/toke.c +++ b/toke.c @@ -9283,7 +9283,7 @@ Perl_yylex(pTHX) if (PL_lex_brackets > 100) Renew(PL_lex_brackstack, PL_lex_brackets + 10, char); PL_lex_brackstack[PL_lex_brackets++] = - (char) ((next_type >> 16) & 0xff); + (char) ((U8) (next_type >> 16)); } if (next_type & (2<<24)) PL_lex_allbrackets++; diff --git a/vms/vms.c b/vms/vms.c index abdbe11bfec4..6c9fbc8ac0d1 100644 --- a/vms/vms.c +++ b/vms/vms.c @@ -601,8 +601,8 @@ copy_expand_vms_filename_escape(char *outspec, const char *inspec, int *output_c if (scnt == 4) { unsigned int c1, c2; scnt = sscanf(inspec, "%2x%2x", &c1, &c2); - outspec[0] = c1 & 0xff; - outspec[1] = c2 & 0xff; + outspec[0] = (U8) c1; + outspec[1] = (U8) c2; if (scnt > 1) { (*output_cnt) += 2; count += 4; diff --git a/win32/fcrypt.c b/win32/fcrypt.c index 219f4f0b866d..35e0dbe19548 100644 --- a/win32/fcrypt.c +++ b/win32/fcrypt.c @@ -35,10 +35,10 @@ typedef struct des_ks_struct l|=((unsigned long)(*((c)++)))<<16, \ l|=((unsigned long)(*((c)++)))<<24) -#define l2c(l,c) (*((c)++)=(unsigned char)(((l) )&0xff), \ - *((c)++)=(unsigned char)(((l)>> 8)&0xff), \ - *((c)++)=(unsigned char)(((l)>>16)&0xff), \ - *((c)++)=(unsigned char)(((l)>>24)&0xff)) +#define l2c(l,c) (*((c)++)=(unsigned char)((l) ), \ + *((c)++)=(unsigned char)((l)>> 8), \ + *((c)++)=(unsigned char)((l)>>16), \ + *((c)++)=(unsigned char)((l)>>24)) static const unsigned long SPtrans[8][64]={ { /* nibble 0 */ @@ -357,7 +357,7 @@ des_set_key(des_cblock *key, des_key_schedule schedule) PERM_OP (d,c,t,1,0x55555555); PERM_OP (c,d,t,8,0x00ff00ff); PERM_OP (d,c,t,1,0x55555555); - d= (((d&0x000000ff)<<16)| (d&0x0000ff00) | + d= ((((U8) d) <<16)| (d&0x0000ff00) | ((d&0x00ff0000)>>16)|((c&0xf0000000)>>4)); c&=0x0fffffff; diff --git a/win32/win32.c b/win32/win32.c index 861e707760fa..70ab455275b6 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -2637,7 +2637,7 @@ win32_internal_wait(pTHX_ int *status, DWORD timeout) else i = waitcode - WAIT_OBJECT_0; if (GetExitCodeThread(w32_pseudo_child_handles[i], &exitcode)) { - *status = (int)((exitcode & 0xff) << 8); + *status = (int)(((U8) exitcode) << 8); retval = (int)w32_pseudo_child_pids[i]; remove_dead_pseudo_process(i); return -retval; @@ -2663,7 +2663,7 @@ win32_internal_wait(pTHX_ int *status, DWORD timeout) else i = waitcode - WAIT_OBJECT_0; if (GetExitCodeProcess(w32_child_handles[i], &exitcode) ) { - *status = (int)((exitcode & 0xff) << 8); + *status = (int)(((U8) exitcode) << 8); retval = (int)w32_child_pids[i]; remove_dead_process(i); return retval; @@ -2695,7 +2695,7 @@ win32_waitpid(int pid, int *status, int flags) } else if (waitcode == WAIT_OBJECT_0) { if (GetExitCodeThread(hThread, &waitcode)) { - *status = (int)((waitcode & 0xff) << 8); + *status = (int)(((U8) waitcode) << 8); retval = (int)w32_pseudo_child_pids[child]; remove_dead_pseudo_process(child); return -retval; @@ -2718,7 +2718,7 @@ win32_waitpid(int pid, int *status, int flags) } else if (waitcode == WAIT_OBJECT_0) { if (GetExitCodeProcess(hProcess, &waitcode)) { - *status = (int)((waitcode & 0xff) << 8); + *status = (int)(((U8) waitcode) << 8); retval = (int)w32_child_pids[child]; remove_dead_process(child); return retval; @@ -2737,7 +2737,7 @@ win32_waitpid(int pid, int *status, int flags) } else if (waitcode == WAIT_OBJECT_0) { if (GetExitCodeProcess(hProcess, &waitcode)) { - *status = (int)((waitcode & 0xff) << 8); + *status = (int)(((U8) waitcode) << 8); CloseHandle(hProcess); return pid; }