@@ -1815,37 +1815,29 @@ char* _str_copy_decimal_str_c(const char *s, char **endpos, char decimal,
1815
1815
1816
1816
double round_trip (const char * p , char * * q , char decimal , char sci , char tsep ,
1817
1817
int skip_trailing , int * error , int * maybe_int ) {
1818
- char * pc = NULL ;
1819
1818
// 'normalize' representation to C-locale; replace decimal with '.' and
1820
1819
// remove t(housand)sep.
1821
1820
char * endptr = NULL ;
1822
- if (decimal != '.' || tsep != '\0' ) {
1823
- pc = _str_copy_decimal_str_c (p , & endptr , decimal , tsep );
1824
- }
1821
+ char * pc = _str_copy_decimal_str_c (p , & endptr , decimal , tsep );
1825
1822
// This is called from a nogil block in parsers.pyx
1826
1823
// so need to explicitly get GIL before Python calls
1827
1824
PyGILState_STATE gstate ;
1828
1825
gstate = PyGILState_Ensure ();
1829
- double r ;
1830
- if (pc != NULL ) {
1831
- char * endpc = NULL ;
1832
- r = PyOS_string_to_double (pc , & endpc , 0 );
1833
- // PyOS_string_to_double needs to consume the whole string
1834
- if (endpc == pc + strlen (pc )) {
1835
- if (q != NULL ) {
1836
- // report endptr from source string (p)
1837
- * q = (char * ) endptr ;
1838
- }
1839
- } else {
1840
- * error = -1 ;
1841
- if (q != NULL ) {
1842
- // p and pc are different len due to tsep removal. Can't report
1843
- // how much it has consumed of p. Just rewind to beginning.
1844
- * q = (char * )p ;
1845
- }
1826
+ char * endpc = NULL ;
1827
+ double r = PyOS_string_to_double (pc , & endpc , 0 );
1828
+ // PyOS_string_to_double needs to consume the whole string
1829
+ if (endpc == pc + strlen (pc )) {
1830
+ if (q != NULL ) {
1831
+ // report endptr from source string (p)
1832
+ * q = (char * ) endptr ;
1846
1833
}
1847
1834
} else {
1848
- r = PyOS_string_to_double (p , q , 0 );
1835
+ * error = -1 ;
1836
+ if (q != NULL ) {
1837
+ // p and pc are different len due to tsep removal. Can't report
1838
+ // how much it has consumed of p. Just rewind to beginning.
1839
+ * q = (char * )p ;
1840
+ }
1849
1841
}
1850
1842
if (maybe_int != NULL ) * maybe_int = 0 ;
1851
1843
if (PyErr_Occurred () != NULL ) * error = -1 ;
0 commit comments