diff --git a/ChangeLog b/ChangeLog index b0be50f..df46a58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -149,6 +149,9 @@ from Ross Burton. 36. Disable SSE2 JIT optimizations in x86 CPUs when SSE2 is not available. Patch by Guillem Jover. +37. Changed expressions such as 1<<10 to 1u<<10 in many places because compiler +warnings were reported. + Version 10.32 10-September-2018 ------------------------------- diff --git a/src/pcre2_auto_possess.c b/src/pcre2_auto_possess.c index 5814af7..6d7b7c4 100644 --- a/src/pcre2_auto_possess.c +++ b/src/pcre2_auto_possess.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2018 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -1051,7 +1051,7 @@ for(;;) if (chr > 255) break; class_bitset = (uint8_t *) ((list_ptr == list ? code : base_end) - list_ptr[2]); - if ((class_bitset[chr >> 3] & (1 << (chr & 7))) != 0) return FALSE; + if ((class_bitset[chr >> 3] & (1u << (chr & 7))) != 0) return FALSE; break; #ifdef SUPPORT_WIDE_CHARS diff --git a/src/pcre2_compile.c b/src/pcre2_compile.c index 90d30a5..30db6d5 100644 --- a/src/pcre2_compile.c +++ b/src/pcre2_compile.c @@ -368,17 +368,17 @@ enum { PSKIP_ALT, PSKIP_CLASS, PSKIP_KET }; experimenting to figure out how to stop gcc 5.3.0 from warning with -Wconversion. This version gets a warning: - #define SETBIT(a,b) a[(b)/8] |= (uint8_t)(1 << ((b)&7)) + #define SETBIT(a,b) a[(b)/8] |= (uint8_t)(1u << ((b)&7)) Let's hope the apparently less efficient version isn't actually so bad if the compiler is clever with identical subexpressions. */ -#define SETBIT(a,b) a[(b)/8] = (uint8_t)(a[(b)/8] | (1 << ((b)&7))) +#define SETBIT(a,b) a[(b)/8] = (uint8_t)(a[(b)/8] | (1u << ((b)&7))) /* Private flags added to firstcu and reqcu. */ -#define REQ_CASELESS (1 << 0) /* Indicates caselessness */ -#define REQ_VARY (1 << 1) /* reqcu followed non-literal item */ +#define REQ_CASELESS (1u << 0) /* Indicates caselessness */ +#define REQ_VARY (1u << 1) /* reqcu followed non-literal item */ /* Negative values for the firstcu and reqcu flags */ #define REQ_UNSET (-2) /* Not yet found anything */ #define REQ_NONE (-1) /* Found not fixed char */ diff --git a/src/pcre2_dfa_match.c b/src/pcre2_dfa_match.c index 0dd814f..bbf3e21 100644 --- a/src/pcre2_dfa_match.c +++ b/src/pcre2_dfa_match.c @@ -2567,7 +2567,7 @@ for (;;) if (clen > 0) { isinclass = (c > 255)? (codevalue == OP_NCLASS) : - ((((uint8_t *)(code + 1))[c/8] & (1 << (c&7))) != 0); + ((((uint8_t *)(code + 1))[c/8] & (1u << (c&7))) != 0); } } @@ -3609,7 +3609,7 @@ for (;;) #if PCRE2_CODE_UNIT_WIDTH != 8 if (c > 255) c = 255; #endif - ok = (start_bits[c/8] & (1 << (c&7))) != 0; + ok = (start_bits[c/8] & (1u << (c&7))) != 0; } } if (!ok) break; @@ -3720,7 +3720,7 @@ for (;;) #if PCRE2_CODE_UNIT_WIDTH != 8 if (c > 255) c = 255; #endif - if ((start_bits[c/8] & (1 << (c&7))) != 0) break; + if ((start_bits[c/8] & (1u << (c&7))) != 0) break; start_match++; } diff --git a/src/pcre2_extuni.c b/src/pcre2_extuni.c index 237211a..5a719e9 100644 --- a/src/pcre2_extuni.c +++ b/src/pcre2_extuni.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2018 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -100,7 +100,7 @@ while (eptr < end_subject) int len = 1; if (!utf) c = *eptr; else { GETCHARLEN(c, eptr, len); } rgb = UCD_GRAPHBREAK(c); - if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break; + if ((PRIV(ucp_gbtable)[lgb] & (1u << rgb)) == 0) break; /* Not breaking between Regional Indicators is allowed only if there are an even number of preceding RIs. */ diff --git a/src/pcre2_maketables.c b/src/pcre2_maketables.c index 1c66579..5921e90 100644 --- a/src/pcre2_maketables.c +++ b/src/pcre2_maketables.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2018 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -114,17 +114,17 @@ test for alnum specially. */ memset(p, 0, cbit_length); for (i = 0; i < 256; i++) { - if (isdigit(i)) p[cbit_digit + i/8] |= 1 << (i&7); - if (isupper(i)) p[cbit_upper + i/8] |= 1 << (i&7); - if (islower(i)) p[cbit_lower + i/8] |= 1 << (i&7); - if (isalnum(i)) p[cbit_word + i/8] |= 1 << (i&7); - if (i == '_') p[cbit_word + i/8] |= 1 << (i&7); - if (isspace(i)) p[cbit_space + i/8] |= 1 << (i&7); - if (isxdigit(i))p[cbit_xdigit + i/8] |= 1 << (i&7); - if (isgraph(i)) p[cbit_graph + i/8] |= 1 << (i&7); - if (isprint(i)) p[cbit_print + i/8] |= 1 << (i&7); - if (ispunct(i)) p[cbit_punct + i/8] |= 1 << (i&7); - if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1 << (i&7); + if (isdigit(i)) p[cbit_digit + i/8] |= 1u << (i&7); + if (isupper(i)) p[cbit_upper + i/8] |= 1u << (i&7); + if (islower(i)) p[cbit_lower + i/8] |= 1u << (i&7); + if (isalnum(i)) p[cbit_word + i/8] |= 1u << (i&7); + if (i == '_') p[cbit_word + i/8] |= 1u << (i&7); + if (isspace(i)) p[cbit_space + i/8] |= 1u << (i&7); + if (isxdigit(i))p[cbit_xdigit + i/8] |= 1u << (i&7); + if (isgraph(i)) p[cbit_graph + i/8] |= 1u << (i&7); + if (isprint(i)) p[cbit_print + i/8] |= 1u << (i&7); + if (ispunct(i)) p[cbit_punct + i/8] |= 1u << (i&7); + if (iscntrl(i)) p[cbit_cntrl + i/8] |= 1u << (i&7); } p += cbit_length; diff --git a/src/pcre2_match.c b/src/pcre2_match.c index 92ee9bf..419561f 100644 --- a/src/pcre2_match.c +++ b/src/pcre2_match.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2015-2018 University of Cambridge + New API code Copyright (c) 2015-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -1849,7 +1849,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); if (Fop == OP_CLASS) RRETURN(MATCH_NOMATCH); } else - if ((Lbyte_map[fc/8] & (1 << (fc&7))) == 0) RRETURN(MATCH_NOMATCH); + if ((Lbyte_map[fc/8] & (1u << (fc&7))) == 0) RRETURN(MATCH_NOMATCH); } } else @@ -1871,7 +1871,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); } else #endif - if ((Lbyte_map[fc/8] & (1 << (fc&7))) == 0) RRETURN(MATCH_NOMATCH); + if ((Lbyte_map[fc/8] & (1u << (fc&7))) == 0) RRETURN(MATCH_NOMATCH); } } @@ -1903,7 +1903,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); if (Fop == OP_CLASS) RRETURN(MATCH_NOMATCH); } else - if ((Lbyte_map[fc/8] & (1 << (fc&7))) == 0) RRETURN(MATCH_NOMATCH); + if ((Lbyte_map[fc/8] & (1u << (fc&7))) == 0) RRETURN(MATCH_NOMATCH); } } else @@ -1928,7 +1928,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); } else #endif - if ((Lbyte_map[fc/8] & (1 << (fc&7))) == 0) RRETURN(MATCH_NOMATCH); + if ((Lbyte_map[fc/8] & (1u << (fc&7))) == 0) RRETURN(MATCH_NOMATCH); } } /* Control never gets here */ @@ -1957,7 +1957,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); if (Fop == OP_CLASS) break; } else - if ((Lbyte_map[fc/8] & (1 << (fc&7))) == 0) break; + if ((Lbyte_map[fc/8] & (1u << (fc&7))) == 0) break; Feptr += len; } @@ -1994,7 +1994,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); } else #endif - if ((Lbyte_map[fc/8] & (1 << (fc&7))) == 0) break; + if ((Lbyte_map[fc/8] & (1u << (fc&7))) == 0) break; Feptr++; } @@ -4085,7 +4085,7 @@ fprintf(stderr, "++ op=%d\n", *Fecode); GETCHAR(fc, fptr); } lgb = UCD_GRAPHBREAK(fc); - if ((PRIV(ucp_gbtable)[lgb] & (1 << rgb)) == 0) break; + if ((PRIV(ucp_gbtable)[lgb] & (1u << rgb)) == 0) break; Feptr = fptr; rgb = lgb; } @@ -6459,7 +6459,7 @@ for(;;) #if PCRE2_CODE_UNIT_WIDTH != 8 if (c > 255) c = 255; #endif - ok = (start_bits[c/8] & (1 << (c&7))) != 0; + ok = (start_bits[c/8] & (1u << (c&7))) != 0; } } if (!ok) @@ -6576,7 +6576,7 @@ for(;;) #if PCRE2_CODE_UNIT_WIDTH != 8 if (c > 255) c = 255; #endif - if ((start_bits[c/8] & (1 << (c&7))) != 0) break; + if ((start_bits[c/8] & (1u << (c&7))) != 0) break; start_match++; } diff --git a/src/pcre2_printint.c b/src/pcre2_printint.c index a4a7693..a903826 100644 --- a/src/pcre2_printint.c +++ b/src/pcre2_printint.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2018 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -679,11 +679,11 @@ for(;;) for (i = 0; i < 256; i++) { - if ((map[i/8] & (1 << (i&7))) != 0) + if ((map[i/8] & (1u << (i&7))) != 0) { int j; for (j = i+1; j < 256; j++) - if ((map[j/8] & (1 << (j&7))) == 0) break; + if ((map[j/8] & (1u << (j&7))) == 0) break; if (i == '-' || i == ']') fprintf(f, "\\"); if (PRINTABLE(i)) fprintf(f, "%c", i); else fprintf(f, "\\x%02x", i); diff --git a/src/pcre2_study.c b/src/pcre2_study.c index a39f38f..e883c2e 100644 --- a/src/pcre2_study.c +++ b/src/pcre2_study.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2018 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -54,7 +54,7 @@ collecting data (e.g. minimum matching length). */ /* Set a bit in the starting code unit bit map. */ -#define SET_BIT(c) re->start_bitmap[(c)/8] |= (1 << ((c)&7)) +#define SET_BIT(c) re->start_bitmap[(c)/8] |= (1u << ((c)&7)) /* Returns from set_start_bits() */ @@ -843,7 +843,7 @@ for (c = 0; c < table_limit; c++) if (table_limit == 32) return; for (c = 128; c < 256; c++) { - if ((re->tables[cbits_offset + c/8] & (1 << (c&7))) != 0) + if ((re->tables[cbits_offset + c/8] & (1u << (c&7))) != 0) { PCRE2_UCHAR buff[6]; (void)PRIV(ord2utf)(c, buff); @@ -1507,11 +1507,11 @@ do for (c = 0; c < 16; c++) re->start_bitmap[c] |= classmap[c]; for (c = 128; c < 256; c++) { - if ((classmap[c/8] & (1 << (c&7))) != 0) + if ((classmap[c/8] & (1u << (c&7))) != 0) { - int d = (c >> 6) | 0xc0; /* Set bit for this starter */ - re->start_bitmap[d/8] |= (1 << (d&7)); /* and then skip on to the */ - c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */ + int d = (c >> 6) | 0xc0; /* Set bit for this starter */ + re->start_bitmap[d/8] |= (1u << (d&7)); /* and then skip on to the */ + c = (c & 0xc0) + 0x40 - 1; /* next relevant character. */ } } } diff --git a/src/pcre2_substitute.c b/src/pcre2_substitute.c index 0b63ef4..ec3dd66 100644 --- a/src/pcre2_substitute.c +++ b/src/pcre2_substitute.c @@ -716,7 +716,7 @@ do { if (((code->tables + cbits_offset + ((forcecase > 0)? cbit_upper:cbit_lower) - )[ch/8] & (1 << (ch%8))) == 0) + )[ch/8] & (1u << (ch%8))) == 0) ch = (code->tables + fcc_offset)[ch]; } forcecase = forcecasereset; @@ -818,7 +818,7 @@ do { if (((code->tables + cbits_offset + ((forcecase > 0)? cbit_upper:cbit_lower) - )[ch/8] & (1 << (ch%8))) == 0) + )[ch/8] & (1u << (ch%8))) == 0) ch = (code->tables + fcc_offset)[ch]; } forcecase = forcecasereset; diff --git a/src/pcre2_tables.c b/src/pcre2_tables.c index 3633294..8401936 100644 --- a/src/pcre2_tables.c +++ b/src/pcre2_tables.c @@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language. Written by Philip Hazel Original API code Copyright (c) 1997-2012 University of Cambridge - New API code Copyright (c) 2016-2018 University of Cambridge + New API code Copyright (c) 2016-2019 University of Cambridge ----------------------------------------------------------------------------- Redistribution and use in source and binary forms, with or without @@ -142,7 +142,7 @@ ucp_gbXX values defined in pcre2_ucp.h. These changed between Unicode versions code points. The left property selects a word from the table, and the right property selects a bit from that word like this: - PRIV(ucp_gbtable)[left-property] & (1 << right-property) + PRIV(ucp_gbtable)[left-property] & (1u << right-property) The value is non-zero if a grapheme break is NOT permitted between the relevant two code points. The breaking rules are as follows: @@ -183,25 +183,25 @@ are implementing). #define ESZ (1< 75) {