[gnome-calculator] Fix '(null)' error message in 'gcalctool' and 'gnome-calculator -s'



commit 2ce8f252b0346b3eb911dca5244298ae8c090ddf
Author: PioneerAxon <arth svnit gmail com>
Date:   Tue Jan 3 23:24:54 2017 +0530

    Fix '(null)' error message in 'gcalctool' and 'gnome-calculator -s'
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773688

 src/gcalccmd.vala         |    5 +++--
 src/gnome-calculator.vala |    5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/src/gcalccmd.vala b/src/gcalccmd.vala
index 867da26..88bf0b0 100644
--- a/src/gcalccmd.vala
+++ b/src/gcalccmd.vala
@@ -23,6 +23,7 @@ static void solve (string equation)
     if (decimal == null)
         decimal = "";
 
+    string? error_token = null;
     var e = new Equation (equation.replace (tsep_string, "").replace (decimal, "."));
     e.base = 10;
     e.wordlen = 32;
@@ -30,7 +31,7 @@ static void solve (string equation)
 
     ErrorCode ret;
     uint representation_base;
-    var z = e.parse (out representation_base, out ret);
+    var z = e.parse (out representation_base, out ret, out error_token);
 
     result_serializer.set_representation_base (representation_base);
     if (z != null)
@@ -45,7 +46,7 @@ static void solve (string equation)
             stdout.printf ("%s\n", str);
     }
     else if (ret == ErrorCode.MP)
-        stderr.printf ("Error %s\n", Number.error);
+        stderr.printf ("Error %s\n", (Number.error != null) ? Number.error : error_token);
     else
         stderr.printf ("Error %d\n", ret);
 }
diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala
index d0bec78..f1cccb1 100644
--- a/src/gnome-calculator.vala
+++ b/src/gnome-calculator.vala
@@ -223,8 +223,9 @@ public class Calculator : Gtk.Application
             e.angle_units = AngleUnit.DEGREES;
 
             ErrorCode error;
+            string? error_token = null;
             uint representation_base;
-            var result = e.parse (out representation_base, out error);
+            var result = e.parse (out representation_base, out error, out error_token);
             if (result != null)
             {
                 var serializer = new Serializer (DisplayFormat.AUTOMATIC, 10, 9);
@@ -234,7 +235,7 @@ public class Calculator : Gtk.Application
             }
             else if (error == ErrorCode.MP)
             {
-                stderr.printf ("Error: %s\n", Number.error);
+                stderr.printf ("Error: %s\n", (Number.error != null) ? Number.error : error_token);
                 return Posix.EXIT_FAILURE;
             }
             else


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]