@@ -57,63 +57,22 @@ def inner_parse(markup, ss, cache)
5757 )
5858 end
5959
60- if ( num = parse_number ( markup , ss ) )
60+ if ( num = parse_number ( markup ) )
6161 num
6262 else
6363 VariableLookup . parse ( markup , ss , cache )
6464 end
6565 end
6666
67- def parse_number ( markup , ss )
67+ def parse_number ( markup )
6868 # check if the markup is simple integer or float
6969 case markup
7070 when INTEGER_REGEX
71- return Integer ( markup , 10 )
71+ Integer ( markup , 10 )
7272 when FLOAT_REGEX
73- return markup . to_f
74- end
75-
76- ss . string = markup
77- # the first byte must be a digit or a dash
78- byte = ss . scan_byte
79-
80- return false if byte != DASH && ( byte < ZERO || byte > NINE )
81-
82- if byte == DASH
83- peek_byte = ss . peek_byte
84-
85- # if it starts with a dash, the next byte must be a digit
86- return false if peek_byte . nil? || !( peek_byte >= ZERO && peek_byte <= NINE )
87- end
88-
89- # The markup could be a float with multiple dots
90- first_dot_pos = nil
91- num_end_pos = nil
92-
93- while ( byte = ss . scan_byte )
94- return false if byte != DOT && ( byte < ZERO || byte > NINE )
95-
96- # we found our number and now we are just scanning the rest of the string
97- next if num_end_pos
98-
99- if byte == DOT
100- if first_dot_pos . nil?
101- first_dot_pos = ss . pos
102- else
103- # we found another dot, so we know that the number ends here
104- num_end_pos = ss . pos - 1
105- end
106- end
107- end
108-
109- num_end_pos = markup . length if ss . eos?
110-
111- if num_end_pos
112- # number ends with a number "123.123"
113- markup . byteslice ( 0 , num_end_pos ) . to_f
73+ markup . to_f
11474 else
115- # number ends with a dot "123."
116- markup . byteslice ( 0 , first_dot_pos ) . to_f
75+ false
11776 end
11877 end
11978 end
0 commit comments