Scan the version number of VERSION-DIRECTIVE. Scope: %YAML 1.1 # a comment \n ^ %YAML 1.1 # a comment \n ^
(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8)
| 1802 | // %YAML 1.1 # a comment \n |
| 1803 | // ^ |
| 1804 | func yaml_parser_scan_version_directive_number(parser *yaml_parser_t, start_mark yaml_mark_t, number *int8) bool { |
| 1805 | |
| 1806 | // Repeat while the next character is digit. |
| 1807 | if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { |
| 1808 | return false |
| 1809 | } |
| 1810 | var value, length int8 |
| 1811 | for is_digit(parser.buffer, parser.buffer_pos) { |
| 1812 | // Check if the number is too long. |
| 1813 | length++ |
| 1814 | if length > max_number_length { |
| 1815 | return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", |
| 1816 | start_mark, "found extremely long version number") |
| 1817 | } |
| 1818 | value = value*10 + int8(as_digit(parser.buffer, parser.buffer_pos)) |
| 1819 | skip(parser) |
| 1820 | if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { |
| 1821 | return false |
| 1822 | } |
| 1823 | } |
| 1824 | |
| 1825 | // Check if the number was present. |
| 1826 | if length == 0 { |
| 1827 | return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive", |
| 1828 | start_mark, "did not find expected version number") |
| 1829 | } |
| 1830 | *number = value |
| 1831 | return true |
| 1832 | } |
| 1833 | |
| 1834 | // Scan the value of a TAG-DIRECTIVE token. |
| 1835 | // |
no test coverage detected