[gcalctool/gcalctool-newui2] Make better error messages
- From: Robert Ancell <rancell src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gcalctool/gcalctool-newui2] Make better error messages
- Date: Thu, 17 Sep 2009 02:42:15 +0000 (UTC)
commit f5d4e0e640f91ee8446310c49796f43c236f9e3c
Author: Robert Ancell <robert ancell gmail com>
Date: Thu Sep 17 12:42:07 2009 +1000
Make better error messages
data/gcalctool.ui | 1 +
src/mp-equation-lexer.l | 38 +++++++++++++++++++-------------------
src/mp-trigonometric.c | 10 +++++-----
src/mp.c | 33 ++++++++++++++++-----------------
4 files changed, 41 insertions(+), 41 deletions(-)
---
diff --git a/data/gcalctool.ui b/data/gcalctool.ui
index e51e0a6..c331da7 100644
--- a/data/gcalctool.ui
+++ b/data/gcalctool.ui
@@ -266,6 +266,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
+ <property name="wrap_mode">word</property>
<property name="justification">right</property>
<property name="right_margin">6</property>
<property name="cursor_visible">False</property>
diff --git a/src/mp-equation-lexer.l b/src/mp-equation-lexer.l
index a717bba..11588ac 100644
--- a/src/mp-equation-lexer.l
+++ b/src/mp-equation-lexer.l
@@ -114,25 +114,25 @@ NOT "¬"|"~"|[nN][oO][tT]
%%
-"+" {return tADD;}
-"-"|"â??" {return tSUBTRACT;}
-"*"|"Ã?" {return tMULTIPLY;}
-"/"|"÷" {return tDIVIDE;}
-{MOD} {return tMOD;}
-"â??" {return tROOT;}
-"â??" {return tROOT3;}
-"â??" {return tROOT4;}
-{NOT} {return tNOT;}
-{AND} {return tAND;}
-{OR} {return tOR;}
-{XOR} {return tXOR;}
-{SUP_NUM} {yylval->integer = super_atoi(yytext); return tSUPNUM; }
-{SUB_NUM} {yylval->integer = sub_atoi(yytext); return tSUBNUM; }
-{NUMBER} {mp_set_from_string(yytext, &yylval->int_t); return tNUMBER;}
-{VARIABLE} {yylval->name = strdup(yytext); return tVARIABLE;}
-{FUNCTION} {yylval->name = strdup(yytext); return tFUNCTION;}
-{INVERSE} {return tINVERSE;}
+"+" {return tADD;}
+"-"|"â??" {return tSUBTRACT;}
+"*"|"Ã?" {return tMULTIPLY;}
+"/"|"â??"|"÷" {return tDIVIDE;}
+{MOD} {return tMOD;}
+"â??" {return tROOT;}
+"â??" {return tROOT3;}
+"â??" {return tROOT4;}
+{NOT} {return tNOT;}
+{AND} {return tAND;}
+{OR} {return tOR;}
+{XOR} {return tXOR;}
+{SUP_NUM} {yylval->integer = super_atoi(yytext); return tSUPNUM; }
+{SUB_NUM} {yylval->integer = sub_atoi(yytext); return tSUBNUM; }
+{NUMBER} {mp_set_from_string(yytext, &yylval->int_t); return tNUMBER;}
+{VARIABLE} {yylval->name = strdup(yytext); return tVARIABLE;}
+{FUNCTION} {yylval->name = strdup(yytext); return tFUNCTION;}
+{INVERSE} {return tINVERSE;}
[ \t\n]
-. {return *yytext;}
+. {return *yytext;}
%%
diff --git a/src/mp-trigonometric.c b/src/mp-trigonometric.c
index ad98c36..723ff57 100644
--- a/src/mp-trigonometric.c
+++ b/src/mp-trigonometric.c
@@ -278,7 +278,7 @@ mp_tan(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_cos(x, unit, &cos_x);
if (mp_is_zero(&cos_x)) {
/* Translators: Error displayed when tangent value is undefined */
- mperr(_("Tangent is infinite"));
+ mperr(_("Tangent not defined for angles that are multiples of Ï?â??2 (180°) from Ï?â??4 (90°)"));
return;
}
@@ -315,7 +315,7 @@ mp_asin(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
/* HERE ABS(X) >= 1. SEE IF X == +-1 */
mp_set_from_integer(x->sign, &t2);
if (!mp_is_equal(x, &t2))
- mperr("*** ABS(X) > 1 IN CALL TO MP_ASIN ***");
+ mperr(_("Inverse sine not defined for values outside [-1, 1]"));
/* X == +-1 SO RETURN +-PI/2 */
mp_get_pi(z);
@@ -336,7 +336,7 @@ mp_acos(const MPNumber *x, MPAngleUnit unit, MPNumber *z)
mp_set_from_integer(-1, &MPn1);
if (mp_is_greater_than(x, &t1) || mp_is_less_than(x, &MPn1)) {
- mperr("Error");
+ mperr(_("Inverse cosine not defined for values outside [-1, 1]"));
mp_set_from_integer(0, z);
} else if (x->sign == 0) {
mp_divide_integer(&pi, 2, z);
@@ -550,7 +550,7 @@ mp_acosh(const MPNumber *x, MPNumber *z)
/* Check x >= 1 */
mp_set_from_integer(1, &t);
if (mp_is_less_than(x, &t)) {
- mperr("Error");
+ mperr(_("Inverse cosine not defined for values less than or equal to one"));
mp_set_from_integer(0, z);
return;
}
@@ -573,7 +573,7 @@ mp_atanh(const MPNumber *x, MPNumber *z)
mp_set_from_integer(1, &one);
mp_set_from_integer(-1, &minus_one);
if (mp_is_greater_equal(x, &one) || mp_is_less_equal(x, &minus_one)) {
- mperr("Error");
+ mperr(_("Inverse hyperbolic tangent not defined for values outside [-1, 1]"));
mp_set_from_integer(0, z);
return;
}
diff --git a/src/mp.c b/src/mp.c
index ba02eb0..f6370ac 100644
--- a/src/mp.c
+++ b/src/mp.c
@@ -453,7 +453,7 @@ mp_divide(const MPNumber *x, const MPNumber *y, MPNumber *z)
/* x/0 */
if (y->sign == 0) {
- mperr("*** ATTEMPTED DIVISION BY ZERO IN CALL TO MP_DIVIDE ***");
+ mperr(_("Division by zero is not defined"));
mp_set_from_integer(0, z);
return;
}
@@ -489,7 +489,7 @@ mp_divide_integer(const MPNumber *x, int y, MPNumber *z)
/* x/0 */
if (y == 0) {
- mperr("*** ATTEMPTED DIVISION BY ZERO IN CALL TO MP_DIVIDE_INTEGER ***");
+ mperr(_("Division by zero is not defined"));
mp_set_from_integer(0, z);
return;
}
@@ -1018,7 +1018,7 @@ mp_ln(const MPNumber *x, MPNumber *z)
/* ln(-x) invalid */
if (x->sign <= 0) {
- mperr("*** X NONPOSITIVE IN CALL TO MP_LN ***");
+ mperr(_("Logarithm of negative values is undefined"));
mp_set_from_integer(0, z);
return;
}
@@ -1373,7 +1373,7 @@ void
mp_multiply_fraction(const MPNumber *x, int numerator, int denominator, MPNumber *z)
{
if (denominator == 0) {
- mperr("*** ATTEMPTED DIVISION BY ZERO IN MP_MULTIPLY_FRACTION ***");
+ mperr(_("Division by zero is not defined"));
mp_set_from_integer(0, z);
return;
}
@@ -1496,14 +1496,14 @@ mp_pwr(const MPNumber *x, const MPNumber *y, MPNumber *z)
/* (-x)^y imaginary */
if (x->sign < 0) {
- mperr(_("Negative X and non-integer Y not supported"));
+ mperr(_("The power of negative numbers only defined for for integer exponents"));
mp_set_from_integer(0, z);
return;
}
/* 0^-y illegal */
if (x->sign == 0 && y->sign < 0) {
- mperr("*** X ZERO AND Y NONPOSITIVE IN CALL TO MP_PWR ***");
+ mperr(_("The power of zero is not defined for a negative exponent"));
mp_set_from_integer(0, z);
return;
}
@@ -1535,9 +1535,9 @@ mp_reciprocal(const MPNumber *x, MPNumber *z)
float rx;
static int it[9] = { 0, 8, 6, 5, 4, 4, 4, 4, 4 };
- /* 1/x invalid */
+ /* 1/0 invalid */
if (x->sign == 0) {
- mperr("*** ATTEMPTED DIVISION BY ZERO IN CALL TO MP_RECIPROCAL ***");
+ mperr(_("Reciprocal of zero is not defined"));
mp_set_from_integer(0, z);
return;
}
@@ -1618,7 +1618,7 @@ mp_root(const MPNumber *x, int n, MPNumber *z)
/* x^(1/0) invalid */
if (n == 0) {
- mperr("*** N == 0 IN CALL TO MP_ROOT ***");
+ mperr(_("Root must non-zero"));
mp_set_from_integer(0, z);
return;
}
@@ -1632,17 +1632,16 @@ mp_root(const MPNumber *x, int n, MPNumber *z)
return;
}
- /* LOOK AT SIGN OF X */
+ /* 0^(1/n) = 0 for positive n */
if (x->sign == 0) {
- /* X == 0 HERE, RETURN 0 IF N POSITIVE, ERROR IF NEGATIVE */
mp_set_from_integer(0, z);
if (n <= 0)
- mperr("*** X == 0 AND N NEGATIVE IN CALL TO MP_ROOT ***");
+ mperr(_("Negative root of zero is undefined"));
return;
}
if (x->sign < 0 && np % 2 == 0) {
- mperr("*** X NEGATIVE AND N EVEN IN CALL TO MP_ROOT ***");
+ mperr(_("nth root of negative number not defined for even n"));
mp_set_from_integer(0, z);
return;
}
@@ -1732,7 +1731,7 @@ void
mp_sqrt(const MPNumber *x, MPNumber *z)
{
if (x->sign < 0)
- mperr("*** X NEGATIVE IN CALL TO SUBROUTINE MP_SQRT ***");
+ mperr(_("Square root is not defined for negative values"));
else if (x->sign == 0)
mp_set_from_integer(0, z);
else {
@@ -1758,7 +1757,7 @@ mp_factorial(const MPNumber *x, MPNumber *z)
return;
}
if (!mp_is_natural(x)) {
- mperr("Cannot take factorial of non-natural number");
+ mperr(_("Factorial only defined for natural numbers"));
return;
}
@@ -1808,9 +1807,9 @@ mp_xpowy_integer(const MPNumber *x, int n, MPNumber *z)
int i;
MPNumber t;
- /* x^-n invalid */
+ /* 0^-n invalid */
if (x->sign == 0 && n < 0) {
- mperr("*** ATTEMPT TO RAISE ZERO TO NEGATIVE POWER IN CALL TO SUBROUTINE mp_xpowy_integer ***");
+ mperr(_("The power of zero is not defined for a negative exponent"));
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]