[gnome-calculator/gnome-3-12] Handle localized radix characters on command line
- From: Arth Patel <arthpatel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/gnome-3-12] Handle localized radix characters on command line
- Date: Sun, 8 Jun 2014 19:46:26 +0000 (UTC)
commit a5be1fa54892ff29496744d6e6bc56d70060e789
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Thu May 29 08:19:58 2014 -0500
Handle localized radix characters on command line
We were accounting for the locale's thousands separator, but not the
radix char (decimal point). For example:
export LC_NUMERIC=de_DE.UTF-8
gnome-calculator --solve 2.000,5 - ,2
The result should be 2.000,3 not an error.
https://bugzilla.gnome.org/show_bug.cgi?id=730905
src/gcalccmd.vala | 6 +++++-
src/gnome-calculator.vala | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/gcalccmd.vala b/src/gcalccmd.vala
index 38b4f74..c63552f 100644
--- a/src/gcalccmd.vala
+++ b/src/gcalccmd.vala
@@ -19,7 +19,11 @@ static void solve (string equation)
if (tsep_string == null || tsep_string == "")
tsep_string = " ";
- var e = new Equation (equation.replace (tsep_string, ""));
+ var decimal = nl_langinfo (NLItem.RADIXCHAR);
+ if (decimal == null)
+ decimal = "";
+
+ var e = new Equation (equation.replace (tsep_string, "").replace (decimal, "."));
e.base = 10;
e.wordlen = 32;
e.angle_units = AngleUnit.DEGREES;
diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala
index 7a02952..2182473 100644
--- a/src/gnome-calculator.vala
+++ b/src/gnome-calculator.vala
@@ -269,7 +269,11 @@ public class Calculator : Gtk.Application
if (tsep_string == null || tsep_string == "")
tsep_string = " ";
- var e = new SolveEquation (solve_equation.replace (tsep_string, ""));
+ var decimal = nl_langinfo (NLItem.RADIXCHAR);
+ if (decimal == null)
+ decimal = "";
+
+ var e = new SolveEquation (solve_equation.replace (tsep_string, "").replace (decimal, "."));
e.base = 10;
e.wordlen = 32;
e.angle_units = AngleUnit.DEGREES;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]