[gcalctool/gcalctool-newui2] ...
- From: Robert Ancell <rancell src gnome org>
- To: svn-commits-list gnome org
- Subject: [gcalctool/gcalctool-newui2] ...
- Date: Mon, 6 Jul 2009 13:36:28 +0000 (UTC)
commit 8d7f7ecdfb0e80e74ceea4cfb5e5dc30b7307373
Author: Robert Ancell <robert ancell gmail com>
Date: Mon Jul 6 20:52:05 2009 +1000
...
src/mp-convert.c | 28 ++++++++++++++++++++++------
src/mp-equation-parser.y | 2 +-
2 files changed, 23 insertions(+), 7 deletions(-)
---
diff --git a/src/mp-convert.c b/src/mp-convert.c
index d9da4e7..d29553d 100644
--- a/src/mp-convert.c
+++ b/src/mp-convert.c
@@ -574,8 +574,7 @@ mp_cast_to_string(const MPNumber *x, int base, int accuracy, int trim_zeroes, ch
static int
char_val(char **c, int base)
{
- int i, j, value;
- //á? á?¡á?¢á?£á?¤á?¥á?¦á?§á?¨á?©á ?á ?á ?á ?á ?á ?á ?á ?á ?á ?á¥?á¥?á¥?á¥?á¥?á¥?á¥?á¥?á¥?á¥?á§?á§?á§?á§?á§?á§?á§?á§?á§?á§?á?á?á?á?á?á?á?á?á?á?᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?á±?ê? ê?¡ê?¢ê?£ê?¤ê?¥ê?¦ê?§ê?¨ê?©ê£?ê£?ê£?ê£?ê£?ê£?ê£?ê£?ê£?ê£?ê¤?ê¤?ê¤?ê¤?ê¤?ê¤?ê¤?ê¤?ê¤?ê¤?ê©?ê©?ê©?ê©?ê©?ê©?ê©?ê©?ê©?ê©?ð?? ð??¡ð??¢ð??£ð??¤ð??¥ð??¦ð??§ð??¨ð??©
+ int i, j, value, offset;
const char *digits[][10] = {{"Ù ", "Ù¡", "Ù¢", "Ù£", "Ù¤", "Ù¥", "Ù¦", "Ù§", "Ù¨", "Ù©"},
{"Û°", "Û±", "Û²", "Û³", "Û´", "Ûµ", "Û¶", "Û·", "Û¸", "Û¹"},
{"ß?", "ß?", "ß?", "ß?", "ß?", "ß?", "ß?", "ß?", "ß?", "ß?"},
@@ -593,17 +592,30 @@ char_val(char **c, int base)
{"༠", "༡", "༢", "༣", "༤", "༥", "༦", "༧", "༨", "༩"},
{"á??", "á??", "á??", "á??", "á??", "á??", "á??", "á??", "á??", "á??"},
{"á??", "á??", "á??", "á??", "á??", "á??", "á??", "á??", "á??", "á??"},
+ {"á? ", "á?¡", "á?¢", "á?£", "á?¤", "á?¥", "á?¦", "á?§", "á?¨", "á?©"},
+ {"á ?", "á ?", "á ?", "á ?", "á ?", "á ?", "á ?", "á ?", "á ?", "á ?"},
+ {"�", "�", "�", "�", "�", "�", "�", "�", "�", "�"},
+ {"�", "�", "�", "�", "�", "�", "�", "�", "�", "�"},
+ {"á?", "á?", "á?", "á?", "á?", "á?", "á?", "á?", "á?", "á?"},
+ {"᮰", "᮱", "᮲", "᮳", "᮴", "᮵", "᮶", "᮷", "᮸", "᮹"},
+ {"á±?", "á±?", "á±?", "á±?", "á±?", "á±?", "á±?", "á±?", "á±?", "á±?"},
+ {"á±?", "á±?", "á±?", "á±?", "á±?", "á±?", "á±?", "á±?", "á±?", "á±?"},
+ {"ê? ", "ê?¡", "ê?¢", "ê?£", "ê?¤", "ê?¥", "ê?¦", "ê?§", "ê?¨", "ê?©"},
+ {"�", "�", "�", "�", "�", "�", "�", "�", "�", "�"},
+ {"�", "�", "�", "�", "�", "�", "�", "�", "�", "�"},
+ {"ê©?", "ê©?", "ê©?", "ê©?", "ê©?", "ê©?", "ê©?", "ê©?", "ê©?", "ê©?"},
+ {"ð?? ", "ð??¡", "ð??¢", "ð??£", "ð??¤", "ð??¥", "ð??¦", "ð??§", "ð??¨", "ð??©"},
{NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}};
if (**c >= '0' && **c <= '9') {
value = **c - '0';
- (*c)++;
+ offset = 1;
} else if (**c >= 'a' && **c <= 'f') {
value = **c - 'a' + 10;
- (*c)++;
+ offset = 1;
} else if (**c >= 'A' && **c <= 'F') {
value = **c - 'A' + 10;
- (*c)++;
+ offset = 1;
} else {
for (i = 0; digits[i][0]; i++) {
for (j = 0; j < 10; j++) {
@@ -616,10 +628,12 @@ char_val(char **c, int base)
if (digits[i][0] == NULL)
return -1;
value = j;
- *c += strlen(digits[i][j]);
+ offset = strlen(digits[i][j]);
}
if (value >= base)
return -1;
+
+ *c += offset;
return value;
}
@@ -641,6 +655,8 @@ mp_set_from_string(const char *str, MPNumber *z)
const char *si_suffixes[] = {"T", "G", "M", "k", "d", "c", "m", "u", "µ", "n", "p", "f", NULL};
int si_multipliers[] = { 12, 9, 6, 3, -1, -2, -3, -6, -6, -9, -12, -15};
+ printf("'%s'\n", str);
+
/* Find the base */
end = str;
while (*end != '\0')
diff --git a/src/mp-equation-parser.y b/src/mp-equation-parser.y
index 94ac6b4..1e746a9 100644
--- a/src/mp-equation-parser.y
+++ b/src/mp-equation-parser.y
@@ -116,7 +116,7 @@ exp:
| exp tINVERSE {mp_reciprocal(&$1, &$$);}
| exp '!' {mp_factorial(&$1, &$$);}
| tVARIABLE {get_variable(yyscanner, $1, &$$); free($1);}
-| tVARIABLE tVARIABLE {MPNumber t; get_variable(yyscanner, $1, &t); get_variable(yyscanner, $2, &$$); mp_multiply(&t, &$$, &$$); free($1);}
+| tVARIABLE tVARIABLE %prec MULTIPLICATION {MPNumber t; get_variable(yyscanner, $1, &t); get_variable(yyscanner, $2, &$$); mp_multiply(&t, &$$, &$$); free($1);}
| function {mp_set_from_mp(&$1, &$$);}
| tNUMBER function %prec MULTIPLICATION {mp_multiply(&$1, &$2, &$$);}
| tNUMBER tVARIABLE %prec MULTIPLICATION {get_variable(yyscanner, $2, &$$); mp_multiply(&$1, &$$, &$$); free($2);}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]