[ruby/yarp] Enable all of -wconversion
https://github.com/ruby/yarp/commit/638163f6c6
This commit is contained in:
parent
f1658efe38
commit
45efbadba5
Notes:
git
2023-08-17 00:48:15 +00:00
@ -281,7 +281,9 @@ typedef enum {
|
||||
#define YP_REGEXP_OPTION_STATE_SLOTS (YP_REGEXP_OPTION_STATE_SLOT_MAXIMUM - YP_REGEXP_OPTION_STATE_SLOT_MINIMUM + 1)
|
||||
|
||||
// This is the set of options that are configurable on the regular expression.
|
||||
typedef struct { unsigned char values[YP_REGEXP_OPTION_STATE_SLOTS]; } yp_regexp_options_t;
|
||||
typedef struct {
|
||||
unsigned char values[YP_REGEXP_OPTION_STATE_SLOTS];
|
||||
} yp_regexp_options_t;
|
||||
|
||||
// Initialize a new set of options to their default values.
|
||||
static void
|
||||
@ -300,7 +302,7 @@ yp_regexp_options_init(yp_regexp_options_t *options) {
|
||||
static bool
|
||||
yp_regexp_options_add(yp_regexp_options_t *options, unsigned char key) {
|
||||
if (key >= YP_REGEXP_OPTION_STATE_SLOT_MINIMUM && key <= YP_REGEXP_OPTION_STATE_SLOT_MAXIMUM) {
|
||||
key -= YP_REGEXP_OPTION_STATE_SLOT_MINIMUM;
|
||||
key = (unsigned char) (key - YP_REGEXP_OPTION_STATE_SLOT_MINIMUM);
|
||||
|
||||
switch (options->values[key]) {
|
||||
case YP_REGEXP_OPTION_STATE_INVALID:
|
||||
@ -323,7 +325,7 @@ yp_regexp_options_add(yp_regexp_options_t *options, unsigned char key) {
|
||||
static bool
|
||||
yp_regexp_options_remove(yp_regexp_options_t *options, unsigned char key) {
|
||||
if (key >= YP_REGEXP_OPTION_STATE_SLOT_MINIMUM && key <= YP_REGEXP_OPTION_STATE_SLOT_MAXIMUM) {
|
||||
key -= YP_REGEXP_OPTION_STATE_SLOT_MINIMUM;
|
||||
key = (unsigned char) (key - YP_REGEXP_OPTION_STATE_SLOT_MINIMUM);
|
||||
|
||||
switch (options->values[key]) {
|
||||
case YP_REGEXP_OPTION_STATE_INVALID:
|
||||
|
@ -64,19 +64,19 @@ unescape_octal(const char *backslash, unsigned char *value) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
*value = (*value << 3) | (backslash[2] - '0');
|
||||
*value = (unsigned char) ((*value << 3) | (backslash[2] - '0'));
|
||||
if (!yp_char_is_octal_digit(backslash[3])) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
*value = (*value << 3) | (backslash[3] - '0');
|
||||
*value = (unsigned char) ((*value << 3) | (backslash[3] - '0'));
|
||||
return 4;
|
||||
}
|
||||
|
||||
// Convert a hexadecimal digit into its equivalent value.
|
||||
static inline unsigned char
|
||||
unescape_hexadecimal_digit(const char value) {
|
||||
return (value <= '9') ? (unsigned char) (value - '0') : (value & 0x7) + 9;
|
||||
return (unsigned char) ((value <= '9') ? (value - '0') : (value & 0x7) + 9);
|
||||
}
|
||||
|
||||
// Scan the 1-2 digits of hexadecimal into the value. Returns the number of
|
||||
@ -88,7 +88,7 @@ unescape_hexadecimal(const char *backslash, unsigned char *value) {
|
||||
return 3;
|
||||
}
|
||||
|
||||
*value = (*value << 4) | unescape_hexadecimal_digit(backslash[3]);
|
||||
*value = (unsigned char) ((*value << 4) | unescape_hexadecimal_digit(backslash[3]));
|
||||
return 4;
|
||||
}
|
||||
|
||||
@ -113,22 +113,22 @@ unescape_unicode_write(char *dest, uint32_t value, const char *start, const char
|
||||
|
||||
if (value <= 0x7F) {
|
||||
// 0xxxxxxx
|
||||
bytes[0] = value;
|
||||
bytes[0] = (unsigned char) value;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (value <= 0x7FF) {
|
||||
// 110xxxxx 10xxxxxx
|
||||
bytes[0] = 0xC0 | (value >> 6);
|
||||
bytes[1] = 0x80 | (value & 0x3F);
|
||||
bytes[0] = (unsigned char) (0xC0 | (value >> 6));
|
||||
bytes[1] = (unsigned char) (0x80 | (value & 0x3F));
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (value <= 0xFFFF) {
|
||||
// 1110xxxx 10xxxxxx 10xxxxxx
|
||||
bytes[0] = 0xE0 | (value >> 12);
|
||||
bytes[1] = 0x80 | ((value >> 6) & 0x3F);
|
||||
bytes[2] = 0x80 | (value & 0x3F);
|
||||
bytes[0] = (unsigned char) (0xE0 | (value >> 12));
|
||||
bytes[1] = (unsigned char) (0x80 | ((value >> 6) & 0x3F));
|
||||
bytes[2] = (unsigned char) (0x80 | (value & 0x3F));
|
||||
return 3;
|
||||
}
|
||||
|
||||
@ -136,10 +136,10 @@ unescape_unicode_write(char *dest, uint32_t value, const char *start, const char
|
||||
// the input is invalid.
|
||||
if (value <= 0x10FFFF) {
|
||||
// 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
|
||||
bytes[0] = 0xF0 | (value >> 18);
|
||||
bytes[1] = 0x80 | ((value >> 12) & 0x3F);
|
||||
bytes[2] = 0x80 | ((value >> 6) & 0x3F);
|
||||
bytes[3] = 0x80 | (value & 0x3F);
|
||||
bytes[0] = (unsigned char) (0xF0 | (value >> 18));
|
||||
bytes[1] = (unsigned char) (0x80 | ((value >> 12) & 0x3F));
|
||||
bytes[2] = (unsigned char) (0x80 | ((value >> 6) & 0x3F));
|
||||
bytes[3] = (unsigned char) (0x80 | (value & 0x3F));
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ yp_strspn_whitespace(const char *string, ptrdiff_t length) {
|
||||
// whitespace while also tracking the location of each newline. Disallows
|
||||
// searching past the given maximum number of characters.
|
||||
size_t
|
||||
yp_strspn_whitespace_newlines(const char *string, long length, yp_newline_list_t *newline_list, bool stop_at_newline) {
|
||||
yp_strspn_whitespace_newlines(const char *string, ptrdiff_t length, yp_newline_list_t *newline_list, bool stop_at_newline) {
|
||||
if (length <= 0) return 0;
|
||||
|
||||
size_t size = 0;
|
||||
|
@ -15,7 +15,7 @@ size_t yp_strspn_whitespace(const char *string, ptrdiff_t length);
|
||||
// whitespace while also tracking the location of each newline. Disallows
|
||||
// searching past the given maximum number of characters.
|
||||
size_t
|
||||
yp_strspn_whitespace_newlines(const char *string, long length, yp_newline_list_t *newline_list, bool);
|
||||
yp_strspn_whitespace_newlines(const char *string, ptrdiff_t length, yp_newline_list_t *newline_list, bool);
|
||||
|
||||
// Returns the number of characters at the start of the string that are inline
|
||||
// whitespace. Disallows searching past the given maximum number of characters.
|
||||
|
@ -110,7 +110,7 @@ yp_constant_pool_init(yp_constant_pool_t *pool, size_t capacity) {
|
||||
// if any potential calls to resize fail.
|
||||
yp_constant_id_t
|
||||
yp_constant_pool_insert(yp_constant_pool_t *pool, const char *start, size_t length) {
|
||||
if (pool->size >= pool->capacity * 0.75) {
|
||||
if (pool->size >= (pool->capacity / 4 * 3)) {
|
||||
if (!yp_constant_pool_resize(pool)) return 0;
|
||||
}
|
||||
|
||||
|
@ -5929,7 +5929,7 @@ parser_lex(yp_parser_t *parser) {
|
||||
}
|
||||
|
||||
size_t ident_length = (size_t) (parser->current.end - ident_start);
|
||||
if (quote != YP_HEREDOC_QUOTE_NONE && !match(parser, quote)) {
|
||||
if (quote != YP_HEREDOC_QUOTE_NONE && !match(parser, (char) quote)) {
|
||||
// TODO: handle unterminated heredoc
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user