diff options
Diffstat (limited to 'src/parse/properties')
-rw-r--r-- | src/parse/properties/aural.c | 473 | ||||
-rw-r--r-- | src/parse/properties/background.c | 110 | ||||
-rw-r--r-- | src/parse/properties/border_outline.c | 176 | ||||
-rw-r--r-- | src/parse/properties/display_sizing.c | 158 | ||||
-rw-r--r-- | src/parse/properties/effects_stacking.c | 84 | ||||
-rw-r--r-- | src/parse/properties/font.c | 208 | ||||
-rw-r--r-- | src/parse/properties/generated_list.c | 230 | ||||
-rw-r--r-- | src/parse/properties/margin.c | 22 | ||||
-rw-r--r-- | src/parse/properties/padding.c | 17 | ||||
-rw-r--r-- | src/parse/properties/page.c | 98 | ||||
-rw-r--r-- | src/parse/properties/positioning.c | 130 | ||||
-rw-r--r-- | src/parse/properties/table.c | 48 | ||||
-rw-r--r-- | src/parse/properties/text.c | 185 | ||||
-rw-r--r-- | src/parse/properties/ui.c | 181 | ||||
-rw-r--r-- | src/parse/properties/utils.c | 13 |
15 files changed, 1708 insertions, 425 deletions
diff --git a/src/parse/properties/aural.c b/src/parse/properties/aural.c index b5b3c90..9367e93 100644 --- a/src/parse/properties/aural.c +++ b/src/parse/properties/aural.c @@ -47,6 +47,7 @@ css_error parse_azimuth(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* angle | [ IDENT(left-side, far-left, left, center-left, center, * center-right, right, far-right, right-side) || @@ -61,15 +62,21 @@ css_error parse_azimuth(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal(c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[LEFTWARDS]) { + (lwc_context_string_caseless_isequal(c->sheet->dictionary, + token->idata, c->strings[LEFTWARDS], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = AZIMUTH_LEFTWARDS; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[RIGHTWARDS]) { + (lwc_context_string_caseless_isequal(c->sheet->dictionary, + token->idata, c->strings[RIGHTWARDS], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = AZIMUTH_RIGHTWARDS; } else if (token->type == CSS_TOKEN_IDENT) { @@ -78,25 +85,55 @@ css_error parse_azimuth(css_language *c, /* Now, we may have one of the other keywords or behind, * potentially followed by behind or other keyword, * respectively */ - if (token->ilower == c->strings[LEFT_SIDE]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LEFT_SIDE], + &match) == lwc_error_ok && match)) { value = AZIMUTH_LEFT_SIDE; - } else if (token->ilower == c->strings[FAR_LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[FAR_LEFT], + &match) == lwc_error_ok && match)) { value = AZIMUTH_FAR_LEFT; - } else if (token->ilower == c->strings[LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LEFT], + &match) == lwc_error_ok && match)) { value = AZIMUTH_LEFT; - } else if (token->ilower == c->strings[CENTER_LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CENTER_LEFT], + &match) == lwc_error_ok && match)) { value = AZIMUTH_CENTER_LEFT; - } else if (token->ilower == c->strings[CENTER]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CENTER], + &match) == lwc_error_ok && match)) { value = AZIMUTH_CENTER; - } else if (token->ilower == c->strings[CENTER_RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CENTER_RIGHT], + &match) == lwc_error_ok && match)) { value = AZIMUTH_CENTER_RIGHT; - } else if (token->ilower == c->strings[RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[RIGHT], + &match) == lwc_error_ok && match)) { value = AZIMUTH_RIGHT; - } else if (token->ilower == c->strings[FAR_RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[FAR_RIGHT], + &match) == lwc_error_ok && match)) { value = AZIMUTH_FAR_RIGHT; - } else if (token->ilower == c->strings[RIGHT_SIDE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[RIGHT_SIDE], + &match) == lwc_error_ok && match)) { value = AZIMUTH_RIGHT_SIDE; - } else if (token->ilower == c->strings[BEHIND]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[BEHIND], + &match) == lwc_error_ok && match)) { value = AZIMUTH_BEHIND; } else { *ctx = orig_ctx; @@ -112,23 +149,50 @@ css_error parse_azimuth(css_language *c, value == AZIMUTH_BEHIND) { parserutils_vector_iterate(vector, ctx); - if (token->ilower == c->strings[LEFT_SIDE]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LEFT_SIDE], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_LEFT_SIDE; - } else if (token->ilower == c->strings[FAR_LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[FAR_LEFT], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_FAR_LEFT; - } else if (token->ilower == c->strings[LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LEFT], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_LEFT; - } else if (token->ilower == c->strings[CENTER_LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CENTER_LEFT], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_CENTER_LEFT; - } else if (token->ilower == c->strings[CENTER]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CENTER], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_CENTER; - } else if (token->ilower == c->strings[CENTER_RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CENTER_RIGHT], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_CENTER_RIGHT; - } else if (token->ilower == c->strings[RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[RIGHT], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_RIGHT; - } else if (token->ilower == c->strings[FAR_RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[FAR_RIGHT], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_FAR_RIGHT; - } else if (token->ilower == c->strings[RIGHT_SIDE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[RIGHT_SIDE], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_RIGHT_SIDE; } else { *ctx = orig_ctx; @@ -138,7 +202,10 @@ css_error parse_azimuth(css_language *c, value != AZIMUTH_BEHIND) { parserutils_vector_iterate(vector, ctx); - if (token->ilower == c->strings[BEHIND]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[BEHIND], + &match) == lwc_error_ok && match)) { value |= AZIMUTH_BEHIND; } else { *ctx = orig_ctx; @@ -233,12 +300,16 @@ css_error parse_cue(css_language *c, int num_read = 0; int prev_ctx; uint32_t required_size; + bool match; css_error error; /* Deal with inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -272,7 +343,10 @@ css_error parse_cue(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -426,6 +500,7 @@ css_error parse_elevation(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* angle | IDENT(below, level, above, higher, lower, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -435,27 +510,45 @@ css_error parse_elevation(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[BELOW]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[BELOW], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = ELEVATION_BELOW; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[LEVEL]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LEVEL], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = ELEVATION_LEVEL; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[ABOVE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[ABOVE], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = ELEVATION_ABOVE; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[HIGHER]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[HIGHER], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = ELEVATION_HIGHER; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[LOWER]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LOWER], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = ELEVATION_LOWER; } else { @@ -543,12 +636,16 @@ css_error parse_pause(css_language *c, int num_read = 0; int prev_ctx; uint32_t required_size; + bool match; css_error error; /* Deal with inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -584,7 +681,10 @@ css_error parse_pause(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -738,6 +838,7 @@ css_error parse_pitch_range(css_language *c, uint32_t opv; css_fixed num = 0; uint32_t required_size; + bool match; /* number | IDENT (inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -747,13 +848,16 @@ css_error parse_pitch_range(css_language *c, return CSS_INVALID; } - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - num = number_from_lwc_string(token->ilower, false, &consumed); + num = number_from_lwc_string(token->idata, false, &consumed); /* Invalid if there are trailing characters */ - if (consumed != lwc_string_length(token->ilower)) { + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -820,6 +924,7 @@ css_error parse_pitch(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* frequency | IDENT(x-low, low, medium, high, x-high, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -829,27 +934,45 @@ css_error parse_pitch(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[X_LOW]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[X_LOW], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = PITCH_X_LOW; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[LOW]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LOW], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = PITCH_LOW; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[MEDIUM]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MEDIUM], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = PITCH_MEDIUM; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[HIGH]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[HIGH], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = PITCH_HIGH; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[X_HIGH]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[X_HIGH], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = PITCH_X_HIGH; } else { @@ -925,6 +1048,7 @@ css_error parse_play_during(css_language *c, uint32_t opv; uint32_t required_size; lwc_string *uri; + bool match; /* URI [ IDENT(mix) || IDENT(repeat) ]? | IDENT(auto,none,inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -935,11 +1059,20 @@ css_error parse_play_during(css_language *c, } if (token->type == CSS_TOKEN_IDENT) { - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (token->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = PLAY_DURING_NONE; - } else if (token->ilower == c->strings[AUTO]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { value = PLAY_DURING_AUTO; } else { *ctx = orig_ctx; @@ -963,15 +1096,23 @@ css_error parse_play_during(css_language *c, token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT) { - if (token->ilower == c->strings[MIX]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MIX], + &match) == lwc_error_ok && + match)) { if ((value & PLAY_DURING_MIX) == 0) value |= PLAY_DURING_MIX; else { *ctx = orig_ctx; return CSS_INVALID; } - } else if (token->ilower == - c->strings[REPEAT]) { + } else if (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, + c->strings[REPEAT], + &match) == lwc_error_ok && + match) { if ((value & PLAY_DURING_REPEAT) == 0) value |= PLAY_DURING_REPEAT; else { @@ -1040,6 +1181,7 @@ css_error parse_richness(css_language *c, uint32_t opv; css_fixed num = 0; uint32_t required_size; + bool match; /* number | IDENT (inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -1049,13 +1191,16 @@ css_error parse_richness(css_language *c, return CSS_INVALID; } - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - num = number_from_lwc_string(token->ilower, false, &consumed); + num = number_from_lwc_string(token->idata, false, &consumed); /* Invalid if there are trailing characters */ - if (consumed != lwc_string_length(token->ilower)) { + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -1119,6 +1264,7 @@ css_error parse_speak_header(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (once, always, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -1127,11 +1273,20 @@ css_error parse_speak_header(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[ONCE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[ONCE], + &match) == lwc_error_ok && match)) { value = SPEAK_HEADER_ONCE; - } else if (ident->ilower == c->strings[ALWAYS]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[ALWAYS], + &match) == lwc_error_ok && match)) { value = SPEAK_HEADER_ALWAYS; } else { *ctx = orig_ctx; @@ -1177,6 +1332,7 @@ css_error parse_speak_numeral(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (digits, continuous, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -1185,11 +1341,20 @@ css_error parse_speak_numeral(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[DIGITS]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[DIGITS], + &match) == lwc_error_ok && match)) { value = SPEAK_NUMERAL_DIGITS; - } else if (ident->ilower == c->strings[CONTINUOUS]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[CONTINUOUS], + &match) == lwc_error_ok && match)) { value = SPEAK_NUMERAL_CONTINUOUS; } else { *ctx = orig_ctx; @@ -1235,6 +1400,7 @@ css_error parse_speak_punctuation(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (code, none, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -1243,11 +1409,20 @@ css_error parse_speak_punctuation(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[CODE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[CODE], + &match) == lwc_error_ok && match)) { value = SPEAK_PUNCTUATION_CODE; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = SPEAK_PUNCTUATION_NONE; } else { *ctx = orig_ctx; @@ -1293,6 +1468,7 @@ css_error parse_speak(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (normal, none, spell-out, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -1301,13 +1477,25 @@ css_error parse_speak(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[NORMAL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { value = SPEAK_NORMAL; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = SPEAK_NONE; - } else if (ident->ilower == c->strings[SPELL_OUT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SPELL_OUT], + &match) == lwc_error_ok && match)) { value = SPEAK_SPELL_OUT; } else { *ctx = orig_ctx; @@ -1355,6 +1543,7 @@ css_error parse_speech_rate(css_language *c, uint32_t opv; css_fixed num = 0; uint32_t required_size; + bool match; /* number | IDENT (x-slow, slow, medium, fast, x-fast, faster, slower, * inherit) @@ -1367,34 +1556,58 @@ css_error parse_speech_rate(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[X_SLOW]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[X_SLOW], + &match) == lwc_error_ok && match)) { value = SPEECH_RATE_X_SLOW; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[SLOW]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SLOW], + &match) == lwc_error_ok && match)) { value = SPEECH_RATE_SLOW; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[MEDIUM]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MEDIUM], + &match) == lwc_error_ok && match)) { value = SPEECH_RATE_MEDIUM; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[FAST]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[FAST], + &match) == lwc_error_ok && match)) { value = SPEECH_RATE_FAST; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[X_FAST]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[X_FAST], + &match) == lwc_error_ok && match)) { value = SPEECH_RATE_X_FAST; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[FASTER]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[FASTER], + &match) == lwc_error_ok && match)) { value = SPEECH_RATE_FASTER; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[SLOWER]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SLOWER], + &match) == lwc_error_ok && match)) { value = SPEECH_RATE_SLOWER; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - num = number_from_lwc_string(token->ilower, false, &consumed); + num = number_from_lwc_string(token->idata, false, &consumed); /* Invalid if there are trailing characters */ - if (consumed != lwc_string_length(token->ilower)) { + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -1460,6 +1673,7 @@ css_error parse_stress(css_language *c, uint32_t opv; css_fixed num = 0; uint32_t required_size; + bool match; /* number | IDENT (inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -1469,13 +1683,16 @@ css_error parse_stress(css_language *c, return CSS_INVALID; } - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - num = number_from_lwc_string(token->ilower, false, &consumed); + num = number_from_lwc_string(token->idata, false, &consumed); /* Invalid if there are trailing characters */ - if (consumed != lwc_string_length(token->ilower)) { + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -1523,9 +1740,20 @@ css_error parse_stress(css_language *c, */ static bool voice_family_reserved(css_language *c, const css_token *ident) { - return ident->ilower == c->strings[MALE] || - ident->ilower == c->strings[FEMALE] || - ident->ilower == c->strings[CHILD]; + bool match; + + return (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[MALE], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[FEMALE], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[CHILD], + &match) == lwc_error_ok && match); } /** @@ -1538,13 +1766,23 @@ static bool voice_family_reserved(css_language *c, const css_token *ident) static uint16_t voice_family_value(css_language *c, const css_token *token) { uint16_t value; + bool match; if (token->type == CSS_TOKEN_IDENT) { - if (token->ilower == c->strings[MALE]) + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MALE], + &match) == lwc_error_ok && match)) value = VOICE_FAMILY_MALE; - else if (token->ilower == c->strings[FEMALE]) + else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[FEMALE], + &match) == lwc_error_ok && match)) value = VOICE_FAMILY_FEMALE; - else if (token->ilower == c->strings[CHILD]) + else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CHILD], + &match) == lwc_error_ok && match)) value = VOICE_FAMILY_CHILD; else value = VOICE_FAMILY_IDENT_LIST; @@ -1582,6 +1820,7 @@ css_error parse_voice_family(css_language *c, uint32_t required_size = sizeof(opv); int temp_ctx = *ctx; uint8_t *ptr; + bool match; /* [ IDENT+ | STRING ] [ ',' [ IDENT+ | STRING ] ]* | IDENT(inherit) * @@ -1598,7 +1837,10 @@ css_error parse_voice_family(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags = FLAG_INHERIT; } else { uint32_t list_size; @@ -1640,7 +1882,10 @@ css_error parse_voice_family(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { /* Nothing to do */ } else { error = comma_list_to_bytecode(c, vector, ctx, token, @@ -1689,6 +1934,7 @@ css_error parse_volume(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* number | percentage | IDENT(silent, x-soft, soft, medium, loud, * x-loud, inherit) @@ -1700,38 +1946,58 @@ css_error parse_volume(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[SILENT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SILENT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VOLUME_SILENT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[X_SOFT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[X_SOFT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VOLUME_X_SOFT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[SOFT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SOFT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VOLUME_SOFT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[MEDIUM]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MEDIUM], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VOLUME_MEDIUM; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[LOUD]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LOUD], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VOLUME_LOUD; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[X_LOUD]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[X_LOUD], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VOLUME_X_LOUD; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - length = number_from_lwc_string(token->ilower, - false, &consumed); - if (consumed != lwc_string_length(token->ilower)) { + length = number_from_lwc_string(token->idata, false, &consumed); + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -1822,6 +2088,7 @@ css_error parse_cue_common(css_language *c, uint32_t opv; uint32_t required_size; lwc_string *uri = NULL; + bool match; /* URI | IDENT (none, inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -1832,10 +2099,16 @@ css_error parse_cue_common(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NONE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = CUE_AFTER_NONE; } else if (token->type == CSS_TOKEN_URI) { value = CUE_AFTER_URI; @@ -1904,6 +2177,7 @@ css_error parse_pause_common(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* time | percentage | IDENT(inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -1913,7 +2187,10 @@ css_error parse_pause_common(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else { diff --git a/src/parse/properties/background.c b/src/parse/properties/background.c index bec2b2f..fb96469 100644 --- a/src/parse/properties/background.c +++ b/src/parse/properties/background.c @@ -41,12 +41,16 @@ css_error parse_background(css_language *c, css_style *repeat = NULL; css_style *ret = NULL; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -266,6 +270,7 @@ css_error parse_background_attachment(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (fixed, scroll, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -274,11 +279,20 @@ css_error parse_background_attachment(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[FIXED]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[FIXED], + &match) == lwc_error_ok && match)) { value = BACKGROUND_ATTACHMENT_FIXED; - } else if (ident->ilower == c->strings[SCROLL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SCROLL], + &match) == lwc_error_ok && match)) { value = BACKGROUND_ATTACHMENT_SCROLL; } else { *ctx = orig_ctx; @@ -326,6 +340,7 @@ css_error parse_background_color(css_language *c, uint32_t opv; uint32_t colour = 0; uint32_t required_size; + bool match; /* colour | IDENT (transparent, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -335,11 +350,17 @@ css_error parse_background_color(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[TRANSPARENT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[TRANSPARENT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = BACKGROUND_COLOR_TRANSPARENT; } else { @@ -400,6 +421,7 @@ css_error parse_background_image(css_language *c, uint16_t value = 0; uint32_t opv; uint32_t required_size; + bool match; lwc_string *uri = NULL; /* URI | IDENT (none, inherit) */ @@ -411,10 +433,16 @@ css_error parse_background_image(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NONE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = BACKGROUND_IMAGE_NONE; } else if (token->type == CSS_TOKEN_URI) { value = BACKGROUND_IMAGE_URI; @@ -482,6 +510,7 @@ css_error parse_background_position(css_language *c, css_fixed length[2] = { 0 }; uint32_t unit[2] = { 0 }; uint32_t required_size; + bool match; /* [length | percentage | IDENT(left, right, top, bottom, center)]{1,2} * | IDENT(inherit) */ @@ -492,7 +521,10 @@ css_error parse_background_position(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else { @@ -504,20 +536,40 @@ css_error parse_background_position(css_language *c, break; if (token->type == CSS_TOKEN_IDENT) { - if (token->ilower == c->strings[LEFT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LEFT], + &match) == lwc_error_ok && + match)) { value[i] = BACKGROUND_POSITION_HORZ_LEFT; - } else if (token->ilower == c->strings[RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[RIGHT], + &match) == lwc_error_ok && + match)) { value[i] = BACKGROUND_POSITION_HORZ_RIGHT; - } else if (token->ilower == c->strings[TOP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[TOP], + &match) == lwc_error_ok && + match)) { value[i] = BACKGROUND_POSITION_VERT_TOP; - } else if (token->ilower == - c->strings[BOTTOM]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, + c->strings[BOTTOM], + &match) == lwc_error_ok && + match)) { value[i] = BACKGROUND_POSITION_VERT_BOTTOM; - } else if (token->ilower == - c->strings[CENTER]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, + c->strings[CENTER], + &match) == lwc_error_ok && + match)) { /* We'll fix this up later */ value[i] = BACKGROUND_POSITION_VERT_CENTER; @@ -671,6 +723,7 @@ css_error parse_background_repeat(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (no-repeat, repeat-x, repeat-y, repeat, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -679,15 +732,30 @@ css_error parse_background_repeat(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[NO_REPEAT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NO_REPEAT], + &match) == lwc_error_ok && match)) { value = BACKGROUND_REPEAT_NO_REPEAT; - } else if (ident->ilower == c->strings[REPEAT_X]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[REPEAT_X], + &match) == lwc_error_ok && match)) { value = BACKGROUND_REPEAT_REPEAT_X; - } else if (ident->ilower == c->strings[REPEAT_Y]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[REPEAT_Y], + &match) == lwc_error_ok && match)) { value = BACKGROUND_REPEAT_REPEAT_Y; - } else if (ident->ilower == c->strings[REPEAT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[REPEAT], + &match) == lwc_error_ok && match)) { value = BACKGROUND_REPEAT_REPEAT; } else { *ctx = orig_ctx; diff --git a/src/parse/properties/border_outline.c b/src/parse/properties/border_outline.c index 4fd73da..d81495a 100644 --- a/src/parse/properties/border_outline.c +++ b/src/parse/properties/border_outline.c @@ -234,6 +234,7 @@ css_error parse_border_collapse(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (collapse, separate, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -242,11 +243,20 @@ css_error parse_border_collapse(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[COLLAPSE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[COLLAPSE], + &match) == lwc_error_ok && match)) { value = BORDER_COLLAPSE_COLLAPSE; - } else if (ident->ilower == c->strings[SEPARATE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SEPARATE], + &match) == lwc_error_ok && match)) { value = BORDER_COLLAPSE_SEPARATE; } else { *ctx = orig_ctx; @@ -296,12 +306,16 @@ css_error parse_border_color(css_language *c, css_style *ret = NULL; uint32_t num_sides = 0; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -341,7 +355,10 @@ css_error parse_border_color(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -716,6 +733,7 @@ css_error parse_border_spacing(css_language *c, css_fixed length[2] = { 0 }; uint32_t unit[2] = { 0 }; uint32_t required_size; + bool match; /* length length? | IDENT(inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -725,7 +743,10 @@ css_error parse_border_spacing(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else { @@ -843,12 +864,16 @@ css_error parse_border_style(css_language *c, css_style *ret = NULL; uint32_t num_sides = 0; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -888,7 +913,10 @@ css_error parse_border_style(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -1177,12 +1205,16 @@ css_error parse_border_width(css_language *c, css_style *ret = NULL; uint32_t num_sides = 0; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -1222,7 +1254,10 @@ css_error parse_border_width(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -1422,12 +1457,16 @@ css_error parse_outline(css_language *c, css_style *width = NULL; css_style *ret = NULL; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -1465,7 +1504,10 @@ css_error parse_outline(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -1600,6 +1642,7 @@ css_error parse_outline_color(css_language *c, uint32_t opv; uint32_t colour = 0; uint32_t required_size; + bool match; /* colour | IDENT (invert, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -1609,11 +1652,17 @@ css_error parse_outline_color(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INVERT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INVERT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = OUTLINE_COLOR_INVERT; } else { @@ -1743,12 +1792,16 @@ css_error parse_border_side(css_language *c, css_style *width = NULL; css_style *ret = NULL; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -1786,7 +1839,10 @@ css_error parse_border_side(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -1917,6 +1973,7 @@ css_error parse_border_side_color(css_language *c, uint16_t value = 0; uint32_t colour = 0; uint32_t required_size; + bool match; /* colour | IDENT (transparent, inherit) */ token= parserutils_vector_peek(vector, *ctx); @@ -1926,11 +1983,17 @@ css_error parse_border_side_color(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[TRANSPARENT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[TRANSPARENT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = BORDER_COLOR_TRANSPARENT; } else { @@ -1991,6 +2054,7 @@ css_error parse_border_side_style(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (none, hidden, dotted, dashed, solid, double, groove, * ridge, inset, outset, inherit) */ @@ -2000,27 +2064,60 @@ css_error parse_border_side_style(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_NONE; - } else if (ident->ilower == c->strings[HIDDEN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[HIDDEN], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_HIDDEN; - } else if (ident->ilower == c->strings[DOTTED]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[DOTTED], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_DOTTED; - } else if (ident->ilower == c->strings[DASHED]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[DASHED], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_DASHED; - } else if (ident->ilower == c->strings[SOLID]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SOLID], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_SOLID; - } else if (ident->ilower == c->strings[DOUBLE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[DOUBLE], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_DOUBLE; - } else if (ident->ilower == c->strings[GROOVE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[GROOVE], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_GROOVE; - } else if (ident->ilower == c->strings[RIDGE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RIDGE], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_RIDGE; - } else if (ident->ilower == c->strings[INSET]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INSET], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_INSET; - } else if (ident->ilower == c->strings[OUTSET]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[OUTSET], + &match) == lwc_error_ok && match)) { value = BORDER_STYLE_OUTSET; } else { *ctx = orig_ctx; @@ -2070,6 +2167,7 @@ css_error parse_border_side_width(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | IDENT(thin, medium, thick, inherit) */ token= parserutils_vector_peek(vector, *ctx); @@ -2079,19 +2177,31 @@ css_error parse_border_side_width(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[THIN]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[THIN], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = BORDER_WIDTH_THIN; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[MEDIUM]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MEDIUM], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = BORDER_WIDTH_MEDIUM; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[THICK]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[THICK], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = BORDER_WIDTH_THICK; } else { diff --git a/src/parse/properties/display_sizing.c b/src/parse/properties/display_sizing.c index d93066f..c25813b 100644 --- a/src/parse/properties/display_sizing.c +++ b/src/parse/properties/display_sizing.c @@ -36,6 +36,7 @@ css_error parse_display(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (inline, block, list-item, run-in, inline-block, table, * inline-table, table-row-group, table-header-group, @@ -47,39 +48,90 @@ css_error parse_display(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[INLINE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INLINE], + &match) == lwc_error_ok && match)) { value = DISPLAY_INLINE; - } else if (ident->ilower == c->strings[BLOCK]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[BLOCK], + &match) == lwc_error_ok && match)) { value = DISPLAY_BLOCK; - } else if (ident->ilower == c->strings[LIST_ITEM]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LIST_ITEM], + &match) == lwc_error_ok && match)) { value = DISPLAY_LIST_ITEM; - } else if (ident->ilower == c->strings[RUN_IN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RUN_IN], + &match) == lwc_error_ok && match)) { value = DISPLAY_RUN_IN; - } else if (ident->ilower == c->strings[INLINE_BLOCK]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INLINE_BLOCK], + &match) == lwc_error_ok && match)) { value = DISPLAY_INLINE_BLOCK; - } else if (ident->ilower == c->strings[TABLE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE; - } else if (ident->ilower == c->strings[INLINE_TABLE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INLINE_TABLE], + &match) == lwc_error_ok && match)) { value = DISPLAY_INLINE_TABLE; - } else if (ident->ilower == c->strings[TABLE_ROW_GROUP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE_ROW_GROUP], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE_ROW_GROUP; - } else if (ident->ilower == c->strings[TABLE_HEADER_GROUP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE_HEADER_GROUP], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE_HEADER_GROUP; - } else if (ident->ilower == c->strings[TABLE_FOOTER_GROUP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE_FOOTER_GROUP], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE_FOOTER_GROUP; - } else if (ident->ilower == c->strings[TABLE_ROW]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE_ROW], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE_ROW; - } else if (ident->ilower == c->strings[TABLE_COLUMN_GROUP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE_COLUMN_GROUP], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE_COLUMN_GROUP; - } else if (ident->ilower == c->strings[TABLE_COLUMN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE_COLUMN], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE_COLUMN; - } else if (ident->ilower == c->strings[TABLE_CELL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE_CELL], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE_CELL; - } else if (ident->ilower == c->strings[TABLE_CAPTION]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TABLE_CAPTION], + &match) == lwc_error_ok && match)) { value = DISPLAY_TABLE_CAPTION; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = DISPLAY_NONE; } else { *ctx = orig_ctx; @@ -128,6 +180,7 @@ css_error parse_height(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(auto, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -137,11 +190,17 @@ css_error parse_height(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[AUTO]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = HEIGHT_AUTO; } else { @@ -218,6 +277,7 @@ css_error parse_line_height(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* number | length | percentage | IDENT(normal, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -227,18 +287,23 @@ css_error parse_line_height(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NORMAL]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = LINE_HEIGHT_NORMAL; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - length = number_from_lwc_string(token->ilower, - false, &consumed); - if (consumed != lwc_string_length(token->ilower)) { + length = number_from_lwc_string(token->idata, false, &consumed); + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -329,6 +394,7 @@ css_error parse_max_height(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(none, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -338,11 +404,17 @@ css_error parse_max_height(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NONE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = MAX_HEIGHT_NONE; } else { @@ -419,6 +491,7 @@ css_error parse_max_width(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(none, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -428,11 +501,17 @@ css_error parse_max_width(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NONE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = MAX_WIDTH_NONE; } else { @@ -509,6 +588,7 @@ css_error parse_min_height(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -518,7 +598,10 @@ css_error parse_min_height(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else { @@ -595,6 +678,7 @@ css_error parse_min_width(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -604,7 +688,10 @@ css_error parse_min_width(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else { @@ -681,6 +768,7 @@ css_error parse_width(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(auto, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -690,11 +778,17 @@ css_error parse_width(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[AUTO]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = WIDTH_AUTO; } else { diff --git a/src/parse/properties/effects_stacking.c b/src/parse/properties/effects_stacking.c index cad612e..ad3e4d7 100644 --- a/src/parse/properties/effects_stacking.c +++ b/src/parse/properties/effects_stacking.c @@ -40,6 +40,7 @@ css_error parse_clip(css_language *c, css_fixed length[4] = { 0 }; uint32_t unit[4] = { 0 }; uint32_t required_size; + bool match; /* FUNCTION(rect) [ [ IDENT(auto) | length ] CHAR(,)? ]{3} * [ IDENT(auto) | length ] CHAR{)} | @@ -51,13 +52,22 @@ css_error parse_clip(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[AUTO]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { value = CLIP_AUTO; } else if (token->type == CSS_TOKEN_FUNCTION && - token->ilower == c->strings[RECT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[RECT], + &match) == lwc_error_ok && match)) { int i; value = CLIP_SHAPE_RECT; @@ -73,7 +83,11 @@ css_error parse_clip(css_language *c, if (token->type == CSS_TOKEN_IDENT) { /* Slightly magical way of generating the auto * values. These are bits 3-6 of the value. */ - if (token->ilower == c->strings[AUTO]) + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && + match)) value |= 1 << (i + 3); else { *ctx = orig_ctx; @@ -188,6 +202,7 @@ css_error parse_overflow(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (visible, hidden, scroll, auto, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -196,15 +211,30 @@ css_error parse_overflow(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[VISIBLE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[VISIBLE], + &match) == lwc_error_ok && match)) { value = OVERFLOW_VISIBLE; - } else if (ident->ilower == c->strings[HIDDEN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[HIDDEN], + &match) == lwc_error_ok && match)) { value = OVERFLOW_HIDDEN; - } else if (ident->ilower == c->strings[SCROLL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SCROLL], + &match) == lwc_error_ok && match)) { value = OVERFLOW_SCROLL; - } else if (ident->ilower == c->strings[AUTO]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { value = OVERFLOW_AUTO; } else { *ctx = orig_ctx; @@ -250,6 +280,7 @@ css_error parse_visibility(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (visible, hidden, collapse, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -258,13 +289,25 @@ css_error parse_visibility(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[VISIBLE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[VISIBLE], + &match) == lwc_error_ok && match)) { value = VISIBILITY_VISIBLE; - } else if (ident->ilower == c->strings[HIDDEN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[HIDDEN], + &match) == lwc_error_ok && match)) { value = VISIBILITY_HIDDEN; - } else if (ident->ilower == c->strings[COLLAPSE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[COLLAPSE], + &match) == lwc_error_ok && match)) { value = VISIBILITY_COLLAPSE; } else { *ctx = orig_ctx; @@ -312,6 +355,7 @@ css_error parse_z_index(css_language *c, uint32_t opv; css_fixed num = 0; uint32_t required_size; + bool match; /* <integer> | IDENT (auto, inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -322,16 +366,22 @@ css_error parse_z_index(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[AUTO]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { value = Z_INDEX_AUTO; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - num = number_from_lwc_string(token->ilower, true, &consumed); + num = number_from_lwc_string(token->idata, true, &consumed); /* Invalid if there are trailing characters */ - if (consumed != lwc_string_length(token->ilower)) { + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } diff --git a/src/parse/properties/font.c b/src/parse/properties/font.c index 4c8d120..36228c2 100644 --- a/src/parse/properties/font.c +++ b/src/parse/properties/font.c @@ -42,13 +42,17 @@ css_error parse_font(css_language *c, css_style *family = NULL; css_style *ret = NULL; uint32_t required_size; + bool match; int svw; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -92,7 +96,10 @@ css_error parse_font(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -125,7 +132,10 @@ css_error parse_font(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -147,7 +157,10 @@ css_error parse_font(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -162,7 +175,10 @@ css_error parse_font(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -306,11 +322,28 @@ cleanup: */ static bool font_family_reserved(css_language *c, const css_token *ident) { - return ident->ilower == c->strings[SERIF] || - ident->ilower == c->strings[SANS_SERIF] || - ident->ilower == c->strings[CURSIVE] || - ident->ilower == c->strings[FANTASY] || - ident->ilower == c->strings[MONOSPACE]; + bool match; + + return (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SERIF], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SANS_SERIF], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[CURSIVE], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[FANTASY], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[MONOSPACE], + &match) == lwc_error_ok && match); } /** @@ -323,17 +356,33 @@ static bool font_family_reserved(css_language *c, const css_token *ident) static uint16_t font_family_value(css_language *c, const css_token *token) { uint16_t value; + bool match; if (token->type == CSS_TOKEN_IDENT) { - if (token->ilower == c->strings[SERIF]) + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SERIF], + &match) == lwc_error_ok && match)) value = FONT_FAMILY_SERIF; - else if (token->ilower == c->strings[SANS_SERIF]) + else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SANS_SERIF], + &match) == lwc_error_ok && match)) value = FONT_FAMILY_SANS_SERIF; - else if (token->ilower == c->strings[CURSIVE]) + else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CURSIVE], + &match) == lwc_error_ok && match)) value = FONT_FAMILY_CURSIVE; - else if (token->ilower == c->strings[FANTASY]) + else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[FANTASY], + &match) == lwc_error_ok && match)) value = FONT_FAMILY_FANTASY; - else if (token->ilower == c->strings[MONOSPACE]) + else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MONOSPACE], + &match) == lwc_error_ok && match)) value = FONT_FAMILY_MONOSPACE; else value = FONT_FAMILY_IDENT_LIST; @@ -371,6 +420,7 @@ css_error parse_font_family(css_language *c, uint32_t required_size = sizeof(opv); int temp_ctx = *ctx; uint8_t *ptr; + bool match; /* [ IDENT+ | STRING ] [ ',' [ IDENT+ | STRING ] ]* | IDENT(inherit) * @@ -390,7 +440,10 @@ css_error parse_font_family(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags = FLAG_INHERIT; } else { uint32_t list_size; @@ -432,7 +485,10 @@ css_error parse_font_family(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { /* Nothing to do */ } else { error = comma_list_to_bytecode(c, vector, ctx, token, @@ -481,6 +537,7 @@ css_error parse_font_size(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(xx-small, x-small, small, medium, * large, x-large, xx-large, larger, smaller, inherit) */ @@ -491,43 +548,73 @@ css_error parse_font_size(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[XX_SMALL]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[XX_SMALL], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_XX_SMALL; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[X_SMALL]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[X_SMALL], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_X_SMALL; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[SMALL]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SMALL], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_SMALL; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[MEDIUM]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MEDIUM], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_MEDIUM; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[LARGE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LARGE], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_LARGE; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[X_LARGE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[X_LARGE], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_X_LARGE; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[XX_LARGE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[XX_LARGE], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_XX_LARGE; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[LARGER]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LARGER], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_LARGER; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[SMALLER]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SMALLER], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = FONT_SIZE_SMALLER; } else { @@ -601,6 +688,7 @@ css_error parse_font_style(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (normal, italic, oblique, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -609,13 +697,25 @@ css_error parse_font_style(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[NORMAL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { value = FONT_STYLE_NORMAL; - } else if (ident->ilower == c->strings[ITALIC]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[ITALIC], + &match) == lwc_error_ok && match)) { value = FONT_STYLE_ITALIC; - } else if (ident->ilower == c->strings[OBLIQUE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[OBLIQUE], + &match) == lwc_error_ok && match)) { value = FONT_STYLE_OBLIQUE; } else { *ctx = orig_ctx; @@ -661,6 +761,7 @@ css_error parse_font_variant(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (normal, small-caps, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -669,11 +770,20 @@ css_error parse_font_variant(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[NORMAL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { value = FONT_VARIANT_NORMAL; - } else if (ident->ilower == c->strings[SMALL_CAPS]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SMALL_CAPS], + &match) == lwc_error_ok && match)) { value = FONT_VARIANT_SMALL_CAPS; } else { *ctx = orig_ctx; @@ -719,6 +829,7 @@ css_error parse_font_weight(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* NUMBER (100, 200, 300, 400, 500, 600, 700, 800, 900) | * IDENT (normal, bold, bolder, lighter, inherit) */ @@ -729,14 +840,17 @@ css_error parse_font_weight(css_language *c, return CSS_INVALID; } - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - css_fixed num = number_from_lwc_string(token->ilower, + css_fixed num = number_from_lwc_string(token->idata, true, &consumed); /* Invalid if there are trailing characters */ - if (consumed != lwc_string_length(token->ilower)) { + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -753,13 +867,25 @@ css_error parse_font_weight(css_language *c, case 900: value = FONT_WEIGHT_900; break; default: *ctx = orig_ctx; return CSS_INVALID; } - } else if (token->ilower == c->strings[NORMAL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { value = FONT_WEIGHT_NORMAL; - } else if (token->ilower == c->strings[BOLD]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[BOLD], + &match) == lwc_error_ok && match)) { value = FONT_WEIGHT_BOLD; - } else if (token->ilower == c->strings[BOLDER]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[BOLDER], + &match) == lwc_error_ok && match)) { value = FONT_WEIGHT_BOLDER; - } else if (token->ilower == c->strings[LIGHTER]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[LIGHTER], + &match) == lwc_error_ok && match)) { value = FONT_WEIGHT_LIGHTER; } else { *ctx = orig_ctx; diff --git a/src/parse/properties/generated_list.c b/src/parse/properties/generated_list.c index 0d9dd7c..0eedd02 100644 --- a/src/parse/properties/generated_list.c +++ b/src/parse/properties/generated_list.c @@ -49,6 +49,7 @@ css_error parse_content(css_language *c, uint32_t required_size = sizeof(opv); int temp_ctx = *ctx; uint8_t *ptr; + bool match; /* IDENT(normal, none, inherit) | * [ @@ -68,15 +69,24 @@ css_error parse_content(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags = FLAG_INHERIT; parserutils_vector_iterate(vector, &temp_ctx); } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NORMAL]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { value = CONTENT_NORMAL; parserutils_vector_iterate(vector, &temp_ctx); } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NONE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = CONTENT_NONE; parserutils_vector_iterate(vector, &temp_ctx); } else { @@ -114,10 +124,19 @@ css_error parse_content(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - (token->ilower == c->strings[INHERIT] || - token->ilower == c->strings[NORMAL] || - token->ilower == c->strings[NONE])) { - parserutils_vector_iterate(vector, ctx); + ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match))) { + parserutils_vector_iterate(vector, ctx); } else { error = parse_content_list(c, vector, ctx, NULL, ptr, NULL); if (error != CSS_OK) { @@ -199,12 +218,16 @@ css_error parse_list_style(css_language *c, css_style *type = NULL; css_style *ret = NULL; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -242,7 +265,10 @@ css_error parse_list_style(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -378,6 +404,7 @@ css_error parse_list_style_image(css_language *c, uint16_t value = 0; uint32_t opv; uint32_t required_size; + bool match; lwc_string *uri = NULL; /* URI | IDENT (none, inherit) */ @@ -389,10 +416,16 @@ css_error parse_list_style_image(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NONE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = LIST_STYLE_IMAGE_NONE; } else if (token->type == CSS_TOKEN_URI) { value = LIST_STYLE_IMAGE_URI; @@ -457,6 +490,7 @@ css_error parse_list_style_position(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (inside, outside, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -465,11 +499,20 @@ css_error parse_list_style_position(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[INSIDE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INSIDE], + &match) == lwc_error_ok && match)) { value = LIST_STYLE_POSITION_INSIDE; - } else if (ident->ilower == c->strings[OUTSIDE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[OUTSIDE], + &match) == lwc_error_ok && match)) { value = LIST_STYLE_POSITION_OUTSIDE; } else { *ctx = orig_ctx; @@ -515,6 +558,7 @@ css_error parse_list_style_type(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (disc, circle, square, decimal, decimal-leading-zero, * lower-roman, upper-roman, lower-greek, lower-latin, @@ -527,7 +571,10 @@ css_error parse_list_style_type(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else { error = parse_list_style_type_value(c, ident, &value); @@ -579,6 +626,7 @@ css_error parse_quotes(css_language *c, uint32_t required_size = sizeof(opv); int temp_ctx = *ctx; uint8_t *ptr; + bool match; /* [ STRING STRING ]+ | IDENT(none,inherit) */ @@ -591,9 +639,15 @@ css_error parse_quotes(css_language *c, } if (token->type == CSS_TOKEN_IDENT) { - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags = FLAG_INHERIT; - } else if (token->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = QUOTES_NONE; } else { *ctx = orig_ctx; @@ -729,40 +783,87 @@ css_error parse_quotes(css_language *c, css_error parse_list_style_type_value(css_language *c, const css_token *ident, uint16_t *value) { + bool match; + /* IDENT (disc, circle, square, decimal, decimal-leading-zero, * lower-roman, upper-roman, lower-greek, lower-latin, * upper-latin, armenian, georgian, lower-alpha, upper-alpha, * none) */ - if (ident->ilower == c->strings[DISC]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[DISC], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_DISC; - } else if (ident->ilower == c->strings[CIRCLE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[CIRCLE], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_CIRCLE; - } else if (ident->ilower == c->strings[SQUARE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SQUARE], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_SQUARE; - } else if (ident->ilower == c->strings[DECIMAL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[DECIMAL], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_DECIMAL; - } else if (ident->ilower == c->strings[DECIMAL_LEADING_ZERO]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[DECIMAL_LEADING_ZERO], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_DECIMAL_LEADING_ZERO; - } else if (ident->ilower == c->strings[LOWER_ROMAN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LOWER_ROMAN], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_LOWER_ROMAN; - } else if (ident->ilower == c->strings[UPPER_ROMAN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[UPPER_ROMAN], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_UPPER_ROMAN; - } else if (ident->ilower == c->strings[LOWER_GREEK]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LOWER_GREEK], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_LOWER_GREEK; - } else if (ident->ilower == c->strings[LOWER_LATIN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LOWER_LATIN], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_LOWER_LATIN; - } else if (ident->ilower == c->strings[UPPER_LATIN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[UPPER_LATIN], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_UPPER_LATIN; - } else if (ident->ilower == c->strings[ARMENIAN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[ARMENIAN], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_ARMENIAN; - } else if (ident->ilower == c->strings[GEORGIAN]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[GEORGIAN], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_GEORGIAN; - } else if (ident->ilower == c->strings[LOWER_ALPHA]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LOWER_ALPHA], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_LOWER_ALPHA; - } else if (ident->ilower == c->strings[UPPER_ALPHA]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[UPPER_ALPHA], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_UPPER_ALPHA; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { *value = LIST_STYLE_TYPE_NONE; } else return CSS_INVALID; @@ -797,6 +898,7 @@ css_error parse_content_list(css_language *c, bool first = true; uint32_t offset = 0; uint32_t opv; + bool match; /* [ * IDENT(open-quote, close-quote, no-open-quote, no-close-quote) | @@ -814,7 +916,10 @@ css_error parse_content_list(css_language *c, while (token != NULL) { if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[OPEN_QUOTE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[OPEN_QUOTE], + &match) == lwc_error_ok && match)) { opv = CONTENT_OPEN_QUOTE; if (first == false) { @@ -826,7 +931,10 @@ css_error parse_content_list(css_language *c, offset += sizeof(opv); } } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[CLOSE_QUOTE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CLOSE_QUOTE], + &match) == lwc_error_ok && match)) { opv = CONTENT_CLOSE_QUOTE; if (first == false) { @@ -838,7 +946,10 @@ css_error parse_content_list(css_language *c, offset += sizeof(opv); } } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NO_OPEN_QUOTE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NO_OPEN_QUOTE], + &match) == lwc_error_ok && match)) { opv = CONTENT_NO_OPEN_QUOTE; if (first == false) { @@ -850,7 +961,10 @@ css_error parse_content_list(css_language *c, offset += sizeof(opv); } } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NO_CLOSE_QUOTE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NO_CLOSE_QUOTE], + &match) == lwc_error_ok && match)) { opv = CONTENT_NO_CLOSE_QUOTE; if (first == false) { @@ -911,7 +1025,10 @@ css_error parse_content_list(css_language *c, offset += sizeof(uri); } else if (token->type == CSS_TOKEN_FUNCTION && - token->ilower == c->strings[ATTR]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[ATTR], + &match) == lwc_error_ok && match)) { opv = CONTENT_ATTR; if (first == false) { @@ -950,7 +1067,10 @@ css_error parse_content_list(css_language *c, return CSS_INVALID; } } else if (token->type == CSS_TOKEN_FUNCTION && - token->ilower == c->strings[COUNTER]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[COUNTER], + &match) == lwc_error_ok && match)) { lwc_string *name; opv = CONTENT_COUNTER; @@ -1033,7 +1153,10 @@ css_error parse_content_list(css_language *c, offset += sizeof(name); } else if (token->type == CSS_TOKEN_FUNCTION && - token->ilower == c->strings[COUNTERS]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[COUNTERS], + &match) == lwc_error_ok && match)) { lwc_string *name; lwc_string *sep; @@ -1209,6 +1332,7 @@ css_error parse_counter_common(css_language *c, uint32_t required_size = sizeof(opv); int temp_ctx = *ctx; uint8_t *ptr; + bool match; /* [IDENT <integer>? ]+ | IDENT(none, inherit) */ @@ -1219,9 +1343,15 @@ css_error parse_counter_common(css_language *c, return CSS_INVALID; } - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags = FLAG_INHERIT; - } else if (token->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = COUNTER_INCREMENT_NONE; } else { bool first = true; @@ -1248,10 +1378,10 @@ css_error parse_counter_common(css_language *c, size_t consumed = 0; increment = number_from_lwc_string( - token->ilower, true, &consumed); + token->idata, true, &consumed); if (consumed != lwc_string_length( - token->ilower)) { + token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -1301,8 +1431,14 @@ css_error parse_counter_common(css_language *c, return CSS_INVALID; } - if (token->ilower == c->strings[INHERIT] || - token->ilower == c->strings[NONE]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match) || + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { /* Nothing to do */ } else { bool first = true; @@ -1329,10 +1465,10 @@ css_error parse_counter_common(css_language *c, size_t consumed = 0; increment = number_from_lwc_string( - token->ilower, true, &consumed); + token->idata, true, &consumed); if (consumed != lwc_string_length( - token->ilower)) { + token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } diff --git a/src/parse/properties/margin.c b/src/parse/properties/margin.c index 3479abf..a0aa6b9 100644 --- a/src/parse/properties/margin.c +++ b/src/parse/properties/margin.c @@ -45,12 +45,16 @@ css_error parse_margin(css_language *c, css_style *ret = NULL; uint32_t num_sides = 0; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -90,7 +94,10 @@ css_error parse_margin(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -372,6 +379,7 @@ css_error parse_margin_side(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(auto, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -381,11 +389,17 @@ css_error parse_margin_side(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[AUTO]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = MARGIN_AUTO; } else { diff --git a/src/parse/properties/padding.c b/src/parse/properties/padding.c index 507159d..3a77c26 100644 --- a/src/parse/properties/padding.c +++ b/src/parse/properties/padding.c @@ -45,12 +45,16 @@ css_error parse_padding(css_language *c, css_style *ret = NULL; uint32_t num_sides = 0; uint32_t required_size; + bool match; css_error error; /* Firstly, handle inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { uint32_t *bytecode; error = css_stylesheet_style_create(c->sheet, @@ -90,7 +94,10 @@ css_error parse_padding(css_language *c, /* Ensure that we're not about to parse another inherit */ token = parserutils_vector_peek(vector, *ctx); if (token != NULL && token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { error = CSS_INVALID; goto cleanup; } @@ -375,6 +382,7 @@ css_error parse_padding_side(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -384,7 +392,10 @@ css_error parse_padding_side(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else { diff --git a/src/parse/properties/page.c b/src/parse/properties/page.c index e2fdcf2..cc2d734 100644 --- a/src/parse/properties/page.c +++ b/src/parse/properties/page.c @@ -38,6 +38,7 @@ css_error parse_orphans(css_language *c, uint32_t opv; css_fixed num = 0; uint32_t required_size; + bool match; /* <integer> | IDENT (inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -47,13 +48,16 @@ css_error parse_orphans(css_language *c, return CSS_INVALID; } - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - num = number_from_lwc_string(token->ilower, true, &consumed); + num = number_from_lwc_string(token->idata, true, &consumed); /* Invalid if there are trailing characters */ - if (consumed != lwc_string_length(token->ilower)) { + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } @@ -117,6 +121,7 @@ css_error parse_page_break_after(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (auto, always, avoid, left, right, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -125,17 +130,35 @@ css_error parse_page_break_after(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[AUTO]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_AFTER_AUTO; - } else if (ident->ilower == c->strings[ALWAYS]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[ALWAYS], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_AFTER_ALWAYS; - } else if (ident->ilower == c->strings[AVOID]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[AVOID], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_AFTER_AVOID; - } else if (ident->ilower == c->strings[LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LEFT], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_AFTER_LEFT; - } else if (ident->ilower == c->strings[RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RIGHT], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_AFTER_RIGHT; } else { *ctx = orig_ctx; @@ -181,6 +204,7 @@ css_error parse_page_break_before(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (auto, always, avoid, left, right, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -189,17 +213,35 @@ css_error parse_page_break_before(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[AUTO]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_BEFORE_AUTO; - } else if (ident->ilower == c->strings[ALWAYS]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[ALWAYS], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_BEFORE_ALWAYS; - } else if (ident->ilower == c->strings[AVOID]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[AVOID], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_BEFORE_AVOID; - } else if (ident->ilower == c->strings[LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LEFT], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_BEFORE_LEFT; - } else if (ident->ilower == c->strings[RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RIGHT], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_BEFORE_RIGHT; } else { *ctx = orig_ctx; @@ -245,6 +287,7 @@ css_error parse_page_break_inside(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (auto, avoid, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -253,11 +296,20 @@ css_error parse_page_break_inside(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[AUTO]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_INSIDE_AUTO; - } else if (ident->ilower == c->strings[AVOID]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[AVOID], + &match) == lwc_error_ok && match)) { value = PAGE_BREAK_INSIDE_AVOID; } else { *ctx = orig_ctx; @@ -305,6 +357,7 @@ css_error parse_widows(css_language *c, uint32_t opv; css_fixed num = 0; uint32_t required_size; + bool match; /* <integer> | IDENT (inherit) */ token = parserutils_vector_iterate(vector, ctx); @@ -314,13 +367,16 @@ css_error parse_widows(css_language *c, return CSS_INVALID; } - if (token->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; } else if (token->type == CSS_TOKEN_NUMBER) { size_t consumed = 0; - num = number_from_lwc_string(token->ilower, true, &consumed); + num = number_from_lwc_string(token->idata, true, &consumed); /* Invalid if there are trailing characters */ - if (consumed != lwc_string_length(token->ilower)) { + if (consumed != lwc_string_length(token->idata)) { *ctx = orig_ctx; return CSS_INVALID; } diff --git a/src/parse/properties/positioning.c b/src/parse/properties/positioning.c index 71b4bab..813b113 100644 --- a/src/parse/properties/positioning.c +++ b/src/parse/properties/positioning.c @@ -124,6 +124,7 @@ css_error parse_position(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (static, relative, absolute, fixed, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -132,15 +133,30 @@ css_error parse_position(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[STATIC]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[STATIC], + &match) == lwc_error_ok && match)) { value = POSITION_STATIC; - } else if (ident->ilower == c->strings[RELATIVE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RELATIVE], + &match) == lwc_error_ok && match)) { value = POSITION_RELATIVE; - } else if (ident->ilower == c->strings[ABSOLUTE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[ABSOLUTE], + &match) == lwc_error_ok && match)) { value = POSITION_ABSOLUTE; - } else if (ident->ilower == c->strings[FIXED]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[FIXED], + &match) == lwc_error_ok && match)) { value = POSITION_FIXED; } else { *ctx = orig_ctx; @@ -186,6 +202,7 @@ css_error parse_clear(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (left, right, both, none, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -194,15 +211,30 @@ css_error parse_clear(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RIGHT], + &match) == lwc_error_ok && match)) { value = CLEAR_RIGHT; - } else if (ident->ilower == c->strings[LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LEFT], + &match) == lwc_error_ok && match)) { value = CLEAR_LEFT; - } else if (ident->ilower == c->strings[BOTH]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[BOTH], + &match) == lwc_error_ok && match)) { value = CLEAR_BOTH; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = CLEAR_NONE; } else { *ctx = orig_ctx; @@ -248,6 +280,7 @@ css_error parse_float(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (left, right, none, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -256,13 +289,25 @@ css_error parse_float(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LEFT], + &match) == lwc_error_ok && match)) { value = FLOAT_LEFT; - } else if (ident->ilower == c->strings[RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RIGHT], + &match) == lwc_error_ok && match)) { value = FLOAT_RIGHT; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = FLOAT_NONE; } else { *ctx = orig_ctx; @@ -311,6 +356,7 @@ css_error parse_vertical_align(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(baseline, sub, super, top, text-top, * middle, bottom, text-bottom, inherit) @@ -322,39 +368,66 @@ css_error parse_vertical_align(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[BASELINE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[BASELINE], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VERTICAL_ALIGN_BASELINE; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[SUB]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SUB], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VERTICAL_ALIGN_SUB; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[SUPER]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SUPER], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VERTICAL_ALIGN_SUPER; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[TOP]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[TOP], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VERTICAL_ALIGN_TOP; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[TEXT_TOP]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[TEXT_TOP], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VERTICAL_ALIGN_TEXT_TOP; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[MIDDLE]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MIDDLE], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VERTICAL_ALIGN_MIDDLE; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[BOTTOM]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[BOTTOM], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VERTICAL_ALIGN_BOTTOM; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[TEXT_BOTTOM]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[TEXT_BOTTOM], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = VERTICAL_ALIGN_TEXT_BOTTOM; } else { @@ -426,6 +499,7 @@ css_error parse_side(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(auto, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -435,11 +509,17 @@ css_error parse_side(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[AUTO]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = BOTTOM_AUTO; } else { diff --git a/src/parse/properties/table.c b/src/parse/properties/table.c index 0e5e270..51f3bdc 100644 --- a/src/parse/properties/table.c +++ b/src/parse/properties/table.c @@ -36,6 +36,7 @@ css_error parse_caption_side(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (top, bottom, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -44,11 +45,20 @@ css_error parse_caption_side(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[TOP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[TOP], + &match) == lwc_error_ok && match)) { value = CAPTION_SIDE_TOP; - } else if (ident->ilower == c->strings[BOTTOM]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[BOTTOM], + &match) == lwc_error_ok && match)) { value = CAPTION_SIDE_BOTTOM; } else { *ctx = orig_ctx; @@ -94,6 +104,7 @@ css_error parse_empty_cells(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (show, hide, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -102,11 +113,20 @@ css_error parse_empty_cells(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[SHOW]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[SHOW], + &match) == lwc_error_ok && match)) { value = EMPTY_CELLS_SHOW; - } else if (ident->ilower == c->strings[HIDE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[HIDE], + &match) == lwc_error_ok && match)) { value = EMPTY_CELLS_HIDE; } else { *ctx = orig_ctx; @@ -152,6 +172,7 @@ css_error parse_table_layout(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (auto, fixed, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -160,11 +181,20 @@ css_error parse_table_layout(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[AUTO]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { value = TABLE_LAYOUT_AUTO; - } else if (ident->ilower == c->strings[FIXED]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[FIXED], + &match) == lwc_error_ok && match)) { value = TABLE_LAYOUT_FIXED; } else { *ctx = orig_ctx; diff --git a/src/parse/properties/text.c b/src/parse/properties/text.c index 58b066e..61ce60b 100644 --- a/src/parse/properties/text.c +++ b/src/parse/properties/text.c @@ -38,6 +38,7 @@ css_error parse_color(css_language *c, uint32_t opv; uint32_t colour = 0; uint32_t required_size; + bool match; /* colour | IDENT (inherit) */ token= parserutils_vector_peek(vector, *ctx); @@ -47,7 +48,10 @@ css_error parse_color(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags |= FLAG_INHERIT; } else { @@ -107,6 +111,7 @@ css_error parse_direction(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (ltr, rtl, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -115,11 +120,20 @@ css_error parse_direction(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[LTR]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LTR], + &match) == lwc_error_ok && match)) { value = DIRECTION_LTR; - } else if (ident->ilower == c->strings[RTL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RTL], + &match) == lwc_error_ok && match)) { value = DIRECTION_RTL; } else { *ctx = orig_ctx; @@ -168,6 +182,7 @@ css_error parse_letter_spacing(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | IDENT(normal, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -177,11 +192,17 @@ css_error parse_letter_spacing(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NORMAL]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = LETTER_SPACING_NORMAL; } else { @@ -250,6 +271,7 @@ css_error parse_text_align(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (left, right, center, justify, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -258,15 +280,30 @@ css_error parse_text_align(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[LEFT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LEFT], + &match) == lwc_error_ok && match)) { value = TEXT_ALIGN_LEFT; - } else if (ident->ilower == c->strings[RIGHT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[RIGHT], + &match) == lwc_error_ok && match)) { value = TEXT_ALIGN_RIGHT; - } else if (ident->ilower == c->strings[CENTER]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[CENTER], + &match) == lwc_error_ok && match)) { value = TEXT_ALIGN_CENTER; - } else if (ident->ilower == c->strings[JUSTIFY]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[JUSTIFY], + &match) == lwc_error_ok && match)) { value = TEXT_ALIGN_JUSTIFY; } else { *ctx = orig_ctx; @@ -312,6 +349,7 @@ css_error parse_text_decoration(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT([ underline || overline || line-through || blink ]) * | IDENT (none, inherit) */ @@ -321,34 +359,52 @@ css_error parse_text_decoration(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = TEXT_DECORATION_NONE; } else { while (ident != NULL) { - if (ident->ilower == c->strings[UNDERLINE]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[UNDERLINE], + &match) == lwc_error_ok && match)) { if ((value & TEXT_DECORATION_UNDERLINE) == 0) value |= TEXT_DECORATION_UNDERLINE; else { *ctx = orig_ctx; return CSS_INVALID; } - } else if (ident->ilower == c->strings[OVERLINE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[OVERLINE], + &match) == lwc_error_ok && match)) { if ((value & TEXT_DECORATION_OVERLINE) == 0) value |= TEXT_DECORATION_OVERLINE; else { *ctx = orig_ctx; return CSS_INVALID; } - } else if (ident->ilower == c->strings[LINE_THROUGH]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LINE_THROUGH], + &match) == lwc_error_ok && match)) { if ((value & TEXT_DECORATION_LINE_THROUGH) == 0) value |= TEXT_DECORATION_LINE_THROUGH; else { *ctx = orig_ctx; return CSS_INVALID; } - } else if (ident->ilower == c->strings[BLINK]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[BLINK], + &match) == lwc_error_ok && match)) { if ((value & TEXT_DECORATION_BLINK) == 0) value |= TEXT_DECORATION_BLINK; else { @@ -411,6 +467,7 @@ css_error parse_text_indent(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | percentage | IDENT(inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -420,7 +477,10 @@ css_error parse_text_indent(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else { @@ -488,6 +548,7 @@ css_error parse_text_transform(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (capitalize, uppercase, lowercase, none, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -496,15 +557,30 @@ css_error parse_text_transform(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[CAPITALIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[CAPITALIZE], + &match) == lwc_error_ok && match)) { value = TEXT_TRANSFORM_CAPITALIZE; - } else if (ident->ilower == c->strings[UPPERCASE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[UPPERCASE], + &match) == lwc_error_ok && match)) { value = TEXT_TRANSFORM_UPPERCASE; - } else if (ident->ilower == c->strings[LOWERCASE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[LOWERCASE], + &match) == lwc_error_ok && match)) { value = TEXT_TRANSFORM_LOWERCASE; - } else if (ident->ilower == c->strings[NONE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NONE], + &match) == lwc_error_ok && match)) { value = TEXT_TRANSFORM_NONE; } else { *ctx = orig_ctx; @@ -550,6 +626,7 @@ css_error parse_unicode_bidi(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (normal, embed, bidi-override, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -558,13 +635,25 @@ css_error parse_unicode_bidi(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[NORMAL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { value = UNICODE_BIDI_NORMAL; - } else if (ident->ilower == c->strings[EMBED]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[EMBED], + &match) == lwc_error_ok && match)) { value = UNICODE_BIDI_EMBED; - } else if (ident->ilower == c->strings[BIDI_OVERRIDE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[BIDI_OVERRIDE], + &match) == lwc_error_ok && match)) { value = UNICODE_BIDI_BIDI_OVERRIDE; } else { *ctx = orig_ctx; @@ -610,6 +699,7 @@ css_error parse_white_space(css_language *c, uint8_t flags = 0; uint16_t value = 0; uint32_t opv; + bool match; /* IDENT (normal, pre, nowrap, pre-wrap, pre-line, inherit) */ ident = parserutils_vector_iterate(vector, ctx); @@ -618,17 +708,35 @@ css_error parse_white_space(css_language *c, return CSS_INVALID; } - if (ident->ilower == c->strings[INHERIT]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags |= FLAG_INHERIT; - } else if (ident->ilower == c->strings[NORMAL]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { value = WHITE_SPACE_NORMAL; - } else if (ident->ilower == c->strings[PRE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[PRE], + &match) == lwc_error_ok && match)) { value = WHITE_SPACE_PRE; - } else if (ident->ilower == c->strings[NOWRAP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[NOWRAP], + &match) == lwc_error_ok && match)) { value = WHITE_SPACE_NOWRAP; - } else if (ident->ilower == c->strings[PRE_WRAP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[PRE_WRAP], + &match) == lwc_error_ok && match)) { value = WHITE_SPACE_PRE_WRAP; - } else if (ident->ilower == c->strings[PRE_LINE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + ident->idata, c->strings[PRE_LINE], + &match) == lwc_error_ok && match)) { value = WHITE_SPACE_PRE_LINE; } else { *ctx = orig_ctx; @@ -677,6 +785,7 @@ css_error parse_word_spacing(css_language *c, css_fixed length = 0; uint32_t unit = 0; uint32_t required_size; + bool match; /* length | IDENT(normal, inherit) */ token = parserutils_vector_peek(vector, *ctx); @@ -686,11 +795,17 @@ css_error parse_word_spacing(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); flags = FLAG_INHERIT; } else if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[NORMAL]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NORMAL], + &match) == lwc_error_ok && match)) { parserutils_vector_iterate(vector, ctx); value = WORD_SPACING_NORMAL; } else { diff --git a/src/parse/properties/ui.c b/src/parse/properties/ui.c index 4a6c34f..93a3c5f 100644 --- a/src/parse/properties/ui.c +++ b/src/parse/properties/ui.c @@ -39,6 +39,7 @@ css_error parse_cursor(css_language *c, uint32_t required_size = sizeof(opv); int temp_ctx = *ctx; uint8_t *ptr; + bool match; /* [ (URI ',')* IDENT(auto, crosshair, default, pointer, move, e-resize, * ne-resize, nw-resize, n-resize, se-resize, sw-resize, @@ -55,7 +56,10 @@ css_error parse_cursor(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { flags = FLAG_INHERIT; } else { bool first = true; @@ -95,71 +99,122 @@ css_error parse_cursor(css_language *c, /* IDENT */ if (token != NULL && token->type == CSS_TOKEN_IDENT) { - if (token->ilower == c->strings[AUTO]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_AUTO; } - } else if (token->ilower == c->strings[CROSSHAIR]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CROSSHAIR], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_CROSSHAIR; } - } else if (token->ilower == c->strings[DEFAULT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[DEFAULT], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_DEFAULT; } - } else if (token->ilower == c->strings[POINTER]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[POINTER], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_POINTER; } - } else if (token->ilower == c->strings[MOVE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MOVE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_MOVE; } - } else if (token->ilower == c->strings[E_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[E_RESIZE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_E_RESIZE; } - } else if (token->ilower == c->strings[NE_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NE_RESIZE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_NE_RESIZE; } - } else if (token->ilower == c->strings[NW_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NW_RESIZE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_NW_RESIZE; } - } else if (token->ilower == c->strings[N_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[N_RESIZE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_N_RESIZE; } - } else if (token->ilower == c->strings[SE_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SE_RESIZE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_SE_RESIZE; } - } else if (token->ilower == c->strings[SW_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SW_RESIZE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_SW_RESIZE; } - } else if (token->ilower == c->strings[S_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[S_RESIZE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_S_RESIZE; } - } else if (token->ilower == c->strings[W_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[W_RESIZE], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_W_RESIZE; } - } else if (token->ilower == c->strings[TEXT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[TEXT], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_TEXT; } - } else if (token->ilower == c->strings[WAIT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[WAIT], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_WAIT; } - } else if (token->ilower == c->strings[HELP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[HELP], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_HELP; } - } else if (token->ilower == c->strings[PROGRESS]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[PROGRESS], + &match) == lwc_error_ok && match)) { if (first) { value = CURSOR_PROGRESS; } @@ -197,7 +252,10 @@ css_error parse_cursor(css_language *c, } if (token->type == CSS_TOKEN_IDENT && - token->ilower == c->strings[INHERIT]) { + (lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[INHERIT], + &match) == lwc_error_ok && match)) { /* Nothing to do */ } else { bool first = true; @@ -249,39 +307,90 @@ css_error parse_cursor(css_language *c, /* IDENT */ if (token != NULL && token->type == CSS_TOKEN_IDENT) { - if (token->ilower == c->strings[AUTO]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[AUTO], + &match) == lwc_error_ok && match)) { opv = CURSOR_AUTO; - } else if (token->ilower == c->strings[CROSSHAIR]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[CROSSHAIR], + &match) == lwc_error_ok && match)) { opv = CURSOR_CROSSHAIR; - } else if (token->ilower == c->strings[DEFAULT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[DEFAULT], + &match) == lwc_error_ok && match)) { opv = CURSOR_DEFAULT; - } else if (token->ilower == c->strings[POINTER]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[POINTER], + &match) == lwc_error_ok && match)) { opv = CURSOR_POINTER; - } else if (token->ilower == c->strings[MOVE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[MOVE], + &match) == lwc_error_ok && match)) { opv = CURSOR_MOVE; - } else if (token->ilower == c->strings[E_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[E_RESIZE], + &match) == lwc_error_ok && match)) { opv = CURSOR_E_RESIZE; - } else if (token->ilower == c->strings[NE_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NE_RESIZE], + &match) == lwc_error_ok && match)) { opv = CURSOR_NE_RESIZE; - } else if (token->ilower == c->strings[NW_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[NW_RESIZE], + &match) == lwc_error_ok && match)) { opv = CURSOR_NW_RESIZE; - } else if (token->ilower == c->strings[N_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[N_RESIZE], + &match) == lwc_error_ok && match)) { opv = CURSOR_N_RESIZE; - } else if (token->ilower == c->strings[SE_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SE_RESIZE], + &match) == lwc_error_ok && match)) { opv = CURSOR_SE_RESIZE; - } else if (token->ilower == c->strings[SW_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[SW_RESIZE], + &match) == lwc_error_ok && match)) { opv = CURSOR_SW_RESIZE; - } else if (token->ilower == c->strings[S_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[S_RESIZE], + &match) == lwc_error_ok && match)) { opv = CURSOR_S_RESIZE; - } else if (token->ilower == c->strings[W_RESIZE]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[W_RESIZE], + &match) == lwc_error_ok && match)) { opv = CURSOR_W_RESIZE; - } else if (token->ilower == c->strings[TEXT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[TEXT], + &match) == lwc_error_ok && match)) { opv = CURSOR_TEXT; - } else if (token->ilower == c->strings[WAIT]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[WAIT], + &match) == lwc_error_ok && match)) { opv = CURSOR_WAIT; - } else if (token->ilower == c->strings[HELP]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[HELP], + &match) == lwc_error_ok && match)) { opv = CURSOR_HELP; - } else if (token->ilower == c->strings[PROGRESS]) { + } else if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[PROGRESS], + &match) == lwc_error_ok && match)) { opv = CURSOR_PROGRESS; } else { *ctx = orig_ctx; diff --git a/src/parse/properties/utils.c b/src/parse/properties/utils.c index 8047040..c93a3fc 100644 --- a/src/parse/properties/utils.c +++ b/src/parse/properties/utils.c @@ -32,6 +32,7 @@ css_error parse_colour_specifier(css_language *c, int orig_ctx = *ctx; const css_token *token; uint8_t r = 0, g = 0, b = 0; + bool match; css_error error; consumeWhitespace(vector, ctx); @@ -54,7 +55,7 @@ css_error parse_colour_specifier(css_language *c, } if (token->type == CSS_TOKEN_IDENT) { - error = parse_named_colour(c, token->ilower, result); + error = parse_named_colour(c, token->idata, result); if (error != CSS_OK && c->sheet->quirks_allowed) { error = parse_hash_colour(token->idata, result); if (error == CSS_OK) @@ -90,7 +91,10 @@ css_error parse_colour_specifier(css_language *c, return error; } else if (token->type == CSS_TOKEN_FUNCTION) { - if (token->ilower == c->strings[RGB]) { + if ((lwc_context_string_caseless_isequal( + c->sheet->dictionary, + token->idata, c->strings[RGB], + &match) == lwc_error_ok && match)) { int i; css_token_type valid = CSS_TOKEN_NUMBER; @@ -329,9 +333,12 @@ css_error parse_named_colour(css_language *c, lwc_string *data, 0x9acd3200 /* YELLOWGREEN */ }; int i; + bool match; for (i = FIRST_COLOUR; i <= LAST_COLOUR; i++) { - if (data == c->strings[i]) + if (lwc_context_string_caseless_isequal(c->sheet->dictionary, + data, c->strings[i], &match) == lwc_error_ok && + match) break; } if (i == LAST_COLOUR + 1) |