@@ -81,7 +81,10 @@ struct parsed_number_string {
8181// Assuming that you use no more than 19 digits, this will
8282// parse an ASCII string.
8383fastfloat_really_inline
84- parsed_number_string parse_number_string (const char *p, const char *pend, chars_format fmt) noexcept {
84+ parsed_number_string parse_number_string (const char *p, const char *pend, parse_options options) noexcept {
85+ const chars_format fmt = options.format ;
86+ const char decimal_point = options.decimal_point ;
87+
8588 parsed_number_string answer;
8689 answer.valid = false ;
8790 answer.too_many_digits = false ;
@@ -91,7 +94,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, chars_
9194 if (p == pend) {
9295 return answer;
9396 }
94- if (!is_integer (*p) && (*p != ' . ' )) { // a sign must be followed by an integer or the dot
97+ if (!is_integer (*p) && (*p != decimal_point )) { // a sign must be followed by an integer or the dot
9598 return answer;
9699 }
97100 }
@@ -109,7 +112,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, chars_
109112 const char *const end_of_integer_part = p;
110113 int64_t digit_count = int64_t (end_of_integer_part - start_digits);
111114 int64_t exponent = 0 ;
112- if ((p != pend) && (*p == ' . ' )) {
115+ if ((p != pend) && (*p == decimal_point )) {
113116 ++p;
114117 // Fast approach only tested under little endian systems
115118 if ((p + 8 <= pend) && is_made_of_eight_digits_fast (p)) {
@@ -179,7 +182,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, chars_
179182 // We need to be mindful of the case where we only have zeroes...
180183 // E.g., 0.000000000...000.
181184 const char *start = start_digits;
182- while ((start != pend) && (*start == ' 0' || *start == ' . ' )) {
185+ while ((start != pend) && (*start == ' 0' || *start == decimal_point )) {
183186 if (*start == ' 0' ) { digit_count --; }
184187 start++;
185188 }
@@ -196,7 +199,7 @@ parsed_number_string parse_number_string(const char *p, const char *pend, chars_
196199 if (i >= minimal_nineteen_digit_integer) { // We have a big integers
197200 exponent = end_of_integer_part - p + exp_number;
198201 } else { // We have a value with a fractional component.
199- p++; // skip the '.'
202+ p++; // skip the dot
200203 const char *first_after_period = p;
201204 while ((i < minimal_nineteen_digit_integer) && (p != pend) && is_integer (*p)) {
202205 i = i * 10 + uint64_t (*p - ' 0' );
@@ -217,7 +220,9 @@ parsed_number_string parse_number_string(const char *p, const char *pend, chars_
217220// This function could be optimized. In particular, we could stop after 19 digits
218221// and try to bail out. Furthermore, we should be able to recover the computed
219222// exponent from the pass in parse_number_string.
220- fastfloat_really_inline decimal parse_decimal (const char *p, const char *pend) noexcept {
223+ fastfloat_really_inline decimal parse_decimal (const char *p, const char *pend, parse_options options) noexcept {
224+ const char decimal_point = options.decimal_point ;
225+
221226 decimal answer;
222227 answer.num_digits = 0 ;
223228 answer.decimal_point = 0 ;
@@ -237,7 +242,7 @@ fastfloat_really_inline decimal parse_decimal(const char *p, const char *pend) n
237242 answer.num_digits ++;
238243 ++p;
239244 }
240- if ((p != pend) && (*p == ' . ' )) {
245+ if ((p != pend) && (*p == decimal_point )) {
241246 ++p;
242247 const char *first_after_period = p;
243248 // if we have not yet encountered a zero, we have to skip it as well
@@ -276,7 +281,7 @@ fastfloat_really_inline decimal parse_decimal(const char *p, const char *pend) n
276281 // we have at least one non-zero digit.
277282 const char *preverse = p - 1 ;
278283 int32_t trailing_zeros = 0 ;
279- while ((*preverse == ' 0' ) || (*preverse == ' . ' )) {
284+ while ((*preverse == ' 0' ) || (*preverse == decimal_point )) {
280285 if (*preverse == ' 0' ) { trailing_zeros++; };
281286 --preverse;
282287 }
0 commit comments