[gcalctool/gnome-2-28] Fix inactive random button



commit 7907e9ecac1e77a7f0fb1effd628cbfe40641368
Author: Robert Ancell <robert ancell gmail com>
Date:   Tue Oct 13 11:28:29 2009 +1100

    Fix inactive random button

 ChangeLog               |    4 ++++
 src/functions.c         |    6 ++++--
 src/mp-equation-lexer.l |    3 ++-
 3 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 4736741..3f078b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@
 gcalctool change history.
 =========================
 
+2009-10-09 Robert Ancell <robert ancell gmail com>
+
+    * Fix inactive random button
+
 2009-09-30 Robin Sonefors <ozamosi flukkost nu>
 
     * Fix numeric exponent parsing (Bug #596892)
diff --git a/src/functions.c b/src/functions.c
index 5714983..ee4d23c 100644
--- a/src/functions.c
+++ b/src/functions.c
@@ -93,7 +93,7 @@ static Function functions[NFUNCTIONS] = {
 { FN_X_POW_Y,           "^", 0 },
 { FN_X_POW_Y_INV,       "^(1/(", 0 },
 { FN_FACTORIAL,         "!", 0 },
-{ FN_RANDOM,            " rand ", 0 },
+{ FN_RANDOM,            "rand", 0 },
 { FN_SIN,               " sin ", 0 },
 { FN_SINH,              " sinh ", 0 },
 { FN_ASIN,              " sin�¹ ", 0 },
@@ -179,7 +179,9 @@ get_variable(const char *name, MPNumber *z, void *data)
     for (c = lower_name; *c; c++)
         *c = tolower(*c);
 
-    if (lower_name[0] == 'r')
+    if (strcmp(lower_name, "rand") == 0)
+        mp_set_from_random(z);
+    else if (lower_name[0] == 'r')
         register_get(atoi(name+1), z);
     else if (strcmp(lower_name, "ans") == 0)
         mp_set_from_mp(display_get_answer(&v->display), z);
diff --git a/src/mp-equation-lexer.l b/src/mp-equation-lexer.l
index 4a84df9..8d06567 100644
--- a/src/mp-equation-lexer.l
+++ b/src/mp-equation-lexer.l
@@ -99,7 +99,8 @@ SUB_NUM  {SUB_DIGITS}+
 GREEKS   "α"|"β"|"γ"|"δ"|"ε"|"ζ"|"η"|"θ"|"ι"|"κ"|"λ"|"μ"|"ν"|"ξ"|"ο"|"Ï?"|"Ï?"|"Ï?"|"Ï?"|"Ï?"|"Ï?"|"Ï?"|"Ï?"|"Ï?"|"Ï?"
 REGISTERS "R0"|"R1"|"R2"|"R3"|"R4"|"R5"|"R6"|"R7"|"R8"|"R9"
 ANS       [aA][nN][sS]
-VARIABLE {REGISTERS}|{GREEKS}|"e"|{ANS}
+RAND      [rR][aA][nN][dD]
+VARIABLE {REGISTERS}|{GREEKS}|"e"|{ANS}|{RAND}
 VARIABLE_NAME [a-zA-Z]+
 FUNCTION {VARIABLE_NAME}|{VARIABLE_NAME}{INVERSE}|{VARIABLE_NAME}{SUB_NUM}
 



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