Skip to content

Commit

Permalink
U8 no & FF
Browse files Browse the repository at this point in the history
  • Loading branch information
khwilliamson committed Jul 19, 2021
1 parent c1592e5 commit e33d5fe
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions perl.h
Expand Up @@ -4178,13 +4178,13 @@ struct ptr_tbl {

PERL_STATIC_INLINE U32
my_swap32(const U32 x) {
return ((x & 0xFF) << 24) | ((x >> 24) & 0xFF)
return ((U8) (x) << 24) | ((U8) (x >> 24))
| ((x & 0x0000FF00) << 8) | ((x & 0x00FF0000) >> 8);
}

PERL_STATIC_INLINE U16
my_swap16(const U16 x) {
return ((x & 0xFF) << 8) | ((x >> 8) & 0xFF);
return (((U8) x) << 8) | ((U8) (x >> 8));
}

# define htonl(x) my_swap32(x)
Expand Down
4 changes: 2 additions & 2 deletions perlio.c
Expand Up @@ -3405,12 +3405,12 @@ PerlIOStdio_unread(pTHX_ PerlIO *f, const void *vbuf, Size_t count)
STDCHAR *eptr = (STDCHAR*)PerlSIO_get_ptr(s);
STDCHAR *buf = ((STDCHAR *) vbuf) + count;
while (count > 0) {
const int ch = *--buf & 0xFF;
const int ch = (U8) *--buf;
if (ungetc(ch,s) != ch) {
/* ungetc did not work */
break;
}
if ((STDCHAR*)PerlSIO_get_ptr(s) != --eptr || ((*eptr & 0xFF) != ch)) {
if ((STDCHAR*)PerlSIO_get_ptr(s) != --eptr || (((U8) *eptr) != ch)) {
/* Did not change pointer as expected */
if (fgetc(s) != EOF) /* get char back again */
break;
Expand Down
2 changes: 1 addition & 1 deletion pp_pack.c
Expand Up @@ -608,7 +608,7 @@ S_next_symbol(pTHX_ tempsym_t* symptr )
patptr++;
} else {
/* We should have found a template code */
I32 code = *patptr++ & 0xFF;
I32 code = (U8) *patptr++;
U32 inherited_modifiers = 0;

if (code == ','){ /* grandfather in commas but with a warning */
Expand Down
2 changes: 1 addition & 1 deletion regcomp.c
Expand Up @@ -3511,7 +3511,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch,
* sizeof(reg_trie_trans) );

{ /* Modify the program and insert the new TRIE node */
U8 nodetype =(U8)(flags & 0xFF);
U8 nodetype =(U8) flags;
char *str=NULL;

#ifdef DEBUGGING
Expand Down
8 changes: 4 additions & 4 deletions regen/warnings.pl
Expand Up @@ -464,10 +464,10 @@ =head1 Warning and Dieing
#define packWARN3(a,b,c) ((a) | ((b)<<8) | ((c)<<16) )
#define packWARN4(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d) <<24))
#define unpackWARN1(x) ((x) & 0xFF)
#define unpackWARN2(x) (((x) >>8) & 0xFF)
#define unpackWARN3(x) (((x) >>16) & 0xFF)
#define unpackWARN4(x) (((x) >>24) & 0xFF)
#define unpackWARN1(x) ((U8) (x) )
#define unpackWARN2(x) ((U8) ((x) >> 8))
#define unpackWARN3(x) ((U8) ((x) >> 16))
#define unpackWARN4(x) ((U8) ((x) >> 24))
#define ckDEAD(x) \
(PL_curcop && \
Expand Down
4 changes: 2 additions & 2 deletions sv.c
Expand Up @@ -1811,7 +1811,7 @@ S_sv_display(pTHX_ SV *const sv, char *tmpbuf, STRLEN tmpbuf_size) {
const char *s = SvPVX_const(sv);
const char * const end = s + SvCUR(sv);
for ( ; s < end && d < limit; s++ ) {
int ch = *s & 0xFF;
int ch = (U8) *s;
if (! isASCII(ch) && !isPRINT_LC(ch)) {
*d++ = 'M';
*d++ = '-';
Expand Down Expand Up @@ -13307,7 +13307,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
sv_catpvn_nomg(msg, f, 1);
} else {
Perl_sv_catpvf(aTHX_ msg,
"\\%03" UVof, (UV)*f & 0xFF);
"\\%03" UVof, ((U8) ((UV)*f)));
}
}
sv_catpvs(msg, "\"");
Expand Down
2 changes: 1 addition & 1 deletion utf8.c
Expand Up @@ -4098,7 +4098,7 @@ Perl_pv_uni_display(pTHX_ SV *dsv, const U8 *spv, STRLEN len, STRLEN pvlim,
}
u = utf8_to_uvchr_buf((U8*)s, (U8*)e, 0);
if (u < 256) {
const unsigned char c = (unsigned char)u & 0xFF;
const U8 c = (U8) u;
if (flags & UNI_DISPLAY_BACKSLASH) {
if ( isMNEMONIC_CNTRL(c)
&& ( c != '\b'
Expand Down
2 changes: 1 addition & 1 deletion util.h
Expand Up @@ -203,7 +203,7 @@ typedef struct {
/* if in the future "" and NULL must be separated, XSVERLEN would be 0
means arg not present, 1 is empty string/null byte */
/* (((key) & 0x0000FF00) >> 8) is less efficient on Visual C */
#define HS_GETXSVERLEN(key) ((key) >> 8 & 0xFF)
#define HS_GETXSVERLEN(key) ((U8) ((key) >> 8))
#define HS_GETAPIVERLEN(key) ((key) & HSm_APIVERLEN)

/* internal to util.h macro to create a packed handshake key, all args must be constants */
Expand Down
8 changes: 4 additions & 4 deletions warnings.h
Expand Up @@ -223,10 +223,10 @@ category parameters passed.
#define packWARN3(a,b,c) ((a) | ((b)<<8) | ((c)<<16) )
#define packWARN4(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d) <<24))

#define unpackWARN1(x) ((x) & 0xFF)
#define unpackWARN2(x) (((x) >>8) & 0xFF)
#define unpackWARN3(x) (((x) >>16) & 0xFF)
#define unpackWARN4(x) (((x) >>24) & 0xFF)
#define unpackWARN1(x) ((U8) (x) )
#define unpackWARN2(x) ((U8) ((x) >> 8))
#define unpackWARN3(x) ((U8) ((x) >> 16))
#define unpackWARN4(x) ((U8) ((x) >> 24))

#define ckDEAD(x) \
(PL_curcop && \
Expand Down

0 comments on commit e33d5fe

Please sign in to comment.