* Given a string that may have a decimal point in the current * locale, change it back to a dot. Since the string cannot get * longer, no need for a maximum buffer size parameter. */
| 176 | * longer, no need for a maximum buffer size parameter. |
| 177 | */ |
| 178 | static void |
| 179 | change_decimal_from_locale_to_dot(char* buffer) |
| 180 | { |
| 181 | struct lconv *locale_data = localeconv(); |
| 182 | const char *decimal_point = locale_data->decimal_point; |
| 183 | |
| 184 | if (decimal_point[0] != '.' || decimal_point[1] != 0) { |
| 185 | size_t decimal_point_len = strlen(decimal_point); |
| 186 | |
| 187 | if (*buffer == '+' || *buffer == '-') { |
| 188 | buffer++; |
| 189 | } |
| 190 | while (isdigit(Py_CHARMASK(*buffer))) { |
| 191 | buffer++; |
| 192 | } |
| 193 | if (strncmp(buffer, decimal_point, decimal_point_len) == 0) { |
| 194 | *buffer = '.'; |
| 195 | buffer++; |
| 196 | if (decimal_point_len > 1) { |
| 197 | /* buffer needs to get smaller */ |
| 198 | size_t rest_len = strlen(buffer + (decimal_point_len - 1)); |
| 199 | memmove(buffer, buffer + (decimal_point_len - 1), rest_len); |
| 200 | buffer[rest_len] = 0; |
| 201 | } |
| 202 | } |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | /* |
| 207 | * Check that the format string is a valid one for NumPyOS_ascii_format* |
no test coverage detected