gcalctool r2080 - in branches/gnome-2-22: . gcalctool
- From: rancell svn gnome org
- To: svn-commits-list gnome org
- Subject: gcalctool r2080 - in branches/gnome-2-22: . gcalctool
- Date: Sat, 19 Apr 2008 04:00:37 +0100 (BST)
Author: rancell
Date: Sat Apr 19 03:00:36 2008
New Revision: 2080
URL: http://svn.gnome.org/viewvc/gcalctool?rev=2080&view=rev
Log:
Convert localized UTF-8 radix and separator characters into english equivalents since the parser is 8-bit and not localized (Bug #527669).
--This line, and those below, will be ignored--
M ChangeLog
M gcalctool/functions.c
Modified:
branches/gnome-2-22/ChangeLog
branches/gnome-2-22/gcalctool/functions.c
Modified: branches/gnome-2-22/gcalctool/functions.c
==============================================================================
--- branches/gnome-2-22/gcalctool/functions.c (original)
+++ branches/gnome-2-22/gcalctool/functions.c Sat Apr 19 03:00:36 2008
@@ -557,9 +557,26 @@
/* Solve the equation */
} else {
int MPval[MP_SIZE];
- char *message = NULL;
+ char *c, *message = NULL;
+ GString *clean;
+ int result;
- switch (ce_parse(e->expression, MPval)) {
+ /* Remove thousands separators and use english radix */
+ clean = g_string_sized_new(strlen(e->expression));
+ for (c = e->expression; *c; c++) {
+ if (strncmp(c, v->tsep, strlen(v->tsep)) == 0) {
+ c += strlen(v->tsep) - 1;
+ } else if (strncmp(c, v->radix, strlen(v->radix)) == 0) {
+ g_string_append_c(clean, '.');
+ c += strlen(v->radix) - 1;
+ } else {
+ g_string_append_c(clean, *c);
+ }
+ }
+ result = ce_parse(clean->str, MPval);
+ g_string_free(clean, TRUE);
+
+ switch (result) {
case 0:
mpstr(MPval, e->ans);
exp_replace("Ans");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]