diff options
author | mbkma <[email protected]> | 2025-08-14 21:16:37 +0200 |
---|---|---|
committer | mbkma <[email protected]> | 2025-08-14 21:16:37 +0200 |
commit | 5396895f2caae84228fd9961197c6bf52c371404 (patch) | |
tree | d05c8d9710b3783056f4c88bb18039fdf5ca7548 | |
parent | 7ef327f6f269c7a49357e001cd41d7aaf5807749 (diff) | |
download | mate-calc-fix/#207.tar.bz2 mate-calc-fix/#207.tar.xz |
handle multiple consecutive spaces correctly on pastefix/#207
-rw-r--r-- | src/math-equation.c | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/src/math-equation.c b/src/math-equation.c index 2ce3ab8..1faee23 100644 --- a/src/math-equation.c +++ b/src/math-equation.c @@ -803,9 +803,29 @@ math_equation_get_equation(MathEquation *equation) continue; } - /* Ignore thousands separators */ - if (c == mp_serializer_get_thousands_separator(equation->priv->serializer) && last_is_digit && next_is_digit) - ; + /* Ignore thousands separators (including spaces between digits) */ + if (c == mp_serializer_get_thousands_separator(equation->priv->serializer) && last_is_digit && next_is_digit) { + /* Skip official thousands separator */ + } + else if (c == ' ' && last_is_digit) { + /* Skip consecutive spaces between digits - look ahead to find next non-space character */ + const gchar *lookahead = read_iter; + while (*lookahead != '\0' && g_utf8_get_char(lookahead) == ' ') { + lookahead = g_utf8_next_char(lookahead); + } + /* Only skip if the next non-space character is a digit */ + if (*lookahead != '\0' && g_unichar_isdigit(g_utf8_get_char(lookahead))) { + /* Skip all consecutive spaces - advance read_iter to the last space */ + while (g_utf8_get_char(g_utf8_next_char(read_iter)) == ' ') { + read_iter = g_utf8_next_char(read_iter); + offset++; + } + /* Current space will be skipped by not appending it */ + } else { + /* Keep this space - it's not between digits */ + g_string_append_unichar(eq_text, c); + } + } /* Substitute radix character */ else if (c == mp_serializer_get_radix(equation->priv->serializer) && (last_is_digit || next_is_digit)) g_string_append_unichar(eq_text, '.'); |