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. --- README | 8 +- build/mkprops.pl | 10 +- docs/API | 6 +- docs/Bytecode | 54 ++-- docs/Grammar | 66 ++--- docs/Representation | 2 +- docs/Tokens | 8 +- examples/example1.c | 14 +- include/libcss/font_face.h | 24 +- include/libcss/fpmath.h | 36 +-- include/libcss/select.h | 12 +- include/libcss/stylesheet.h | 8 +- 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 +- test/README | 20 +- test/css21.c | 8 +- test/dump.h | 116 ++++----- test/dump_computed.h | 16 +- test/lex-auto.c | 22 +- test/lex.c | 30 +-- test/number.c | 8 +- test/parse-auto.c | 60 ++--- test/parse.c | 6 +- test/parse2-auto.c | 18 +- test/select.c | 140 +++++----- 190 files changed, 1790 insertions(+), 1790 deletions(-) diff --git a/README b/README index 1318506..ea20b12 100644 --- a/README +++ b/README @@ -32,15 +32,15 @@ Compilation Verification ------------ - To verify that the parser is working, it is necessary to specify a + To verify that the parser is working, it is necessary to specify a different makefile target than that used for normal compilation, thus: - + $ make test API documentation ----------------- - Currently, there is none. However, the code is well commented and the - public API may be found in the "include" directory. The testcase sources + Currently, there is none. However, the code is well commented and the + public API may be found in the "include" directory. The testcase sources may also be of use in working out how to use it. diff --git a/build/mkprops.pl b/build/mkprops.pl index 5464053..33fb0f8 100755 --- a/build/mkprops.pl +++ b/build/mkprops.pl @@ -24,7 +24,7 @@ EOF foreach my $prop (@PROPS) { print <. +CSS dimensions are stored as two 32bit values: . Length is a 32bit numeric value (as described above) and unit is as follows: bit 8 clear => length unit @@ -160,7 +160,7 @@ Opcodes 04 - background-position (14bits) : bits 8-13: MBZ - bits 0-7 : + bits 0-7 : bit 7: set => percentage or length unit follows bits 4-6: MBZ clear => keywords: @@ -251,7 +251,7 @@ Opcodes 14 - bottom (14bits) : bits 8-13: MBZ - bits 0-7: + bits 0-7: bit 7 set => length/percentage follows bits 0-6: MBZ bit 7 clear => keywords: @@ -275,7 +275,7 @@ Opcodes 17 - clip (14bits) : bits 8-13: MBZ - bits 0-7: + bits 0-7: bit 7 set => shape follows bits 0-2: 000 => rect, bit 3 => top auto @@ -284,19 +284,19 @@ Opcodes bit 6 => left auto other => rffe. bits 3-6: MBZ. - + bit 7 clear => keywords: bits 0-6: 0000000 => auto, other => rffe. If the value is rect(top, right, bottom, left), then bits 3-6 encode - which of , , , is set to auto. The + which of , , , is set to auto. The subsequent parameter list is then 4 - entries long. - Each entry is a dimension. Entries are always ordered top, right, + Each entry is a dimension. Entries are always ordered top, right, bottom, left. For example, - clip: rect(10px, auto, auto, 10px) + clip: rect(10px, auto, auto, 10px) would produce the following bytecode: <02c00017> <00002800> <00000000> <00002800> <00000000> @@ -304,7 +304,7 @@ Opcodes 18 - color (14bits) : bits 8-13: MBZ - bits 0-7: + bits 0-7: bit 7: set => colour follows. bits 0-6: MBZ. clear => keywords: @@ -341,8 +341,8 @@ Opcodes declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "normal"). - For example, - content: open-quote url('http://example.com/') + For example, + content: open-quote url('http://example.com/') " : " attr(name) " " counter(x) "." counters(y, ".") close-quote;" would result in the following bytecode: @@ -351,9 +351,9 @@ Opcodes <00000081> <00000080> <00000084> - <00000080> + <00000080> <00000382> - <00000080> + <00000080> <00000383> <00000003> <00000000> @@ -368,8 +368,8 @@ Opcodes bits 0-6: 0000000 => none, other => rffe. - If the value is not "none", or "inherit", then there is a parameter - list. Each item is preceded by a word which declares the type + If the value is not "none", or "inherit", then there is a parameter + list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "none"). @@ -384,8 +384,8 @@ Opcodes bits 0-6: 0000000 => none, other => rffe. - If the value is not "none", or "inherit", then there is a parameter - list. Each item is preceded by a word which declares the type + If the value is not "none", or "inherit", then there is a parameter + list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits set to zero (the encoding for "none"). @@ -435,7 +435,7 @@ Opcodes 0010000 => progress, other => rffe. - If the value indicates that a uri is present, then there is a + If the value indicates that a uri is present, then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with bit 7 clear. @@ -499,7 +499,7 @@ Opcodes bits 0-7 : bit 7 set => data follows bits 1-6: MBZ - bit 0 : clear => string, + bit 0 : clear => string, set => ident list (as string) bit 7 clear => keywords: bits 0-6: 0000000 => Reserved. @@ -510,8 +510,8 @@ Opcodes 0000101 => monospace, other => rffe. - In all cases, there is a parameter list. Each item is preceded by a - word which declares the type of the next item. The list is + In all cases, there is a parameter list. Each item is preceded by a + word which declares the type of the next item. The list is terminated by a word with all bits clear. 25 - font-size @@ -855,7 +855,7 @@ Opcodes bits 0-6: 0000000 => none, other => rffe. - If the value indicates that strings are present, then there is a + If the value indicates that strings are present, then there is a parameter list. Each item is preceded by a word which declares the type of the next item. The list is terminated by a word with all bits clear (the encoding for "none"). @@ -954,7 +954,7 @@ Opcodes otherwise: bits 4-7: MBZ bit 3: set => blink, clear => no blink - bit 2: set => line-through, + bit 2: set => line-through, clear => no line-through bit 1: set => overline, clear => no overline bit 0: set => underline, clear => no underline @@ -1023,7 +1023,7 @@ Opcodes bits 0-7 : bit 7 set => data follows bits 1-6: MBZ - bit 0 : clear => string, + bit 0 : clear => string, set => ident list (as string) bit 7 clear => keywords: bits 0-6: 0000000 => Reserved. @@ -1032,10 +1032,10 @@ Opcodes 0000011 => child, other => rffe. - In all cases, there is a parameter list. Each item is preceded by a - word which declares the type of the next item. The list is + In all cases, there is a parameter list. Each item is preceded by a + word which declares the type of the next item. The list is terminated by a word with all bits clear. - + 5d - volume (14bits) : bits 8-13: MBZ diff --git a/docs/Grammar b/docs/Grammar index 0fd27d3..c3d24b4 100644 --- a/docs/Grammar +++ b/docs/Grammar @@ -86,16 +86,16 @@ Differences from the specification 1) The start non-terminal has been introduced. It eats any leading whitespace and handles EOF. 2) The "stylesheet -> S stylesheet" production has been removed. -3) The "stylesheet -> CDO stylesheet" production has been changed to +3) The "stylesheet -> CDO stylesheet" production has been changed to "stylesheet -> CDO ws stylesheet". 4) The "stylesheet -> CDC stylesheet" production has been changed to "stylesheet -> CDC ws stylesheet". Essentially, the above changes remove the expectation of leading whitespace -from the stylesheet non-terminal. This is handled by either the start -non-terminal, or by the changes made to the production rules for the stylesheet -non-terminal. Note that the "stylesheet -> statement stylesheet" production -does not require modification as the statement production rule already consumes +from the stylesheet non-terminal. This is handled by either the start +non-terminal, or by the changes made to the production rules for the stylesheet +non-terminal. Note that the "stylesheet -> statement stylesheet" production +does not require modification as the statement production rule already consumes any whitespace following the statement. If '{', '}', '[', ']', '(', ')', and ';' are omitted from any, then the above @@ -104,18 +104,18 @@ grammar is LL(1). Nullable productions -------------------- -stylesheet, block-content, decl-list, decl-list-end, value0, any0, ws +stylesheet, block-content, decl-list, decl-list-end, value0, any0, ws FIRST sets ---------- -start CDO, CDC, S, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +start CDO, CDC, S, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -stylesheet CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +stylesheet CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD statement IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, PREFIXMATCH, SUFFIXMATCH, @@ -162,29 +162,29 @@ FOLLOW sets start stylesheet EOF -statement CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +statement CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -ruleset CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +ruleset CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -ruleset-end CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +ruleset-end CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -at-rule CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +at-rule CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -at-rule-end CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +at-rule-end CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF -block CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +block CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF, ';', '}' block-content '}' selector '{' @@ -202,9 +202,9 @@ any1 '{' any IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ';', ATKEYWORD, '}' -ws CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, - CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, - PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', +ws CDO, CDC, IDENT, NUMBER, PERCENTAGE, DIMENSION, STRING, + CHAR, URI, HASH, UNICODE-RANGE, INCLUDES, DASHMATCH, + PREFIXMATCH, SUFFIXMATCH, SUBSTRINGMATCH, FUNCTION, '(', '[', '{', ATKEYWORD, EOF, ';', '}', ':' diff --git a/docs/Representation b/docs/Representation index 3eb63eb..b91419f 100644 --- a/docs/Representation +++ b/docs/Representation @@ -78,7 +78,7 @@ struct stylesheet { uint32_t rule_count; /**< Number of rules in sheet */ struct rule *rule_list; /**< List of rules in sheet */ - bool disabled; /**< Whether this sheet is + bool disabled; /**< Whether this sheet is * disabled */ char *url; /**< URL of this sheet */ diff --git a/docs/Tokens b/docs/Tokens index 907fabd..9535e81 100644 --- a/docs/Tokens +++ b/docs/Tokens @@ -54,13 +54,13 @@ Differences from the CSS3 Syntax module specification 2) escape follows CSS2.1. CSS3 defines it as: escape ::= unicode | '\' [#x20-#x7E#x80-#xD7FF#xE000-#xFFFD#x10000-#x10FFFF] 3) urlchar omits ' and ): - a) If ' is permitted verbatim then, as stringchar inherits from urlchar, - single quoted strings may contain verbatim single quotes. This is + a) If ' is permitted verbatim then, as stringchar inherits from urlchar, + single quoted strings may contain verbatim single quotes. This is clearly nonsense. b) If ) is permitted verbatim then it becomes impossible to determine the true end of URI. Thus, for sanity's sake, it's omitted here. -4) stringchar explicitly includes ). See 3(b) for why it won't inherit it +4) stringchar explicitly includes ). See 3(b) for why it won't inherit it from urlchar as the spec implies. -5) BOM ::= #xFEFF is omitted. It is assumed that any leading BOM will be +5) BOM ::= #xFEFF is omitted. It is assumed that any leading BOM will be stripped from the document before lexing occurs. diff --git a/examples/example1.c b/examples/example1.c index be7a582..1c0dcf9 100644 --- a/examples/example1.c +++ b/examples/example1.c @@ -43,8 +43,8 @@ static css_error named_generic_sibling_node(void *pw, void *node, void **sibling); static css_error parent_node(void *pw, void *node, void **parent); static css_error sibling_node(void *pw, void *node, void **sibling); -static css_error node_has_name(void *pw, void *node, - const css_qname *qname, +static css_error node_has_name(void *pw, void *node, + const css_qname *qname, bool *match); static css_error node_has_class(void *pw, void *node, lwc_string *name, @@ -299,9 +299,9 @@ css_error node_name(void *pw, void *n, css_qname *qname) lwc_string *node = n; UNUSED(pw); - + qname->name = lwc_string_ref(node); - + return CSS_OK; } @@ -691,17 +691,17 @@ css_error compute_font_size(void *pw, const css_hint *parent, css_hint *size) size->data.length = sizes[size->status - 1]; } else if (size->status == CSS_FONT_SIZE_LARGER) { /** \todo Step within table, if appropriate */ - size->data.length.value = + size->data.length.value = FMUL(parent_size->value, FLTTOFIX(1.2)); size->data.length.unit = parent_size->unit; } else if (size->status == CSS_FONT_SIZE_SMALLER) { /** \todo Step within table, if appropriate */ - size->data.length.value = + size->data.length.value = FMUL(parent_size->value, FLTTOFIX(1.2)); size->data.length.unit = parent_size->unit; } else if (size->data.length.unit == CSS_UNIT_EM || size->data.length.unit == CSS_UNIT_EX) { - size->data.length.value = + size->data.length.value = FMUL(size->data.length.value, parent_size->value); if (size->data.length.unit == CSS_UNIT_EX) { diff --git a/include/libcss/font_face.h b/include/libcss/font_face.h index 6b18433..135682c 100644 --- a/include/libcss/font_face.h +++ b/include/libcss/font_face.h @@ -15,7 +15,7 @@ extern "C" #endif #include - + #include #include #include @@ -32,15 +32,15 @@ typedef enum css_font_face_format { /* Embedded OpenType; .eot */ CSS_FONT_FACE_FORMAT_SVG = 0x08, /* SVG Font; .svg, .svgz */ - + CSS_FONT_FACE_FORMAT_UNKNOWN = 0x10, /* Format specified, but not recognised */ - - /* We don't define CSS_FONT_FACE_SRC_FORMAT_TRUETYPE as might be - * expected, because the CSS3 specification + + /* We don't define CSS_FONT_FACE_SRC_FORMAT_TRUETYPE as might be + * expected, because the CSS3 specification * (http://www.w3.org/TR/css3-fonts/, ยง4.3) says: * "Given the overlap in common usage between TrueType and - * OpenType, the format hints "truetype" and "opentype" must be + * OpenType, the format hints "truetype" and "opentype" must be * considered as synonymous" * so we compute a hint of 'truetype' to css_font_face_format_opentype. */ @@ -52,19 +52,19 @@ typedef enum css_font_face_location_type { CSS_FONT_FACE_LOCATION_TYPE_URI = 2, } css_font_face_location_type; - + css_error css_font_face_get_font_family( - const css_font_face *font_face, + const css_font_face *font_face, lwc_string **font_family); - -css_error css_font_face_count_srcs(const css_font_face *font_face, + +css_error css_font_face_count_srcs(const css_font_face *font_face, uint32_t *count); css_error css_font_face_get_src(const css_font_face *font_face, uint32_t index, const css_font_face_src **src); - + css_error css_font_face_src_get_location(const css_font_face_src *src, lwc_string **location); - + css_font_face_location_type css_font_face_src_location_type( const css_font_face_src *src); css_font_face_format css_font_face_src_format(const css_font_face_src *src); diff --git a/include/libcss/fpmath.h b/include/libcss/fpmath.h index 91f2b7e..1e3fa43 100644 --- a/include/libcss/fpmath.h +++ b/include/libcss/fpmath.h @@ -22,66 +22,66 @@ extern "C" /* type for fixed point numbers */ typedef int32_t css_fixed; -static inline css_fixed +static inline css_fixed css_add_fixed(const css_fixed x, const css_fixed y) { int32_t ux = x; int32_t uy = y; int32_t res = ux + uy; - + /* Calculate overflowed result. (Don't change the sign bit of ux) */ ux = (ux >> 31) + INT_MAX; - + /* Force compiler to use cmovns instruction */ if ((int32_t) ((ux ^ uy) | ~(uy ^ res)) >= 0) { res = ux; } - + return res; } -static inline css_fixed +static inline css_fixed css_subtract_fixed(const css_fixed x, const css_fixed y) { int32_t ux = x; int32_t uy = y; int32_t res = ux - uy; - + ux = (ux >> 31) + INT_MAX; - + /* Force compiler to use cmovns instruction */ if ((int32_t)((ux ^ uy) & (ux ^ res)) < 0) { res = ux; } - + return res; } -static inline css_fixed +static inline css_fixed css_divide_fixed(const css_fixed x, const css_fixed y) { int64_t xx = ((int64_t)x << CSS_RADIX_POINT) / y; - + if (xx < INT_MIN) xx = INT_MIN; if (xx > INT_MAX) xx = INT_MAX; - + return xx; } -static inline css_fixed +static inline css_fixed css_multiply_fixed(const css_fixed x, const css_fixed y) { int64_t xx = ((int64_t)x * (int64_t)y) >> CSS_RADIX_POINT; - + if (xx < INT_MIN) xx = INT_MIN; if (xx > INT_MAX) xx = INT_MAX; - + return xx; } -static inline css_fixed +static inline css_fixed css_int_to_fixed(const int a) { int64_t xx = ((int64_t) a) << CSS_RADIX_POINT; @@ -90,11 +90,11 @@ css_int_to_fixed(const int a) { if (xx > INT_MAX) xx = INT_MAX; - + return xx; } -static inline css_fixed +static inline css_fixed css_float_to_fixed(const float a) { float xx = a * (float) (1 << CSS_RADIX_POINT); @@ -103,7 +103,7 @@ css_float_to_fixed(const float a) { if (xx > INT_MAX) xx = INT_MAX; - + return (css_fixed) xx; } diff --git a/include/libcss/select.h b/include/libcss/select.h index 3f1e14a..f1de409 100644 --- a/include/libcss/select.h +++ b/include/libcss/select.h @@ -34,9 +34,9 @@ typedef enum css_pseudo_element { */ typedef struct css_select_results { /** - * Array of pointers to computed styles, + * Array of pointers to computed styles, * indexed by css_pseudo_element. If there - * was no styling for a given pseudo element, + * was no styling for a given pseudo element, * then no computed style will be created and * the corresponding pointer will be set to NULL */ @@ -157,7 +157,7 @@ typedef struct css_select_handler { */ typedef struct css_select_font_faces_results { /** - * Array of pointers to computed font faces. + * Array of pointers to computed font faces. */ css_font_face **font_faces; uint32_t n_font_faces; @@ -204,8 +204,8 @@ css_error css_libcss_node_data_handler(css_select_handler *handler, css_error css_select_ctx_create(css_select_ctx **result); css_error css_select_ctx_destroy(css_select_ctx *ctx); -css_error css_select_ctx_append_sheet(css_select_ctx *ctx, - const css_stylesheet *sheet, +css_error css_select_ctx_append_sheet(css_select_ctx *ctx, + const css_stylesheet *sheet, css_origin origin, uint64_t media); css_error css_select_ctx_insert_sheet(css_select_ctx *ctx, const css_stylesheet *sheet, uint32_t index, @@ -224,7 +224,7 @@ css_error css_select_style(css_select_ctx *ctx, void *node, uint64_t media, const css_stylesheet *inline_style, css_select_handler *handler, void *pw, css_select_results **result); -css_error css_select_results_destroy(css_select_results *results); +css_error css_select_results_destroy(css_select_results *results); css_error css_select_font_faces(css_select_ctx *ctx, uint64_t media, lwc_string *font_family, diff --git a/include/libcss/stylesheet.h b/include/libcss/stylesheet.h index f92d870..68c4dfc 100644 --- a/include/libcss/stylesheet.h +++ b/include/libcss/stylesheet.h @@ -65,12 +65,12 @@ typedef struct css_system_font { enum css_font_style_e style; enum css_font_variant_e variant; enum css_font_weight_e weight; - struct { - css_fixed size; + struct { + css_fixed size; css_unit unit; } size; - struct { - css_fixed size; + struct { + css_fixed size; css_unit unit; } line_height; /* Note: must be a single family name only */ 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 = "