From 2fcb157f28b152ba32e89baddbd811b0d6e76b79 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Mon, 4 Sep 2017 14:56:51 +0100 Subject: Strip trailing whitespace. --- src/bytecode/bytecode.h | 2 +- src/charset/detect.c | 50 ++-- src/lex/lex.c | 208 +++++++-------- src/lex/lex.h | 24 +- src/parse/font_face.c | 120 ++++----- src/parse/important.c | 24 +- src/parse/language.c | 244 +++++++++--------- src/parse/language.h | 2 +- src/parse/parse.c | 206 +++++++-------- src/parse/parse.h | 8 +- src/parse/properties/azimuth.c | 16 +- src/parse/properties/background.c | 44 ++-- src/parse/properties/background_position.c | 42 +-- src/parse/properties/border.c | 6 +- src/parse/properties/border_color.c | 16 +- src/parse/properties/border_spacing.c | 22 +- src/parse/properties/border_style.c | 24 +- src/parse/properties/border_width.c | 16 +- src/parse/properties/clip.c | 26 +- src/parse/properties/content.c | 6 +- src/parse/properties/css_property_parser_gen.c | 26 +- src/parse/properties/cue.c | 8 +- src/parse/properties/cursor.c | 14 +- src/parse/properties/elevation.c | 4 +- src/parse/properties/font.c | 70 ++--- src/parse/properties/font_family.c | 8 +- src/parse/properties/font_weight.c | 12 +- src/parse/properties/list_style.c | 30 +-- src/parse/properties/list_style_type.c | 8 +- src/parse/properties/margin.c | 16 +- src/parse/properties/opacity.c | 2 +- src/parse/properties/outline.c | 32 +-- src/parse/properties/padding.c | 18 +- src/parse/properties/pause.c | 2 +- src/parse/properties/play_during.c | 18 +- src/parse/properties/properties.h | 222 ++++++++-------- src/parse/properties/quotes.c | 22 +- src/parse/properties/text_decoration.c | 4 +- src/parse/properties/utils.c | 58 ++--- src/parse/properties/utils.h | 8 +- src/parse/properties/voice_family.c | 6 +- src/parse/propstrings.h | 42 +-- src/select/computed.c | 70 ++--- src/select/computed.h | 8 +- src/select/dispatch.h | 4 +- src/select/font_face.c | 46 ++-- src/select/font_face.h | 2 +- src/select/hash.c | 8 +- src/select/properties/azimuth.c | 4 +- src/select/properties/background_attachment.c | 6 +- src/select/properties/background_color.c | 6 +- src/select/properties/background_image.c | 6 +- src/select/properties/background_position.c | 12 +- src/select/properties/background_repeat.c | 6 +- src/select/properties/border_bottom_color.c | 6 +- src/select/properties/border_bottom_style.c | 4 +- src/select/properties/border_bottom_width.c | 4 +- src/select/properties/border_collapse.c | 6 +- src/select/properties/border_left_color.c | 8 +- src/select/properties/border_left_style.c | 4 +- src/select/properties/border_left_width.c | 4 +- src/select/properties/border_right_color.c | 8 +- src/select/properties/border_right_style.c | 4 +- src/select/properties/border_right_width.c | 4 +- src/select/properties/border_spacing.c | 10 +- src/select/properties/border_top_color.c | 4 +- src/select/properties/border_top_style.c | 4 +- src/select/properties/border_top_width.c | 8 +- src/select/properties/bottom.c | 6 +- src/select/properties/box_sizing.c | 2 +- src/select/properties/break_after.c | 2 +- src/select/properties/break_before.c | 2 +- src/select/properties/break_inside.c | 2 +- src/select/properties/caption_side.c | 6 +- src/select/properties/clear.c | 4 +- src/select/properties/clip.c | 10 +- src/select/properties/color.c | 8 +- src/select/properties/column_count.c | 4 +- src/select/properties/column_fill.c | 2 +- src/select/properties/column_gap.c | 2 +- src/select/properties/column_rule_color.c | 2 +- src/select/properties/column_rule_style.c | 2 +- src/select/properties/column_rule_width.c | 2 +- src/select/properties/content.c | 16 +- src/select/properties/counter_increment.c | 16 +- src/select/properties/counter_reset.c | 8 +- src/select/properties/cue_after.c | 2 +- src/select/properties/cue_before.c | 2 +- src/select/properties/cursor.c | 14 +- src/select/properties/direction.c | 2 +- src/select/properties/display.c | 2 +- src/select/properties/elevation.c | 4 +- src/select/properties/empty_cells.c | 2 +- src/select/properties/float.c | 2 +- src/select/properties/font_family.c | 22 +- src/select/properties/font_size.c | 8 +- src/select/properties/font_style.c | 4 +- src/select/properties/font_variant.c | 2 +- src/select/properties/font_weight.c | 2 +- src/select/properties/height.c | 2 +- src/select/properties/helpers.c | 28 +- src/select/properties/helpers.h | 12 +- src/select/properties/left.c | 2 +- src/select/properties/letter_spacing.c | 4 +- src/select/properties/line_height.c | 4 +- src/select/properties/list_style_image.c | 4 +- src/select/properties/list_style_position.c | 4 +- src/select/properties/list_style_type.c | 2 +- src/select/properties/margin_bottom.c | 2 +- src/select/properties/margin_left.c | 2 +- src/select/properties/margin_right.c | 2 +- src/select/properties/margin_top.c | 2 +- src/select/properties/max_height.c | 4 +- src/select/properties/max_width.c | 2 +- src/select/properties/min_height.c | 4 +- src/select/properties/min_width.c | 2 +- src/select/properties/opacity.c | 2 +- src/select/properties/orphans.c | 6 +- src/select/properties/outline_color.c | 2 +- src/select/properties/outline_style.c | 2 +- src/select/properties/outline_width.c | 2 +- src/select/properties/overflow_x.c | 2 +- src/select/properties/overflow_y.c | 2 +- src/select/properties/padding_bottom.c | 4 +- src/select/properties/padding_left.c | 2 +- src/select/properties/padding_right.c | 4 +- src/select/properties/padding_top.c | 2 +- src/select/properties/page_break_after.c | 2 +- src/select/properties/page_break_before.c | 10 +- src/select/properties/page_break_inside.c | 8 +- src/select/properties/pause_after.c | 2 +- src/select/properties/pause_before.c | 2 +- src/select/properties/pitch.c | 2 +- src/select/properties/pitch_range.c | 2 +- src/select/properties/play_during.c | 2 +- src/select/properties/position.c | 2 +- src/select/properties/quotes.c | 8 +- src/select/properties/richness.c | 2 +- src/select/properties/right.c | 2 +- src/select/properties/speak.c | 2 +- src/select/properties/speak_header.c | 2 +- src/select/properties/speak_numeral.c | 2 +- src/select/properties/speak_punctuation.c | 2 +- src/select/properties/speech_rate.c | 2 +- src/select/properties/stress.c | 2 +- src/select/properties/table_layout.c | 2 +- src/select/properties/text_align.c | 8 +- src/select/properties/text_decoration.c | 6 +- src/select/properties/text_indent.c | 4 +- src/select/properties/text_transform.c | 6 +- src/select/properties/top.c | 2 +- src/select/properties/unicode_bidi.c | 4 +- src/select/properties/vertical_align.c | 2 +- src/select/properties/visibility.c | 4 +- src/select/properties/voice_family.c | 4 +- src/select/properties/volume.c | 2 +- src/select/properties/white_space.c | 4 +- src/select/properties/widows.c | 6 +- src/select/properties/width.c | 2 +- src/select/properties/word_spacing.c | 4 +- src/select/properties/writing_mode.c | 6 +- src/select/properties/z_index.c | 2 +- src/select/select.c | 338 ++++++++++++------------- src/stylesheet.c | 114 ++++----- src/stylesheet.h | 38 +-- src/utils/parserutilserror.h | 2 +- src/utils/utils.c | 4 +- 167 files changed, 1444 insertions(+), 1444 deletions(-) (limited to 'src') diff --git a/src/bytecode/bytecode.h b/src/bytecode/bytecode.h index 4ac3dfb..656d7a5 100644 --- a/src/bytecode/bytecode.h +++ b/src/bytecode/bytecode.h @@ -14,7 +14,7 @@ #include #include -typedef uint32_t css_code_t; +typedef uint32_t css_code_t; typedef enum css_properties_e opcode_t; diff --git a/src/charset/detect.c b/src/charset/detect.c index a6b2346..23c1bf9 100644 --- a/src/charset/detect.c +++ b/src/charset/detect.c @@ -13,13 +13,13 @@ #include "charset/detect.h" #include "utils/utils.h" -static parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, +static parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, size_t len, uint16_t *mibenum); -static parserutils_error try_utf32_charset(const uint8_t *data, +static parserutils_error try_utf32_charset(const uint8_t *data, size_t len, uint16_t *result); -static parserutils_error try_utf16_charset(const uint8_t *data, +static parserutils_error try_utf16_charset(const uint8_t *data, size_t len, uint16_t *result); -static parserutils_error try_ascii_compatible_charset(const uint8_t *data, +static parserutils_error try_ascii_compatible_charset(const uint8_t *data, size_t len, uint16_t *result); /** @@ -60,7 +60,7 @@ parserutils_error css__charset_extract(const uint8_t *data, size_t len, return PARSERUTILS_OK; } - /* If we've already got a charset from the linking mechanism or + /* If we've already got a charset from the linking mechanism or * referring document, then we've nothing further to do */ if (*source != CSS_CHARSET_DEFAULT) return PARSERUTILS_OK; @@ -84,7 +84,7 @@ parserutils_error css__charset_extract(const uint8_t *data, size_t len, * \param mibenum Pointer to location to receive MIB enum * \return PARSERUTILS_OK on success, appropriate error otherwise */ -parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, +parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, size_t len, uint16_t *mibenum) { parserutils_error error; @@ -99,30 +99,30 @@ parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, /* Look for BOM */ - if (data[0] == 0x00 && data[1] == 0x00 && + if (data[0] == 0x00 && data[1] == 0x00 && data[2] == 0xFE && data[3] == 0xFF) { - charset = parserutils_charset_mibenum_from_name("UTF-32BE", + charset = parserutils_charset_mibenum_from_name("UTF-32BE", SLEN("UTF-32BE")); } else if (data[0] == 0xFF && data[1] == 0xFE && data[2] == 0x00 && data[3] == 0x00) { - charset = parserutils_charset_mibenum_from_name("UTF-32LE", + charset = parserutils_charset_mibenum_from_name("UTF-32LE", SLEN("UTF-32LE")); } else if (data[0] == 0xFE && data[1] == 0xFF) { - charset = parserutils_charset_mibenum_from_name("UTF-16BE", + charset = parserutils_charset_mibenum_from_name("UTF-16BE", SLEN("UTF-16BE")); } else if (data[0] == 0xFF && data[1] == 0xFE) { - charset = parserutils_charset_mibenum_from_name("UTF-16LE", + charset = parserutils_charset_mibenum_from_name("UTF-16LE", SLEN("UTF-16LE")); } else if (data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF) { - charset = parserutils_charset_mibenum_from_name("UTF-8", + charset = parserutils_charset_mibenum_from_name("UTF-8", SLEN("UTF-8")); } /* BOM beats @charset. - * UAs differ here, but none appear to match the spec. - * The spec indicates that any @charset present in conjunction with a - * BOM, should match the BOM. In reality, it appears UAs just take the - * BOM as gospel and ignore any @charset rule. The w3c CSS validator + * UAs differ here, but none appear to match the spec. + * The spec indicates that any @charset present in conjunction with a + * BOM, should match the BOM. In reality, it appears UAs just take the + * BOM as gospel and ignore any @charset rule. The w3c CSS validator * appears to do the same (at the least, it doesn't complain about a * mismatch). */ @@ -150,7 +150,7 @@ parserutils_error css_charset_read_bom_or_charset(const uint8_t *data, return PARSERUTILS_OK; } -static parserutils_error try_utf32_charset(const uint8_t *data, +static parserutils_error try_utf32_charset(const uint8_t *data, size_t len, uint16_t *result) { uint16_t charset = 0; @@ -170,7 +170,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, /* Look for "; at end of charset declaration */ for (end = start; end < data + len - 4; end += 4) { - uint32_t c = end[0] | (end[1] << 8) | + uint32_t c = end[0] | (end[1] << 8) | (end[2] << 16) | (end[3] << 24); /* Bail if non-ASCII */ @@ -202,7 +202,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, } /* Ensure we have something that looks like UTF-32(LE)? */ - if ((ptr - buf == SLEN("UTF-32LE") && + if ((ptr - buf == SLEN("UTF-32LE") && memcmp(buf, "UTF-32LE", ptr - buf) == 0) || (ptr - buf == SLEN("UTF-32") && memcmp(buf, "UTF-32", ptr - buf) == 0)) { @@ -218,7 +218,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, /* Look for "; at end of charset declaration */ for (end = start; end < data + len - 4; end += 4) { - uint32_t c = end[3] | (end[2] << 8) | + uint32_t c = end[3] | (end[2] << 8) | (end[1] << 16) | (end[0] << 24); /* Bail if non-ASCII */ @@ -250,7 +250,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, } /* Ensure we have something that looks like UTF-32(BE)? */ - if ((ptr - buf == SLEN("UTF-32BE") && + if ((ptr - buf == SLEN("UTF-32BE") && memcmp(buf, "UTF-32BE", ptr - buf) == 0) || (ptr - buf == SLEN("UTF-32") && memcmp(buf, "UTF-32", ptr - buf) == 0)) { @@ -268,7 +268,7 @@ static parserutils_error try_utf32_charset(const uint8_t *data, return PARSERUTILS_OK; } -static parserutils_error try_utf16_charset(const uint8_t *data, +static parserutils_error try_utf16_charset(const uint8_t *data, size_t len, uint16_t *result) { uint16_t charset = 0; @@ -318,7 +318,7 @@ static parserutils_error try_utf16_charset(const uint8_t *data, } /* Ensure we have something that looks like UTF-16(LE)? */ - if ((ptr - buf == SLEN("UTF-16LE") && + if ((ptr - buf == SLEN("UTF-16LE") && memcmp(buf, "UTF-16LE", ptr - buf) == 0) || (ptr - buf == SLEN("UTF-16") && memcmp(buf, "UTF-16", ptr - buf) == 0)) { @@ -364,7 +364,7 @@ static parserutils_error try_utf16_charset(const uint8_t *data, } /* Ensure we have something that looks like UTF-16(BE)? */ - if ((ptr - buf == SLEN("UTF-16BE") && + if ((ptr - buf == SLEN("UTF-16BE") && memcmp(buf, "UTF-16BE", ptr - buf) == 0) || (ptr - buf == SLEN("UTF-16") && memcmp(buf, "UTF-16", ptr - buf) == 0)) { @@ -399,7 +399,7 @@ parserutils_error try_ascii_compatible_charset(const uint8_t *data, size_t len, /* Look for "; at end of charset declaration */ for (end = start; end < data + len; end++) { - if (*end == '"' && end < data + len - 1 && + if (*end == '"' && end < data + len - 1 && *(end + 1) == ';') break; } diff --git a/src/lex/lex.c b/src/lex/lex.c index 0f956db..2be1145 100644 --- a/src/lex/lex.c +++ b/src/lex/lex.c @@ -6,7 +6,7 @@ */ /** \file CSS lexer - * + * * See docs/Tokens for the production rules used by this lexer. * * See docs/Lexer for the inferred first characters for each token. @@ -36,15 +36,15 @@ #include "utils/parserutilserror.h" #include "utils/utils.h" -/** \todo Optimisation -- we're currently revisiting a bunch of input - * characters (Currently, we're calling parserutils_inputstream_peek - * about 1.5x the number of characters in the input stream). Ideally, - * we'll visit each character in the input exactly once. In reality, - * the upper bound is twice, due to the need, in some cases, to read - * one character beyond the end of a token's input to detect the end - * of the token. Resumability adds a little overhead here, unless - * we're somewhat more clever when it comes to having support for - * restarting mid-escape sequence. Currently, we rewind back to the +/** \todo Optimisation -- we're currently revisiting a bunch of input + * characters (Currently, we're calling parserutils_inputstream_peek + * about 1.5x the number of characters in the input stream). Ideally, + * we'll visit each character in the input exactly once. In reality, + * the upper bound is twice, due to the need, in some cases, to read + * one character beyond the end of a token's input to detect the end + * of the token. Resumability adds a little overhead here, unless + * we're somewhat more clever when it comes to having support for + * restarting mid-escape sequence. Currently, we rewind back to the * start of the sequence and process the whole thing again. */ @@ -53,17 +53,17 @@ enum { sATKEYWORD = 1, sSTRING = 2, sHASH = 3, - sNUMBER = 4, + sNUMBER = 4, sCDO = 5, sCDC = 6, sS = 7, sCOMMENT = 8, - sMATCH = 9, + sMATCH = 9, sURI = 10, sIDENT = 11, sESCAPEDIDENT = 12, sURL = 13, - sUCR = 14 + sUCR = 14 }; /** @@ -73,16 +73,16 @@ struct css_lexer { parserutils_inputstream *input; /**< Inputstream containing CSS */ - size_t bytesReadForToken; /**< Total bytes read from the + size_t bytesReadForToken; /**< Total bytes read from the * inputstream for the current token */ css_token token; /**< The current token */ - bool escapeSeen; /**< Whether an escape sequence has + bool escapeSeen; /**< Whether an escape sequence has * been seen while processing the input * for the current token */ - parserutils_buffer *unescapedTokenData; /**< Buffer containing - * unescaped token data + parserutils_buffer *unescapedTokenData; /**< Buffer containing + * unescaped token data * (used iff escapeSeen == true) */ @@ -91,13 +91,13 @@ struct css_lexer struct { uint8_t first; /**< First character read for token */ - size_t origBytes; /**< Storage of current number of + size_t origBytes; /**< Storage of current number of * bytes read, for rewinding */ - bool lastWasStar; /**< Whether the previous character + bool lastWasStar; /**< Whether the previous character * was an asterisk */ bool lastWasCR; /**< Whether the previous character * was CR */ - size_t bytesForURL; /**< Input bytes read for "url(", for + size_t bytesForURL; /**< Input bytes read for "url(", for * rewinding */ size_t dataLenForURL; /**< Output length for "url(", for * rewinding */ @@ -121,7 +121,7 @@ do { \ (lexer)->currentCol += (len); \ } while(0) \ -static css_error appendToTokenData(css_lexer *lexer, +static css_error appendToTokenData(css_lexer *lexer, const uint8_t *data, size_t len); static css_error emitToken(css_lexer *lexer, css_token_type type, css_token **token); @@ -287,7 +287,7 @@ css_error css__lexer_get_token(css_lexer *lexer, css_token **token) return S(lexer, token); case sCOMMENT: error = Comment(lexer, token); - if (!lexer->emit_comments && error == CSS_OK && + if (!lexer->emit_comments && error == CSS_OK && (*token)->type == CSS_TOKEN_COMMENT) goto start; return error; @@ -324,7 +324,7 @@ css_error css__lexer_get_token(css_lexer *lexer, css_token **token) * \return CSS_OK on success, appropriate error otherwise * * This should not be called directly without good reason. Use the APPEND() - * macro instead. + * macro instead. */ css_error appendToTokenData(css_lexer *lexer, const uint8_t *data, size_t len) { @@ -358,16 +358,16 @@ css_error emitToken(css_lexer *lexer, css_token_type type, t->type = type; - /* Calculate token data start pointer. We have to do this here as + /* Calculate token data start pointer. We have to do this here as * the inputstream's buffer may have moved under us. */ if (lexer->escapeSeen) { t->data.data = lexer->unescapedTokenData->data; } else { size_t clen; const uint8_t *data; - parserutils_error error; + parserutils_error error; - error = parserutils_inputstream_peek(lexer->input, 0, + error = parserutils_inputstream_peek(lexer->input, 0, &data, &clen); #ifndef NDEBUG @@ -439,7 +439,7 @@ css_error emitToken(css_lexer *lexer, css_token_type type, } /* Strip any trailing quote */ - if (t->data.len > 0 && (t->data.data[t->data.len - 1] == '"' || + if (t->data.len > 0 && (t->data.data[t->data.len - 1] == '"' || t->data.data[t->data.len - 1] == '\'')) { t->data.len -= 1; } @@ -487,14 +487,14 @@ css_error AtKeyword(css_lexer *lexer, css_token **token) parserutils_error perror; enum { Initial = 0, Escape = 1, NMChar = 2 }; - /* ATKEYWORD = '@' ident - * + /* ATKEYWORD = '@' ident + * * The '@' has been consumed. */ switch (lexer->substate) { case Initial: - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -561,15 +561,15 @@ css_error CDCOrIdentOrFunctionOrNPD(css_lexer *lexer, css_token **token) * PERCENTAGE = num '%' * DIMENSION = num ident * - * The first dash has been consumed. Thus, we must consume the next - * character in the stream. If it's a dash, then we're dealing with - * CDC. If it's a digit or dot, then we're dealing with NPD. + * The first dash has been consumed. Thus, we must consume the next + * character in the stream. If it's a dash, then we're dealing with + * CDC. If it's a digit or dot, then we're dealing with NPD. * Otherwise, we're dealing with IDENT/FUNCTION. */ switch (lexer->substate) { case Initial: - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -617,7 +617,7 @@ css_error CDCOrIdentOrFunctionOrNPD(css_lexer *lexer, css_token **token) lexer->substate = Gt; /* Ok, so we're dealing with CDC. Expect a '>' */ - perror = parserutils_inputstream_peek(lexer->input, + perror = parserutils_inputstream_peek(lexer->input, lexer->bytesReadForToken, &cptr, &clen); if (perror != PARSERUTILS_OK && perror != PARSERUTILS_EOF) return css_error_from_parserutils_error(perror); @@ -677,14 +677,14 @@ css_error CDO(css_lexer *lexer, css_token **token) enum { Initial = 0, Dash1 = 1, Dash2 = 2 }; /* CDO = "