genius r749 - in trunk: . src
- From: jirka svn gnome org
- To: svn-commits-list gnome org
- Subject: genius r749 - in trunk: . src
- Date: Mon, 9 Mar 2009 21:48:32 +0000 (UTC)
Author: jirka
Date: Mon Mar 9 21:48:32 2009
New Revision: 749
URL: http://svn.gnome.org/viewvc/genius?rev=749&view=rev
Log:
Mon Mar 09 16:48:03 2009 Jiri (George) Lebl <jirka 5z com>
* src/*.[ch]: lots of cleanup plus bin compat breakage for plugins:
Moved many things to the gel_ or genius_ namespace for consistency
sake. There aren't actually any plugins that I know of so, who
cares if this all changes. Plus bin compat is already broken this
release, as it does almost every other release
* src/funclib.c: accept opposite orientation interval for
CompositeSimpsonsRule
* src/geniustests.txt: update tests
Modified:
trunk/ChangeLog
trunk/src/calc.c
trunk/src/calc.h
trunk/src/compil.c
trunk/src/dict.c
trunk/src/eval.c
trunk/src/eval.h
trunk/src/funclib.c
trunk/src/funclibhelper.cP
trunk/src/genius.c
trunk/src/genius_lists.c
trunk/src/geniustests.txt
trunk/src/gnome-genius.c
trunk/src/gnome-genius.h
trunk/src/graphing.c
trunk/src/inter.c
trunk/src/lexer.l
trunk/src/matop.c
trunk/src/matrixw.c
trunk/src/mpwrap.c
trunk/src/mpzextra.c
trunk/src/parse.y
trunk/src/parseutil.c
trunk/src/parseutil.h
trunk/src/structs.h
trunk/src/symbolic.c
trunk/src/testplugin.c
trunk/src/util.c
trunk/src/util.h
trunk/src/utype.c
Modified: trunk/src/calc.c
==============================================================================
--- trunk/src/calc.c (original)
+++ trunk/src/calc.c Mon Mar 9 21:48:32 2009
@@ -57,21 +57,16 @@
#include "parse.h"
-extern int lex_fd[2];
-extern int first_tok;
-extern int lex_init;
+extern int gel_lex_fd[2];
+extern int gel_first_tok;
+extern gboolean gel_lex_init;
extern char *yytext;
extern int yydebug;
extern const char *genius_toplevels[];
-gboolean genius_is_gui = FALSE;
-
-GelOutput *main_out = NULL;
-
-void (*evalnode_hook)(void) = NULL;
-void (*statechange_hook)(calcstate_t) = NULL;
+GelOutput *gel_main_out = NULL;
typedef struct {
char *category;
@@ -92,11 +87,11 @@
GSList *gel_parsestack=NULL;
/*error .. global as well*/
-GeniusError error_num = NO_ERROR;
+GeniusError gel_error_num = GEL_NO_ERROR;
gboolean gel_got_eof = FALSE;
/*the current state of the calculator*/
-calcstate_t calcstate = {0};
+GelCalcState gel_calcstate = {0};
/*error reporting function*/
void (*errorout)(const char *) = NULL;
@@ -105,7 +100,7 @@
GelCommand gel_command = GEL_NO_COMMAND;
char *gel_command_arg = NULL;
-gboolean interrupted = FALSE;
+gboolean gel_interrupted = FALSE;
static GSList *curfile = NULL;
static GSList *curline = NULL;
@@ -164,11 +159,14 @@
}
}
+/* The cache stuff is to increase startup time really, otherwise it is
+ * not really needed to be done fast, but during startup it is done many times
+ */
static GelHelp *get_help_cache = NULL;
static const char *get_help_func_cache = NULL;
GelHelp *
-get_help (const char *func, gboolean insert)
+gel_get_help (const char *func, gboolean insert)
{
GelHelp *help;
@@ -200,7 +198,7 @@
/* well sorted */
GSList *
-get_categories (void)
+gel_get_categories (void)
{
GSList *li, *list = NULL;
for (li = gel_categories; li != NULL; li = li->next) {
@@ -211,7 +209,7 @@
}
const char *
-get_category_name (const char *category)
+gel_get_category_name (const char *category)
{
HelpCategory *cat;
@@ -246,7 +244,7 @@
if (f->id == NULL ||
f->id->token == NULL)
continue;
- help = get_help (f->id->token, FALSE /* insert */);
+ help = gel_get_help (f->id->token, FALSE /* insert */);
if (help != NULL &&
help->category == NULL &&
help->aliasfor == NULL)
@@ -259,7 +257,7 @@
/* null for uncategorized */
GSList *
-get_helps (const char *category)
+gel_get_helps (const char *category)
{
HelpCategory *cat;
@@ -280,7 +278,7 @@
}
for (li = cat->funcs; li != NULL; li = li->next) {
const char *func = li->data;
- GelHelp *help = get_help (func, FALSE /* insert */);
+ GelHelp *help = gel_get_help (func, FALSE /* insert */);
if (help != NULL)
list = g_slist_prepend (list, help);
}
@@ -290,7 +288,7 @@
/* gets undocumented functions */
GSList *
-get_undocumented (void)
+gel_get_undocumented (void)
{
GSList *funcs;
GSList *li;
@@ -311,7 +309,7 @@
strcmp (f->id->token, "ninini") == 0 ||
strcmp (f->id->token, "shrubbery") == 0)
continue;
- help = get_help (f->id->token, FALSE /* insert */);
+ help = gel_get_help (f->id->token, FALSE /* insert */);
if (help == NULL)
list = g_slist_insert_sorted (list,
g_strdup (f->id->token),
@@ -321,7 +319,7 @@
}
void
-new_category (const char *category, const char *name, gboolean internal)
+gel_new_category (const char *category, const char *name, gboolean internal)
{
HelpCategory *cat;
@@ -354,9 +352,9 @@
}
void
-add_category (const char *func, const char *category)
+gel_add_category (const char *func, const char *category)
{
- GelHelp *help = get_help (func, TRUE /* insert */);
+ GelHelp *help = gel_get_help (func, TRUE /* insert */);
HelpCategory *cat = get_category (category,
TRUE /* insert */);
@@ -379,7 +377,7 @@
GelHelp *help;
GSList *li;
- help = get_help (func, TRUE /* insert */);
+ help = gel_get_help (func, TRUE /* insert */);
for (li = help->aliases; li != NULL; li = li->next) {
char *f = li->data;
if (strcmp (f, alias) == 0) {
@@ -392,17 +390,17 @@
}
void
-add_alias (const char *func, const char *alias)
+gel_add_alias (const char *func, const char *alias)
{
GelHelp *help, *ahelp;
- help = get_help (func, TRUE /* insert */);
+ help = gel_get_help (func, TRUE /* insert */);
if G_UNLIKELY (help->aliasfor != NULL) {
gel_errorout (_("Trying to set an alias for an alias"));
return;
}
- ahelp = get_help (alias, TRUE /* insert */);
+ ahelp = gel_get_help (alias, TRUE /* insert */);
if (ahelp->aliasfor != NULL) {
remove_alias (ahelp->aliasfor, alias);
g_free (ahelp->aliasfor);
@@ -414,37 +412,37 @@
}
void
-add_help_link (const char *func, const char *link)
+gel_add_help_link (const char *func, const char *link)
{
GelHelp *help;
- help = get_help (func, TRUE /* insert */);
+ help = gel_get_help (func, TRUE /* insert */);
g_free (help->help_html);
help->help_link = g_strdup (link);
}
void
-add_help_html (const char *func, const char *html)
+gel_add_help_html (const char *func, const char *html)
{
GelHelp *help;
- help = get_help (func, TRUE /* insert */);
+ help = gel_get_help (func, TRUE /* insert */);
g_free (help->help_html);
help->help_html = g_strdup (html);
}
void
-add_description (const char *func, const char *desc)
+gel_add_description (const char *func, const char *desc)
{
GelHelp *help;
- help = get_help (func, TRUE /* insert */);
+ help = gel_get_help (func, TRUE /* insert */);
g_free (help->description);
help->description = g_strdup (desc);
}
void
-whack_help (const char *func)
+gel_whack_help (const char *func)
{
GelHelp *help;
@@ -457,7 +455,7 @@
list = g_slist_copy (help->aliases);
for (li = list; li != NULL; li = li->next) {
- whack_help (li->data);
+ gel_whack_help (li->data);
g_free (li->data);
}
g_slist_free (list);
@@ -545,7 +543,7 @@
gboolean extra_param1 = FALSE;
gboolean extra_param2 = FALSE;
GelETree *l,*r;
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
if (l->type == VALUE_NODE &&
(mpw_is_complex (l->val.value) ||
mpw_sgn (l->val.value) < 0 ||
@@ -577,7 +575,7 @@
append_binaryoper(GelOutput *gelo, char *p, GelETree *n)
{
GelETree *l,*r;
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string(gelo, "(");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo, p);
@@ -589,7 +587,7 @@
append_unaryoper(GelOutput *gelo, char *p, GelETree *n)
{
GelETree *l;
- GET_L (n, l);
+ GEL_GET_L (n, l);
gel_output_string (gelo, "(");
gel_output_string (gelo, p);
gel_print_etree (gelo, l, FALSE);
@@ -618,7 +616,7 @@
case E_EQUALS:
append_binaryoper(gelo,"=",n); break;
case E_PARAMETER:
- GET_LRR(n,l,r,rr);
+ GEL_GET_LRR(n,l,r,rr);
if (l->type != NULL_NODE) {
gel_output_string(gelo,"(parameter (");
gel_print_etree (gelo, l, FALSE);
@@ -636,7 +634,7 @@
}
break;
case E_ABS:
- GET_L(n,l);
+ GEL_GET_L(n,l);
gel_output_string(gelo,"|");
gel_print_etree(gelo, l, FALSE);
gel_output_string(gelo,"|");
@@ -682,7 +680,7 @@
case E_ELTEXP:
append_anal_binaryoper(gelo,".^",n); break;
case E_FACT:
- GET_L(n,l);
+ GEL_GET_L(n,l);
gel_output_string(gelo, "(");
if (l->type == VALUE_NODE &&
(mpw_is_complex (l->val.value) ||
@@ -697,7 +695,7 @@
gel_output_string(gelo, "!)");
break;
case E_DBLFACT:
- GET_L(n,l);
+ GEL_GET_L(n,l);
gel_output_string(gelo, "(");
if (l->type == VALUE_NODE &&
(mpw_is_complex (l->val.value) ||
@@ -713,14 +711,14 @@
break;
case E_TRANSPOSE:
- GET_L(n,l);
+ GEL_GET_L(n,l);
gel_output_string(gelo, "(");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo, ".')");
break;
case E_CONJUGATE_TRANSPOSE:
- GET_L(n,l);
+ GEL_GET_L(n,l);
gel_output_string(gelo, "(");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo, "')");
@@ -753,7 +751,7 @@
append_binaryoper(gelo,":",n); break;
case E_REGION_SEP_BY:
- GET_LRR(n,l,r,rr);
+ GEL_GET_LRR(n,l,r,rr);
gel_output_string(gelo,"(");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo,":");
@@ -764,7 +762,7 @@
break;
case E_GET_VELEMENT:
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string(gelo,"(");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo,"@(");
@@ -773,7 +771,7 @@
break;
case E_GET_ELEMENT:
- GET_LRR(n,l,r,rr);
+ GEL_GET_LRR(n,l,r,rr);
gel_output_string(gelo,"(");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo,"@(");
@@ -783,7 +781,7 @@
gel_output_string(gelo,"))");
break;
case E_GET_ROW_REGION:
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string(gelo,"(");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo,"@(");
@@ -791,7 +789,7 @@
gel_output_string(gelo,",))");
break;
case E_GET_COL_REGION:
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string(gelo,"(");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo,"@(,");
@@ -807,7 +805,7 @@
append_unaryoper(gelo,"*",n); break;
case E_IF_CONS:
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string(gelo,"(if ");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo," then ");
@@ -815,7 +813,7 @@
gel_output_string(gelo,")");
break;
case E_IFELSE_CONS:
- GET_LRR(n,l,r,rr);
+ GEL_GET_LRR(n,l,r,rr);
gel_output_string(gelo,"(if ");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo," then ");
@@ -825,7 +823,7 @@
gel_output_string(gelo,")");
break;
case E_WHILE_CONS:
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string(gelo,"(while ");
gel_print_etree (gelo, l, FALSE);
gel_output_string (gelo," do ");
@@ -833,7 +831,7 @@
gel_output_string(gelo,")");
break;
case E_UNTIL_CONS:
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string(gelo, "(until ");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo, " do ");
@@ -841,7 +839,7 @@
gel_output_string(gelo, ")");
break;
case E_DOWHILE_CONS:
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string (gelo, "(do ");
gel_print_etree (gelo, l, FALSE);
gel_output_string (gelo, " while ");
@@ -849,7 +847,7 @@
gel_output_string (gelo, ")");
break;
case E_DOUNTIL_CONS:
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_output_string(gelo,"(do ");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo," until ");
@@ -857,7 +855,7 @@
gel_output_string(gelo,")");
break;
case E_FOR_CONS:
- GET_ABCD (n, a, b, c, d);
+ GEL_GET_ABCD (n, a, b, c, d);
gel_output_string (gelo, "(for ");
gel_print_etree (gelo, a, FALSE);
gel_output_string (gelo, " = ");
@@ -869,7 +867,7 @@
gel_output_string (gelo, ")");
break;
case E_FORBY_CONS:
- GET_ABCDE (n, a, b, c, d, e);
+ GEL_GET_ABCDE (n, a, b, c, d, e);
gel_output_string (gelo, "(for ");
gel_print_etree (gelo, a, FALSE);
gel_output_string (gelo, " = ");
@@ -883,7 +881,7 @@
gel_output_string (gelo, ")");
break;
case E_FORIN_CONS:
- GET_LRR(n,l,r,rr);
+ GEL_GET_LRR(n,l,r,rr);
gel_output_string(gelo,"(for ");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo," in ");
@@ -893,7 +891,7 @@
gel_output_string(gelo,")");
break;
case E_SUM_CONS:
- GET_ABCD (n, a, b, c, d);
+ GEL_GET_ABCD (n, a, b, c, d);
gel_output_string (gelo, "(sum ");
gel_print_etree (gelo, a, FALSE);
gel_output_string (gelo, " = ");
@@ -905,7 +903,7 @@
gel_output_string (gelo, ")");
break;
case E_SUMBY_CONS:
- GET_ABCDE (n, a, b, c, d, e);
+ GEL_GET_ABCDE (n, a, b, c, d, e);
gel_output_string (gelo, "(sum ");
gel_print_etree (gelo, a, FALSE);
gel_output_string (gelo, " = ");
@@ -919,7 +917,7 @@
gel_output_string (gelo, ")");
break;
case E_SUMIN_CONS:
- GET_LRR(n,l,r,rr);
+ GEL_GET_LRR(n,l,r,rr);
gel_output_string(gelo,"(sum ");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo," in ");
@@ -929,7 +927,7 @@
gel_output_string(gelo,")");
break;
case E_PROD_CONS:
- GET_ABCD(n,a,b,c,d);
+ GEL_GET_ABCD(n,a,b,c,d);
gel_output_string (gelo, "(prod ");
gel_print_etree (gelo, a, FALSE);
gel_output_string (gelo, " = ");
@@ -941,7 +939,7 @@
gel_output_string (gelo, ")");
break;
case E_PRODBY_CONS:
- GET_ABCDE (n, a, b, c, d, e);
+ GEL_GET_ABCDE (n, a, b, c, d, e);
gel_output_string (gelo, "(prod ");
gel_print_etree (gelo, a, FALSE);
gel_output_string (gelo, " = ");
@@ -955,7 +953,7 @@
gel_output_string (gelo, ")");
break;
case E_PRODIN_CONS:
- GET_LRR(n,l,r,rr);
+ GEL_GET_LRR(n,l,r,rr);
gel_output_string(gelo,"(prod ");
gel_print_etree (gelo, l, FALSE);
gel_output_string(gelo," in ");
@@ -967,7 +965,7 @@
case E_DIRECTCALL:
case E_CALL:
- GET_L(n,l);
+ GEL_GET_L(n,l);
if (l->type==IDENTIFIER_NODE) {
gel_output_string (gelo, l->id.id->token);
} else if (l->type == FUNCTION_NODE &&
@@ -975,7 +973,7 @@
gel_output_string (gelo, l->func.func->id->token);
} else if(l->type == OPERATOR_NODE && l->op.oper == E_DEREFERENCE) {
GelETree *t;
- GET_L(l,t);
+ GEL_GET_L(l,t);
if G_UNLIKELY (t->type!=IDENTIFIER_NODE) {
gel_errorout (_("Bad identifier for function node!"));
gel_output_string(gelo,"?)");
@@ -1160,13 +1158,13 @@
{
int i,j;
- if (calcstate.output_style == GEL_OUTPUT_TROFF) {
+ if (gel_calcstate.output_style == GEL_OUTPUT_TROFF) {
appendmatrix_troff (gelo, m, FALSE /* nice */);
return;
- } else if (calcstate.output_style == GEL_OUTPUT_LATEX) {
+ } else if (gel_calcstate.output_style == GEL_OUTPUT_LATEX) {
appendmatrix_latex (gelo, m, FALSE /* nice */);
return;
- } else if (calcstate.output_style == GEL_OUTPUT_MATHML) {
+ } else if (gel_calcstate.output_style == GEL_OUTPUT_MATHML) {
appendmatrix_mathml (gelo, m, FALSE /* nice */);
return;
}
@@ -1228,15 +1226,15 @@
first = FALSE;
p = mpw_getstring_chop (n->poly.indexes[i],
- calcstate.max_digits,
- calcstate.scientific_notation,
- calcstate.results_as_floats,
- calcstate.mixed_fractions,
- calcstate.output_style,
- calcstate.integer_output_base,
+ gel_calcstate.max_digits,
+ gel_calcstate.scientific_notation,
+ gel_calcstate.results_as_floats,
+ gel_calcstate.mixed_fractions,
+ gel_calcstate.output_style,
+ gel_calcstate.integer_output_base,
TRUE /* add parenths */,
- calcstate.chop,
- calcstate.chop_when,
+ gel_calcstate.chop,
+ gel_calcstate.chop_when,
gelo->force_chop);
gel_output_string (gelo, p);
g_free (p);
@@ -1370,7 +1368,7 @@
/* all non-value nodes printed as <ci></ci> and
* value nodes as <cn></cn> */
- if (calcstate.output_style == GEL_OUTPUT_MATHML &&
+ if (gel_calcstate.output_style == GEL_OUTPUT_MATHML &&
n->type != VALUE_NODE)
gel_output_string (gelo, "<ci>");
@@ -1380,15 +1378,15 @@
gel_output_string (gelo, "(null)");
break;
case VALUE_NODE:
- p=mpw_getstring_chop (n->val.value,calcstate.max_digits,
- calcstate.scientific_notation,
- calcstate.results_as_floats,
- calcstate.mixed_fractions,
- calcstate.output_style,
- calcstate.integer_output_base,
+ p=mpw_getstring_chop (n->val.value,gel_calcstate.max_digits,
+ gel_calcstate.scientific_notation,
+ gel_calcstate.results_as_floats,
+ gel_calcstate.mixed_fractions,
+ gel_calcstate.output_style,
+ gel_calcstate.integer_output_base,
! toplevel /* add parenths */,
- calcstate.chop,
- calcstate.chop_when,
+ gel_calcstate.chop,
+ gel_calcstate.chop_when,
gelo->force_chop);
#if 0
/* should we print the full number at toplevel ...??? no,
@@ -1397,10 +1395,10 @@
if(toplevel)
gel_output_full_string(gelo,p);
#endif
- if (calcstate.output_style == GEL_OUTPUT_MATHML)
+ if (gel_calcstate.output_style == GEL_OUTPUT_MATHML)
gel_output_string (gelo, "<cn>");
gel_output_string(gelo,p);
- if (calcstate.output_style == GEL_OUTPUT_MATHML)
+ if (gel_calcstate.output_style == GEL_OUTPUT_MATHML)
gel_output_string (gelo, "</cn>");
g_free(p);
break;
@@ -1408,11 +1406,11 @@
old_force_chop = gelo->force_chop;
if ( ! gelo->force_chop &&
matrix_chop_p (n->mat.matrix,
- calcstate.chop_when))
+ gel_calcstate.chop_when))
gelo->force_chop ++;
- if (calcstate.output_style != GEL_OUTPUT_TROFF &&
- calcstate.output_style != GEL_OUTPUT_LATEX &&
- calcstate.output_style != GEL_OUTPUT_MATHML &&
+ if (gel_calcstate.output_style != GEL_OUTPUT_TROFF &&
+ gel_calcstate.output_style != GEL_OUTPUT_LATEX &&
+ gel_calcstate.output_style != GEL_OUTPUT_MATHML &&
n->mat.quoted)
gel_output_string (gelo, "`");
appendmatrix (gelo, n->mat.matrix);
@@ -1433,7 +1431,7 @@
break;
case STRING_NODE:
gel_output_string(gelo,"\"");
- p = escape_string(n->str.str);
+ p = gel_escape_string(n->str.str);
gel_output_string(gelo,p);
g_free(p);
gel_output_string(gelo,"\"");
@@ -1457,7 +1455,7 @@
}
/* all non-value nodes printed as <ci></ci> and
* value nodes as <cn></cn> */
- if (calcstate.output_style == GEL_OUTPUT_MATHML &&
+ if (gel_calcstate.output_style == GEL_OUTPUT_MATHML &&
n->type != VALUE_NODE)
gel_output_string (gelo, "</ci>");
@@ -1512,15 +1510,15 @@
z = mpw_peek_real_mpz (den);
if (z == NULL ||
- mpz_sizeinbase (z, calcstate.integer_output_base) - 1
- > calcstate.max_digits) {
+ mpz_sizeinbase (z, gel_calcstate.integer_output_base) - 1
+ > gel_calcstate.max_digits) {
mpw_clear (den);
mpw_clear (num);
mpw_clear (whole);
goto just_print_a_number;
}
- if (calcstate.mixed_fractions &&
+ if (gel_calcstate.mixed_fractions &&
mpw_cmp (num, den) > 0) {
mpz_t quot;
mpz_t rem;
@@ -1539,8 +1537,8 @@
z = mpw_peek_real_mpz (whole);
if (z == NULL ||
- mpz_sizeinbase (z, calcstate.integer_output_base) - 1
- > calcstate.max_digits) {
+ mpz_sizeinbase (z, gel_calcstate.integer_output_base) - 1
+ > gel_calcstate.max_digits) {
mpw_clear (den);
mpw_clear (num);
mpw_clear (whole);
@@ -1548,12 +1546,12 @@
}
wholes = mpw_getstring (whole,
- 0 /* calcstate.max_digits */,
- calcstate.scientific_notation,
- calcstate.results_as_floats,
- calcstate.mixed_fractions,
- calcstate.output_style,
- calcstate.integer_output_base,
+ 0 /* gel_calcstate.max_digits */,
+ gel_calcstate.scientific_notation,
+ gel_calcstate.results_as_floats,
+ gel_calcstate.mixed_fractions,
+ gel_calcstate.output_style,
+ gel_calcstate.integer_output_base,
FALSE);
lenw = strlen_max (wholes, columns);
} else {
@@ -1563,8 +1561,8 @@
z = mpw_peek_real_mpz (num);
if (z == NULL ||
- mpz_sizeinbase (z, calcstate.integer_output_base) - 1
- > calcstate.max_digits) {
+ mpz_sizeinbase (z, gel_calcstate.integer_output_base) - 1
+ > gel_calcstate.max_digits) {
mpw_clear (den);
mpw_clear (num);
mpw_clear (whole);
@@ -1575,21 +1573,21 @@
since sizeinbase can be 1 off, but that's ok */
nums = mpw_getstring (num,
- 0 /* calcstate.max_digits */,
- calcstate.scientific_notation,
- calcstate.results_as_floats,
- calcstate.mixed_fractions,
- calcstate.output_style,
- calcstate.integer_output_base,
+ 0 /* gel_calcstate.max_digits */,
+ gel_calcstate.scientific_notation,
+ gel_calcstate.results_as_floats,
+ gel_calcstate.mixed_fractions,
+ gel_calcstate.output_style,
+ gel_calcstate.integer_output_base,
FALSE);
lenn = strlen_max (nums, columns);
dens = mpw_getstring (den,
- 0 /* calcstate.max_digits */,
- calcstate.scientific_notation,
- calcstate.results_as_floats,
- calcstate.mixed_fractions,
- calcstate.output_style,
- calcstate.integer_output_base,
+ 0 /* gel_calcstate.max_digits */,
+ gel_calcstate.scientific_notation,
+ gel_calcstate.results_as_floats,
+ gel_calcstate.mixed_fractions,
+ gel_calcstate.output_style,
+ gel_calcstate.integer_output_base,
FALSE);
lend = strlen_max (dens, columns);
@@ -1652,7 +1650,7 @@
top node*/
gel_output_push_nonotify (gelo);
if (n->type == VALUE_NODE &&
- calcstate.output_style == GEL_OUTPUT_NORMAL) {
+ gel_calcstate.output_style == GEL_OUTPUT_NORMAL) {
pretty_print_value_normal (gelo, n);
} else if (n->type == MATRIX_NODE) {
int i, j, w, h;
@@ -1662,22 +1660,22 @@
GelOutput *sgelo;
if ( ! gelo->force_chop &&
matrix_chop_p (n->mat.matrix,
- calcstate.chop_when))
+ gel_calcstate.chop_when))
gelo->force_chop ++;
- if (calcstate.output_style == GEL_OUTPUT_TROFF) {
+ if (gel_calcstate.output_style == GEL_OUTPUT_TROFF) {
appendmatrix_troff (gelo, n->mat.matrix, TRUE /* nice */);
gel_output_pop_nonotify (gelo);
gelo->force_chop = old_force_chop;
return;
- } else if (calcstate.output_style == GEL_OUTPUT_LATEX) {
+ } else if (gel_calcstate.output_style == GEL_OUTPUT_LATEX) {
appendmatrix_latex (gelo, n->mat.matrix, TRUE /* nice */);
gel_output_pop_nonotify (gelo);
gelo->force_chop = old_force_chop;
return;
- } else if (calcstate.output_style == GEL_OUTPUT_MATHML) {
+ } else if (gel_calcstate.output_style == GEL_OUTPUT_MATHML) {
if (gelo->cur_line_pos != 0)
gel_output_string (gelo, "\n");
gel_output_string (gelo, "<math>");
@@ -1757,10 +1755,10 @@
gel_output_string(gelo, "]");
gelo->force_chop = old_force_chop;
} else {
- if (calcstate.output_style == GEL_OUTPUT_MATHML)
+ if (gel_calcstate.output_style == GEL_OUTPUT_MATHML)
gel_output_string (gelo, "\n<math>\n ");
gel_print_etree (gelo, n, TRUE);
- if (calcstate.output_style == GEL_OUTPUT_MATHML)
+ if (gel_calcstate.output_style == GEL_OUTPUT_MATHML)
gel_output_string (gelo, "\n</math>");
}
@@ -1858,7 +1856,7 @@
func->extra_dict,
TRUE /* is_extra_dict */);
- help = get_help (func->id->token, FALSE /* insert */);
+ help = gel_get_help (func->id->token, FALSE /* insert */);
if (help != NULL && help->aliasfor != NULL) {
fprintf (outfile, "A;%s;%s\n",
help->aliasfor,
@@ -1931,11 +1929,11 @@
dictionary*/
d_singlecontext ();
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
/*if we this was set, then the mp library was initialized for
sure*/
- g_assert (calcstate.float_prec > 0);
+ g_assert (gel_calcstate.float_prec > 0);
while ( ! break_on_next && fgets (buf, buf_size, fp) != NULL) {
char *p;
@@ -1986,7 +1984,7 @@
gel_errorout (_("Badly formed record"));
continue;
}
- add_alias(p,d);
+ gel_add_alias(p,d);
continue;
} else if (*p == 'C') {
char *d;
@@ -2000,7 +1998,7 @@
gel_errorout (_("Badly formed record"));
continue;
}
- add_category(p,d);
+ gel_add_category(p,d);
continue;
} else if (*p == 'D') {
char *d;
@@ -2014,7 +2012,7 @@
gel_errorout (_("Badly formed record"));
continue;
}
- add_description(p,d);
+ gel_add_description(p,d);
continue;
} else if (*p == 'L') {
char *d, *h;
@@ -2029,7 +2027,7 @@
continue;
}
h = gel_decode_string (d);
- add_help_link (p, h);
+ gel_add_help_link (p, h);
g_free (h);
continue;
} else if (*p == 'H') {
@@ -2045,7 +2043,7 @@
continue;
}
h = gel_decode_string (d);
- add_help_html (p, h);
+ gel_add_help_html (p, h);
g_free (h);
continue;
} else if (*p == 'P') {
@@ -2226,7 +2224,7 @@
do_cyan (void)
{
if (genius_is_gui) {
- gel_output_full_string (main_out, "\e[1;36m");
+ gel_output_full_string (gel_main_out, "\e[1;36m");
}
}
@@ -2234,7 +2232,7 @@
do_blue (void)
{
if (genius_is_gui) {
- gel_output_full_string (main_out, "\e[1;34m");
+ gel_output_full_string (gel_main_out, "\e[1;34m");
}
}
@@ -2242,7 +2240,7 @@
do_green (void)
{
if (genius_is_gui) {
- gel_output_full_string (main_out, "\e[0;32m");
+ gel_output_full_string (gel_main_out, "\e[0;32m");
}
}
@@ -2251,7 +2249,7 @@
do_red (void)
{
if (genius_is_gui) {
- gel_output_full_string (main_out, "\e[01;31m");
+ gel_output_full_string (gel_main_out, "\e[01;31m");
}
}
*/
@@ -2260,7 +2258,7 @@
do_black (void)
{
if (genius_is_gui) {
- gel_output_full_string (main_out, "\e[0m");
+ gel_output_full_string (gel_main_out, "\e[0m");
}
}
@@ -2279,13 +2277,13 @@
static void
print_description (int start, const char *desc)
{
- int ll = gel_output_get_columns (main_out) - start - 3;
+ int ll = gel_output_get_columns (gel_main_out) - start - 3;
char **words;
int i;
int cur;
if (ll <= 5) {
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"%s\n", desc);
return;
}
@@ -2297,17 +2295,17 @@
if (cur != 0 && cur + len >= ll) {
cur = 0;
gel_output_full_string
- (main_out, "\n ");
+ (gel_main_out, "\n ");
} else if (cur != 0) {
- gel_output_full_string (main_out, " ");
+ gel_output_full_string (gel_main_out, " ");
cur++;
}
- gel_output_full_string (main_out, words[i]);
+ gel_output_full_string (gel_main_out, words[i]);
cur += len;
}
g_strfreev (words);
- gel_output_full_string (main_out, "\n");
+ gel_output_full_string (gel_main_out, "\n");
}
static void
@@ -2322,7 +2320,7 @@
#if 0
/* This can be used to autogenerate some docbook */
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
" <varlistentry id=\"gel-function-%s\">\n"
" <term>%s</term>\n"
" <listitem>\n"
@@ -2336,23 +2334,23 @@
! ff->vararg) ||
(ff->named_args == NULL &&
d_intern (help->func)->parameter)) {
- gel_output_printf_full (main_out, FALSE, "%s</synopsis>\n", help->func);
+ gel_output_printf_full (gel_main_out, FALSE, "%s</synopsis>\n", help->func);
} else {
GSList *li;
- gel_output_printf_full (main_out, FALSE, "%s (", help->func);
+ gel_output_printf_full (gel_main_out, FALSE, "%s (", help->func);
for (li = ff->named_args; li != NULL; li = li->next) {
GelToken *id = li->data;
if (li != ff->named_args)
- gel_output_full_string (main_out, ",");
- gel_output_full_string (main_out, id->token);
+ gel_output_full_string (gel_main_out, ",");
+ gel_output_full_string (gel_main_out, id->token);
}
if (ff->vararg)
- gel_output_full_string (main_out, "...");
- gel_output_full_string (main_out, ")</synopsis>\n");
+ gel_output_full_string (gel_main_out, "...");
+ gel_output_full_string (gel_main_out, ")</synopsis>\n");
}
- gel_output_printf_full (main_out, FALSE, " <para>");
+ gel_output_printf_full (gel_main_out, FALSE, " <para>");
if (help->aliases != NULL) {
GSList *li;
GString *gs = g_string_new ("Aliases:");
@@ -2361,11 +2359,11 @@
g_string_append (gs, li->data);
g_string_append (gs, "</function>");
}
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"%s</para>\n <para>", gs->str);
g_string_free (gs, TRUE);
}
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"%s</para>\n </listitem>\n </varlistentry>\n\n",
help->description);
}
@@ -2374,20 +2372,20 @@
/*if (len <= 20)*/
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"%-20s", f);
/*else
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"%-20s", help->func);*/
g_free (f);
do_black ();
- gel_output_full_string (main_out, " - ");
+ gel_output_full_string (gel_main_out, " - ");
do_green ();
if (help->description != NULL)
print_description (MAX (20, len),
_(help->description));
else
- gel_output_full_string (main_out, "\n");
+ gel_output_full_string (gel_main_out, "\n");
/* if we didn't fit aliases on one line */
/*
if (len > 20 && help->aliases != NULL) {
@@ -2399,7 +2397,7 @@
g_string_append (gs, " ");
g_string_append (gs, li->data);
}
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"%s\n", gs->str);
g_string_free (gs, TRUE);
}
@@ -2411,31 +2409,31 @@
print_command_help (const char *cmd)
{
do_cyan ();
- gel_output_printf_full (main_out, FALSE, "%-20s", cmd);
+ gel_output_printf_full (gel_main_out, FALSE, "%-20s", cmd);
do_black ();
- gel_output_full_string (main_out, " - ");
+ gel_output_full_string (gel_main_out, " - ");
do_green ();
if (strcmp (cmd, "load") == 0) {
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("Load a file into the interpretor"));
} else if (strcmp (cmd, "plugin") == 0) {
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("Load a plugin"));
} else if (strcmp (cmd, "ls") == 0) {
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("List files in the current directory"));
} else if (strcmp (cmd, "cd") == 0) {
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("Change directory"));
} else if (strcmp (cmd, "pwd") == 0) {
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("Print current directory"));
} else if (strcmp (cmd, "help") == 0) {
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("Print help (or help on a function/command)"));
}
- gel_output_full_string (main_out, "\n");
+ gel_output_full_string (gel_main_out, "\n");
}
static void
@@ -2445,34 +2443,34 @@
GSList *cli, *fli;
int i;
- gel_output_push_nonotify (main_out);
+ gel_output_push_nonotify (gel_main_out);
do_green ();
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("\nFor a manual on using Genius and the GEL language type:\n"));
do_black ();
- gel_output_full_string (main_out, _(" manual\n"));
+ gel_output_full_string (gel_main_out, _(" manual\n"));
do_green ();
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("\nFor help on a specific function type:\n"));
do_black ();
- gel_output_full_string (main_out, _(" help FunctionName\n"));
+ gel_output_full_string (gel_main_out, _(" help FunctionName\n"));
do_black ();
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("\nCommands:\n"));
for (i = 0; genius_toplevels[i] != NULL; i++)
print_command_help (genius_toplevels[i]);
for (cli = gel_categories; cli != NULL; cli = cli->next) {
HelpCategory *cat = cli->data;
- functions = get_helps (cat->category);
+ functions = gel_get_helps (cat->category);
if (functions != NULL) {
do_black ();
- gel_output_printf_full (main_out, FALSE, "\n%s:\n",
- get_category_name (cat->category));
+ gel_output_printf_full (gel_main_out, FALSE, "\n%s:\n",
+ gel_get_category_name (cat->category));
for (fli = functions; fli != NULL; fli = fli->next) {
GelHelp *help = fli->data;
@@ -2483,11 +2481,11 @@
}
}
- functions = get_helps (NULL);
+ functions = gel_get_helps (NULL);
if (functions != NULL) {
do_black ();
- gel_output_printf_full (main_out, FALSE, "\n%s:\n",
- get_category_name (NULL));
+ gel_output_printf_full (gel_main_out, FALSE, "\n%s:\n",
+ gel_get_category_name (NULL));
for (fli = functions; fli != NULL; fli = fli->next) {
GelHelp *help = fli->data;
@@ -2497,15 +2495,15 @@
g_slist_free (functions);
}
- functions = get_undocumented ();
+ functions = gel_get_undocumented ();
if (functions != NULL) {
GString *gs = g_string_new (NULL);
int len = 0;
- int line_len = gel_output_get_columns (main_out);
+ int line_len = gel_output_get_columns (gel_main_out);
do_black ();
- gel_output_full_string (main_out,
+ gel_output_full_string (gel_main_out,
_("\nUndocumented:\n"));
do_cyan ();
@@ -2514,7 +2512,7 @@
int flen = strlen (f);
if (len + flen + 1 > line_len-2 && len > 0) {
- gel_output_printf_full (main_out, FALSE, "%s\n",
+ gel_output_printf_full (gel_main_out, FALSE, "%s\n",
gs->str);
g_string_truncate (gs, 0);
len = 0;
@@ -2529,7 +2527,7 @@
g_free (f);
}
if (len > 0) {
- gel_output_printf_full (main_out, FALSE, "%s\n",
+ gel_output_printf_full (gel_main_out, FALSE, "%s\n",
gs->str);
}
g_string_free (gs, TRUE);
@@ -2539,7 +2537,7 @@
do_black ();
- gel_output_pop_nonotify (main_out);
+ gel_output_pop_nonotify (gel_main_out);
}
void
@@ -2556,18 +2554,18 @@
GelEFunc *f;
int i;
- gel_output_push_nonotify (main_out);
+ gel_output_push_nonotify (gel_main_out);
for (i = 0; genius_toplevels[i] != NULL; i++)
if (strcmp (text, genius_toplevels[i]) == 0) {
print_command_help (text);
gel_call_help (text);
do_black ();
- gel_output_pop_nonotify (main_out);
+ gel_output_pop_nonotify (gel_main_out);
return;
}
- help = get_help (text, FALSE /*insert*/);
+ help = gel_get_help (text, FALSE /*insert*/);
if (help == NULL) {
char *similar_ids = gel_similar_possible_ids (text);
if (similar_ids == NULL) {
@@ -2582,12 +2580,12 @@
}
if (help->aliasfor) {
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
_("%s is an alias for %s\n"),
text, help->aliasfor);
gel_help_on (help->aliasfor);
do_black ();
- gel_output_pop_nonotify (main_out);
+ gel_output_pop_nonotify (gel_main_out);
return;
}
@@ -2596,27 +2594,27 @@
f = d_lookup_global (d_intern (text));
if (d_intern (text)->parameter) {
- gel_output_printf_full (main_out, FALSE, "%s%s\n",
+ gel_output_printf_full (gel_main_out, FALSE, "%s%s\n",
_("Parameter: "), text);
} else if (f == NULL
|| (f->type == GEL_BUILTIN_FUNC &&
f->named_args == NULL &&
! f->vararg)) {
- gel_output_printf_full (main_out, FALSE, "%s\n", text);
+ gel_output_printf_full (gel_main_out, FALSE, "%s\n", text);
} else {
GSList *li;
- gel_output_printf_full (main_out, FALSE, "%s (", text);
+ gel_output_printf_full (gel_main_out, FALSE, "%s (", text);
for (li = f->named_args; li != NULL; li = li->next) {
GelToken *id = li->data;
if (li != f->named_args)
- gel_output_full_string (main_out, ",");
- gel_output_full_string (main_out, id->token);
+ gel_output_full_string (gel_main_out, ",");
+ gel_output_full_string (gel_main_out, id->token);
}
if (f->vararg)
- gel_output_full_string (main_out, "...");
- gel_output_full_string (main_out, ")\n");
+ gel_output_full_string (gel_main_out, "...");
+ gel_output_full_string (gel_main_out, ")\n");
}
do_green ();
@@ -2627,19 +2625,19 @@
g_string_append (gs, " ");
g_string_append (gs, li->data);
}
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"%s\n", gs->str);
g_string_free (gs, TRUE);
}
if (help->description != NULL) {
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
_("Description: %s\n"),
_(help->description));
}
do_black ();
- gel_output_pop_nonotify (main_out);
+ gel_output_pop_nonotify (gel_main_out);
if (help != ¬_documented)
gel_call_help (text);
@@ -2663,7 +2661,7 @@
GSList *functions;
GSList *fli;
- functions = get_helps (cat);
+ functions = gel_get_helps (cat);
if (functions != NULL) {
for (fli = functions; fli != NULL; fli = fli->next) {
@@ -2706,20 +2704,19 @@
}
void
-set_new_calcstate(calcstate_t state)
+gel_set_new_calcstate(GelCalcState state)
{
- if(calcstate.float_prec != state.float_prec) {
+ if(gel_calcstate.float_prec != state.float_prec) {
mpw_init_mp(); /*just in case we haven't yet*/
mpw_set_default_prec(state.float_prec);
gel_break_fp_caches();
}
/*set the state variable for calculator*/
- calcstate=state;
+ gel_calcstate=state;
/*if the calling process already knows, who cares,
but call it anyway*/
- if(statechange_hook)
- (*statechange_hook)(state);
+ gel_set_state (state);
}
static void
@@ -2732,7 +2729,7 @@
gel_got_eof = FALSE;
break;
}
- if(interrupted)
+ if G_UNLIKELY (gel_interrupted)
break;
}
gel_test_max_nodes_again ();
@@ -2803,13 +2800,13 @@
}
void
-set_new_errorout(void (*func)(const char *))
+gel_set_new_errorout(void (*func)(const char *))
{
errorout = func;
}
void
-set_new_infoout(void (*func)(const char *))
+gel_set_new_infoout(void (*func)(const char *))
{
infoout = func;
}
@@ -2884,17 +2881,17 @@
break;
case GEL_LOADFILE:
while (gel_parsestack)
- gel_freetree (stack_pop (&gel_parsestack));
+ gel_freetree (gel_stack_pop (&gel_parsestack));
gel_load_file (dirprefix, arg, TRUE);
ret = TRUE;
break;
case GEL_LOADFILE_GLOB:
list = get_wordlist (arg);
while (gel_parsestack)
- gel_freetree (stack_pop (&gel_parsestack));
+ gel_freetree (gel_stack_pop (&gel_parsestack));
for (li = list; li != NULL; li = li->next) {
gel_load_guess_file (dirprefix, li->data, TRUE);
- if (interrupted)
+ if G_UNLIKELY (gel_interrupted)
break;
}
g_slist_foreach (list, (GFunc)g_free, NULL);
@@ -2904,7 +2901,7 @@
case GEL_CHANGEDIR:
list = get_wordlist (arg);
while (gel_parsestack)
- gel_freetree (stack_pop (&gel_parsestack));
+ gel_freetree (gel_stack_pop (&gel_parsestack));
for (li = list; li != NULL; li = li->next) {
our_chdir (dirprefix, li->data);
}
@@ -2941,11 +2938,11 @@
S_ISDIR (s.st_mode)) {
if (genius_is_gui)
do_blue ();
- gel_output_string (main_out, de->d_name);
+ gel_output_string (gel_main_out, de->d_name);
if (genius_is_gui)
do_black ();
- gel_output_string (main_out, "/\n");
+ gel_output_string (gel_main_out, "/\n");
}
}
rewinddir (dir);
@@ -2962,10 +2959,10 @@
strcmp (ext, ".gel") == 0) {
do_green ();
}
- gel_output_string (main_out, de->d_name);
+ gel_output_string (gel_main_out, de->d_name);
if (genius_is_gui)
do_black ();
- gel_output_string (main_out, "\n");
+ gel_output_string (gel_main_out, "\n");
}
}
@@ -2982,10 +2979,10 @@
S_ISDIR (s.st_mode)) {
if (genius_is_gui)
do_blue ();
- gel_output_string (main_out, li->data);
+ gel_output_string (gel_main_out, li->data);
if (genius_is_gui)
do_black ();
- gel_output_string (main_out, "/\n");
+ gel_output_string (gel_main_out, "/\n");
}
}
@@ -2999,10 +2996,10 @@
strcmp (ext, ".gel") == 0) {
do_green ();
}
- gel_output_string (main_out, li->data);
+ gel_output_string (gel_main_out, li->data);
if (genius_is_gui)
do_black ();
- gel_output_string (main_out, "\n");
+ gel_output_string (gel_main_out, "\n");
}
}
@@ -3016,8 +3013,8 @@
gel_errorout (_("getcwd error: %s"),
g_strerror (errno));
} else {
- gel_output_string (main_out, buf);
- gel_output_string (main_out, "\n");
+ gel_output_string (gel_main_out, buf);
+ gel_output_string (gel_main_out, "\n");
}
ret = TRUE;
break;
@@ -3042,7 +3039,7 @@
void
gel_execinit (void)
{
- interrupted = FALSE;
+ gel_interrupted = FALSE;
/*init the context stack and clear out any stale dictionaries
except the global one, if this is the first time called it
@@ -3057,13 +3054,13 @@
{
int stacklen;
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
/*if we this was set, then the mp library was initialized for
sure*/
- g_assert(calcstate.float_prec>0);
+ g_assert(gel_calcstate.float_prec>0);
- first_tok = STARTTOK;
+ gel_first_tok = STARTTOK;
g_assert(str || infile);
g_assert(!(str && infile));
@@ -3071,26 +3068,26 @@
if(str) {
int l = strlen(str);
errno = 0;
- if G_UNLIKELY (pipe(lex_fd) != 0) {
+ if G_UNLIKELY (pipe(gel_lex_fd) != 0) {
gel_errorout (_("ERROR: 'pipe' failed: %s"),
g_strerror (errno));
return NULL;
}
- infile = fdopen(lex_fd[0], "r");
+ infile = fdopen(gel_lex_fd[0], "r");
errno = 0;
- if (write(lex_fd[1], str, l) < l) {
+ if (write(gel_lex_fd[1], str, l) < l) {
gel_errorout (_("ERROR: 'write' possibly failed: %s"),
g_strerror (errno));
}
if(str[l-1] != '\n') {
errno = 0;
- if (write(lex_fd[1], "\n", 1) < 1) {
+ if (write(gel_lex_fd[1], "\n", 1) < 1) {
gel_errorout (_("ERROR: 'write' possibly failed: %s"),
g_strerror (errno));
}
}
- close(lex_fd[1]);
+ close(gel_lex_fd[1]);
gel_lexer_open(infile);
}
@@ -3098,7 +3095,7 @@
g_free (gel_command_arg);
gel_command_arg = NULL;
- lex_init = TRUE;
+ gel_lex_init = TRUE;
/*yydebug=TRUE;*/ /*turn debugging of parsing on here!*/
if(testparse) ignore_end_parse_errors = TRUE;
got_end_too_soon = FALSE;
@@ -3111,7 +3108,7 @@
if(str) {
while(my_yyinput()!=EOF)
;
- close(lex_fd[0]);
+ close(gel_lex_fd[0]);
fflush(infile);
gel_lexer_close(infile);
/*fclose(infile);*/
@@ -3128,15 +3125,15 @@
/*if we are testing and got an unfinished expression just report that*/
if(testparse && got_end_too_soon) {
while(gel_parsestack)
- gel_freetree(stack_pop(&gel_parsestack));
+ gel_freetree(gel_stack_pop(&gel_parsestack));
if(finished) *finished = FALSE;
return NULL;
}
/*catch parsing errors*/
- if(error_num!=NO_ERROR) {
+ if(gel_error_num!=GEL_NO_ERROR) {
while(gel_parsestack)
- gel_freetree(stack_pop(&gel_parsestack));
+ gel_freetree(gel_stack_pop(&gel_parsestack));
if(finished) *finished = TRUE;
return NULL;
}
@@ -3151,21 +3148,21 @@
/*stack is supposed to have only ONE entry*/
if(stacklen!=1) {
while(gel_parsestack)
- gel_freetree(stack_pop(&gel_parsestack));
+ gel_freetree(gel_stack_pop(&gel_parsestack));
if G_UNLIKELY (!testparse)
gel_errorout (_("ERROR: Probably corrupt stack!"));
if(finished) *finished = FALSE;
return NULL;
}
- replace_equals (gel_parsestack->data, FALSE /* in_expression */);
- replace_exp (gel_parsestack->data);
- fixup_num_neg (gel_parsestack->data);
- gel_parsestack->data = gather_comparisons (gel_parsestack->data);
- try_to_do_precalc (gel_parsestack->data);
+ gel_replace_equals (gel_parsestack->data, FALSE /* in_expression */);
+ gel_replace_exp (gel_parsestack->data);
+ gel_fixup_num_neg (gel_parsestack->data);
+ gel_parsestack->data = gel_gather_comparisons (gel_parsestack->data);
+ gel_try_to_do_precalc (gel_parsestack->data);
if (finished != NULL)
*finished = TRUE;
- return stack_pop (&gel_parsestack);
+ return gel_stack_pop (&gel_parsestack);
}
GelETree *
@@ -3182,13 +3179,13 @@
busy = TRUE;
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
gel_push_file_info(NULL,0);
- ctx = eval_get_context();
- ret = eval_etree (ctx, exp);
- eval_free_context(ctx);
+ ctx = gel_eval_get_context();
+ ret = gel_eval_etree (ctx, exp);
+ gel_eval_free_context(ctx);
gel_pop_file_info();
@@ -3197,7 +3194,7 @@
/*catch evaluation errors*/
if(!ret)
return NULL;
- if(error_num!=NO_ERROR) {
+ if(gel_error_num!=GEL_NO_ERROR) {
gel_freetree(ret);
return NULL;
}
@@ -3295,7 +3292,7 @@
g_free (tmp);
}
- error_num = PARSE_ERROR;
+ gel_error_num = GEL_PARSE_ERROR;
}
void
Modified: trunk/src/calc.h
==============================================================================
--- trunk/src/calc.h (original)
+++ trunk/src/calc.h Mon Mar 9 21:48:32 2009
@@ -29,22 +29,22 @@
#include "structs.h"
-#define COPYRIGHT_STRING "Copyright (C) 1997-2009 JiÅÃ (George) Lebl, Ph.D."
+#define GENIUS_COPYRIGHT_STRING "Copyright (C) 1997-2009 JiÅÃ (George) Lebl, Ph.D."
typedef enum {
- NO_ERROR = 0,
- PARSE_ERROR,
- INTERNAL_MPW_ERROR,
- NUMERICAL_MPW_ERROR,
- EOF_ERROR,
- EOE_ERROR, /*end of expression*/
- IGNORE_ERROR /*set this if you want to ignore the result*/
+ GEL_NO_ERROR = 0,
+ GEL_PARSE_ERROR,
+ GEL_INTERNAL_MPW_ERROR,
+ GEL_NUMERICAL_MPW_ERROR,
+ GEL_EOF_ERROR,
+ GEL_EOE_ERROR, /*end of expression*/
+ GEL_IGNORE_ERROR /*set this if you want to ignore the result*/
} GeniusError;
/* FIXME: This should be nicer */
-extern GeniusError error_num;
+extern GeniusError gel_error_num;
-extern gboolean interrupted;
+extern gboolean gel_interrupted;
typedef enum {
GEL_OUTPUT_NORMAL,
@@ -53,7 +53,7 @@
GEL_OUTPUT_MATHML
} GelOutputStyle;
-typedef struct _calcstate_t {
+typedef struct {
/*about incoming stuff*/
int float_prec; /*precision of floats to use*/
/*about outgoing stuff*/
@@ -70,7 +70,7 @@
smaller than approximately 10^-chop */
int chop_when; /* but only if the object contains a number greater
than 10^-chop_when */
-} calcstate_t;
+} GelCalcState;
/*so we can use and set the yyparse function for parse errors*/
int yyparse(void);
@@ -147,9 +147,15 @@
void gel_dump_strings_from_user_funcs (FILE *outfile);
void gel_dump_strings_from_help (FILE *outfile);
-void set_new_calcstate(calcstate_t state);
-void set_new_errorout(void (*func)(const char *));
-void set_new_infoout(void (*func)(const char *));
+void gel_set_new_calcstate(GelCalcState state);
+void gel_set_new_errorout(void (*func)(const char *));
+void gel_set_new_infoout(void (*func)(const char *));
+
+/* Don't set directly */
+extern GelCalcState gel_calcstate;
+
+/* frontend specific function, implemented there */
+void gel_set_state (GelCalcState state);
void gel_errorout (const char *format, ...) G_GNUC_PRINTF (1, 2);
void gel_infoout (const char *format, ...) G_GNUC_PRINTF (1, 2);
@@ -164,10 +170,9 @@
void gel_rewind_file_info(void);
void gel_get_file_info(char **file, int *line);
-extern FILE *outputfp;
-extern void (*evalnode_hook)(void);
-#define RUN_HOOK_EVERY_MASK 0x3FF
-extern void (*statechange_hook)(calcstate_t);
+extern const GelHookFunc gel_evalnode_hook;
+#define GEL_RUN_HOOK_EVERY_MASK 0x3FF
+
typedef struct {
char *func;
@@ -185,25 +190,25 @@
} GelHelp;
/* well sorted */
-GSList *get_categories (void);
-const char *get_category_name (const char *category);
+GSList *gel_get_categories (void);
+const char *gel_get_category_name (const char *category);
/* null for uncategorized */
-GSList *get_helps (const char *category);
+GSList *gel_get_helps (const char *category);
/* gets undocumented functions */
-GSList *get_undocumented (void);
+GSList *gel_get_undocumented (void);
-void new_category (const char *category, const char *name, gboolean internal);
+void gel_new_category (const char *category, const char *name, gboolean internal);
-GelHelp *get_help (const char *func, gboolean insert);
+GelHelp *gel_get_help (const char *func, gboolean insert);
-void add_description (const char *func, const char *desc);
-void add_category (const char *func, const char *category);
-void add_alias (const char *func, const char *alias);
-void add_help_link (const char *func, const char *link);
-void add_help_html (const char *func, const char *html);
-void whack_help (const char *func);
+void gel_add_description (const char *func, const char *desc);
+void gel_add_category (const char *func, const char *category);
+void gel_add_alias (const char *func, const char *alias);
+void gel_add_help_link (const char *func, const char *link);
+void gel_add_help_html (const char *func, const char *html);
+void gel_whack_help (const char *func);
-extern gboolean genius_is_gui;
+extern const gboolean genius_is_gui;
typedef enum {
GEL_NO_COMMAND,
@@ -221,7 +226,7 @@
extern GelCommand gel_command;
extern char *gel_command_arg;
-extern GelOutput *main_out;
+extern GelOutput *gel_main_out;
extern gboolean gel_got_eof;
Modified: trunk/src/compil.c
==============================================================================
--- trunk/src/compil.c (original)
+++ trunk/src/compil.c Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2004 George Lebl
+ * Copyright (C) 1997-2009 George Lebl
*
* Author: George Lebl
*
@@ -257,7 +257,7 @@
}
}
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = m;
n->mat.quoted = quote;
@@ -293,7 +293,7 @@
li->any.next = NULL;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.args = args;
n->op.nargs = nargs;
@@ -302,7 +302,7 @@
case IDENTIFIER_NODE:
p = strtok_r (NULL,";", ptrptr);
if G_UNLIKELY (!p) return NULL;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = IDENTIFIER_NODE;
n->id.id = d_intern(p);
return n;
@@ -381,7 +381,7 @@
func->propagate_mod = propagate_mod ? 1 : 0;
func->no_mod_all_args = no_mod_all_args ? 1 : 0;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = FUNCTION_NODE;
n->func.func = func;
return n;
@@ -427,7 +427,7 @@
li->any.next = NULL;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = COMPARISON_NODE;
n->comp.args = args;
n->comp.nargs = nargs;
Modified: trunk/src/dict.c
==============================================================================
--- trunk/src/dict.c (original)
+++ trunk/src/dict.c Mon Mar 9 21:48:32 2009
@@ -191,7 +191,7 @@
if(n->type == GEL_USER_FUNC ||
n->type == GEL_VARIABLE_FUNC) {
D_ENSURE_USER_BODY (o);
- n->data.user=copynode(o->data.user);
+ n->data.user = gel_copynode(o->data.user);
}
n->named_args = g_slist_copy (o->named_args);
@@ -229,7 +229,7 @@
n->data.user = o->data.user;
o->data.user = NULL;
} else
- n->data.user = copynode(o->data.user);
+ n->data.user = gel_copynode(o->data.user);
}
if(use) {
o->named_args = NULL;
@@ -275,7 +275,7 @@
n->data.user = fake->data.user;
fake->data.user = NULL;
} else
- n->data.user = copynode(fake->data.user);
+ n->data.user = gel_copynode(fake->data.user);
}
if(use) {
Modified: trunk/src/eval.c
==============================================================================
--- trunk/src/eval.c (original)
+++ trunk/src/eval.c Mon Mar 9 21:48:32 2009
@@ -41,9 +41,7 @@
#define EDEBUG(x) ;
#endif
-extern calcstate_t calcstate;
-
-GelETree *free_trees = NULL;
+GelETree *gel_free_trees = NULL;
static GelEvalStack *free_stack = NULL;
#ifndef MEM_DEBUG_FRIENDLY
@@ -56,10 +54,6 @@
static void _gel_make_free_evfi (void);
#endif /* ! MEM_DEBUG_FRIENDLY */
-extern gboolean interrupted;
-
-extern char *genius_params[];
-
#ifdef MEM_DEBUG_FRIENDLY
static GelCtx *most_recent_ctx = NULL;
#endif
@@ -328,7 +322,7 @@
gel_makenum_null (void)
{
GelETree *n;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = NULL_NODE;
n->any.next = NULL;
return n;
@@ -338,7 +332,7 @@
gel_makenum_identifier (GelToken *id)
{
GelETree *n;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = IDENTIFIER_NODE;
n->id.id = id;
n->any.next = NULL;
@@ -350,7 +344,7 @@
gel_makenum_string (const char *str)
{
GelETree *n;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = STRING_NODE;
n->str.str = g_strdup (str);
n->str.constant = FALSE;
@@ -363,7 +357,7 @@
gel_makenum_string_use (char *str)
{
GelETree *n;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = STRING_NODE;
n->str.str = str;
n->str.constant = FALSE;
@@ -390,7 +384,7 @@
hstr, hstr);
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = STRING_NODE;
n->str.str = hstr;
n->str.constant = TRUE;
@@ -403,7 +397,7 @@
gel_makenum_ui(unsigned long num)
{
GelETree *n;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type=VALUE_NODE;
mpw_init(n->val.value);
mpw_set_ui(n->val.value,num);
@@ -415,7 +409,7 @@
gel_makenum_si(long num)
{
GelETree *n;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type=VALUE_NODE;
mpw_init(n->val.value);
mpw_set_si(n->val.value,num);
@@ -427,7 +421,7 @@
gel_makenum_d (double num)
{
GelETree *n;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = VALUE_NODE;
mpw_init (n->val.value);
mpw_set_d (n->val.value, num);
@@ -439,7 +433,7 @@
gel_makenum_bool (gboolean bool_)
{
GelETree *n;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = BOOL_NODE;
n->bool_.bool_ = bool_ ? 1 : 0;
n->any.next = NULL;
@@ -450,7 +444,7 @@
gel_makenum(mpw_t num)
{
GelETree *n;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type=VALUE_NODE;
mpw_init_set(n->val.value,num);
n->any.next = NULL;
@@ -462,7 +456,7 @@
gel_makenum_use(mpw_t num)
{
GelETree *n;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type=VALUE_NODE;
memcpy(n->val.value,num,sizeof(struct _mpw_t));
n->any.next = NULL;
@@ -605,8 +599,8 @@
# endif /* ! MEM_DEBUG_SUPER_FRIENDLY */
#else /* ! MEM_DEBUG_FRIENDLY */
/*put onto the free list*/
- n->any.next = free_trees;
- free_trees = n;
+ n->any.next = gel_free_trees;
+ gel_free_trees = n;
#endif
}
@@ -642,7 +636,7 @@
if (n == NULL)
return NULL;
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
memcpy (nn, n, sizeof(GelETree));
#ifdef MEM_DEBUG_FRIENDLY
@@ -692,9 +686,9 @@
empty->op.args = o->op.args;
if(empty->op.args) {
GelETree *li;
- empty->op.args = copynode(empty->op.args);
+ empty->op.args = gel_copynode(empty->op.args);
for(li=empty->op.args;li->any.next;li=li->any.next) {
- li->any.next = copynode(li->any.next);
+ li->any.next = gel_copynode(li->any.next);
}
}
break;
@@ -724,9 +718,9 @@
empty->comp.args = o->comp.args;
if(empty->comp.args) {
GelETree *li;
- empty->comp.args = copynode(empty->comp.args);
+ empty->comp.args = gel_copynode(empty->comp.args);
for(li=empty->comp.args;li->any.next;li=li->any.next) {
- li->any.next = copynode(li->any.next);
+ li->any.next = gel_copynode(li->any.next);
}
}
empty->comp.comp = g_slist_copy(o->comp.comp);
@@ -750,9 +744,9 @@
empty->row.args = o->row.args;
if(empty->row.args) {
GelETree *li;
- empty->row.args = copynode(empty->row.args);
+ empty->row.args = gel_copynode(empty->row.args);
for(li=empty->row.args;li->any.next;li=li->any.next) {
- li->any.next = copynode(li->any.next);
+ li->any.next = gel_copynode(li->any.next);
}
}
break;
@@ -760,7 +754,7 @@
empty->type = SPACER_NODE;
empty->any.next = o->any.next;
if(o->sp.arg)
- empty->sp.arg = copynode(o->sp.arg);
+ empty->sp.arg = gel_copynode(o->sp.arg);
else
empty->sp.arg = NULL;
break;
@@ -771,14 +765,14 @@
}
GelETree *
-copynode(GelETree *o)
+gel_copynode(GelETree *o)
{
GelETree *n;
if(!o)
return NULL;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
copynode_to(n,o);
@@ -805,8 +799,8 @@
# endif
#else /* MEM_DEBUG_FRIENDLY */
/*put onto the free list*/
- from->any.next = free_trees;
- free_trees = from;
+ from->any.next = gel_free_trees;
+ gel_free_trees = from;
#endif /* MEM_DEBUG_FRIENDLY */
to->any.next = next;
@@ -831,7 +825,7 @@
}
GelETree *
-makeoperator (int oper, GSList **stack)
+gel_makeoperator (int oper, GSList **stack)
{
GelETree *n;
int args;
@@ -841,7 +835,7 @@
int i;
int popargs = args;
for (i = 0; i < popargs; i++) {
- GelETree *tree = stack_pop (stack);
+ GelETree *tree = gel_stack_pop (stack);
if(!tree) {
while(list) {
GelETree *a = list->any.next;
@@ -879,7 +873,7 @@
int i=0;
for(;;) {
GelETree *tree;
- tree = stack_pop(stack);
+ tree = gel_stack_pop(stack);
/*we have gone all the way to the top and haven't
found a marker*/
if G_UNLIKELY (!tree) {
@@ -895,7 +889,7 @@
/*pop one more in case of -2*/
if(args==-2) {
GelETree *t;
- t = stack_pop(stack);
+ t = gel_stack_pop(stack);
/*we have gone all the way to the top
whoops!*/
if(!t) {
@@ -919,7 +913,7 @@
args = i;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = oper;
@@ -987,7 +981,7 @@
} else if(et->type!=MATRIX_NODE) {
gel_matrix_index(dest,i,di) = et;
for(x=1;x<height;x++)
- gel_matrix_index(dest,i,di+x) = copynode(et);
+ gel_matrix_index(dest,i,di+x) = gel_copynode(et);
/*single column matrix, convert to regular nodes*/
} else if(gel_matrixw_width(et->mat.matrix) == 1) {
int xx;
@@ -1001,7 +995,7 @@
xx = 0;
for(x=h;x<height;x++) {
gel_matrix_index(dest,i,di+x) =
- copynode(gel_matrix_index(dest,i,di+xx));
+ gel_copynode(gel_matrix_index(dest,i,di+xx));
if((++xx)>=h)
xx=0;
}
@@ -1017,7 +1011,7 @@
for(x=0;x<h;x++) {
GelETree *n;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_ROW_NODE;
n->row.args = NULL;
@@ -1038,7 +1032,7 @@
xx = 0;
for(x=h;x<height;x++) {
gel_matrix_index(dest,i,di+x) =
- copynode(gel_matrix_index(dest,i,di+xx));
+ gel_copynode(gel_matrix_index(dest,i,di+xx));
if((++xx)>=h)
xx=0;
}
@@ -1067,7 +1061,7 @@
int x;
gel_matrix_index (dest, di, i) = et;
for (x = 1; x < w; x++)
- gel_matrix_index (dest, di+x, i) = copynode (et);
+ gel_matrix_index (dest, di+x, i) = gel_copynode (et);
} else {
int x;
int xx;
@@ -1095,7 +1089,7 @@
xx = 0;
for (; x < w; x++) {
gel_matrix_index (dest, di+x, i) =
- copynode (gel_matrix_index (dest, di+xx, i));
+ gel_copynode (gel_matrix_index (dest, di+xx, i));
xx++;
if (xx >= et->row.nargs)
xx = 0;
@@ -1191,7 +1185,7 @@
if (nm->m->use == 1) {
gel_matrixw_set_index (nm, 0, 0) = NULL;
} else {
- t = copynode (t);
+ t = gel_copynode (t);
}
replacenode (n, t);
return;
@@ -1303,12 +1297,12 @@
GelETree *ret;
GelETree *li = NULL;
- GET_NEW_NODE(l);
+ GEL_GET_NEW_NODE(l);
l->type = FUNCTION_NODE;
l->func.func = d_copyfunc(func);
l->any.next = NULL;
- GET_NEW_NODE(ret);
+ GEL_GET_NEW_NODE(ret);
ret->type = OPERATOR_NODE;
ret->op.oper = E_DIRECTCALL;
ret->op.args = l;
@@ -1316,7 +1310,7 @@
li = l;
for(i=0;i<nargs;i++) {
- li = li->any.next = copynode(args[i]);
+ li = li->any.next = gel_copynode(args[i]);
}
li->any.next = NULL;
ret->op.nargs = nargs+1;
@@ -1324,14 +1318,14 @@
}
GelETree *
-funccall(GelCtx *ctx, GelEFunc *func, GelETree **args, int nargs)
+gel_funccall(GelCtx *ctx, GelEFunc *func, GelETree **args, int nargs)
{
GelETree *ret = NULL;
g_return_val_if_fail(func!=NULL,NULL);
ret = get_func_call_node(func,args,nargs);
- return eval_etree(ctx,ret);
+ return gel_eval_etree(ctx,ret);
}
/*compare nodes, return TRUE if equal */
@@ -1350,7 +1344,7 @@
}
} else {
gboolean n = mpw_eql(l->val.value,r->val.value);
- if G_UNLIKELY (error_num) return 0;
+ if G_UNLIKELY (gel_error_num) return 0;
return n;
}
}
@@ -1365,7 +1359,7 @@
n=mpw_cmp(l->val.value,r->val.value);
- if G_UNLIKELY (error_num) return 0;
+ if G_UNLIKELY (gel_error_num) return 0;
if(n>0) n=1;
else if(n<0) n=-1;
@@ -1377,8 +1371,8 @@
cmpcmpop(GelCtx *ctx, GelETree *n, GelETree *l, GelETree *r)
{
int ret = cmpnodes(l,r);
- if G_UNLIKELY (error_num) {
- error_num = NO_ERROR;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = GEL_NO_ERROR;
return TRUE;
}
freetree_full(n,TRUE,FALSE);
@@ -1392,8 +1386,8 @@
gboolean bad_node = FALSE;
gboolean ret = gel_isnodetrue (l, &bad_node) != gel_isnodetrue (r,& bad_node);
- if G_UNLIKELY (bad_node || error_num) {
- error_num = NO_ERROR;
+ if G_UNLIKELY (bad_node || gel_error_num) {
+ gel_error_num = GEL_NO_ERROR;
return TRUE;
}
freetree_full (n, TRUE, FALSE);
@@ -1408,8 +1402,8 @@
{
gboolean bad_node = FALSE;
gboolean ret = !gel_isnodetrue(l,&bad_node);
- if G_UNLIKELY (bad_node || error_num) {
- error_num = NO_ERROR;
+ if G_UNLIKELY (bad_node || gel_error_num) {
+ gel_error_num = GEL_NO_ERROR;
return TRUE;
}
freetree_full(n,TRUE,FALSE);
@@ -1579,7 +1573,7 @@
mpw_mod (num, num, mod);
if (mpw_sgn (num) < 0)
mpw_add (num, mod, num);
- if G_UNLIKELY (error_num != NO_ERROR)
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR)
return FALSE;
else
return TRUE;
@@ -1598,14 +1592,14 @@
if (mpw_sgn (d) < 0)
mpw_add (d, mod, d);
- if G_UNLIKELY (error_num != NO_ERROR) {
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
mpw_clear (n);
mpw_clear (d);
return FALSE;
}
mpw_invert (num, d, mod);
- if G_UNLIKELY (error_num != NO_ERROR) {
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
mpw_clear (n);
mpw_clear (d);
return FALSE;
@@ -1613,7 +1607,7 @@
mpw_mul (num, num, n);
mpw_mod (num, num, mod);
- if G_UNLIKELY (error_num != NO_ERROR)
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR)
return FALSE;
else
return TRUE;
@@ -1674,19 +1668,19 @@
}
if (!skipmod && ctx->modulo != NULL) {
if G_UNLIKELY ( ! gel_mod_integer_rational (res, ctx->modulo)) {
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
}
}
- if G_UNLIKELY (error_num == NUMERICAL_MPW_ERROR) {
- GET_NEW_NODE(n);
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = oper;
- n->op.args = copynode(ll);
- n->op.args->any.next = copynode(rr);
+ n->op.args = gel_copynode(ll);
+ n->op.args->any.next = gel_copynode(rr);
n->op.args->any.next->any.next = NULL;
n->op.nargs = 2;
mpw_clear(res);
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return n;
}
return gel_makenum_use(res);
@@ -1719,15 +1713,15 @@
break;
}
if G_UNLIKELY ( ! got_res ||
- error_num == NUMERICAL_MPW_ERROR) {
- GET_NEW_NODE(n);
+ gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = oper;
- n->op.args = copynode(ll);
- n->op.args->any.next = copynode(rr);
+ n->op.args = gel_copynode(ll);
+ n->op.args->any.next = gel_copynode(rr);
n->op.args->any.next->any.next = NULL;
n->op.nargs = 2;
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return n;
}
return gel_makenum_bool (res);
@@ -1735,12 +1729,12 @@
/*this is the less common case so we can get around with a
wierd thing, we'll just make a new fake node and pretend
we want to evaluate that*/
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = oper;
- n->op.args = copynode(ll);
- n->op.args->any.next = copynode(rr);
+ n->op.args = gel_copynode(ll);
+ n->op.args->any.next = gel_copynode(rr);
n->op.args->any.next->any.next = NULL;
n->op.nargs = 2;
@@ -1897,7 +1891,7 @@
t->bool_.bool_ = ! t->bool_.bool_;
} else {
GelETree *nn;
- GET_NEW_NODE(nn);
+ GEL_GET_NEW_NODE(nn);
nn->type = OPERATOR_NODE;
nn->op.oper = n->op.oper;
nn->op.args = t;
@@ -2056,10 +2050,10 @@
return TRUE;
}
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
power = mpw_get_long(r->val.value);
- if G_UNLIKELY (error_num) {
- error_num = NO_ERROR;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = GEL_NO_ERROR;
gel_errorout (_("Exponent too large"));
return TRUE;
}
@@ -2341,14 +2335,14 @@
if(n->type == VALUE_NODE) {
if ( ! gel_mod_integer_rational (n->val.value, mod)) {
GelETree *nn;
- GET_NEW_NODE(nn);
+ GEL_GET_NEW_NODE(nn);
nn->type = OPERATOR_NODE;
nn->op.oper = E_MOD_CALC;
- nn->op.args = copynode (n);
+ nn->op.args = gel_copynode (n);
nn->op.args->any.next = gel_makenum (mod);
nn->op.args->any.next->any.next = NULL;
nn->op.nargs = 2;
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
replacenode (n, nn);
}
} else if(n->type == MATRIX_NODE) {
@@ -2460,9 +2454,9 @@
\
mpw_init(res); \
mpwfunc(res,l->val.value); \
- if G_UNLIKELY (error_num == NUMERICAL_MPW_ERROR) { \
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) { \
mpw_clear(res); \
- error_num = NO_ERROR; \
+ gel_error_num = GEL_NO_ERROR; \
return TRUE; \
} \
\
@@ -2478,9 +2472,9 @@
\
mpw_init(res); \
mpwfunc(res,l->val.value,r->val.value); \
- if G_UNLIKELY (error_num == NUMERICAL_MPW_ERROR) { \
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) { \
mpw_clear(res); \
- error_num = NO_ERROR; \
+ gel_error_num = GEL_NO_ERROR; \
return TRUE; \
} \
\
@@ -2510,9 +2504,9 @@
mpw_powm (res, l->val.value, r->val.value, ctx->modulo);
else
mpw_pow (res, l->val.value, r->val.value);
- if G_UNLIKELY (error_num == NUMERICAL_MPW_ERROR) {
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
mpw_clear (res);
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return TRUE;
}
@@ -2592,12 +2586,12 @@
GelETree *n;
GelETree *nn;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = OPERATOR_NODE;
n->op.oper = E_DIRECTCALL;
n->op.nargs = a->nargs+1;
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = FUNCTION_NODE;
nn->func.func = d_copyfunc (a);
nn->func.func->context = -1;
@@ -2623,7 +2617,7 @@
GelETree *nn;
GelEFunc *f;
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = OPERATOR_NODE;
nn->op.oper = n->op.oper;
nn->op.args = la;
@@ -2694,7 +2688,7 @@
la = make_funccall (a);
- return function_finish_bin_op (ctx, n, a->nargs, la, copynode (r));
+ return function_finish_bin_op (ctx, n, a->nargs, la, gel_copynode (r));
}
static gboolean
@@ -2715,7 +2709,7 @@
lb = make_funccall (b);
- return function_finish_bin_op (ctx, n, b->nargs, copynode (l), lb);
+ return function_finish_bin_op (ctx, n, b->nargs, gel_copynode (l), lb);
}
static gboolean
@@ -2739,7 +2733,7 @@
la = make_funccall (a);
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = OPERATOR_NODE;
nn->op.oper = n->op.oper;
nn->op.args = la;
@@ -2764,7 +2758,7 @@
}
GelETree *
-function_from_function (GelEFunc *func, GelETree *l)
+gel_function_from_function (GelEFunc *func, GelETree *l)
{
int i;
GSList *args;
@@ -2790,12 +2784,12 @@
la = make_funccall (a);
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = FUNCTION_NODE;
n->func.func = d_copyfunc (func);
n->func.func->context = -1;
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = OPERATOR_NODE;
nn->op.oper = E_DIRECTCALL;
nn->op.args = n;
@@ -2812,7 +2806,7 @@
nn /* value */,
args, a->nargs,
NULL /* extra_dict */);
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = FUNCTION_NODE;
n->func.func = f;
n->func.func->context = -1;
@@ -3161,9 +3155,9 @@
free_evfi = (GelEvalForIn *)free_evfi->body;
g_free(evfi);
}
- while(free_trees) {
- GelETree *et = free_trees;
- free_trees = free_trees->any.next;
+ while(gel_free_trees) {
+ GelETree *et = gel_free_trees;
+ gel_free_trees = gel_free_trees->any.next;
g_free(et);
}
#endif
@@ -3303,7 +3297,7 @@
n->type = FUNCTION_NODE;
/* FIXME: are we ok with passing the token as well? */
n->func.func = d_makeufunc (f->id /* FIXME: does this need to be NULL */,
- copynode (f->data.user),
+ gel_copynode (f->data.user),
g_slist_copy (f->named_args),
f->nargs,
f->extra_dict);
@@ -3329,7 +3323,7 @@
ret = (*f->data.func)(ctx,NULL,&exception);
/* interruption happened during the function, which
means an exception */
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
exception = TRUE;
}
if G_UNLIKELY (exception) {
@@ -3343,7 +3337,7 @@
GelETree *i;
f = f->data.ref;
- GET_NEW_NODE(i);
+ GEL_GET_NEW_NODE(i);
i->type = IDENTIFIER_NODE;
if(f->id) {
i->id.id = f->id;
@@ -3448,7 +3442,7 @@
GelEFunc *f;
GelETree *l;
- GET_L(n,l);
+ GEL_GET_L(n,l);
f = d_lookup_global(l->id.id);
if G_UNLIKELY (f == NULL) {
@@ -3527,8 +3521,8 @@
switch(oper) {
case E_EQ_CMP:
if ( ! eqlnodes (l, r)) {
- if G_UNLIKELY (error_num != NO_ERROR) {
- error_num = NO_ERROR;
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
return;
}
RET_RES(0)
@@ -3537,15 +3531,15 @@
case E_NE_CMP:
if (eqlnodes (l, r)) {
RET_RES(0)
- } else if G_UNLIKELY (error_num != NO_ERROR) {
- error_num = NO_ERROR;
+ } else if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
return;
}
break;
case E_LT_CMP:
if(cmpnodes(l,r)>=0) {
- if G_UNLIKELY (error_num != NO_ERROR) {
- error_num = NO_ERROR;
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
return;
}
RET_RES(0)
@@ -3553,8 +3547,8 @@
break;
case E_GT_CMP:
if(cmpnodes(l,r)<=0) {
- if G_UNLIKELY (error_num != NO_ERROR) {
- error_num = NO_ERROR;
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
return;
}
RET_RES(0)
@@ -3563,16 +3557,16 @@
case E_LE_CMP:
if(cmpnodes(l,r)>0) {
RET_RES(0)
- } else if G_UNLIKELY (error_num != NO_ERROR) {
- error_num = NO_ERROR;
+ } else if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
return;
}
break;
case E_GE_CMP:
if(cmpnodes(l,r)<0) {
RET_RES(0)
- } else if G_UNLIKELY (error_num != NO_ERROR) {
- error_num = NO_ERROR;
+ } else if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
+ gel_error_num = GEL_NO_ERROR;
return;
}
break;
@@ -3585,7 +3579,7 @@
case E_EQ_CMP:
if(!eqmatrix(l,r,&err)) {
if G_UNLIKELY (err) {
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return;
}
RET_RES(0)
@@ -3595,13 +3589,13 @@
if(eqmatrix(l,r,&err)) {
RET_RES(0)
} else if G_UNLIKELY (err) {
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return;
}
break;
default:
gel_errorout (_("Cannot compare matrixes"));
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return;
}
break;
@@ -3643,7 +3637,7 @@
break;
default:
gel_errorout (_("Primitives must get numeric/matrix/string arguments"));
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return;
}
}
@@ -3727,7 +3721,7 @@
{
GelETree *l, *r;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
if G_UNLIKELY (r->type != VALUE_NODE ||
mpw_is_complex (r->val.value) ||
@@ -3800,10 +3794,10 @@
gboolean bad_node = FALSE;
EDEBUG(" POPPED AN OR or AND");
ret = gel_isnodetrue(li,&bad_node);
- if G_UNLIKELY (bad_node || error_num) {
+ if G_UNLIKELY (bad_node || gel_error_num) {
int n_flag;
EDEBUG(" AND/OR BAD BAD NODE");
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
GE_POP_STACK (ctx, data, n_flag);
if (n_flag & GE_WHACKARG) {
@@ -3890,9 +3884,9 @@
EDEBUG(" LOOP CONDITION CHECK");
ret = gel_isnodetrue(evl->condition,&bad_node);
- if G_UNLIKELY (bad_node || error_num) {
+ if G_UNLIKELY (bad_node || gel_error_num) {
EDEBUG(" LOOP CONDITION BAD BAD NODE");
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
replacenode (n->op.args, evl->condition);
gel_freetree (evl->body);
evl_free (evl);
@@ -3908,14 +3902,14 @@
(!evl->is_while && !ret)) {
GelETree *l,*r;
EDEBUG(" LOOP CONDITION MET");
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_freetree (evl->condition);
evl->condition = NULL;
gel_freetree (evl->body);
if (evl->body_first)
- evl->body = copynode (l);
+ evl->body = gel_copynode (l);
else
- evl->body = copynode (r);
+ evl->body = gel_copynode (r);
ctx->current = evl->body;
ctx->post = FALSE;
ctx->whackarg = FALSE;
@@ -3956,12 +3950,12 @@
EDEBUG(" LOOP LOOP BODY FINISHED");
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
gel_freetree (evl->condition);
if (evl->body_first)
- evl->condition = copynode (r);
+ evl->condition = gel_copynode (r);
else
- evl->condition = copynode (l);
+ evl->condition = gel_copynode (l);
ctx->current = evl->condition;
ctx->post = FALSE;
ctx->whackarg = FALSE;
@@ -4073,7 +4067,7 @@
if (evf->body != NULL) {
gel_freetree (evf->body);
}
- evf->body = copynode (evf->orig_body);
+ evf->body = gel_copynode (evf->orig_body);
ctx->current = evf->body;
ctx->post = FALSE;
ctx->whackarg = FALSE;
@@ -4122,10 +4116,10 @@
}
GE_PUSH_STACK(ctx,evfi,GE_FORIN);
d_addfunc(d_makevfunc(evfi->id,
- copynode(gel_matrixw_index(evfi->mat,
+ gel_copynode(gel_matrixw_index(evfi->mat,
evfi->i,evfi->j))));
gel_freetree(evfi->body);
- evfi->body = copynode(evfi->orig_body);
+ evfi->body = gel_copynode(evfi->orig_body);
ctx->current = evfi->body;
ctx->post = FALSE;
ctx->whackarg = FALSE;
@@ -4469,7 +4463,7 @@
} else if(l->type == OPERATOR_NODE &&
l->op.oper == E_DEREFERENCE) {
GelETree *ll;
- GET_L(l,ll);
+ GEL_GET_L(l,ll);
f = d_lookup_global(ll->id.id);
if (f == NULL) {
if G_UNLIKELY ( ! silent) {
@@ -4498,7 +4492,7 @@
{
GelETree *l;
- GET_L (n,l);
+ GEL_GET_L (n,l);
return get_func_from (l, silent);
}
@@ -4574,7 +4568,7 @@
}
d_addfunc(d_makereffunc(li->data,rf));
} else {
- d_addfunc(d_makevfunc(li->data,copynode(ali)));
+ d_addfunc(d_makevfunc(li->data,gel_copynode(ali)));
}
li = li->next;
if (li == NULL)
@@ -4603,10 +4597,10 @@
/* continue with ali */
i = 0;
for (; ali != NULL; ali = ali->any.next) {
- gel_matrix_index (m, i++, 0) = copynode (ali);
+ gel_matrix_index (m, i++, 0) = gel_copynode (ali);
}
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = MATRIX_NODE;
nn->mat.quoted = FALSE;
nn->mat.matrix = gel_matrixw_new_with_matrix (m);
@@ -4626,7 +4620,7 @@
/*the next to be evaluated is the body*/
ctx->post = FALSE;
- ctx->current = copynode(f->data.user);
+ ctx->current = gel_copynode(f->data.user);
ctx->whackarg = FALSE;
/*printf("copying: %p\n", ctx->current);*/
@@ -4681,7 +4675,7 @@
}
/* interruption happened during the function, which
means an exception */
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
exception = TRUE;
}
if G_UNLIKELY (exception) {
@@ -4708,7 +4702,7 @@
goto funccall_done_ok;
}
- GET_NEW_NODE(id);
+ GEL_GET_NEW_NODE(id);
id->type = IDENTIFIER_NODE;
id->id.id = f->id; /*this WILL have an id*/
id->any.next = NULL;
@@ -4794,27 +4788,27 @@
switch (n->op.oper) {
case E_FOR_CONS:
type = GEL_EVAL_FOR;
- GET_ABCD(n,ident,from,to,body);
+ GEL_GET_ABCD(n,ident,from,to,body);
break;
case E_SUM_CONS:
type = GEL_EVAL_SUM;
- GET_ABCD(n,ident,from,to,body);
+ GEL_GET_ABCD(n,ident,from,to,body);
break;
case E_PROD_CONS:
type = GEL_EVAL_PROD;
- GET_ABCD(n,ident,from,to,body);
+ GEL_GET_ABCD(n,ident,from,to,body);
break;
case E_FORBY_CONS:
type = GEL_EVAL_FOR;
- GET_ABCDE(n,ident,from,to,by,body);
+ GEL_GET_ABCDE(n,ident,from,to,by,body);
break;
case E_SUMBY_CONS:
type = GEL_EVAL_SUM;
- GET_ABCDE(n,ident,from,to,by,body);
+ GEL_GET_ABCDE(n,ident,from,to,by,body);
break;
case E_PRODBY_CONS:
type = GEL_EVAL_PROD;
- GET_ABCDE(n,ident,from,to,by,body);
+ GEL_GET_ABCDE(n,ident,from,to,by,body);
break;
default:
g_assert_not_reached ();
@@ -4842,7 +4836,7 @@
/*if no iterations*/
if(!by) {
if(init_cmp>0) {
- d_addfunc(d_makevfunc(ident->id.id,copynode(from)));
+ d_addfunc(d_makevfunc(ident->id.id,gel_copynode(from)));
freetree_full(n,TRUE,FALSE);
if (type == GEL_EVAL_FOR) {
n->type = NULL_NODE;
@@ -4857,11 +4851,11 @@
init_cmp = -1;
}
evf = evf_new(type, from->val.value,to->val.value,NULL,init_cmp,
- copynode(body),body,ident->id.id);
+ gel_copynode(body),body,ident->id.id);
} else {
int sgn = mpw_sgn(by->val.value);
if((sgn>0 && init_cmp>0) || (sgn<0 && init_cmp<0)) {
- d_addfunc(d_makevfunc(ident->id.id,copynode(from)));
+ d_addfunc(d_makevfunc(ident->id.id,gel_copynode(from)));
freetree_full(n,TRUE,FALSE);
if (type == GEL_EVAL_FOR) {
n->type = NULL_NODE;
@@ -4876,7 +4870,7 @@
if(init_cmp == 0)
init_cmp = -sgn;
evf = evf_new(type, from->val.value,to->val.value,by->val.value,
- init_cmp,copynode(body),body,ident->id.id);
+ init_cmp,gel_copynode(body),body,ident->id.id);
}
d_addfunc(d_makevfunc(ident->id.id,gel_makenum(evf->x)));
@@ -4913,7 +4907,7 @@
break;
}
- GET_LRR(n,ident,from,body);
+ GEL_GET_LRR(n,ident,from,body);
EDEBUG(" ITER FORIN LOOP");
@@ -4950,14 +4944,14 @@
if(from->type == MATRIX_NODE) {
evfi = evfi_new (type, from->mat.matrix,
- copynode (body), body, ident->id.id);
+ gel_copynode (body), body, ident->id.id);
d_addfunc(d_makevfunc(ident->id.id,
- copynode(gel_matrixw_index(from->mat.matrix,
+ gel_copynode(gel_matrixw_index(from->mat.matrix,
evfi->i,
evfi->j))));
} else {
- evfi = evfi_new (type, NULL, copynode(body), body, ident->id.id);
- d_addfunc(d_makevfunc(ident->id.id,copynode(from)));
+ evfi = evfi_new (type, NULL, gel_copynode(body), body, ident->id.id);
+ d_addfunc(d_makevfunc(ident->id.id,gel_copynode(from)));
}
GE_PUSH_STACK (ctx, n,
@@ -4976,7 +4970,7 @@
GelEvalLoop *evl;
GelETree *l, *r;
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
EDEBUG(" ITER LOOP");
@@ -4984,14 +4978,14 @@
GE_ADDWHACKARG (GE_POST, ctx->whackarg));
if (body_first) {
EDEBUG (" BODY FIRST");
- evl = evl_new (NULL, copynode (l), is_while, body_first);
+ evl = evl_new (NULL, gel_copynode (l), is_while, body_first);
GE_PUSH_STACK (ctx, evl, GE_LOOP_LOOP);
ctx->current = evl->body;
ctx->post = FALSE;
ctx->whackarg = FALSE;
} else {
EDEBUG(" CHECK FIRST");
- evl = evl_new (copynode(l), NULL, is_while, body_first);
+ evl = evl_new (gel_copynode(l), NULL, is_while, body_first);
GE_PUSH_STACK (ctx, evl, GE_LOOP_COND);
ctx->current = evl->condition;
ctx->post = FALSE;
@@ -5009,15 +5003,15 @@
EDEBUG(" IF/IFELSE ITER OP");
if(has_else) {
- GET_LRR(n,l,r,rr);
+ GEL_GET_LRR(n,l,r,rr);
} else {
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
}
ret = gel_isnodetrue(l,&bad_node);
- if G_UNLIKELY (bad_node || error_num) {
+ if G_UNLIKELY (bad_node || gel_error_num) {
EDEBUG(" IF/IFELSE BAD BAD NODE");
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
iter_pop_stack(ctx);
return;
}
@@ -5206,8 +5200,8 @@
}
i = mpw_get_long(num->val.value);
- if G_UNLIKELY (error_num) {
- error_num = NO_ERROR;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = GEL_NO_ERROR;
return -1;
}
if G_UNLIKELY (i > INT_MAX) {
@@ -5306,7 +5300,7 @@
f = d_lookup_local(m->id.id);
if(!f) {
GelETree *t;
- GET_NEW_NODE(t);
+ GEL_GET_NEW_NODE(t);
t->type = MATRIX_NODE;
t->mat.matrix = gel_matrixw_new();
t->mat.quoted = FALSE;
@@ -5323,7 +5317,7 @@
D_ENSURE_USER_BODY (f);
if(f->data.user->type != MATRIX_NODE) {
GelETree *t;
- GET_NEW_NODE(t);
+ GEL_GET_NEW_NODE(t);
t->type = MATRIX_NODE;
t->mat.matrix = gel_matrixw_new();
t->mat.quoted = FALSE;
@@ -5337,7 +5331,7 @@
m->op.oper == E_DEREFERENCE) {
GelETree *l;
GelEFunc *f;
- GET_L(m,l);
+ GEL_GET_L(m,l);
if G_UNLIKELY (l->type != IDENTIFIER_NODE) {
gel_errorout (_("Dereference of non-identifier!"));
@@ -5368,7 +5362,7 @@
D_ENSURE_USER_BODY (f->data.ref);
if(f->data.ref->data.user->type != MATRIX_NODE) {
GelETree *t;
- GET_NEW_NODE(t);
+ GEL_GET_NEW_NODE(t);
t->type = MATRIX_NODE;
t->mat.matrix = gel_matrixw_new();
t->mat.quoted = FALSE;
@@ -5396,11 +5390,11 @@
return setfunc (val);
return gel_makenum_null ();
} else {
- func = d_makevfunc (token, copynode (val));
+ func = d_makevfunc (token, gel_copynode (val));
/* make function global */
func->context = 0;
d_addfunc_global (func);
- return copynode (val);
+ return gel_copynode (val);
}
}
@@ -5409,7 +5403,7 @@
{
GelETree *l,*r;
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
if G_UNLIKELY (l->type != IDENTIFIER_NODE &&
!(l->type == OPERATOR_NODE && l->op.oper == E_GET_VELEMENT) &&
@@ -5447,12 +5441,12 @@
}
d_addfunc(d_makereffunc(l->id.id,rf));
} else {
- d_addfunc(d_makevfunc(l->id.id,copynode(r)));
+ d_addfunc(d_makevfunc(l->id.id,gel_copynode(r)));
}
} else if(l->op.oper == E_DEREFERENCE) {
GelEFunc *f;
GelETree *ll;
- GET_L(l,ll);
+ GEL_GET_L(l,ll);
if G_UNLIKELY (ll->type != IDENTIFIER_NODE) {
gel_errorout (_("Dereference of non-identifier!"));
@@ -5488,12 +5482,12 @@
}
d_set_ref(f->data.ref,rf);
} else {
- d_set_value(f->data.ref,copynode(r));
+ d_set_value(f->data.ref,gel_copynode(r));
}
} else if(l->op.oper == E_GET_ELEMENT) {
GelMatrixW *mat;
GelETree *m, *index1, *index2;
- GET_LRR (l, m, index1, index2);
+ GEL_GET_LRR (l, m, index1, index2);
if (index1->type == VALUE_NODE &&
index2->type == VALUE_NODE) {
@@ -5510,7 +5504,7 @@
if (mat == NULL)
return;
- gel_matrixw_set_element (mat, x, y, copynode (r));
+ gel_matrixw_set_element (mat, x, y, gel_copynode (r));
} else if ((index1->type == VALUE_NODE ||
index1->type == MATRIX_NODE) &&
(index2->type == VALUE_NODE ||
@@ -5553,7 +5547,7 @@
} else if(l->op.oper == E_GET_VELEMENT) {
GelMatrixW *mat;
GelETree *m, *index;
- GET_LR (l, m, index);
+ GEL_GET_LR (l, m, index);
if (index->type == VALUE_NODE) {
int i;
@@ -5566,7 +5560,7 @@
if (mat == NULL)
return;
- gel_matrixw_set_velement (mat, i, copynode (r));
+ gel_matrixw_set_velement (mat, i, gel_copynode (r));
} else if (index->type == MATRIX_NODE) {
int *reg;
int len;
@@ -5593,7 +5587,7 @@
} else /*l->data.oper == E_GET_COL_REGION E_GET_ROW_REGION*/ {
GelMatrixW *mat;
GelETree *m, *index;
- GET_LR (l, m, index);
+ GEL_GET_LR (l, m, index);
if (index->type == VALUE_NODE ||
index->type == MATRIX_NODE) {
@@ -5667,7 +5661,7 @@
{
GelETree *l,*r,*rr;
- GET_LRR (n, l, r, rr);
+ GEL_GET_LRR (n, l, r, rr);
/* FIXME: l should be the set func */
@@ -5678,7 +5672,7 @@
return;
}
- d_addfunc (d_makevfunc (r->id.id, copynode (rr)));
+ d_addfunc (d_makevfunc (r->id.id, gel_copynode (rr)));
r->id.id->parameter = 1;
/*remove from arglist so that it doesn't get freed on replacenode*/
@@ -5691,12 +5685,12 @@
{
GelETree *l,*ident;
- GET_L(n,l);
+ GEL_GET_L(n,l);
if (l->op.oper == E_GET_ELEMENT) {
GelETree *ll,*rr;
- GET_LRR(l,ident,ll,rr);
+ GEL_GET_LRR(l,ident,ll,rr);
GE_PUSH_STACK(ctx,n->op.args->any.next,GE_PRE);
GE_PUSH_STACK(ctx,rr,GE_PRE);
@@ -5708,7 +5702,7 @@
l->op.oper == E_GET_ROW_REGION) {
GelETree *ll;
- GET_LR(l,ident,ll);
+ GEL_GET_LR(l,ident,ll);
GE_PUSH_STACK(ctx,n->op.args->any.next,GE_PRE);
ctx->post = FALSE;
@@ -5727,7 +5721,7 @@
GelETree *m;
GelETree *index;
- GET_LR (n, m, index);
+ GEL_GET_LR (n, m, index);
if G_UNLIKELY (m->type != MATRIX_NODE) {
gel_errorout (_("Index works only on matricies"));
@@ -5739,7 +5733,7 @@
int i = iter_get_matrix_index_num (index, gel_matrixw_elements (m->mat.matrix));
if (i < 0)
return;
- t = copynode (gel_matrixw_vindex (m->mat.matrix, i));
+ t = gel_copynode (gel_matrixw_vindex (m->mat.matrix, i));
replacenode (n, t);
} else if (index->type == MATRIX_NODE) {
GelMatrixW *vec;
@@ -5772,7 +5766,7 @@
{
GelETree *m, *index1, *index2;
- GET_LRR (n, m, index1, index2);
+ GEL_GET_LRR (n, m, index1, index2);
if G_UNLIKELY (m->type != MATRIX_NODE) {
gel_errorout (_("Index works only on matricies"));
@@ -5819,7 +5813,7 @@
freetree_full (n, FALSE /* freeargs */, FALSE /* kill */);
gel_makenum_ui_from (n, 0);
} else {
- replacenode (n, copynode (t));
+ replacenode (n, gel_copynode (t));
}
/* free the args now */
@@ -5863,7 +5857,7 @@
{
GelETree *m, *index;
- GET_LR (n, m, index);
+ GEL_GET_LR (n, m, index);
if G_UNLIKELY (m->type != MATRIX_NODE) {
gel_errorout (_("Index works only on matricies"));
@@ -5992,7 +5986,7 @@
guint32 arg1,arg2;
int i;
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
arg1 = iter_get_arg(l);
arg2 = iter_get_arg(r);
@@ -6023,7 +6017,7 @@
guint32 arg1;
int i;
- GET_L(n,l);
+ GEL_GET_L(n,l);
arg1 = iter_get_arg(l);
@@ -6053,7 +6047,7 @@
int bysgn = 1, cmp, initcmp, count, i;
mpw_t tmp;
if (n->op.oper == E_REGION_SEP_BY) {
- GET_LRR (n, from, by, to);
+ GEL_GET_LRR (n, from, by, to);
if G_UNLIKELY (from->type != VALUE_NODE ||
to->type != VALUE_NODE ||
by->type != VALUE_NODE) {
@@ -6071,7 +6065,7 @@
return;
}
} else {
- GET_LR (n, from, to);
+ GEL_GET_LR (n, from, to);
if G_UNLIKELY (from->type != VALUE_NODE ||
to->type != VALUE_NODE) {
gel_errorout (_("Vector building only works on numbers"));
@@ -6701,16 +6695,16 @@
while((n = ctx->current)) {
EDEBUG("ITER");
- if (evalnode_hook != NULL) {
+ if (gel_evalnode_hook != NULL) {
static int i = 0;
- if G_UNLIKELY ((i++ & RUN_HOOK_EVERY_MASK) == RUN_HOOK_EVERY_MASK) {
- (*evalnode_hook)();
+ if G_UNLIKELY ((i++ & GEL_RUN_HOOK_EVERY_MASK) == GEL_RUN_HOOK_EVERY_MASK) {
+ (*gel_evalnode_hook)();
i = 0;
}
}
whack_saved = ctx->whackarg;
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
if (whack_saved) {
ctx->current = NULL;
gel_freetree (n);
@@ -6855,7 +6849,7 @@
}
GelCtx *
-eval_get_context(void)
+gel_eval_get_context(void)
{
GelCtx *ctx = g_new0(GelCtx,1);
ge_add_stack_array(ctx);
@@ -6866,7 +6860,7 @@
}
void
-eval_free_context(GelCtx *ctx)
+gel_eval_free_context(GelCtx *ctx)
{
#ifdef MEM_DEBUG_FRIENDLY
if (most_recent_ctx == ctx)
@@ -6877,7 +6871,7 @@
}
GelETree *
-eval_etree (GelCtx *ctx, GelETree *etree)
+gel_eval_etree (GelCtx *ctx, GelETree *etree)
{
/*level measures any recursion into here such as from
external functions etc, so that we can purge free lists,
@@ -6960,7 +6954,7 @@
}
GelETree *
-gather_comparisons(GelETree *n)
+gel_gather_comparisons(GelETree *n)
{
GelETree *next,*ret;
if(!n) return NULL;
@@ -6971,7 +6965,7 @@
if(n->type == SPACER_NODE) {
GelETree *t = n->sp.arg;
freenode(n);
- ret = gather_comparisons(t);
+ ret = gel_gather_comparisons(t);
} else if(n->type==OPERATOR_NODE) {
GelETree *nn;
GelETree *ali = NULL;
@@ -6982,7 +6976,7 @@
case E_GT_CMP:
case E_LE_CMP:
case E_GE_CMP:
- GET_NEW_NODE(nn);
+ GEL_GET_NEW_NODE(nn);
nn->type = COMPARISON_NODE;
nn->comp.nargs = 0;
nn->comp.args = NULL;
@@ -6993,10 +6987,10 @@
t = n->op.args->any.next;
if(!ali) {
ali = nn->comp.args =
- gather_comparisons(n->op.args);
+ gel_gather_comparisons(n->op.args);
} else {
ali = ali->any.next =
- gather_comparisons(n->op.args);
+ gel_gather_comparisons(n->op.args);
}
ali->any.next = NULL;
nn->comp.nargs++;
@@ -7014,7 +7008,7 @@
n->op.oper != E_LE_CMP &&
n->op.oper != E_GE_CMP)) {
ali = ali->any.next =
- gather_comparisons(n);
+ gel_gather_comparisons(n);
ali->any.next = NULL;
nn->comp.nargs++;
break;
@@ -7024,10 +7018,10 @@
break;
default:
if(n->op.args) {
- n->op.args = gather_comparisons(n->op.args);
+ n->op.args = gel_gather_comparisons(n->op.args);
for(ali=n->op.args;ali->any.next;ali=ali->any.next)
ali->any.next =
- gather_comparisons(ali->any.next);
+ gel_gather_comparisons(ali->any.next);
}
}
} else if(n->type==MATRIX_NODE) {
@@ -7045,24 +7039,24 @@
GelETree *t = gel_matrixw_get_index(n->mat.matrix,i,j);
if (t != NULL) {
gel_matrixw_set_index(n->mat.matrix,i,j) =
- gather_comparisons(t);
+ gel_gather_comparisons(t);
}
}
}
} else if(n->type==SET_NODE) {
GelETree *ali;
if(n->set.items) {
- n->set.items = gather_comparisons(n->set.items);
+ n->set.items = gel_gather_comparisons(n->set.items);
for(ali=n->set.items;ali->any.next;ali=ali->any.next)
ali->any.next =
- gather_comparisons(ali->any.next);
+ gel_gather_comparisons(ali->any.next);
}
} else if(n->type==FUNCTION_NODE) {
if ((n->func.func->type == GEL_USER_FUNC ||
n->func.func->type == GEL_VARIABLE_FUNC) &&
n->func.func->data.user) {
n->func.func->data.user =
- gather_comparisons(n->func.func->data.user);
+ gel_gather_comparisons(n->func.func->data.user);
}
}
gather_comparisons_end:
@@ -7071,13 +7065,13 @@
}
void
-replace_equals (GelETree *n, gboolean in_expression)
+gel_replace_equals (GelETree *n, gboolean in_expression)
{
if (n == NULL)
return;
if (n->type == SPACER_NODE) {
- replace_equals (n->sp.arg, in_expression);
+ gel_replace_equals (n->sp.arg, in_expression);
} else if(n->type == OPERATOR_NODE) {
gboolean run_through_args = TRUE;
if (n->op.oper == E_EQUALS &&
@@ -7087,24 +7081,24 @@
n->op.oper == E_UNTIL_CONS ||
n->op.oper == E_IF_CONS) {
run_through_args = FALSE;
- replace_equals (n->op.args, TRUE);
- replace_equals (n->op.args->any.next, in_expression);
+ gel_replace_equals (n->op.args, TRUE);
+ gel_replace_equals (n->op.args->any.next, in_expression);
} else if (n->op.oper == E_DOWHILE_CONS ||
n->op.oper == E_DOUNTIL_CONS) {
run_through_args = FALSE;
- replace_equals (n->op.args, in_expression);
- replace_equals (n->op.args->any.next, TRUE);
+ gel_replace_equals (n->op.args, in_expression);
+ gel_replace_equals (n->op.args->any.next, TRUE);
} else if (n->op.oper == E_IFELSE_CONS) {
run_through_args = FALSE;
- replace_equals (n->op.args, TRUE);
- replace_equals (n->op.args->any.next, in_expression);
- replace_equals (n->op.args->any.next->any.next, in_expression);
+ gel_replace_equals (n->op.args, TRUE);
+ gel_replace_equals (n->op.args->any.next, in_expression);
+ gel_replace_equals (n->op.args->any.next->any.next, in_expression);
}
if (run_through_args) {
GelETree *args = n->op.args;
while (args != NULL) {
- replace_equals (args, in_expression);
+ gel_replace_equals (args, in_expression);
args = args->any.next;
}
}
@@ -7121,30 +7115,30 @@
GelETree *t = gel_matrixw_get_index
(n->mat.matrix, i, j);
if (t != NULL)
- replace_equals (t, in_expression);
+ gel_replace_equals (t, in_expression);
}
}
} else if (n->type == SET_NODE ) {
GelETree *ali;
for(ali = n->set.items; ali != NULL; ali = ali->any.next)
- replace_equals (ali, in_expression);
+ gel_replace_equals (ali, in_expression);
} else if (n->type == FUNCTION_NODE &&
(n->func.func->type == GEL_USER_FUNC ||
n->func.func->type == GEL_VARIABLE_FUNC) &&
n->func.func->data.user != NULL) {
/* function bodies are a completely new thing */
- replace_equals (n->func.func->data.user, FALSE);
+ gel_replace_equals (n->func.func->data.user, FALSE);
}
}
void
-replace_exp (GelETree *n)
+gel_replace_exp (GelETree *n)
{
if (n == NULL)
return;
if (n->type == SPACER_NODE) {
- replace_exp (n->sp.arg);
+ gel_replace_exp (n->sp.arg);
} else if(n->type == OPERATOR_NODE) {
GelETree *args;
if (n->op.oper == E_EXP &&
@@ -7157,7 +7151,7 @@
args = n->op.args;
while (args != NULL) {
- replace_exp (args);
+ gel_replace_exp (args);
args = args->any.next;
}
} else if (n->type == MATRIX_NODE &&
@@ -7173,30 +7167,30 @@
GelETree *t = gel_matrixw_get_index
(n->mat.matrix, i, j);
if (t != NULL)
- replace_exp (t);
+ gel_replace_exp (t);
}
}
} else if (n->type == SET_NODE ) {
GelETree *ali;
for(ali = n->set.items; ali != NULL; ali = ali->any.next)
- replace_exp (ali);
+ gel_replace_exp (ali);
} else if (n->type == FUNCTION_NODE &&
(n->func.func->type == GEL_USER_FUNC ||
n->func.func->type == GEL_VARIABLE_FUNC) &&
n->func.func->data.user != NULL) {
- replace_exp (n->func.func->data.user);
+ gel_replace_exp (n->func.func->data.user);
}
}
/* Fixup number negation */
void
-fixup_num_neg (GelETree *n)
+gel_fixup_num_neg (GelETree *n)
{
if (n == NULL)
return;
if (n->type == SPACER_NODE) {
- fixup_num_neg (n->sp.arg);
+ gel_fixup_num_neg (n->sp.arg);
} else if(n->type == OPERATOR_NODE) {
/* replace -1^2 with something like (-1)^2, only
* for numbers. If you typed parenthesis as in
@@ -7212,11 +7206,11 @@
replacenode (n, t);
mpw_neg (n->op.args->val.value,
n->op.args->val.value);
- fixup_num_neg (n->op.args->any.next);
+ gel_fixup_num_neg (n->op.args->any.next);
} else {
GelETree *args = n->op.args;
while (args != NULL) {
- fixup_num_neg (args);
+ gel_fixup_num_neg (args);
args = args->any.next;
}
}
@@ -7233,18 +7227,18 @@
GelETree *t = gel_matrixw_get_index
(n->mat.matrix, i, j);
if (t != NULL)
- fixup_num_neg (t);
+ gel_fixup_num_neg (t);
}
}
} else if (n->type == SET_NODE ) {
GelETree *ali;
for(ali = n->set.items; ali != NULL; ali = ali->any.next)
- fixup_num_neg (ali);
+ gel_fixup_num_neg (ali);
} else if (n->type == FUNCTION_NODE &&
(n->func.func->type == GEL_USER_FUNC ||
n->func.func->type == GEL_VARIABLE_FUNC) &&
n->func.func->data.user != NULL) {
- fixup_num_neg (n->func.func->data.user);
+ gel_fixup_num_neg (n->func.func->data.user);
}
}
@@ -7252,13 +7246,13 @@
/* find an identifier */
gboolean
-eval_find_identifier (GelETree *n, GelToken *tok, gboolean funcbody)
+gel_eval_find_identifier (GelETree *n, GelToken *tok, gboolean funcbody)
{
if (n == NULL)
return FALSE;
if (n->type == SPACER_NODE) {
- return eval_find_identifier (n->sp.arg, tok, funcbody);
+ return gel_eval_find_identifier (n->sp.arg, tok, funcbody);
} else if (n->type == IDENTIFIER_NODE ) {
if (n->id.id == tok)
return TRUE;
@@ -7267,7 +7261,7 @@
} else if(n->type == OPERATOR_NODE) {
GelETree *args = n->op.args;
while (args != NULL) {
- if (eval_find_identifier (args, tok, funcbody))
+ if (gel_eval_find_identifier (args, tok, funcbody))
return TRUE;
args = args->any.next;
}
@@ -7283,7 +7277,7 @@
GelETree *t = gel_matrixw_get_index
(n->mat.matrix, i, j);
if (t != NULL &&
- eval_find_identifier (t, tok, funcbody))
+ gel_eval_find_identifier (t, tok, funcbody))
return TRUE;
}
}
@@ -7291,7 +7285,7 @@
} else if (n->type == SET_NODE ) {
GelETree *ali;
for (ali = n->set.items; ali != NULL; ali = ali->any.next) {
- if (eval_find_identifier (ali, tok, funcbody))
+ if (gel_eval_find_identifier (ali, tok, funcbody))
return TRUE;
}
return FALSE;
@@ -7300,7 +7294,7 @@
(n->func.func->type == GEL_USER_FUNC ||
n->func.func->type == GEL_VARIABLE_FUNC)) {
D_ENSURE_USER_BODY (n->func.func);
- return eval_find_identifier (n->func.func->data.user, tok,
+ return gel_eval_find_identifier (n->func.func->data.user, tok,
funcbody);
}
return FALSE;
@@ -7313,14 +7307,14 @@
{
GelETree *l;
mpw_t res;
- GET_L(n,l);
+ GEL_GET_L(n,l);
if(l->type != VALUE_NODE)
return;
mpw_init(res);
(*func)(res,l->val.value);
- if G_UNLIKELY (error_num) {
+ if G_UNLIKELY (gel_error_num) {
mpw_clear(res);
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return;
}
freetree_full(n,TRUE,FALSE);
@@ -7334,7 +7328,7 @@
{
GelETree *l;
mpw_t res;
- GET_L(n,l);
+ GEL_GET_L(n,l);
if (l->type != VALUE_NODE ||
(respect_type &&
(mpw_is_complex (l->val.value) ||
@@ -7342,9 +7336,9 @@
return;
mpw_init(res);
(*func)(res,l->val.value);
- if G_UNLIKELY (error_num) {
+ if G_UNLIKELY (gel_error_num) {
mpw_clear(res);
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return;
}
freetree_full(n,TRUE,FALSE);
@@ -7358,7 +7352,7 @@
{
GelETree *l,*r,*next;
mpw_t res;
- GET_LR(n,l,r);
+ GEL_GET_LR(n,l,r);
if (l->type != VALUE_NODE ||
r->type != VALUE_NODE ||
(respect_type &&
@@ -7369,9 +7363,9 @@
return;
mpw_init(res);
(*func)(res,l->val.value,r->val.value);
- if G_UNLIKELY (error_num) {
+ if G_UNLIKELY (gel_error_num) {
mpw_clear(res);
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return;
}
next = n->any.next;
@@ -7436,7 +7430,7 @@
}
void
-try_to_do_precalc(GelETree *n)
+gel_try_to_do_precalc(GelETree *n)
{
if(!n) return;
@@ -7451,17 +7445,17 @@
nn = n->op.args->op.args;
n->op.args->op.args = NULL;
replacenode (n, nn);
- try_to_do_precalc (n);
+ gel_try_to_do_precalc (n);
} else if(n->op.oper == E_MOD_CALC) {
/* in case of modular calculation, only do
precalc on the second argument (don't descend
at all into the first one) */
/* FIXME: precalc might be broken in case of mod */
- /* try_to_do_precalc(n->op.args->any.next); */;
+ /* gel_try_to_do_precalc(n->op.args->any.next); */;
} else {
if(n->op.args) {
for(ali=n->op.args;ali;ali=ali->any.next)
- try_to_do_precalc(ali);
+ gel_try_to_do_precalc(ali);
}
if(n->type==OPERATOR_NODE)
try_to_precalc_op (n,
@@ -7480,20 +7474,20 @@
for(i=0;i<w;i++) {
GelETree *t = gel_matrixw_get_index(n->mat.matrix,i,j);
if(t)
- try_to_do_precalc(t);
+ gel_try_to_do_precalc(t);
}
}
} else if(n->type==SET_NODE) {
GelETree *ali;
if(n->set.items) {
for(ali=n->set.items;ali;ali=ali->any.next)
- try_to_do_precalc(ali);
+ gel_try_to_do_precalc(ali);
}
} else if(n->type==FUNCTION_NODE) {
if ((n->func.func->type == GEL_USER_FUNC ||
n->func.func->type == GEL_VARIABLE_FUNC) &&
n->func.func->data.user)
- try_to_do_precalc(n->func.func->data.user);
+ gel_try_to_do_precalc(n->func.func->data.user);
}
}
@@ -7581,7 +7575,7 @@
if (n->op.oper == oper) {
GelETree *l, *r;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
/* always swap values to go first */
if (r->type == VALUE_NODE &&
@@ -7592,7 +7586,7 @@
shuffled = TRUE;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
}
/* make into (a*b)*c, "*" is * or + (oper) */
@@ -7610,7 +7604,7 @@
r->op.args = NULL;
gel_freetree (r);
- GET_NEW_NODE (l);
+ GEL_GET_NEW_NODE (l);
l->type = OPERATOR_NODE;
l->op.oper = oper;
l->op.nargs = 2;
@@ -7624,7 +7618,7 @@
shuffled = TRUE;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
}
}
@@ -7643,7 +7637,7 @@
l->op.args = NULL;
gel_freetree (l);
- GET_NEW_NODE (r);
+ GEL_GET_NEW_NODE (r);
r->type = OPERATOR_NODE;
r->op.oper = oper;
r->op.nargs = 2;
@@ -7657,7 +7651,7 @@
shuffled = TRUE;
- /* GET_LR (n, l, r); */
+ /* GEL_GET_LR (n, l, r); */
}
}
}
@@ -7688,7 +7682,7 @@
precalc on the second argument (don't descend
at all into the first one) */
/* FIXME: precalc might be broken in case of mod */
- /* try_to_do_precalc(n->op.args->any.next); */;
+ /* gel_try_to_do_precalc(n->op.args->any.next); */;
/* double negation is always positive no matter what */
return;
}
@@ -7725,7 +7719,7 @@
GelETree *l, *r;
GelETree *ll, *rr;
GelETree *le = NULL, *re = NULL;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
ll = l;
rr = r;
if (l->type == OPERATOR_NODE &&
@@ -7753,7 +7747,7 @@
gel_freetree (l);
}
- GET_NEW_NODE (e);
+ GEL_GET_NEW_NODE (e);
e->type = OPERATOR_NODE;
e->op.oper = E_PLUS;
e->op.nargs = 2;
@@ -7769,7 +7763,7 @@
}
e->op.args->any.next->any.next = NULL;
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = OPERATOR_NODE;
nn->op.oper = E_EXP;
nn->op.nargs = 2;
@@ -7790,7 +7784,7 @@
GelETree *l, *r;
GelETree *ll, *rr;
GelETree *le = NULL, *re = NULL;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
ll = l;
rr = r;
if (l->type == OPERATOR_NODE &&
@@ -7818,7 +7812,7 @@
gel_freetree (l);
}
- GET_NEW_NODE (e);
+ GEL_GET_NEW_NODE (e);
e->type = OPERATOR_NODE;
e->op.oper = E_PLUS;
e->op.nargs = 2;
@@ -7834,7 +7828,7 @@
}
e->op.args->any.next->any.next = NULL;
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = OPERATOR_NODE;
nn->op.oper = E_MUL;
nn->op.nargs = 2;
@@ -7853,7 +7847,7 @@
(n->op.args->type == VALUE_NODE ||
n->op.args->any.next->type == VALUE_NODE)) {
GelETree *l, *r;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
/* multiply by 0, so nothing */
if ((l->type == VALUE_NODE &&
@@ -7879,7 +7873,7 @@
(n->op.args->type == VALUE_NODE ||
n->op.args->any.next->type == VALUE_NODE)) {
GelETree *l, *r;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
/* divide 0 by something so nothing
(unless the bottom is 0) */
@@ -7900,7 +7894,7 @@
(n->op.args->type == VALUE_NODE ||
n->op.args->any.next->type == VALUE_NODE)) {
GelETree *l, *r;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
if (l->type == VALUE_NODE &&
mpw_zero_p (l->val.value)) {
@@ -7917,7 +7911,7 @@
}
} else if (n->op.oper == E_EXP) {
GelETree *l, *r;
- GET_LR (n, l, r);
+ GEL_GET_LR (n, l, r);
if (r->type == VALUE_NODE &&
mpw_zero_p (r->val.value)) {
@@ -7937,7 +7931,7 @@
l->op.args = NULL;
gel_freetree (l);
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = OPERATOR_NODE;
nn->op.oper = E_MUL;
nn->op.nargs = 2;
@@ -7990,7 +7984,6 @@
static long _gel_tree_num = 0;
static gboolean _gel_max_nodes_check = TRUE;
-void (*_gel_tree_limit_hook)(void) = NULL;
/* Will get to the warning another page later, but that's OK
* we don't expect this to be happening often */
@@ -8007,8 +8000,8 @@
char *p;
if G_UNLIKELY (_gel_max_nodes_check &&
- calcstate.max_nodes > 0 &&
- _gel_tree_num > calcstate.max_nodes) {
+ gel_calcstate.max_nodes > 0 &&
+ _gel_tree_num > gel_calcstate.max_nodes) {
if (_gel_tree_limit_hook != NULL) {
(*_gel_tree_limit_hook) ();
}
@@ -8020,8 +8013,8 @@
for (i = 0; i < (GEL_CHUNK_SIZE / ALIGNED_SIZE (GelETree)); i++) {
GelETree *t = (GelETree *)p;
/*put onto the free list*/
- t->any.next = free_trees;
- free_trees = t;
+ t->any.next = gel_free_trees;
+ gel_free_trees = t;
p += ALIGNED_SIZE (GelETree);
_gel_tree_num ++;
}
Modified: trunk/src/eval.h
==============================================================================
--- trunk/src/eval.h (original)
+++ trunk/src/eval.h Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2008 Jiri (George) Lebl
+ * Copyright (C) 1997-2009 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -143,7 +143,7 @@
GelETree * gel_makenum_string_use (char *str);
GelETree * gel_makenum_string_constant (const char *str);
/* FIXME: implement GelETree * gel_makenum_polynomial (...); */
-GelETree * makeoperator(int oper, GSList **stack);
+GelETree * gel_makeoperator(int oper, GSList **stack);
/*make new node, but don't actually get a new GelETree, just stick it
into an already allocated but unused structure*/
@@ -155,7 +155,7 @@
void gel_makenum_null_from(GelETree *n);
/*copy a node*/
-GelETree * copynode(GelETree *o);
+GelETree * gel_copynode(GelETree *o);
void gel_replacenode (GelETree *to, GelETree *from, gboolean copy);
@@ -167,37 +167,37 @@
GelETree * gel_stealnode (GelETree *n);
/* you need to get, then free an evaluation context*/
-GelCtx * eval_get_context(void);
-void eval_free_context(GelCtx *ctx);
+GelCtx * gel_eval_get_context(void);
+void gel_eval_free_context(GelCtx *ctx);
/* evaluate tree*/
-GelETree * eval_etree(GelCtx *ctx, GelETree *etree);
+GelETree * gel_eval_etree(GelCtx *ctx, GelETree *etree);
/*return TRUE if node is true (a number node !=0, or nonempty string),
false otherwise*/
int gel_isnodetrue(GelETree *n, int *bad_node);
/*call a function (arguments should have already been evaluated)*/
-GelETree * funccall(GelCtx *ctx, GelEFunc *func, GelETree **args, int nargs);
+GelETree * gel_funccall(GelCtx *ctx, GelEFunc *func, GelETree **args, int nargs);
void gel_expandmatrix (GelETree *n);
/* func is a function taking one argument and l is a function/identifier */
/* Note: a copy of the function is made */
-GelETree * function_from_function (GelEFunc *func, GelETree *l);
+GelETree * gel_function_from_function (GelEFunc *func, GelETree *l);
/* Functions to fixup the parsed tree */
-GelETree * gather_comparisons(GelETree *n);
-void replace_equals (GelETree *n, gboolean in_expression);
-void replace_exp (GelETree *n);
-void fixup_num_neg (GelETree *n);
+GelETree * gel_gather_comparisons(GelETree *n);
+void gel_replace_equals (GelETree *n, gboolean in_expression);
+void gel_replace_exp (GelETree *n);
+void gel_fixup_num_neg (GelETree *n);
/* careful precalculation */
-void try_to_do_precalc (GelETree *n);
+void gel_try_to_do_precalc (GelETree *n);
/* aggressive precalculation/simplification */
void gel_simplify (GelETree *n);
/* is the tree semantically the same? */
gboolean gel_is_tree_same (GelETree *l, GelETree *r);
/* find an identifier */
-gboolean eval_find_identifier (GelETree *n,
+gboolean gel_eval_find_identifier (GelETree *n,
GelToken *tok,
gboolean funcbody);
@@ -217,28 +217,28 @@
makes them the same type as a side effect*/
gboolean gel_eqlnodes (GelETree *l, GelETree *r);
-#define GET_ABCDE(n,a,b,c,d,e) { \
+#define GEL_GET_ABCDE(n,a,b,c,d,e) { \
(a) = (n)->op.args; \
(b) = (n)->op.args->any.next; \
(c) = (n)->op.args->any.next->any.next; \
(d) = (n)->op.args->any.next->any.next->any.next; \
(e) = (n)->op.args->any.next->any.next->any.next->any.next; \
}
-#define GET_ABCD(n,a,b,c,d) { \
+#define GEL_GET_ABCD(n,a,b,c,d) { \
(a) = (n)->op.args; \
(b) = (n)->op.args->any.next; \
(c) = (n)->op.args->any.next->any.next; \
(d) = (n)->op.args->any.next->any.next->any.next; \
}
-#define GET_LRR(n,l,r,rr) { \
+#define GEL_GET_LRR(n,l,r,rr) { \
(l) = (n)->op.args; \
(r) = (n)->op.args->any.next; \
(rr) = (n)->op.args->any.next->any.next; \
}
-#define GET_LR(n,l,r) { (l) = (n)->op.args; (r) = (n)->op.args->any.next; }
-#define GET_L(n,l) { (l) = (n)->op.args; }
+#define GEL_GET_LR(n,l,r) { (l) = (n)->op.args; (r) = (n)->op.args->any.next; }
+#define GEL_GET_L(n,l) { (l) = (n)->op.args; }
-extern GelETree *free_trees;
+extern GelETree *gel_free_trees;
#ifdef MEM_DEBUG_FRIENDLY
@@ -248,14 +248,14 @@
void deregister_tree (GelETree *n);
void print_live_trees (void);
void deregister_all_trees (void);
-# define GET_NEW_NODE(n) { \
+# define GEL_GET_NEW_NODE(n) { \
n = g_new0 (GelETree, 1); \
printf ("%s NEW NODE %p\n", G_STRLOC, n); \
register_new_tree (n); \
}
# else /* EVAL_DEBUG */
-# define GET_NEW_NODE(n) { \
+# define GEL_GET_NEW_NODE(n) { \
n = g_new0 (GelETree, 1); \
}
# endif /* EVAL_DEBUG */
@@ -263,15 +263,15 @@
#else /* MEM_DEBUG_FRIENDLY */
void _gel_make_free_trees (void);
-# define GET_NEW_NODE(n) { \
- if G_UNLIKELY (free_trees == NULL) \
+# define GEL_GET_NEW_NODE(n) { \
+ if G_UNLIKELY (gel_free_trees == NULL) \
_gel_make_free_trees (); \
- n = free_trees; \
- free_trees = free_trees->any.next; \
+ n = gel_free_trees; \
+ gel_free_trees = gel_free_trees->any.next; \
}
#endif
-extern void (*_gel_tree_limit_hook)(void);
+const extern GelHookFunc _gel_tree_limit_hook;
void gel_test_max_nodes_again (void);
extern GelEFunc *_internal_ln_function;
Modified: trunk/src/funclib.c
==============================================================================
--- trunk/src/funclib.c (original)
+++ trunk/src/funclib.c Mon Mar 9 21:48:32 2009
@@ -40,8 +40,6 @@
#include "binreloc.h"
-extern calcstate_t calcstate;
-
GelEFunc *_internal_ln_function = NULL;
GelEFunc *_internal_exp_function = NULL;
@@ -105,8 +103,8 @@
{
long i;
i = mpw_get_long(z);
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return -1;
}
if G_UNLIKELY (i < 0) {
@@ -125,7 +123,7 @@
manual_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
{
gel_call_help (NULL);
- error_num = IGNORE_ERROR;
+ gel_error_num = GEL_IGNORE_ERROR;
RAISE_EXCEPTION (exception);
return NULL;
}
@@ -144,7 +142,7 @@
} else {
gel_errorout (_("Cannot parse version string: %s"),
VERSION);
- error_num = IGNORE_ERROR;
+ gel_error_num = GEL_IGNORE_ERROR;
RAISE_EXCEPTION (exception);
return NULL;
}
@@ -159,7 +157,7 @@
gel_matrix_index (m, 1, 0) = gel_makenum_ui (b);
gel_matrix_index (m, 2, 0) = gel_makenum_ui (c);
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only_integer (m);
n->mat.quoted = FALSE;
@@ -186,8 +184,8 @@
" You should have received a copy of the GNU General Public License\n"
" along with this program. If not, see <http://www.gnu.org/licenses/>.\n"),
VERSION,
- COPYRIGHT_STRING);
- error_num = IGNORE_ERROR;
+ GENIUS_COPYRIGHT_STRING);
+ gel_error_num = GEL_IGNORE_ERROR;
RAISE_EXCEPTION (exception);
return NULL;
}
@@ -205,7 +203,7 @@
{
gel_infoout ("We are the Knights Who Say... Ni!");
RAISE_EXCEPTION (exception);
- error_num = IGNORE_ERROR;
+ gel_error_num = GEL_IGNORE_ERROR;
return NULL;
}
@@ -216,7 +214,7 @@
"cut down the mightiest tree in the forest... with...\n"
"A HERRING!");
RAISE_EXCEPTION (exception);
- error_num = IGNORE_ERROR;
+ gel_error_num = GEL_IGNORE_ERROR;
return NULL;
}
@@ -339,21 +337,21 @@
if G_UNLIKELY (secs < 0)
return NULL;
if (secs == 0) {
- if (evalnode_hook != NULL)
- (*evalnode_hook)();
+ if (gel_evalnode_hook != NULL)
+ (*gel_evalnode_hook)();
- if G_UNLIKELY (interrupted)
+ if G_UNLIKELY (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
} else {
- if (evalnode_hook != NULL) {
+ if (gel_evalnode_hook != NULL) {
struct timeval tv;
struct timeval tv2;
gettimeofday (&tv, NULL);
for (;;) {
- (*evalnode_hook)();
- if G_UNLIKELY (interrupted) {
+ (*gel_evalnode_hook)();
+ if G_UNLIKELY (gel_interrupted) {
break;
}
gettimeofday (&tv2, NULL);
@@ -369,11 +367,11 @@
int i;
/* kind of hacky, but I don't want to risk long sleep not
being interrupted on some systems */
- for (i = 0; i < secs && ! interrupted; i++)
+ for (i = 0; i < secs && ! gel_interrupted; i++)
sleep (1);
}
- if G_UNLIKELY (interrupted)
+ if G_UNLIKELY (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
@@ -384,16 +382,16 @@
static GelETree *
print_op (GelCtx *ctx, GelETree * * a, gboolean *exception)
{
- gboolean old_limit = main_out->length_limit;
- gel_output_set_length_limit (main_out, FALSE);
+ gboolean old_limit = gel_main_out->length_limit;
+ gel_output_set_length_limit (gel_main_out, FALSE);
if (a[0]->type==STRING_NODE) {
- gel_output_printf_full (main_out, FALSE, "%s\n", a[0]->str.str);
+ gel_output_printf_full (gel_main_out, FALSE, "%s\n", a[0]->str.str);
} else {
- gel_pretty_print_etree (main_out, a[0]);
- gel_output_string (main_out,"\n");
+ gel_pretty_print_etree (gel_main_out, a[0]);
+ gel_output_string (gel_main_out,"\n");
}
- gel_output_set_length_limit (main_out, old_limit);
- gel_output_flush (main_out);
+ gel_output_set_length_limit (gel_main_out, old_limit);
+ gel_output_flush (gel_main_out);
return gel_makenum_null();
}
/*print function*/
@@ -408,33 +406,33 @@
static GelETree *
printn_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
{
- gboolean old_limit = main_out->length_limit;
- gel_output_set_length_limit (main_out, FALSE);
+ gboolean old_limit = gel_main_out->length_limit;
+ gel_output_set_length_limit (gel_main_out, FALSE);
if(a[0]->type==STRING_NODE)
- gel_output_printf (main_out, "%s", a[0]->str.str);
+ gel_output_printf (gel_main_out, "%s", a[0]->str.str);
else
- gel_print_etree (main_out, a[0], TRUE);
- gel_output_set_length_limit (main_out, old_limit);
- gel_output_flush(main_out);
+ gel_print_etree (gel_main_out, a[0], TRUE);
+ gel_output_set_length_limit (gel_main_out, old_limit);
+ gel_output_flush(gel_main_out);
return gel_makenum_null();
}
/*print function*/
static GelETree *
display_op(GelCtx *ctx, GelETree * * a, gboolean *exception)
{
- gboolean old_limit = main_out->length_limit;
+ gboolean old_limit = gel_main_out->length_limit;
if G_UNLIKELY ( ! check_argument_string (a, 0, "display"))
return NULL;
- gel_output_set_length_limit (main_out, FALSE);
+ gel_output_set_length_limit (gel_main_out, FALSE);
- gel_output_printf(main_out, "%s: ", a[0]->str.str);
- gel_pretty_print_etree (main_out, a[1]);
- gel_output_string(main_out, "\n");
+ gel_output_printf(gel_main_out, "%s: ", a[0]->str.str);
+ gel_pretty_print_etree (gel_main_out, a[1]);
+ gel_output_string(gel_main_out, "\n");
- gel_output_set_length_limit (main_out, old_limit);
+ gel_output_set_length_limit (gel_main_out, old_limit);
- gel_output_flush(main_out);
+ gel_output_flush(gel_main_out);
return gel_makenum_null();
}
@@ -464,7 +462,7 @@
return NULL;
}
- func = d_makevfunc (id, copynode (a[1]));
+ func = d_makevfunc (id, gel_copynode (a[1]));
/* make function global */
func->context = 0;
d_addfunc_global (func);
@@ -522,7 +520,7 @@
gel_matrix_index (m, i, 0) = gel_makenum_use (fr);
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only_real_nonrational (m);
n->mat.quoted = FALSE;
@@ -559,7 +557,7 @@
}
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only_real_nonrational (m);
n->mat.quoted = FALSE;
@@ -592,7 +590,7 @@
mpw_init (fr);
mpw_randint (fr, a[0]->val.value);
- if G_UNLIKELY (error_num != 0) {
+ if G_UNLIKELY (gel_error_num != 0) {
mpw_clear (fr);
return NULL;
}
@@ -620,7 +618,7 @@
mpw_t fr;
mpw_init (fr);
mpw_randint (fr, a[0]->val.value);
- if G_UNLIKELY (error_num != 0) {
+ if G_UNLIKELY (gel_error_num != 0) {
mpw_clear (fr);
/* This can only happen if a[0]->val.value is
* evil, in which case we have not set any
@@ -634,7 +632,7 @@
gel_matrix_index (m, i, 0) = gel_makenum_use (fr);
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only_integer (m);
n->mat.quoted = FALSE;
@@ -667,7 +665,7 @@
mpw_t fr;
mpw_init (fr);
mpw_randint (fr, a[0]->val.value);
- if G_UNLIKELY (error_num != 0) {
+ if G_UNLIKELY (gel_error_num != 0) {
mpw_clear (fr);
/* This can only happen if a[0]->val.value is
* evil, in which case we have not set any
@@ -682,7 +680,7 @@
}
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only_integer (m);
n->mat.quoted = FALSE;
@@ -735,7 +733,7 @@
h = gel_matrixw_height (m1);
/*make us a new empty node*/
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
new = n->mat.matrix = gel_matrixw_new();
n->mat.quoted = quote;
@@ -760,17 +758,17 @@
if G_UNLIKELY (e == NULL) {
GelETree *nn;
GelETree *ni;
- GET_NEW_NODE(ni);
+ GEL_GET_NEW_NODE(ni);
ni->type = IDENTIFIER_NODE;
ni->id.id = d_intern(ident);
- GET_NEW_NODE(nn);
+ GEL_GET_NEW_NODE(nn);
nn->type = OPERATOR_NODE;
nn->op.oper = E_CALL;
nn->op.nargs = 3;
nn->op.args = ni;
- nn->op.args->any.next = copynode(t[0]);
- nn->op.args->any.next->any.next = copynode(t[1]);
+ nn->op.args->any.next = gel_copynode(t[0]);
+ nn->op.args->any.next->any.next = gel_copynode(t[1]);
nn->op.args->any.next->any.next->any.next = NULL;
gel_matrixw_set_index(new,i,j) = nn;
@@ -806,7 +804,7 @@
h = gel_matrixw_height(m);
/*make us a new empty node*/
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
new = n->mat.matrix = gel_matrixw_new();
n->mat.quoted = mat->mat.quoted;
@@ -825,18 +823,18 @@
if G_UNLIKELY (e == NULL) {
GelETree *nn;
GelETree *ni;
- GET_NEW_NODE(nn);
+ GEL_GET_NEW_NODE(nn);
nn->type = OPERATOR_NODE;
nn->op.oper = E_CALL;
nn->op.args = NULL;
nn->op.nargs = 2;
- GET_NEW_NODE(ni);
+ GEL_GET_NEW_NODE(ni);
ni->type = IDENTIFIER_NODE;
ni->id.id = d_intern(ident);
nn->op.args = ni;
- nn->op.args->any.next = copynode(t[0]);
+ nn->op.args->any.next = gel_copynode(t[0]);
nn->op.args->any.next->any.next = NULL;
gel_matrixw_set_index(new,i,j) = nn;
@@ -866,7 +864,7 @@
if G_UNLIKELY ( ! check_argument_matrix (a, 0, "ExpandMatrix"))
return NULL;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_copy (a[0]->mat.matrix);
gel_expandmatrix (n);
@@ -882,7 +880,7 @@
if G_UNLIKELY ( ! check_argument_matrix (a, 0, "RowsOf"))
return NULL;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_rowsof (a[0]->mat.matrix);
n->mat.quoted = FALSE;
@@ -897,7 +895,7 @@
if G_UNLIKELY ( ! check_argument_matrix (a, 0, "ColumnsOf"))
return NULL;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_columnsof (a[0]->mat.matrix);
n->mat.quoted = FALSE;
@@ -915,7 +913,7 @@
if (a[0]->type == NULL_NODE)
return gel_makenum_null ();
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_diagonalof (a[0]->mat.matrix);
n->mat.quoted = FALSE;
@@ -995,7 +993,7 @@
if (cnt == w) {
g_slist_free (cols);
- return copynode (a[0]);
+ return gel_copynode (a[0]);
}
nm = gel_matrix_new ();
@@ -1008,14 +1006,14 @@
GelETree *t = gel_matrixw_get_index (m, i, j);
if (t != NULL)
gel_matrix_index (nm, tj, j) =
- copynode (t);
+ gel_copynode (t);
}
tj--;
}
g_slist_free (cols);
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix (nm);
n->mat.quoted = a[0]->mat.quoted;
@@ -1031,7 +1029,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (conj_function, a[0]);
+ return gel_function_from_function (conj_function, a[0]);
}
if (a[0]->type == MATRIX_NODE)
@@ -1055,7 +1053,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (sin_function, a[0]);
+ return gel_function_from_function (sin_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1079,7 +1077,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (sinh_function, a[0]);
+ return gel_function_from_function (sinh_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1103,7 +1101,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (cos_function, a[0]);
+ return gel_function_from_function (cos_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1127,7 +1125,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (cosh_function, a[0]);
+ return gel_function_from_function (cosh_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1152,7 +1150,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (tan_function, a[0]);
+ return gel_function_from_function (tan_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1182,7 +1180,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (atan_function, a[0]);
+ return gel_function_from_function (atan_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1216,8 +1214,8 @@
mpw_arctan2 (fr,
a[0]->val.value,
a[1]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear (fr);
return NULL;
}
@@ -1306,7 +1304,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (ErrorFunction_function, a[0]);
+ return gel_function_from_function (ErrorFunction_function, a[0]);
}
if (a[0]->type == MATRIX_NODE)
@@ -1344,7 +1342,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (RiemannZeta_function, a[0]);
+ return gel_function_from_function (RiemannZeta_function, a[0]);
}
if (a[0]->type == MATRIX_NODE)
@@ -1381,7 +1379,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (GammaFunction_function, a[0]);
+ return gel_function_from_function (GammaFunction_function, a[0]);
}
if (a[0]->type == MATRIX_NODE)
@@ -1627,7 +1625,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (trunc_function, a[0]);
+ return gel_function_from_function (trunc_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1646,7 +1644,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (floor_function, a[0]);
+ return gel_function_from_function (floor_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1665,7 +1663,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (ceil_function, a[0]);
+ return gel_function_from_function (ceil_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1684,7 +1682,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (round_function, a[0]);
+ return gel_function_from_function (round_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1703,7 +1701,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (float_function, a[0]);
+ return gel_function_from_function (float_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1723,7 +1721,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (Numerator_function, a[0]);
+ return gel_function_from_function (Numerator_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1733,8 +1731,8 @@
return NULL;
mpw_init(fr);
mpw_numerator(fr,a[0]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(fr);
return NULL;
}
@@ -1748,7 +1746,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (Denominator_function, a[0]);
+ return gel_function_from_function (Denominator_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1758,8 +1756,8 @@
return NULL;
mpw_init(fr);
mpw_denominator(fr,a[0]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(fr);
return NULL;
}
@@ -1773,7 +1771,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (Re_function, a[0]);
+ return gel_function_from_function (Re_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1793,7 +1791,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (Im_function, a[0]);
+ return gel_function_from_function (Im_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1811,7 +1809,7 @@
{
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (sqrt_function, a[0]);
+ return gel_function_from_function (sqrt_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1849,7 +1847,7 @@
arg[0] = a[0];
arg[1] = gel_makenum (ctx->modulo);
arg[2] = NULL;
- ret = funccall (ctx, SqrtModPrime, arg, 2);
+ ret = gel_funccall (ctx, SqrtModPrime, arg, 2);
gel_freetree (arg[1]);
return ret;
@@ -1869,7 +1867,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (exp_function, a[0]);
+ return gel_function_from_function (exp_function, a[0]);
}
if(a[0]->type==MATRIX_NODE) {
@@ -1879,7 +1877,7 @@
"exp");
return NULL;
}
- return funccall(ctx,_internal_exp_function,a,1);
+ return gel_funccall(ctx,_internal_exp_function,a,1);
}
if G_UNLIKELY ( ! check_argument_number (a, 0, "exp"))
@@ -1896,7 +1894,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (ln_function, a[0]);
+ return gel_function_from_function (ln_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1906,8 +1904,8 @@
return NULL;
mpw_init(fr);
mpw_ln(fr,a[0]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(fr);
return NULL;
}
@@ -1921,7 +1919,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (log2_function, a[0]);
+ return gel_function_from_function (log2_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1931,8 +1929,8 @@
return NULL;
mpw_init(fr);
mpw_log2(fr,a[0]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(fr);
return NULL;
}
@@ -1946,7 +1944,7 @@
if (a[0]->type == FUNCTION_NODE ||
a[0]->type == IDENTIFIER_NODE) {
- return function_from_function (log10_function, a[0]);
+ return gel_function_from_function (log10_function, a[0]);
}
if(a[0]->type==MATRIX_NODE)
@@ -1956,8 +1954,8 @@
return NULL;
mpw_init(fr);
mpw_log10(fr,a[0]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(fr);
return NULL;
}
@@ -1982,8 +1980,8 @@
mpw_gcd(tmp,
a[0]->val.value,
a[1]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(tmp);
return NULL;
}
@@ -2082,8 +2080,8 @@
mpw_lcm(tmp,
a[0]->val.value,
a[1]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(tmp);
return NULL;
}
@@ -2181,8 +2179,8 @@
mpw_jacobi(tmp,
a[0]->val.value,
a[1]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(tmp);
return NULL;
}
@@ -2208,8 +2206,8 @@
mpw_kronecker(tmp,
a[0]->val.value,
a[1]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(tmp);
return NULL;
}
@@ -2235,8 +2233,8 @@
mpw_legendre(tmp,
a[0]->val.value,
a[1]->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
mpw_clear(tmp);
return NULL;
}
@@ -2257,8 +2255,8 @@
if(mpw_perfect_square(a[0]->val.value)) {
return gel_makenum_bool (1);
} else {
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
return gel_makenum_bool (0);
@@ -2279,8 +2277,8 @@
if(mpw_perfect_power(a[0]->val.value)) {
return gel_makenum_bool (1);
} else {
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
return gel_makenum_bool (0);
@@ -2299,8 +2297,8 @@
if(mpw_even_p(a[0]->val.value)) {
return gel_makenum_bool (1);
} else {
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
return gel_makenum_bool (0);
@@ -2319,8 +2317,8 @@
if(mpw_odd_p(a[0]->val.value)) {
return gel_makenum_bool (1);
} else {
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
return gel_makenum_bool (0);
@@ -2340,13 +2338,13 @@
return NULL;
if(mpw_cmp(a[0]->val.value,a[1]->val.value)<0)
- return copynode (a[1]);
+ return gel_copynode (a[1]);
else {
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
- return copynode (a[0]);
+ return gel_copynode (a[0]);
}
}
@@ -2378,7 +2376,7 @@
}
}
g_assert (max != NULL);
- return copynode (max);
+ return gel_copynode (max);
} else if (a[0]->type == VALUE_NODE) {
/*
* Evil optimization to avoid copying the node from the argument
@@ -2427,13 +2425,13 @@
return NULL;
if(mpw_cmp(a[0]->val.value,a[1]->val.value)>0)
- return copynode (a[1]);
+ return gel_copynode (a[1]);
else {
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
- return copynode (a[0]);
+ return gel_copynode (a[0]);
}
}
@@ -2465,7 +2463,7 @@
}
}
g_assert (min != NULL);
- return copynode (min);
+ return gel_copynode (min);
} else if (a[0]->type == VALUE_NODE) {
/*
* Evil optimization to avoid copying the node from the argument
@@ -2652,7 +2650,7 @@
return gel_makenum_null ();
/*make us a new empty node*/
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.quoted = FALSE;
@@ -2724,7 +2722,7 @@
return gel_makenum_null ();
/*make us a new empty node*/
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = m = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -2782,7 +2780,7 @@
return gel_makenum_null ();
/*make us a new empty node*/
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = m = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -3055,7 +3053,7 @@
}
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only_integer (nm);
if (a[0]->type == MATRIX_NODE)
@@ -3199,7 +3197,7 @@
if (a[0]->type == NULL_NODE) {
return gel_makenum_null ();
} else if (a[1]->type == NULL_NODE) {
- return copynode (a[0]);
+ return gel_copynode (a[0]);
}
m1 = a[0]->mat.matrix;
@@ -3218,7 +3216,7 @@
if (t == the_zero)
list = g_slist_prepend (list, NULL);
else
- list = g_slist_prepend (list, copynode (t));
+ list = g_slist_prepend (list, gel_copynode (t));
len ++;
}
}
@@ -3237,7 +3235,7 @@
}
g_slist_free (list);
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix (nm);
n->mat.quoted = a[0]->mat.quoted;
@@ -3281,7 +3279,7 @@
if (t == the_zero)
list = g_slist_prepend (list, NULL);
else
- list = g_slist_prepend (list, copynode (t));
+ list = g_slist_prepend (list, gel_copynode (t));
len ++;
}
}
@@ -3300,7 +3298,7 @@
}
g_slist_free (list);
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix (nm);
n->mat.quoted = a[0]->mat.quoted;
@@ -3328,7 +3326,7 @@
if G_UNLIKELY ( ! check_argument_value_only_matrix (a, 0, "ref"))
return NULL;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_copy(a[0]->mat.matrix);
gel_value_matrix_gauss (ctx, n->mat.matrix, FALSE, FALSE, FALSE, FALSE, NULL, NULL);
@@ -3342,7 +3340,7 @@
if G_UNLIKELY ( ! check_argument_value_only_matrix (a, 0, "rref"))
return NULL;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_copy(a[0]->mat.matrix);
if ( ! n->mat.matrix->rref) {
@@ -3432,7 +3430,7 @@
gel_matrix_index (nm, i, 1) = gel_makenum_ui (rows[i]+1);
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only_integer (nm);
n->mat.quoted = FALSE;
@@ -3542,7 +3540,7 @@
(m, i, pivot_rows[pi]);
if (t != NULL)
gel_matrix_index (nm, j, pivot_cols[pi])
- = copynode (t);
+ = gel_copynode (t);
} else {
break;
}
@@ -3556,7 +3554,7 @@
g_free (pivot_cols);
g_free (pivot_rows);
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only (nm);
n->mat.quoted = FALSE;
@@ -3642,7 +3640,7 @@
ret = gel_value_matrix_gauss (ctx, RM, TRUE, FALSE, FALSE, FALSE, NULL, RV);
if (retm != NULL) {
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = RM;
n->mat.quoted = FALSE;
@@ -3652,7 +3650,7 @@
}
if (retv != NULL) {
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_copy (RV);
n->mat.quoted = FALSE;
@@ -3691,7 +3689,7 @@
gel_matrixw_free (RV);
RV = tmp;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = RV;
n->mat.quoted = FALSE;
@@ -3787,10 +3785,10 @@
mpw_init (ret);
mpw_nextprime (ret, a[0]->val.value);
- if G_UNLIKELY (error_num != NO_ERROR) {
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
mpw_clear (ret);
/* eek! should not happen */
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return NULL;
}
return gel_makenum_use (ret);
@@ -3809,9 +3807,9 @@
mpw_init (ret);
mpw_lucnum (ret, a[0]->val.value);
- if G_UNLIKELY (error_num != NO_ERROR) {
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
mpw_clear (ret);
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return NULL;
}
return gel_makenum_use (ret);
@@ -3943,7 +3941,7 @@
return NULL;
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = mn = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -3981,9 +3979,9 @@
mpw_init (ret);
mpw_invert (ret, a[0]->val.value, a[1]->val.value);
- if G_UNLIKELY (error_num != NO_ERROR) {
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
mpw_clear (ret);
- error_num = NO_ERROR;
+ gel_error_num = GEL_NO_ERROR;
return NULL;
}
return gel_makenum_use (ret);
@@ -4124,7 +4122,7 @@
m1 = a[0]->mat.matrix;
m2 = a[1]->mat.matrix;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = mn = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -4143,10 +4141,10 @@
gel_matrixw_set_index(mn,i,0) = gel_makenum_use(t);
} else if(i<gel_matrixw_width(m1)) {
gel_matrixw_set_index(mn,i,0) =
- copynode(gel_matrixw_get_index(m1,i,0));
+ gel_copynode(gel_matrixw_get_index(m1,i,0));
} else /*if(i<gel_matrixw_width(m2)*/ {
gel_matrixw_set_index(mn,i,0) =
- copynode(gel_matrixw_set_index(m2,i,0));
+ gel_copynode(gel_matrixw_set_index(m2,i,0));
}
}
@@ -4169,7 +4167,7 @@
m1 = a[0]->mat.matrix;
m2 = a[1]->mat.matrix;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = mn = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -4188,7 +4186,7 @@
gel_matrixw_set_index(mn,i,0) = gel_makenum_use(t);
} else if(i<gel_matrixw_width(m1)) {
gel_matrixw_set_index(mn,i,0) =
- copynode(gel_matrixw_set_index(m1,i,0));
+ gel_copynode(gel_matrixw_set_index(m1,i,0));
} else /*if(i<gel_matrixw_width(m2))*/ {
GelETree *nn,*r;
r = gel_matrixw_index(m2,i,0);
@@ -4217,7 +4215,7 @@
m1 = a[0]->mat.matrix;
m2 = a[1]->mat.matrix;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = mn = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -4292,7 +4290,7 @@
return NULL;
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = mn = gel_matrixw_new ();
n->mat.quoted = FALSE;
@@ -4302,7 +4300,7 @@
gel_matrixw_set_size (mn, 1, 1);
if (retrem != NULL) {
- GET_NEW_NODE(rn);
+ GEL_GET_NEW_NODE(rn);
rn->type = MATRIX_NODE;
rn->mat.matrix = gel_matrixw_copy (pm);
poly_cut_zeros (rn->mat.matrix);
@@ -4354,7 +4352,7 @@
if (retrem != NULL) {
poly_cut_zeros (rem);
- GET_NEW_NODE (rn);
+ GEL_GET_NEW_NODE (rn);
rn->type = MATRIX_NODE;
rn->mat.matrix = rem;
rn->mat.quoted = FALSE;
@@ -4378,7 +4376,7 @@
m = a[0]->mat.matrix;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = mn = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -4414,7 +4412,7 @@
m = a[0]->mat.matrix;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = mn = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -4446,7 +4444,7 @@
if G_UNLIKELY ( ! check_poly(a,1,"TrimPoly",TRUE))
return NULL;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_copy(a[0]->mat.matrix);
n->mat.quoted = FALSE;
@@ -4537,7 +4535,7 @@
gel_matrix_index (nm, 0, 0) = gel_makenum_use (r1);
gel_matrix_index (nm, 0, 1) = gel_makenum_use (r2);
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only (nm);
n->mat.quoted = FALSE;
@@ -4634,7 +4632,7 @@
r = gel_output_snarf_string (gelo);
gel_output_unref (gelo);
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = STRING_NODE;
n->str.str = r;
n->str.constant = FALSE;
@@ -4647,14 +4645,14 @@
{
GelETree *n;
GelETree *tokn;
- GET_NEW_NODE(tokn);
+ GEL_GET_NEW_NODE(tokn);
tokn->type = IDENTIFIER_NODE;
tokn->id.id = id;
if(power == 1)
return tokn;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = E_EXP;
n->op.args = tokn;
@@ -4675,7 +4673,7 @@
} else if (mpw_eql_ui (mul, 1)) {
n = ptf_makenew_power(id,power);
} else {
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = E_MUL;
n->op.args = gel_makenum (mul);
@@ -4714,7 +4712,7 @@
nn = ptf_makenew_term(t->val.value,var,i);
else {
GelETree *nnn;
- GET_NEW_NODE(nnn);
+ GEL_GET_NEW_NODE(nnn);
nnn->type = OPERATOR_NODE;
nnn->op.oper = E_PLUS;
nnn->op.args = nn;
@@ -4728,7 +4726,7 @@
if(!nn)
nn = gel_makenum_ui(0);
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = FUNCTION_NODE;
n->func.func = d_makeufunc(NULL,nn,g_slist_append(NULL,var),1, NULL);
n->func.func->context = -1;
@@ -4753,7 +4751,7 @@
if (size == 0)
return gel_makenum_null ();
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = m = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -4836,7 +4834,7 @@
if (size == 0)
return gel_makenum_null ();
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = MATRIX_NODE;
n->mat.matrix = m = gel_matrixw_new();
n->mat.quoted = FALSE;
@@ -4910,8 +4908,8 @@
fname = a[0]->str.str;
}
- add_category (fname, a[1]->str.str);
- add_description (fname, a[2]->str.str);
+ gel_add_category (fname, a[1]->str.str);
+ gel_add_description (fname, a[2]->str.str);
return gel_makenum_null();
}
@@ -4938,7 +4936,7 @@
fname2 = a[1]->str.str;
}
- add_alias (fname1, fname2);
+ gel_add_alias (fname1, fname2);
return gel_makenum_null();
}
@@ -4966,7 +4964,7 @@
gel_matrix_index (mm, i, 0) = gel_makenum_si (vec[i]);
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix_value_only_integer (mm);
n->mat.quoted = FALSE;
@@ -4991,7 +4989,7 @@
li = li->next;
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_new_with_matrix (mm);
n->mat.quoted = FALSE;
@@ -5100,15 +5098,15 @@
! check_argument_integer (a, 1, "Combinations"))
return NULL;
- error_num = 0;
+ gel_error_num = 0;
k = mpw_get_long(a[0]->val.value);
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return NULL;
}
n = mpw_get_long(a[1]->val.value);
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return NULL;
}
if G_UNLIKELY (n < 1 || n > G_MAXINT || k < 1 || k > n) {
@@ -5155,15 +5153,15 @@
! check_argument_integer (a, 1, "Permutations"))
return NULL;
- error_num = 0;
+ gel_error_num = 0;
k = mpw_get_long(a[0]->val.value);
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return NULL;
}
n = mpw_get_long(a[1]->val.value);
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return NULL;
}
if G_UNLIKELY (n < 1 || n > G_MAXINT || k < 1 || k > n) {
@@ -5230,10 +5228,10 @@
m = a[0]->mat.matrix;
k = gel_matrixw_elements (m);
- error_num = 0;
+ gel_error_num = 0;
n = mpw_get_long(a[1]->val.value);
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return NULL;
}
if G_UNLIKELY (n < 1 || n > G_MAXINT || k < 1 || k > n) {
@@ -5245,8 +5243,8 @@
comb = g_new (int, k);
for (i = 0; i < k; i++) {
int j = mpw_get_long (gel_matrixw_vindex (m, i)->val.value);
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
g_free (comb);
return NULL;
} else if G_UNLIKELY (j < 1 || j > n) {
@@ -5282,10 +5280,10 @@
! check_argument_nonnegative_integer (a, 1, "nCr"))
return NULL;
- error_num = 0;
+ gel_error_num = 0;
r = mpw_get_ulong(a[1]->val.value);
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return NULL;
}
@@ -5423,11 +5421,11 @@
args[0] = &arg;
args[1] = NULL;
- ret = funccall (ctx, func, args, 1);
+ ret = gel_funccall (ctx, func, args, 1);
mpw_clear (arg.val.value);
- if G_UNLIKELY (error_num != 0 ||
+ if G_UNLIKELY (gel_error_num != 0 ||
ret == NULL ||
ret->type != VALUE_NODE) {
gel_freetree (ret);
@@ -5472,6 +5470,7 @@
long n, i;
mpw_t X, XI0, XI1, XI2, h, fret;
GelETree *ret = NULL;
+ gboolean do_neg = FALSE;
if G_UNLIKELY ( ! check_argument_function_or_identifier (a, 0, "CompositeSimpsonsRule") ||
! check_argument_real_number (a, 1, "CompositeSimpsonsRule") ||
@@ -5486,8 +5485,8 @@
mpw_add_ui (in, in, 1);
n = mpw_get_long (in);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
@@ -5496,9 +5495,10 @@
}
if (mpw_cmp (ia, ib) > 0) {
- gel_errorout (_("%s: argument 2 must be less than or equal to argument 3"),
- "CompositeSimpsonsRule");
- return NULL;
+ mpw_ptr tmp = ia;
+ ia = ib;
+ ib = tmp;
+ do_neg = TRUE;
}
if (a[0]->type == FUNCTION_NODE) {
@@ -5564,9 +5564,9 @@
mpw_add (XI2, XI2, fret);
}
- if (evalnode_hook) {
+ if (gel_evalnode_hook) {
if G_UNLIKELY ((i & 0x3FF) == 0x3FF) {
- (*evalnode_hook)();
+ (*gel_evalnode_hook)();
}
}
}
@@ -5581,6 +5581,9 @@
mpw_mul (fret, fret, h);
mpw_div_ui (fret, fret, 3);
+ if (do_neg)
+ mpw_neg (fret, fret);
+
ret = gel_makenum (fret);
end_of_simpson:
@@ -5629,7 +5632,7 @@
NULL /* finished */,
NULL /* dirprefix */);
- return eval_etree (ctx, et);
+ return gel_eval_etree (ctx, et);
}
static GelETree *
@@ -5665,8 +5668,8 @@
return NULL;
bits = mpw_get_long(a->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
if G_UNLIKELY (bits < 60 || bits > 16384) {
@@ -5675,21 +5678,20 @@
return NULL;
}
- if(calcstate.float_prec != bits) {
- calcstate.float_prec = bits;
- mpw_set_default_prec (calcstate.float_prec);
+ if(gel_calcstate.float_prec != bits) {
+ gel_calcstate.float_prec = bits;
+ mpw_set_default_prec (gel_calcstate.float_prec);
gel_break_fp_caches ();
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ gel_set_state (gel_calcstate);
}
- return gel_makenum_ui(calcstate.float_prec);
+ return gel_makenum_ui(gel_calcstate.float_prec);
}
static GelETree *
get_FloatPrecision (void)
{
- return gel_makenum_ui(calcstate.float_prec);
+ return gel_makenum_ui(gel_calcstate.float_prec);
}
static GelETree *
@@ -5701,8 +5703,8 @@
return NULL;
digits = mpw_get_long(a->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
if G_UNLIKELY (digits < 0 || digits > 256) {
@@ -5711,19 +5713,18 @@
return NULL;
}
- if(calcstate.max_digits != digits) {
- calcstate.max_digits = digits;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ if(gel_calcstate.max_digits != digits) {
+ gel_calcstate.max_digits = digits;
+ gel_set_state (gel_calcstate);
}
- return gel_makenum_ui(calcstate.max_digits);
+ return gel_makenum_ui(gel_calcstate.max_digits);
}
static GelETree *
get_MaxDigits (void)
{
- return gel_makenum_ui(calcstate.max_digits);
+ return gel_makenum_ui(gel_calcstate.max_digits);
}
static GelETree *
@@ -5735,24 +5736,23 @@
return NULL;
e = mpw_get_long(a->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
- if(calcstate.chop != e) {
- calcstate.chop = e;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ if(gel_calcstate.chop != e) {
+ gel_calcstate.chop = e;
+ gel_set_state (gel_calcstate);
}
- return gel_makenum_ui(calcstate.chop);
+ return gel_makenum_ui(gel_calcstate.chop);
}
static GelETree *
get_OutputChopExponent (void)
{
- return gel_makenum_ui(calcstate.chop);
+ return gel_makenum_ui(gel_calcstate.chop);
}
static GelETree *
@@ -5764,24 +5764,23 @@
return NULL;
e = mpw_get_long(a->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
- if(calcstate.chop_when != e) {
- calcstate.chop_when = e;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ if(gel_calcstate.chop_when != e) {
+ gel_calcstate.chop_when = e;
+ gel_set_state (gel_calcstate);
}
- return gel_makenum_ui(calcstate.chop_when);
+ return gel_makenum_ui(gel_calcstate.chop_when);
}
static GelETree *
get_OutputChopWhenExponent (void)
{
- return gel_makenum_ui(calcstate.chop_when);
+ return gel_makenum_ui(gel_calcstate.chop_when);
}
static GelETree *
@@ -5790,18 +5789,17 @@
if G_UNLIKELY ( ! check_argument_bool (&a, 0, "set_ResultsAsFloats"))
return NULL;
if (a->type == VALUE_NODE)
- calcstate.results_as_floats = ! mpw_zero_p (a->val.value);
+ gel_calcstate.results_as_floats = ! mpw_zero_p (a->val.value);
else /* a->type == BOOL_NODE */
- calcstate.results_as_floats = a->bool_.bool_;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ gel_calcstate.results_as_floats = a->bool_.bool_;
+ gel_set_state (gel_calcstate);
- return gel_makenum_bool (calcstate.results_as_floats);
+ return gel_makenum_bool (gel_calcstate.results_as_floats);
}
static GelETree *
get_ResultsAsFloats (void)
{
- return gel_makenum_bool (calcstate.results_as_floats);
+ return gel_makenum_bool (gel_calcstate.results_as_floats);
}
static GelETree *
set_ScientificNotation (GelETree * a)
@@ -5809,18 +5807,17 @@
if G_UNLIKELY ( ! check_argument_bool (&a, 0, "set_ScientificNotation"))
return NULL;
if (a->type == VALUE_NODE)
- calcstate.scientific_notation = ! mpw_zero_p (a->val.value);
+ gel_calcstate.scientific_notation = ! mpw_zero_p (a->val.value);
else /* a->type == BOOL_NODE */
- calcstate.scientific_notation = a->bool_.bool_;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ gel_calcstate.scientific_notation = a->bool_.bool_;
+ gel_set_state (gel_calcstate);
- return gel_makenum_bool (calcstate.scientific_notation);
+ return gel_makenum_bool (gel_calcstate.scientific_notation);
}
static GelETree *
get_ScientificNotation (void)
{
- return gel_makenum_bool (calcstate.scientific_notation);
+ return gel_makenum_bool (gel_calcstate.scientific_notation);
}
static GelETree *
set_FullExpressions (GelETree * a)
@@ -5828,18 +5825,17 @@
if G_UNLIKELY ( ! check_argument_bool (&a, 0, "set_FullExpressions"))
return NULL;
if (a->type == VALUE_NODE)
- calcstate.full_expressions = ! mpw_zero_p (a->val.value);
+ gel_calcstate.full_expressions = ! mpw_zero_p (a->val.value);
else /* a->type == BOOL_NODE */
- calcstate.full_expressions = a->bool_.bool_;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ gel_calcstate.full_expressions = a->bool_.bool_;
+ gel_set_state (gel_calcstate);
- return gel_makenum_bool (calcstate.full_expressions);
+ return gel_makenum_bool (gel_calcstate.full_expressions);
}
static GelETree *
get_FullExpressions (void)
{
- return gel_makenum_bool (calcstate.full_expressions);
+ return gel_makenum_bool (gel_calcstate.full_expressions);
}
static GelETree *
@@ -5869,9 +5865,8 @@
return NULL;
}
- calcstate.output_style = output_style;
- if (statechange_hook)
- (*statechange_hook)(calcstate);
+ gel_calcstate.output_style = output_style;
+ gel_set_state (gel_calcstate);
return gel_makenum_string (token);
}
@@ -5882,11 +5877,11 @@
const char *token;
token = "normal";
- if (calcstate.output_style == GEL_OUTPUT_TROFF)
+ if (gel_calcstate.output_style == GEL_OUTPUT_TROFF)
token = "troff";
- else if (calcstate.output_style == GEL_OUTPUT_LATEX)
+ else if (gel_calcstate.output_style == GEL_OUTPUT_LATEX)
token = "latex";
- else if (calcstate.output_style == GEL_OUTPUT_MATHML)
+ else if (gel_calcstate.output_style == GEL_OUTPUT_MATHML)
token = "mathml";
return gel_makenum_string (token);
@@ -5901,8 +5896,8 @@
return NULL;
errors = mpw_get_long(a->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
if G_UNLIKELY (errors < 0) {
@@ -5911,19 +5906,18 @@
return NULL;
}
- if(calcstate.max_errors != errors) {
- calcstate.max_errors = errors;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ if(gel_calcstate.max_errors != errors) {
+ gel_calcstate.max_errors = errors;
+ gel_set_state (gel_calcstate);
}
- return gel_makenum_ui(calcstate.max_errors);
+ return gel_makenum_ui(gel_calcstate.max_errors);
}
static GelETree *
get_MaxErrors (void)
{
- return gel_makenum_ui(calcstate.max_errors);
+ return gel_makenum_ui(gel_calcstate.max_errors);
}
static GelETree *
@@ -5932,18 +5926,17 @@
if G_UNLIKELY ( ! check_argument_bool (&a, 0, "set_MixedFractions"))
return NULL;
if (a->type == VALUE_NODE)
- calcstate.mixed_fractions = ! mpw_zero_p (a->val.value);
+ gel_calcstate.mixed_fractions = ! mpw_zero_p (a->val.value);
else /* a->type == BOOL_NODE */
- calcstate.mixed_fractions = a->bool_.bool_;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ gel_calcstate.mixed_fractions = a->bool_.bool_;
+ gel_set_state (gel_calcstate);
- return gel_makenum_bool (calcstate.mixed_fractions);
+ return gel_makenum_bool (gel_calcstate.mixed_fractions);
}
static GelETree *
get_MixedFractions (void)
{
- return gel_makenum_bool (calcstate.mixed_fractions);
+ return gel_makenum_bool (gel_calcstate.mixed_fractions);
}
static GelETree *
@@ -5955,8 +5948,8 @@
return NULL;
base = mpw_get_long(a->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
if G_UNLIKELY (base < 2 || base > 36) {
@@ -5965,19 +5958,18 @@
return NULL;
}
- if(calcstate.integer_output_base != base) {
- calcstate.integer_output_base = base;
- if(statechange_hook)
- (*statechange_hook)(calcstate);
+ if(gel_calcstate.integer_output_base != base) {
+ gel_calcstate.integer_output_base = base;
+ gel_set_state (gel_calcstate);
}
- return gel_makenum_ui(calcstate.integer_output_base);
+ return gel_makenum_ui(gel_calcstate.integer_output_base);
}
static GelETree *
get_IntegerOutputBase (void)
{
- return gel_makenum_ui(calcstate.integer_output_base);
+ return gel_makenum_ui(gel_calcstate.integer_output_base);
}
static GelETree *
@@ -5989,8 +5981,8 @@
return NULL;
reps = mpw_get_long (a->val.value);
- if G_UNLIKELY (error_num) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num) {
+ gel_error_num = 0;
return NULL;
}
@@ -6022,22 +6014,22 @@
GelEFunc *f;
GelToken *id;
- new_category ("basic", N_("Basic"), TRUE /* internal */);
- new_category ("parameters", N_("Parameters"), TRUE /* internal */);
- new_category ("constants", N_("Constants"), TRUE /* internal */);
- new_category ("numeric", N_("Numeric"), TRUE /* internal */);
- new_category ("trigonometry", N_("Trigonometry"), TRUE /* internal */);
- new_category ("number_theory", N_("Number Theory"), TRUE /* internal */);
- new_category ("matrix", N_("Matrix Manipulation"), TRUE /* internal */);
- new_category ("linear_algebra", N_("Linear Algebra"), TRUE /* internal */);
- new_category ("combinatorics", N_("Combinatorics"), TRUE /* internal */);
- new_category ("calculus", N_("Calculus"), TRUE /* internal */);
- new_category ("functions", N_("Functions"), TRUE /* internal */);
- new_category ("equation_solving", N_("Equation Solving"), TRUE /* internal */);
- new_category ("statistics", N_("Statistics"), TRUE /* internal */);
- new_category ("polynomial", N_("Polynomials"), TRUE /* internal */);
- new_category ("sets", N_("Set Theory"), TRUE /* internal */);
- new_category ("misc", N_("Miscellaneous"), TRUE /* internal */);
+ gel_new_category ("basic", N_("Basic"), TRUE /* internal */);
+ gel_new_category ("parameters", N_("Parameters"), TRUE /* internal */);
+ gel_new_category ("constants", N_("Constants"), TRUE /* internal */);
+ gel_new_category ("numeric", N_("Numeric"), TRUE /* internal */);
+ gel_new_category ("trigonometry", N_("Trigonometry"), TRUE /* internal */);
+ gel_new_category ("number_theory", N_("Number Theory"), TRUE /* internal */);
+ gel_new_category ("matrix", N_("Matrix Manipulation"), TRUE /* internal */);
+ gel_new_category ("linear_algebra", N_("Linear Algebra"), TRUE /* internal */);
+ gel_new_category ("combinatorics", N_("Combinatorics"), TRUE /* internal */);
+ gel_new_category ("calculus", N_("Calculus"), TRUE /* internal */);
+ gel_new_category ("functions", N_("Functions"), TRUE /* internal */);
+ gel_new_category ("equation_solving", N_("Equation Solving"), TRUE /* internal */);
+ gel_new_category ("statistics", N_("Statistics"), TRUE /* internal */);
+ gel_new_category ("polynomial", N_("Polynomials"), TRUE /* internal */);
+ gel_new_category ("sets", N_("Set Theory"), TRUE /* internal */);
+ gel_new_category ("misc", N_("Miscellaneous"), TRUE /* internal */);
FUNC (manual, 0, "", "basic", N_("Displays the user manual"));
FUNC (warranty, 0, "", "basic", N_("Gives the warranty information"));
@@ -6053,9 +6045,9 @@
/* FIXME: TRUE, FALSE aliases can't be done with the macros in funclibhelper.cP! */
d_addfunc (d_makebifunc (d_intern ("TRUE"), true_op, 0));
- add_alias ("true", "TRUE");
+ gel_add_alias ("true", "TRUE");
d_addfunc (d_makebifunc (d_intern ("FALSE"), false_op, 0));
- add_alias ("false", "FALSE");
+ gel_add_alias ("false", "FALSE");
FUNC (IntegerFromBoolean, 1, "bval", "basic", N_("Make integer (0 or 1) from a boolean value"));
Modified: trunk/src/funclibhelper.cP
==============================================================================
--- trunk/src/funclibhelper.cP (original)
+++ trunk/src/funclibhelper.cP Mon Mar 9 21:48:32 2009
@@ -5,29 +5,29 @@
#define FUNC(name,args,argn,category,desc) \
f = d_addfunc (d_makebifunc (d_intern ( #name ), name ## _op, args)); \
d_add_named_args (f, argn); \
- add_category ( #name , category); \
- add_description ( #name , desc);
+ gel_add_category ( #name , category); \
+ gel_add_description ( #name , desc);
#define VFUNC(name,args,argn,category,desc) \
f = d_addfunc (d_makebifunc (d_intern ( #name ), name ## _op, args)); \
d_add_named_args (f, argn); \
f->vararg = TRUE; \
- add_category ( #name , category); \
- add_description ( #name , desc);
+ gel_add_category ( #name , category); \
+ gel_add_description ( #name , desc);
#define ALIAS(name,args,aliasfor) \
d_addfunc (d_makebifunc (d_intern ( #name ), aliasfor ## _op, args)); \
- add_alias ( #aliasfor , #name );
+ gel_add_alias ( #aliasfor , #name );
#define VALIAS(name,args,aliasfor) \
f = d_addfunc (d_makebifunc (d_intern ( #name ), aliasfor ## _op, args)); \
f->vararg = TRUE; \
- add_alias ( #aliasfor , #name );
+ gel_add_alias ( #aliasfor , #name );
#define PARAMETER(name,desc) \
id = d_intern ( #name ); \
id->parameter = 1; \
id->built_in_parameter = 1; \
id->data1 = set_ ## name; \
id->data2 = get_ ## name; \
- add_category ( #name , "parameters"); \
- add_description ( #name , desc); \
+ gel_add_category ( #name , "parameters"); \
+ gel_add_description ( #name , desc); \
/* bogus value */ \
d_addfunc_global (d_makevfunc (id, gel_makenum_null()));
Modified: trunk/src/genius.c
==============================================================================
--- trunk/src/genius.c (original)
+++ trunk/src/genius.c Mon Mar 9 21:48:32 2009
@@ -68,8 +68,10 @@
/*Globals:*/
+const gboolean genius_is_gui = FALSE;
+
/*calculator state*/
-calcstate_t curstate={
+GelCalcState curstate={
128,
12,
FALSE,
@@ -83,11 +85,12 @@
20, /* chop */
5 /* chop_when */
};
+
+const GelHookFunc gel_evalnode_hook = NULL;
+const GelHookFunc _gel_tree_limit_hook = NULL;
extern int parenth_depth;
-extern int interrupted;
-
static int use_readline = TRUE;
static gboolean genius_in_dev_dir = FALSE;
@@ -252,8 +255,8 @@
}
-static void
-set_state(calcstate_t state)
+void
+gel_set_state(GelCalcState state)
{
curstate = state;
@@ -261,15 +264,15 @@
state.output_style == GEL_OUTPUT_LATEX ||
state.output_style == GEL_OUTPUT_MATHML ||
state.output_style == GEL_OUTPUT_TROFF)
- gel_output_set_length_limit (main_out, FALSE);
+ gel_output_set_length_limit (gel_main_out, FALSE);
else
- gel_output_set_length_limit (main_out, TRUE);
+ gel_output_set_length_limit (gel_main_out, TRUE);
}
static void
interrupt (int sig)
{
- interrupted = TRUE;
+ gel_interrupted = TRUE;
if (use_readline)
rl_stuff_char ('\n');
signal (SIGINT, interrupt);
@@ -302,8 +305,6 @@
gboolean be_quiet = FALSE;
char *exec = NULL;
- genius_is_gui = FALSE;
-
g_set_prgname ("genius");
g_set_application_name (_("Genius"));
@@ -330,8 +331,6 @@
signal (SIGINT, interrupt);
- statechange_hook = set_state;
-
for(i=1;i<argc;i++) {
int val;
if(lastarg || argv[i][0]!='-')
@@ -444,7 +443,7 @@
g_print (_("Genius %s\n"
"%s%s\n"),
VERSION,
- COPYRIGHT_STRING,
+ GENIUS_COPYRIGHT_STRING,
get_version_details ());
exit (0);
} else {
@@ -499,22 +498,22 @@
"For license details type `warranty'.\n"
"For help type 'manual' or 'help'.%s\n\n"),
VERSION,
- COPYRIGHT_STRING,
+ GENIUS_COPYRIGHT_STRING,
get_version_details ());
be_quiet = FALSE;
}
- main_out = gel_output_new();
+ gel_main_out = gel_output_new();
if(!be_quiet)
- gel_output_setup_file(main_out, stdout, 80,
+ gel_output_setup_file(gel_main_out, stdout, 80,
get_term_width);
else
- gel_output_setup_black_hole(main_out);
+ gel_output_setup_black_hole(gel_main_out);
- set_new_calcstate(curstate);
- set_new_errorout(calc_puterror);
- set_new_infoout(puterror);
+ gel_set_new_calcstate(curstate);
+ gel_set_new_errorout(calc_puterror);
+ gel_set_new_infoout(puterror);
/*init the context stack and clear out any stale dictionaries
except the global one, if this is the first time called it
@@ -614,7 +613,7 @@
if (exec != NULL) {
line_len_cache = -1;
- gel_evalexp (exec, NULL, main_out, NULL, FALSE, NULL);
+ gel_evalexp (exec, NULL, gel_main_out, NULL, FALSE, NULL);
gel_test_max_nodes_again ();
line_len_cache = -1;
goto after_exec;
@@ -628,14 +627,14 @@
line_len_cache = -1;
e = get_p_expression();
line_len_cache = -1;
- if(e) gel_evalexp_parsed(e,main_out,"= ",TRUE);
+ if(e) gel_evalexp_parsed(e,gel_main_out,"= ",TRUE);
gel_test_max_nodes_again ();
line_len_cache = -1;
} else {
line_len_cache = -1;
- gel_evalexp(NULL, fp, main_out, NULL, FALSE, NULL);
+ gel_evalexp(NULL, fp, gel_main_out, NULL, FALSE, NULL);
line_len_cache = -1;
- if (interrupted)
+ if G_UNLIKELY (gel_interrupted)
gel_got_eof = TRUE;
}
if(inter)
Modified: trunk/src/genius_lists.c
==============================================================================
--- trunk/src/genius_lists.c (original)
+++ trunk/src/genius_lists.c Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2002 George Lebl
+ * Copyright (C) 1997-2009 George Lebl
*
* Author: George Lebl
*
Modified: trunk/src/geniustests.txt
==============================================================================
--- trunk/src/geniustests.txt (original)
+++ trunk/src/geniustests.txt Mon Mar 9 21:48:32 2009
@@ -927,5 +927,8 @@
EulersMethod (`(x,y)=[(x-y@(1));0],0,[0;0],3,3) [2.0;0.0]
EulersMethod (`(x,y)=[0;(x-y@(2))],0,[0;0],3,3) [0.0;2.0]
EulersMethod (`(x,y)=[(x-y@(1));(x-y@(2))],0,[0;0],3,3) [2.0;2.0]
+CompositeSimpsonsRule(`(x)=x^2,0,3,100) 9.0
+CompositeSimpsonsRule(`(x)=x^2,3,0,100) -9.0
+CompositeSimpsonsRule(`(x)=x^2,3,3,100) 0
load "nullspacetest.gel" true
load "longtest.gel" true
Modified: trunk/src/gnome-genius.c
==============================================================================
--- trunk/src/gnome-genius.c (original)
+++ trunk/src/gnome-genius.c Mon Mar 9 21:48:32 2009
@@ -76,8 +76,10 @@
/*Globals:*/
+const gboolean genius_is_gui = TRUE;
+
/*calculator state*/
-calcstate_t curstate={
+GelCalcState curstate={
128,
12,
FALSE,
@@ -93,9 +95,14 @@
};
#define MAX_CHOP 1000
-
+
+static void check_events (void);
+const GelHookFunc gel_evalnode_hook = check_events;
+
+static void tree_limit_hit (void);
+const GelHookFunc _gel_tree_limit_hook = tree_limit_hit;
+
extern int parenth_depth;
-extern gboolean interrupted;
extern const char *genius_toplevels[];
GtkWidget *genius_window = NULL;
@@ -816,7 +823,7 @@
if (ret == GTK_RESPONSE_OK) {
char *txt = g_strstrip (g_strdup (gtk_entry_get_text (GTK_ENTRY (e))));
- GelHelp *help = get_help (txt, FALSE /* insert */);
+ GelHelp *help = gel_get_help (txt, FALSE /* insert */);
gboolean found = FALSE;
int i;
@@ -1513,10 +1520,10 @@
}
} else {
if(errors_printed-curstate.max_errors > 0) {
- gel_output_printf(main_out,
+ gel_output_printf(gel_main_out,
_("\e[01;31mToo many errors! (%d followed)\e[0m\n"),
errors_printed-curstate.max_errors);
- gel_output_flush (main_out);
+ gel_output_flush (gel_main_out);
}
}
errors_printed = 0;
@@ -1588,9 +1595,9 @@
errors = g_string_new(str);
}
} else {
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"\e[01;31m%s\e[0m\r\n", str);
- gel_output_flush (main_out);
+ gel_output_flush (gel_main_out);
}
g_free(str);
@@ -1753,9 +1760,9 @@
infos = g_string_new(str);
}
} else {
- gel_output_printf_full (main_out, FALSE,
+ gel_output_printf_full (gel_main_out, FALSE,
"\e[32m%s\e[0m\r\n", str);
- gel_output_flush (main_out);
+ gel_output_flush (gel_main_out);
}
g_free(str);
@@ -1828,11 +1835,11 @@
" You should have received a copy of the GNU General Public License\n"
" along with this program. If not, see <http://www.gnu.org/licenses/>.\n"),
VERSION,
- COPYRIGHT_STRING);
+ GENIUS_COPYRIGHT_STRING);
gtk_show_about_dialog (GTK_WINDOW (genius_window),
"program-name", _("Genius Mathematical Tool"),
"version", VERSION,
- "copyright", COPYRIGHT_STRING,
+ "copyright", GENIUS_COPYRIGHT_STRING,
"comments",
_("The Gnome calculator style edition of "
"the Genius Mathematical Tool."),
@@ -2035,7 +2042,7 @@
"unsaved programs.\nAre "
"you sure you wish to quit?")))
return;
- interrupted = TRUE;
+ gel_interrupted = TRUE;
} else {
if ( ! genius_ask_question (NULL,
_("There are unsaved programs, "
@@ -2049,7 +2056,7 @@
"are you sure you wish to "
"quit?")))
return;
- interrupted = TRUE;
+ gel_interrupted = TRUE;
} else {
if ( ! genius_ask_question (NULL,
_("Are you sure you wish "
@@ -2086,10 +2093,10 @@
}
-static calcstate_t tmpstate={0};
+static GelCalcState tmpstate={0};
static GeniusSetup tmpsetup={0};
-static calcstate_t cancelstate={0};
+static GelCalcState cancelstate={0};
static GeniusSetup cancelsetup={0};
static void
@@ -2117,7 +2124,7 @@
curstate = tmpstate;
}
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
vte_terminal_set_scrollback_lines (VTE_TERMINAL (term),
genius_setup.scrollback);
vte_terminal_set_font_from_string
@@ -2538,7 +2545,7 @@
void
genius_interrupt_calc (void)
{
- interrupted = TRUE;
+ gel_interrupted = TRUE;
if (!calc_running) {
vte_terminal_feed_child (VTE_TERMINAL (term), "\n", 1);
}
@@ -2563,7 +2570,7 @@
/* perhaps a bit ugly */
gboolean last = genius_setup.info_box;
genius_setup.info_box = TRUE;
- gel_evalexp ("warranty", NULL, main_out, NULL, TRUE, NULL);
+ gel_evalexp ("warranty", NULL, gel_main_out, NULL, TRUE, NULL);
gel_printout_infos ();
genius_setup.info_box = last;
}
@@ -2636,7 +2643,7 @@
g_free (str);
/* interrupt the current command line */
- interrupted = TRUE;
+ gel_interrupted = TRUE;
vte_terminal_feed_child (VTE_TERMINAL (term), "\n", 1);
}
@@ -2886,12 +2893,12 @@
/* FIXME: Ugly push/pop of output style */
GelOutputStyle last_style = curstate.output_style;
curstate.output_style = GEL_OUTPUT_NORMAL;
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
copy_answer ();
curstate.output_style = last_style;
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
}
}
@@ -2905,12 +2912,12 @@
/* FIXME: Ugly push/pop of output style */
GelOutputStyle last_style = curstate.output_style;
curstate.output_style = GEL_OUTPUT_LATEX;
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
copy_answer ();
curstate.output_style = last_style;
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
}
}
@@ -2924,12 +2931,12 @@
/* FIXME: Ugly push/pop of output style */
GelOutputStyle last_style = curstate.output_style;
curstate.output_style = GEL_OUTPUT_TROFF;
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
copy_answer ();
curstate.output_style = last_style;
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
}
}
@@ -2943,12 +2950,12 @@
/* FIXME: Ugly push/pop of output style */
GelOutputStyle last_style = curstate.output_style;
curstate.output_style = GEL_OUTPUT_MATHML;
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
copy_answer ();
curstate.output_style = last_style;
- set_new_calcstate (curstate);
+ gel_set_new_calcstate (curstate);
}
}
@@ -3996,17 +4003,17 @@
running_program = selected_program;
gel_push_file_info (name, 1);
- /* FIXME: Should not use main_out, we should have a separate
+ /* FIXME: Should not use gel_main_out, we should have a separate
console for output, the switching is annoying */
while (1) {
- gel_evalexp (NULL, fp, main_out, "= \e[1;36m",
+ gel_evalexp (NULL, fp, gel_main_out, "= \e[1;36m",
TRUE, NULL);
- gel_output_full_string (main_out, "\e[0m");
+ gel_output_full_string (gel_main_out, "\e[0m");
if (gel_got_eof) {
gel_got_eof = FALSE;
break;
}
- if (interrupted) {
+ if (gel_interrupted) {
break;
}
}
@@ -4028,7 +4035,7 @@
g_free (str);
/* interrupt the current command line */
- interrupted = TRUE;
+ gel_interrupted = TRUE;
vte_terminal_feed_child (VTE_TERMINAL (term), "\n", 1);
/* sanity */
@@ -4266,8 +4273,8 @@
return vte_terminal_get_column_count (VTE_TERMINAL (term));
}
-static void
-set_state (calcstate_t state)
+void
+gel_set_state (GelCalcState state)
{
curstate = state;
@@ -4275,9 +4282,9 @@
state.output_style == GEL_OUTPUT_LATEX ||
state.output_style == GEL_OUTPUT_MATHML ||
state.output_style == GEL_OUTPUT_TROFF)
- gel_output_set_length_limit (main_out, FALSE);
+ gel_output_set_length_limit (gel_main_out, FALSE);
else
- gel_output_set_length_limit (main_out, TRUE);
+ gel_output_set_length_limit (gel_main_out, TRUE);
}
static void
@@ -4292,7 +4299,7 @@
{
if (genius_ask_question (NULL,
_("Memory (node number) limit has been reached, interrupt the computation?"))) {
- interrupted = TRUE;
+ gel_interrupted = TRUE;
/*genius_interrupt_calc ();*/
}
}
@@ -4406,18 +4413,18 @@
{
if (e != NULL) {
calc_running ++;
- gel_evalexp_parsed (e, main_out, "= \e[1;36m", TRUE);
+ gel_evalexp_parsed (e, gel_main_out, "= \e[1;36m", TRUE);
gel_test_max_nodes_again ();
calc_running --;
- gel_output_full_string (main_out, "\e[0m");
- gel_output_flush (main_out);
+ gel_output_full_string (gel_main_out, "\e[0m");
+ gel_output_flush (gel_main_out);
}
gel_printout_infos ();
if (gel_got_eof) {
- gel_output_full_string (main_out, "\n");
- gel_output_flush (main_out);
+ gel_output_full_string (gel_main_out, "\n");
+ gel_output_flush (gel_main_out);
gel_got_eof = FALSE;
gtk_main_quit();
}
@@ -4758,8 +4765,6 @@
int plugin_count = 0;
gboolean give_no_lib_error_after_init = FALSE;
- genius_is_gui = TRUE;
-
arg0 = g_strdup (argv[0]);
g_set_prgname ("gnome-genius");
@@ -4820,14 +4825,10 @@
/*read parameters */
get_properties ();
- main_out = gel_output_new();
- gel_output_setup_string (main_out, 80, get_term_width);
- gel_output_set_notify (main_out, output_notify_func);
+ gel_main_out = gel_output_new();
+ gel_output_setup_string (gel_main_out, 80, get_term_width);
+ gel_output_set_notify (gel_main_out, output_notify_func);
- evalnode_hook = check_events;
- statechange_hook = set_state;
- _gel_tree_limit_hook = tree_limit_hit;
-
file = g_build_filename (genius_datadir,
"icons",
"hicolor",
@@ -4990,7 +4991,7 @@
}
- gel_output_printf (main_out,
+ gel_output_printf (gel_main_out,
_("%sGenius %s%s\n"
"%s\n"
"This is free software with ABSOLUTELY NO WARRANTY.\n"
@@ -4999,7 +5000,7 @@
"\e[0;32m" /* green */,
"\e[0m" /* white on black */,
VERSION,
- COPYRIGHT_STRING,
+ GENIUS_COPYRIGHT_STRING,
"\e[01;36m" /* cyan */,
"\e[0m" /* white on black */,
"\e[01;36m" /* cyan */,
@@ -5007,12 +5008,12 @@
"\e[01;36m" /* cyan */,
"\e[0m" /* white on black */,
get_version_details ());
- gel_output_flush (main_out);
+ gel_output_flush (gel_main_out);
check_events ();
- set_new_calcstate (curstate);
- set_new_errorout (geniuserror);
- set_new_infoout (geniusinfo);
+ gel_set_new_calcstate (curstate);
+ gel_set_new_errorout (geniuserror);
+ gel_set_new_infoout (geniusinfo);
setup_rl_fifos ();
Modified: trunk/src/gnome-genius.h
==============================================================================
--- trunk/src/gnome-genius.h (original)
+++ trunk/src/gnome-genius.h Mon Mar 9 21:48:32 2009
@@ -35,7 +35,6 @@
extern GeniusSetup genius_setup;
extern GtkWidget *genius_window;
-extern calcstate_t calcstate;
void genius_interrupt_calc (void);
Modified: trunk/src/graphing.c
==============================================================================
--- trunk/src/graphing.c (original)
+++ trunk/src/graphing.c Mon Mar 9 21:48:32 2009
@@ -598,7 +598,7 @@
graph_window_delete_event (GtkWidget *w, gpointer data)
{
if (plot_in_progress > 0) {
- interrupted = TRUE;
+ gel_interrupted = TRUE;
whack_window_after_plot = TRUE;
return TRUE;
} else {
@@ -613,13 +613,13 @@
if (response == GTK_RESPONSE_CLOSE ||
response == GTK_RESPONSE_DELETE_EVENT) {
if (plot_in_progress > 0) {
- interrupted = TRUE;
+ gel_interrupted = TRUE;
whack_window_after_plot = TRUE;
} else {
gtk_widget_destroy (graph_window);
}
} else if (response == RESPONSE_STOP && plot_in_progress > 0) {
- interrupted = TRUE;
+ gel_interrupted = TRUE;
}
}
@@ -710,13 +710,13 @@
gtk_widget_queue_draw (GTK_WIDGET (plot_canvas));
}
- if ( ! ret || interrupted) {
+ if ( ! ret || gel_interrupted) {
plot_in_progress --;
plot_window_setup ();
- if ( ! interrupted)
+ if ( ! gel_interrupted)
genius_display_error (graph_window, _("Printing failed"));
- interrupted = FALSE;
+ gel_interrupted = FALSE;
close (fd);
unlink (tmpfile);
return;
@@ -853,11 +853,11 @@
plot_in_progress --;
plot_window_setup ();
- if ( ! ret || interrupted) {
- if ( ! interrupted)
+ if ( ! ret || gel_interrupted) {
+ if ( ! gel_interrupted)
genius_display_error (graph_window, _("Export failed"));
g_free (s);
- interrupted = FALSE;
+ gel_interrupted = FALSE;
return;
}
@@ -1075,8 +1075,8 @@
plot_axis ();
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -1121,8 +1121,8 @@
plot_axis ();
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -1213,8 +1213,8 @@
plot_axis ();
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -1250,8 +1250,8 @@
plot_axis ();
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -1360,8 +1360,8 @@
plot_axis ();
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -2132,22 +2132,22 @@
args[2] = arg3;
args[3] = NULL;
- ret = funccall (ctx, func, args, 3);
+ ret = gel_funccall (ctx, func, args, 3);
/* FIXME: handle errors! */
- if (error_num != 0)
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0)
+ gel_error_num = 0;
/* only do one level of indirection to avoid infinite loops */
if (ret != NULL && ret->type == FUNCTION_NODE) {
if (ret->func.func->nargs == 3) {
GelETree *ret2;
- ret2 = funccall (ctx, ret->func.func, args, 3);
+ ret2 = gel_funccall (ctx, ret->func.func, args, 3);
gel_freetree (ret);
ret = ret2;
/* FIXME: handle errors! */
- if (error_num != 0)
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0)
+ gel_error_num = 0;
} else if (func_ret != NULL) {
*func_ret = ret;
#ifdef HUGE_VAL
@@ -2170,9 +2170,9 @@
}
retd = mpw_get_double (ret->val.value);
- if (error_num != 0) {
+ if G_UNLIKELY (gel_error_num != 0) {
*ex = TRUE;
- error_num = 0;
+ gel_error_num = 0;
#ifdef HUGE_VAL
retd = HUGE_VAL;
#endif
@@ -2198,22 +2198,22 @@
args[1] = arg2;
args[2] = NULL;
- ret = funccall (ctx, func, args, 2);
+ ret = gel_funccall (ctx, func, args, 2);
/* FIXME: handle errors! */
- if (error_num != 0)
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0)
+ gel_error_num = 0;
/* only do one level of indirection to avoid infinite loops */
if (ret != NULL && ret->type == FUNCTION_NODE) {
if (ret->func.func->nargs == 2) {
GelETree *ret2;
- ret2 = funccall (ctx, ret->func.func, args, 2);
+ ret2 = gel_funccall (ctx, ret->func.func, args, 2);
gel_freetree (ret);
ret = ret2;
/* FIXME: handle errors! */
- if (error_num != 0)
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0)
+ gel_error_num = 0;
} else if (func_ret != NULL) {
*func_ret = ret;
#ifdef HUGE_VAL
@@ -2235,9 +2235,9 @@
}
retd = mpw_get_double (ret->val.value);
- if (error_num != 0) {
+ if G_UNLIKELY (gel_error_num != 0) {
*ex = TRUE;
- error_num = 0;
+ gel_error_num = 0;
#ifdef HUGE_VAL
retd = HUGE_VAL;
#endif
@@ -2261,22 +2261,22 @@
args[0] = arg;
args[1] = NULL;
- ret = funccall (ctx, func, args, 1);
+ ret = gel_funccall (ctx, func, args, 1);
/* FIXME: handle errors! */
- if (error_num != 0)
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0)
+ gel_error_num = 0;
/* only do one level of indirection to avoid infinite loops */
if (ret != NULL && ret->type == FUNCTION_NODE) {
if (ret->func.func->nargs == 1) {
GelETree *ret2;
- ret2 = funccall (ctx, ret->func.func, args, 1);
+ ret2 = gel_funccall (ctx, ret->func.func, args, 1);
gel_freetree (ret);
ret = ret2;
/* FIXME: handle errors! */
- if (error_num != 0)
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0)
+ gel_error_num = 0;
} else if (func_ret != NULL) {
*func_ret = ret;
#ifdef HUGE_VAL
@@ -2299,9 +2299,9 @@
}
retd = mpw_get_double (ret->val.value);
- if (error_num != 0) {
+ if G_UNLIKELY (gel_error_num != 0) {
*ex = TRUE;
- error_num = 0;
+ gel_error_num = 0;
#ifdef HUGE_VAL
retd = HUGE_VAL;
#endif
@@ -2326,22 +2326,22 @@
args[0] = arg;
args[1] = NULL;
- ret = funccall (ctx, func, args, 1);
+ ret = gel_funccall (ctx, func, args, 1);
/* FIXME: handle errors! */
- if (error_num != 0)
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0)
+ gel_error_num = 0;
/* only do one level of indirection to avoid infinite loops */
if (ret != NULL && ret->type == FUNCTION_NODE) {
if (ret->func.func->nargs == 1) {
GelETree *ret2;
- ret2 = funccall (ctx, ret->func.func, args, 1);
+ ret2 = gel_funccall (ctx, ret->func.func, args, 1);
gel_freetree (ret);
ret = ret2;
/* FIXME: handle errors! */
- if (error_num != 0)
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0)
+ gel_error_num = 0;
} else if (func_ret != NULL) {
*func_ret = ret;
#ifdef HUGE_VAL
@@ -2370,9 +2370,9 @@
}
mpw_get_complex_double (ret->val.value, retx, rety);
- if (error_num != 0) {
+ if G_UNLIKELY (gel_error_num != 0) {
*ex = TRUE;
- error_num = 0;
+ gel_error_num = 0;
#ifdef HUGE_VAL
*retx = HUGE_VAL;
*rety = HUGE_VAL;
@@ -2396,7 +2396,7 @@
if (error != NULL)
*error = FALSE;
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
if (error != NULL)
*error = TRUE;
return 0.0;
@@ -2434,11 +2434,11 @@
*/
- if (hookrun++ >= 10) {
- hookrun = 0;
- if (evalnode_hook != NULL) {
- (*evalnode_hook)();
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (hookrun++ >= 10) {
+ if (gel_evalnode_hook != NULL) {
+ hookrun = 0;
+ (*gel_evalnode_hook)();
+ if G_UNLIKELY (gel_interrupted) {
if (error != NULL)
*error = TRUE;
return y;
@@ -2506,7 +2506,7 @@
if (error != NULL)
*error = FALSE;
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
if (error != NULL)
*error = TRUE;
return 0.0;
@@ -2532,11 +2532,11 @@
}
- if (hookrun++ >= 10) {
- hookrun = 0;
- if (evalnode_hook != NULL) {
- (*evalnode_hook)();
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (hookrun++ >= 10) {
+ if (gel_evalnode_hook != NULL) {
+ hookrun = 0;
+ (*gel_evalnode_hook)();
+ if G_UNLIKELY (gel_interrupted) {
if (error != NULL)
*error = TRUE;
return z;
@@ -2720,10 +2720,10 @@
gel_output_setup_string (out, 0, NULL);
/* FIXME: the push/pop of style is UGLY */
- old_style = calcstate.output_style;
- calcstate.output_style = GEL_OUTPUT_NORMAL;
+ old_style = gel_calcstate.output_style;
+ gel_calcstate.output_style = GEL_OUTPUT_NORMAL;
gel_print_etree (out, func->data.user, TRUE /* toplevel */);
- calcstate.output_style = old_style;
+ gel_calcstate.output_style = old_style;
text = gel_output_snarf_string (out);
gel_output_unref (out);
@@ -2801,8 +2801,8 @@
*y2 = mpw_get_double (t->val.value);
/* FIXME: what about errors */
- if (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return FALSE;
}
@@ -2833,7 +2833,7 @@
GelETree *n;
GelMatrixW *m;
/*make us a new empty node*/
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
m = n->mat.matrix = gel_matrixw_new ();
n->mat.quoted = FALSE;
@@ -2896,8 +2896,8 @@
*z2 = mpw_get_double (t->val.value);
/* FIXME: what about errors */
- if (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
return FALSE;
}
@@ -2937,7 +2937,7 @@
GelETree *n;
GelMatrixW *m;
/*make us a new empty node*/
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
m = n->mat.matrix = gel_matrixw_new ();
n->mat.quoted = FALSE;
@@ -2984,10 +2984,10 @@
}
/* FIXME: sanity on x/y ??? */
- if (hookrun++ >= 10) {
- hookrun = 0;
- if (evalnode_hook != NULL) {
- (*evalnode_hook)();
+ if G_UNLIKELY (hookrun++ >= 10) {
+ if (gel_evalnode_hook != NULL) {
+ hookrun = 0;
+ (*gel_evalnode_hook)();
}
}
@@ -3418,7 +3418,7 @@
if G_UNLIKELY (plot_ctx == NULL) {
mpw_t xx;
- plot_ctx = eval_get_context ();
+ plot_ctx = gel_eval_get_context ();
mpw_init (xx);
plot_arg = gel_makenum_use (xx);
@@ -3492,8 +3492,8 @@
init_plot_ctx ();
- if (evalnode_hook != NULL)
- (*evalnode_hook)();
+ if (gel_evalnode_hook != NULL)
+ (*gel_evalnode_hook)();
color_i = 0;
@@ -3538,7 +3538,7 @@
for (i = 0; i < len; i++) {
parametric_get_value (&(x[i]), &(y[i]), t);
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
break;
}
@@ -3641,8 +3641,8 @@
init_plot_ctx ();
- if (evalnode_hook != NULL)
- (*evalnode_hook)();
+ if (gel_evalnode_hook != NULL)
+ (*gel_evalnode_hook)();
if (surface_func != NULL) {
@@ -4316,9 +4316,9 @@
g_free (ce);
/* FIXME: funcbody? I think it must be done. */
- got_x = eval_find_identifier (value, d_intern ("x"), TRUE /*funcbody*/);
- got_y = eval_find_identifier (value, d_intern ("y"), TRUE /*funcbody*/);
- got_z = eval_find_identifier (value, d_intern ("z"), TRUE /*funcbody*/);
+ got_x = gel_eval_find_identifier (value, d_intern ("x"), TRUE /*funcbody*/);
+ got_y = gel_eval_find_identifier (value, d_intern ("y"), TRUE /*funcbody*/);
+ got_z = gel_eval_find_identifier (value, d_intern ("z"), TRUE /*funcbody*/);
/* FIXME: if "x" or "y" or "z" not used try to evaluate and if it returns a function use that */
if (value != NULL) {
@@ -4499,8 +4499,8 @@
plot_mode = MODE_SURFACE;
plot_surface_functions (TRUE /* do_window_present */);
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -4642,8 +4642,8 @@
plot_functions (TRUE /* do_window_present */);
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -4768,8 +4768,8 @@
plot_functions (TRUE /* do_window_present */);
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -4861,8 +4861,8 @@
plot_functions (TRUE /* do_window_present */);
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -4958,8 +4958,8 @@
plot_functions (TRUE /* do_window_present */);
- if (interrupted)
- interrupted = FALSE;
+ if (gel_interrupted)
+ gel_interrupted = FALSE;
gel_printout_infos ();
genius_setup.info_box = last_info;
@@ -5122,8 +5122,8 @@
}
}
/* FIXME: what about errors */
- if (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
goto whack_copied_funcs;
}
}
@@ -5181,7 +5181,7 @@
plot_mode = MODE_SURFACE;
plot_surface_functions (FALSE /* do_window_present */);
- if (interrupted)
+ if (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
@@ -5362,8 +5362,8 @@
}
}
/* FIXME: what about errors */
- if (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
goto whack_copied_funcs;
}
}
@@ -5403,7 +5403,7 @@
plot_mode = MODE_LINEPLOT_SLOPEFIELD;
plot_functions (FALSE /* do_window_present */);
- if (interrupted)
+ if (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
@@ -5474,8 +5474,8 @@
}
}
/* FIXME: what about errors */
- if (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
goto whack_copied_funcs;
}
}
@@ -5519,7 +5519,7 @@
plot_mode = MODE_LINEPLOT_VECTORFIELD;
plot_functions (FALSE /* do_window_present */);
- if (interrupted)
+ if (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
@@ -5592,8 +5592,8 @@
}
}
/* FIXME: what about errors */
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
goto whack_copied_funcs;
}
}
@@ -5636,7 +5636,7 @@
plot_mode = MODE_LINEPLOT;
plot_functions (FALSE /* do_window_present */);
- if G_UNLIKELY (interrupted)
+ if G_UNLIKELY (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
@@ -5700,8 +5700,8 @@
}
}
/* FIXME: what about errors */
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
goto whack_copied_funcs;
}
}
@@ -5728,8 +5728,8 @@
}
}
/* FIXME: what about errors */
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
goto whack_copied_funcs;
}
}
@@ -5779,7 +5779,7 @@
plot_mode = MODE_LINEPLOT_PARAMETRIC;
plot_functions (FALSE /* do_window_present */);
- if G_UNLIKELY (interrupted)
+ if G_UNLIKELY (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
@@ -5840,8 +5840,8 @@
}
}
/* FIXME: what about errors */
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
goto whack_copied_funcs;
}
}
@@ -5868,8 +5868,8 @@
}
}
/* FIXME: what about errors */
- if G_UNLIKELY (error_num != 0) {
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) {
+ gel_error_num = 0;
goto whack_copied_funcs;
}
}
@@ -5918,7 +5918,7 @@
plot_mode = MODE_LINEPLOT_PARAMETRIC;
plot_functions (FALSE /* do_window_present */);
- if G_UNLIKELY (interrupted)
+ if G_UNLIKELY (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
@@ -5945,7 +5945,7 @@
plot_mode = MODE_LINEPLOT;
plot_functions (FALSE /* do_window_present */);
- if G_UNLIKELY (interrupted)
+ if G_UNLIKELY (gel_interrupted)
return NULL;
else
return gel_makenum_null ();
@@ -6520,7 +6520,7 @@
GelEFunc *f;
GelToken *id;
- new_category ("plotting", N_("Plotting"), TRUE /* internal */);
+ gel_new_category ("plotting", N_("Plotting"), TRUE /* internal */);
VFUNC (LinePlot, 2, "func,args", "plotting", N_("Plot a function with a line. First come the functions (up to 10) then optionally limits as x1,x2,y1,y2"));
VFUNC (LinePlotParametric, 3, "xfunc,yfunc,args", "plotting", N_("Plot a parametric function with a line. First come the functions for x and y then optionally the t limits as t1,t2,tinc, then optionally the limits as x1,x2,y1,y2"));
Modified: trunk/src/inter.c
==============================================================================
--- trunk/src/inter.c (original)
+++ trunk/src/inter.c Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2002 George Lebl
+ * Copyright (C) 1997-2009 George Lebl
*
* Author: George Lebl
*
@@ -35,8 +35,6 @@
#include "inter.h"
-extern int interrupted;
-
static int toplevelokg = TRUE;
static int
@@ -62,7 +60,7 @@
GString *gs;
char *prompt = "genius> ";
- interrupted = FALSE;
+ gel_interrupted = FALSE;
gs = g_string_new("");
@@ -76,7 +74,7 @@
s = readline(prompt);
toplevelokg = oldtop;
- if(interrupted) {
+ if(gel_interrupted) {
g_string_free(gs,TRUE);
if(s) free(s);
return NULL;
@@ -172,9 +170,9 @@
char *prompt = " > ";
toplevelokg = old_toplevelokg;
- if(interrupted) {
+ if(gel_interrupted) {
prompt = "\001\e[1m\002genius>\001\e[0m\002 ";
- interrupted = FALSE;
+ gel_interrupted = FALSE;
if(p_expr) g_string_free(p_expr,TRUE);
p_expr = NULL;
goto done_with_get;
@@ -187,7 +185,7 @@
g_string_free(p_expr, TRUE);
p_expr = NULL;
(*got_expr_func)(ret);
- interrupted = FALSE;
+ gel_interrupted = FALSE;
prompt = "\001\e[1m\002genius>\001\e[0m\002 ";
goto done_with_get;
}
@@ -205,7 +203,7 @@
g_string_free(p_expr,TRUE);
p_expr = NULL;
(*got_expr_func)(ret);
- interrupted = FALSE;
+ gel_interrupted = FALSE;
prompt = "\001\e[1m\002genius>\001\e[0m\002 ";
}
done_with_get:
@@ -221,7 +219,7 @@
void
start_cb_p_expression(void (*get_func)(GelETree *), FILE *torlfp)
{
- interrupted = FALSE;
+ gel_interrupted = FALSE;
gel_rewind_file_info();
Modified: trunk/src/lexer.l
==============================================================================
--- trunk/src/lexer.l (original)
+++ trunk/src/lexer.l Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2007 Jiri (George) Lebl
+ * Copyright (C) 1997-2009 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -34,11 +34,11 @@
#include "util.h"
#include "binreloc.h"
-int lex_fd[2];
-int first_tok = STARTTOK;
-int return_ret = FALSE;
-int parenth_depth = 0;
-int lex_init = TRUE;
+int gel_lex_fd[2];
+int gel_first_tok = STARTTOK;
+gboolean gel_return_ret = FALSE;
+int gel_parenth_depth = 0;
+gboolean gel_lex_init = TRUE;
extern GSList *gel_parsestack;
static int matrix_entry = 0;
static GSList *matrix_entry_stack = NULL;
@@ -50,12 +50,12 @@
int yylex(void);
#endif
-#define NO_RET {return_ret = FALSE;}
+#define NO_RET {gel_return_ret = FALSE;}
#define DO_RET { \
- if(!parenth_depth) \
- return_ret = TRUE; \
+ if(!gel_parenth_depth) \
+ gel_return_ret = TRUE; \
else \
- return_ret = FALSE; \
+ gel_return_ret = FALSE; \
}
static GHashTable *fp_hash = NULL;
@@ -115,17 +115,17 @@
%%
%{
- if(lex_init) {
- return_ret = FALSE;
- parenth_depth = 0;
+ if(gel_lex_init) {
+ gel_return_ret = FALSE;
+ gel_parenth_depth = 0;
matrix_entry = 0;
matrix_entry_stack = NULL;
- lex_init = FALSE;
+ gel_lex_init = FALSE;
}
- if(first_tok!=INT_MAX) {
- int i = first_tok;
- first_tok = INT_MAX;
+ if(gel_first_tok!=INT_MAX) {
+ int i = gel_first_tok;
+ gel_first_tok = INT_MAX;
return i;
}
%}
@@ -137,10 +137,10 @@
char *s;
char *end;
char *dir;
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
s=strchr(yytext,'<')+1; /*find the beginning*/
end=strrchr(yytext,'>'); /*find the end*/
- s = unescape_string(s,end,NULL);
+ s = gel_unescape_string(s,end,NULL);
dir = gbr_find_data_dir (DATADIR);
yylval.id = g_build_filename (dir,
"genius",
@@ -154,7 +154,7 @@
^[ ]*load[ ]+[^ ].*$ {
char *s;
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
s=strchr(yytext,'d')+1; /*move after the load*/
/*btw from the above RE we know this will work*/
while(*s==' ' || *s=='\t')
@@ -166,7 +166,7 @@
^[ ]*cd[ ]+[^ ].*$ {
char *s;
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
s=strchr(yytext,'d')+1; /*move after the cd*/
/*btw from the above RE we know this will work*/
while(*s==' ' || *s=='\t')
@@ -178,7 +178,7 @@
^[ ]*plugin[ ]+[^ ].*$ {
char *s;
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
s=strchr(yytext,'n')+1; /*move after the plugin*/
/*btw from the above RE we know this will work*/
while(*s==' ' || *s=='\t')
@@ -189,14 +189,14 @@
}
^[ ]*pwd[ ]*$ {
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
DO_RET;
return PWD;
}
^[ ]*ls[ ]+[^ ].*$ {
char *s;
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
s=strchr(yytext,'s')+1; /*move after the ls*/
/*btw from the above RE we know this will work*/
while(*s==' ' || *s=='\t')
@@ -207,14 +207,14 @@
}
^[ ]*ls[ ]*$ {
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
DO_RET;
return LS;
}
^[ ]*help[ ]+[^ ].*$ {
char *s;
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
s=strchr(yytext,'p')+1; /*move after the help*/
/*btw from the above RE we know this will work*/
while(*s==' ' || *s=='\t')
@@ -225,7 +225,7 @@
}
^[ ]*help[ ]*$ {
- if(gel_parsestack || parenth_depth) {REJECT;}
+ if(gel_parsestack || gel_parenth_depth) {REJECT;}
DO_RET;
return HELP;
}
@@ -242,7 +242,7 @@
\"([^"]|\\\")*\" {
DO_RET;
- yylval.id = unescape_string(&yytext[1],NULL,NULL);
+ yylval.id = gel_unescape_string(&yytext[1],NULL,NULL);
/*kill the trailing "*/
yylval.id[strlen(yylval.id)-1]='\0';
return STRING;
@@ -295,7 +295,7 @@
null { DO_RET; return '.'; }
"@(" {
- parenth_depth++;
+ gel_parenth_depth++;
if (matrix_entry_stack != NULL)
matrix_entry_stack->data =
GINT_TO_POINTER
@@ -310,7 +310,7 @@
[[][\t ]* {
matrix_entry++;
- parenth_depth++;
+ gel_parenth_depth++;
matrix_entry_stack =
g_slist_prepend (matrix_entry_stack,
GINT_TO_POINTER (0));
@@ -321,7 +321,7 @@
[\t ]*[]] {
GSList *li;
matrix_entry--;
- parenth_depth--;
+ gel_parenth_depth--;
li = matrix_entry_stack;
matrix_entry_stack = g_slist_remove_link (matrix_entry_stack, li);
g_slist_free_1 (li);
@@ -331,7 +331,7 @@
[({] {
- parenth_depth++;
+ gel_parenth_depth++;
if (matrix_entry_stack != NULL)
matrix_entry_stack->data =
GINT_TO_POINTER
@@ -341,7 +341,7 @@
}
[)][ \t]*i {
- parenth_depth--;
+ gel_parenth_depth--;
if (matrix_entry_stack != NULL)
matrix_entry_stack->data =
GINT_TO_POINTER
@@ -351,7 +351,7 @@
}
[)}] {
- parenth_depth--;
+ gel_parenth_depth--;
if (matrix_entry_stack != NULL)
matrix_entry_stack->data =
GINT_TO_POINTER
@@ -443,8 +443,8 @@
gel_incr_file_info();
if(matrix_entry) {
return NEXTROW;
- } else if(return_ret) {
- first_tok = 0;
+ } else if(gel_return_ret) {
+ gel_first_tok = 0;
return '\n';
}
}
Modified: trunk/src/matop.c
==============================================================================
--- trunk/src/matop.c (original)
+++ trunk/src/matop.c Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2008 Jiri (George) Lebl
+ * Copyright (C) 1997-2009 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -35,8 +35,6 @@
#include "matop.h"
-extern calcstate_t calcstate;
-
gboolean
gel_is_matrix_value_only (GelMatrixW *m)
{
@@ -221,11 +219,11 @@
mpw_conj (n->val.value, n->val.value);
} else {
GelETree *nn;
- GET_NEW_NODE (nn);
+ GEL_GET_NEW_NODE (nn);
nn->type = OPERATOR_NODE;
nn->op.oper = E_DIRECTCALL;
- GET_NEW_NODE (nn->op.args);
+ GEL_GET_NEW_NODE (nn->op.args);
nn->op.args->type = IDENTIFIER_NODE;
nn->op.args->id.id = d_intern ("conj");
@@ -268,8 +266,8 @@
mpw_add(accu,accu,tmp);
if (modulo != NULL) {
mpw_mod (accu, accu, modulo);
- if (error_num != 0) { /*FIXME: for now ignore errors in moding*/
- error_num = 0;
+ if G_UNLIKELY (gel_error_num != 0) { /*FIXME: for now ignore errors in moding*/
+ gel_error_num = 0;
}
if (mpw_sgn (accu) < 0)
mpw_add (accu, modulo, accu);
Modified: trunk/src/matrixw.c
==============================================================================
--- trunk/src/matrixw.c (original)
+++ trunk/src/matrixw.c Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2008 Jiri (George) Lebl
+ * Copyright (C) 1997-2009 Jiri (George) Lebl
*
* Author: George Lebl
*
@@ -299,7 +299,7 @@
#ifdef MATRIX_DEBUG
printf ("(%d,%d) = (%d,%d)\n", i, j,mi, mj);
#endif
- gel_matrix_index (m->m, i, j) = copynode (t);
+ gel_matrix_index (m->m, i, j) = gel_copynode (t);
}
}
@@ -338,7 +338,7 @@
int mi = m->regx ? m->regx[regx[i]] : regx[i];
int mj = m->regy ? m->regy[regy[j]] : regy[j];
GelETree *t = gel_matrix_index (old, mi, mj);
- gel_matrix_index (m->m, i, j) = copynode (t);
+ gel_matrix_index (m->m, i, j) = gel_copynode (t);
}
}
@@ -380,7 +380,7 @@
if (t != NULL &&
(t->type != VALUE_NODE ||
! mpw_exact_zero_p (t->val.value)))
- gel_matrix_index (m->m, i, j) = copynode (t);
+ gel_matrix_index (m->m, i, j) = gel_copynode (t);
}
}
@@ -717,7 +717,7 @@
for (i = 0; i < len; i++) {
GelETree *t = gel_matrixw_get_vindex (m, reg[i]);
if (t != NULL)
- t = copynode (t);
+ t = gel_copynode (t);
gel_matrix_index (vec, i, 0) = t;
}
@@ -780,7 +780,7 @@
sj >= src->regh) {
gel_matrix_index (m->m, destx[i], desty[j]) = NULL;
} else {
- gel_matrix_index (m->m, destx[i], desty[j]) = copynode
+ gel_matrix_index (m->m, destx[i], desty[j]) = gel_copynode
(gel_matrix_index (src->m,
src->regx ? src->regx[si] : si,
src->regy ? src->regy[sj] : sj));
@@ -831,7 +831,7 @@
for (i = 0; i < w; i++) {
for ( j = 0; j < h; j++) {
GelETree *t = gel_matrix_index (m->m, destx[i], desty[j]);
- gel_matrix_index (m->m, destx[i], desty[j]) = copynode (src);
+ gel_matrix_index (m->m, destx[i], desty[j]) = gel_copynode (src);
if (t != NULL)
gel_freetree (t);
}
@@ -891,7 +891,7 @@
for (i = 0; i < height; i++) {
GelETree *n;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_get_region (source, reg, &i, width, 1);
@@ -929,7 +929,7 @@
for (i = 0; i < width; i++) {
GelETree *n;
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = MATRIX_NODE;
n->mat.matrix = gel_matrixw_get_region (source, &i, reg, 1, height);
n->mat.quoted = 0;
@@ -965,7 +965,7 @@
for (i = 0; i < len; i++) {
GelETree *n = gel_matrixw_get_index (source, i, i);
if (n != NULL)
- n = copynode (n);
+ n = gel_copynode (n);
gel_matrix_index (mm, 0, i) = n;
}
@@ -1124,7 +1124,7 @@
} else {
GelETree *s = gel_matrixw_get_vindex (src, i);
if (s != NULL)
- s = copynode (s);
+ s = gel_copynode (s);
gel_matrix_index (m->m, x, y) = s;
}
@@ -1163,7 +1163,7 @@
} else {
GelETree *s = gel_matrixw_get_vindex (src, i);
if (s != NULL)
- s = copynode (s);
+ s = gel_copynode (s);
gel_matrix_index (m->m, x, y) = s;
}
@@ -1200,7 +1200,7 @@
int x = desti[i] / m->regw;
int y = desti[i] % m->regw;
GelETree *t = gel_matrix_index (m->m, x, y);
- gel_matrix_index (m->m, x, y) = copynode (src);
+ gel_matrix_index (m->m, x, y) = gel_copynode (src);
if (t != NULL)
gel_freetree (t);
}
@@ -1219,7 +1219,7 @@
int x = desti[i] % m->regw;
int y = desti[i] / m->regw;
GelETree *t = gel_matrix_index (m->m, x, y);
- gel_matrix_index (m->m, x, y) = copynode (src);
+ gel_matrix_index (m->m, x, y) = gel_copynode (src);
if (t != NULL)
gel_freetree (t);
}
Modified: trunk/src/mpwrap.c
==============================================================================
--- trunk/src/mpwrap.c (original)
+++ trunk/src/mpwrap.c Mon Mar 9 21:48:32 2009
@@ -494,7 +494,7 @@
mpz_set_si (rop, -1);
} else {
gel_errorout (_("Integer exponent too large to compute"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
mpz_set_ui (rop, 1);
}
}
@@ -1276,7 +1276,7 @@
MpwRealNum r = {{NULL}};
if G_UNLIKELY (mpwl_zero_p (op2)) {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -1345,7 +1345,7 @@
mpwl_div_ui(MpwRealNum *rop,MpwRealNum *op,unsigned long int i)
{
if G_UNLIKELY (i==0) {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -1385,7 +1385,7 @@
mpwl_ui_div(MpwRealNum *rop,unsigned long int i,MpwRealNum *op)
{
if G_UNLIKELY (mpwl_zero_p (op)) {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -1424,7 +1424,7 @@
mpwl_mod(MpwRealNum *rop,MpwRealNum *op1,MpwRealNum *op2)
{
if G_UNLIKELY (mpwl_zero_p (op2)) {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -1435,7 +1435,7 @@
mpwl_move (rop, &r);
} else {
gel_errorout (_("Can't do modulo of floats or rationals!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
}
@@ -1449,7 +1449,7 @@
mpwl_move (rop, &r);
} else {
gel_errorout (_("Can't do GCD of floats or rationals!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
}
@@ -1476,7 +1476,7 @@
return suc;
} else {
gel_errorout (_("Can't modulo invert non integers!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return FALSE;
}
@@ -1497,7 +1497,7 @@
mpwl_set_si (rop, ret);
} else {
gel_errorout (_("Can't get jacobi symbols of floats or rationals!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
}
@@ -1516,7 +1516,7 @@
mpwl_set_si (rop, ret);
} else {
gel_errorout (_("Can't get legendre symbols of floats or rationals!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
}
@@ -1535,7 +1535,7 @@
mpwl_set_si (rop, ret);
} else {
gel_errorout (_("Can't get jacobi symbol with Kronecker extension of floats or rationals!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
}
@@ -1544,18 +1544,18 @@
{
if G_UNLIKELY (op->type!=MPW_INTEGER) {
gel_errorout (_("Lucas must get an integer argument!"));
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
if G_UNLIKELY (mpz_cmp_ui(op->data.ival,G_MAXULONG)>0) {
gel_errorout (_("Number too large to compute lucas number!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
if G_UNLIKELY (mpz_sgn(op->data.ival)<0) {
gel_errorout (_("No such thing as negative lucas numbers!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
if (rop->type != MPW_INTEGER) {
@@ -1570,7 +1570,7 @@
{
if G_UNLIKELY (op->type!=MPW_INTEGER) {
gel_errorout (_("Cannot get next prime after non-integer!"));
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -1591,7 +1591,7 @@
} else {
gel_errorout (_("%s: can't work on non-integers!"),
"perfect_square");
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return FALSE;
}
}
@@ -1604,7 +1604,7 @@
} else {
gel_errorout (_("%s: can't work on non-integers!"),
"perfect_power");
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return FALSE;
}
}
@@ -1617,7 +1617,7 @@
} else {
gel_errorout (_("%s: can't work on non-integers!"),
"even_p");
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return FALSE;
}
}
@@ -1630,7 +1630,7 @@
} else {
gel_errorout (_("%s: can't work on non-integers!"),
"odd_p");
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return FALSE;
}
}
@@ -1671,18 +1671,18 @@
{
if G_UNLIKELY (op->type!=MPW_INTEGER) {
gel_errorout (_("Can't do factorials of rationals or floats!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
if G_UNLIKELY (mpz_cmp_ui(op->data.ival,G_MAXULONG)>0) {
gel_errorout (_("Number too large to compute factorial!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
if G_UNLIKELY (mpz_sgn(op->data.ival)<0) {
gel_errorout (_("Can't do factorials of negative numbers!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
mpwl_fac_ui(rop,mpz_get_ui(op->data.ival));
@@ -1711,18 +1711,18 @@
{
if G_UNLIKELY (op->type!=MPW_INTEGER) {
gel_errorout (_("Can't do factorials of rationals or floats!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
if G_UNLIKELY (mpz_cmp_ui(op->data.ival,G_MAXULONG)>0) {
gel_errorout (_("Number too large to compute factorial!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
if G_UNLIKELY (mpz_sgn(op->data.ival)<0) {
gel_errorout (_("Can't do factorials of negative numbers!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
mpwl_dblfac_ui(rop,mpz_get_ui(op->data.ival));
@@ -1733,7 +1733,7 @@
{
if G_UNLIKELY (op->type!=MPW_INTEGER) {
gel_errorout (_("Can't do binomials of rationals or floats!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
if(rop->type!=MPW_INTEGER) {
@@ -1758,7 +1758,7 @@
if G_UNLIKELY (op2->type!=MPW_RATIONAL) {
- error_num=INTERNAL_MPW_ERROR;
+ gel_error_num = GEL_INTERNAL_MPW_ERROR;
return FALSE;
}
@@ -1911,7 +1911,7 @@
{
gboolean reverse = FALSE;;
if G_UNLIKELY (op2->type!=MPW_INTEGER) {
- error_num=INTERNAL_MPW_ERROR;
+ gel_error_num = GEL_INTERNAL_MPW_ERROR;
return;
}
@@ -1983,7 +1983,7 @@
MpwRealNum r = {{NULL}};
if G_UNLIKELY (op2->type!=MPW_FLOAT) {
- error_num=INTERNAL_MPW_ERROR;
+ gel_error_num = GEL_INTERNAL_MPW_ERROR;
return FALSE;
}
if(mpwl_sgn(op1)<=0)
@@ -2041,7 +2041,7 @@
(mod->type != MPW_INTEGER)) {
gel_errorout (_("%s: Bad types for mod power"),
"powm");
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -2081,7 +2081,7 @@
n1, n2, "powm");
g_free (n1);
g_free (n2);
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
mpwl_clear (&r);
return;
}
@@ -2109,7 +2109,7 @@
(mod->type != MPW_INTEGER)) {
gel_errorout (_("%s: Bad types for mod power"),
"powm");
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -2398,12 +2398,12 @@
if G_UNLIKELY (op->type != MPW_INTEGER) {
gel_errorout (_("Can't make random integer from a non-integer"));
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
if G_UNLIKELY (mpwl_sgn (op) <= 0) {
gel_errorout (_("Range for random integer must be positive"));
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -2588,7 +2588,7 @@
mpwl_set(rop, op);
} else if G_UNLIKELY (op->type == MPW_FLOAT) {
gel_errorout (_("Can't get numerator of floating types"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
} else { /* must be rational */
if(rop != op) {
if G_UNLIKELY (rop->type != MPW_INTEGER) {
@@ -2616,7 +2616,7 @@
mpwl_set_si(rop, 1);
} else if G_UNLIKELY (op->type == MPW_FLOAT) {
gel_errorout (_("Can't get numerator of floating types"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
} else { /* must be rational */
if(rop != op) {
if G_UNLIKELY (rop->type != MPW_INTEGER) {
@@ -2805,12 +2805,12 @@
if(p[0]=='-') {
if (len > 2) {
- shiftstr(p+2,1);
+ gel_shiftstr(p+2,1);
p[2]='.';
}
} else {
if (len > 1) {
- shiftstr(p+1,1);
+ gel_shiftstr(p+1,1);
p[1]='.';
}
}
@@ -2834,10 +2834,10 @@
} else if(e<len) {
p = g_realloc (p, strlen(p) + 2);
if(p[0]=='-') {
- shiftstr(p+1+e,1);
+ gel_shiftstr(p+1+e,1);
p[e+1]='.';
} else {
- shiftstr(p+e,1);
+ gel_shiftstr(p+e,1);
p[e]='.';
}
}
@@ -2849,13 +2849,13 @@
} else {
p = g_realloc (p, strlen(p)+2+(-e)+2);
if(p[0]=='-') {
- shiftstr(p+1,2+(-e));
+ gel_shiftstr(p+1,2+(-e));
p[1]='0';
p[2]='.';
for(i=0;i<(-e);i++)
p[i+3]='0';
} else {
- shiftstr(p,2+(-e));
+ gel_shiftstr(p,2+(-e));
p[0]='0';
p[1]='.';
for(i=0;i<(-e);i++)
@@ -2902,7 +2902,7 @@
return p2;
}
}
- p=appendstr(p,postfix);
+ p=gel_appendstr(p,postfix);
return p;
}
@@ -2920,36 +2920,36 @@
int l;
p=mpz_get_str(NULL,10,num);
digits = strlen(p);
- p=prependstr(p,"\\frac{");
- p=appendstr(p,"}{");
+ p=gel_prependstr(p,"\\frac{");
+ p=gel_appendstr(p,"}{");
p2=mpz_get_str(NULL,10,den);
- p=appendstr(p,p2);
+ p=gel_appendstr(p,p2);
l = strlen (p2);
if (l > digits)
digits = l;
g_free(p2);
- p=appendstr(p,"}");
- p=appendstr(p,postfix);
+ p=gel_appendstr(p,"}");
+ p=gel_appendstr(p,postfix);
} else if (style == GEL_OUTPUT_TROFF) {
int l;
p=mpz_get_str(NULL,10,num);
digits = strlen(p);
- p=prependstr(p,"{");
- p=appendstr(p,"} over {");
+ p=gel_prependstr(p,"{");
+ p=gel_appendstr(p,"} over {");
p2=mpz_get_str(NULL,10,den);
- p=appendstr(p,p2);
+ p=gel_appendstr(p,p2);
l = strlen (p2);
if (l > digits)
digits = l;
g_free(p2);
- p=appendstr(p,"}");
- p=appendstr(p,postfix);
+ p=gel_appendstr(p,"}");
+ p=gel_appendstr(p,postfix);
} else {
p=mpz_get_str(NULL,10,num);
- p=appendstr(p,postfix);
- p=appendstr(p,"/");
+ p=gel_appendstr(p,postfix);
+ p=gel_appendstr(p,"/");
p2=mpz_get_str(NULL,10,den);
- p=appendstr(p,p2);
+ p=gel_appendstr(p,p2);
g_free(p2);
digits = strlen(p) - 1; /* don't count the / */
digits -= strlen (postfix); /* don't count the i */
@@ -3002,29 +3002,29 @@
if (postfix != NULL &&
*postfix != '\0') {
if (style == GEL_OUTPUT_LATEX)
- p = prependstr (p, "\\left(");
+ p = gel_prependstr (p, "\\left(");
else if (style == GEL_OUTPUT_TROFF)
- p = prependstr (p, " left ( ");
+ p = gel_prependstr (p, " left ( ");
else
- p = prependstr (p, "(");
+ p = gel_prependstr (p, "(");
}
- p=appendstr(p," ");
+ p=gel_appendstr(p," ");
p2 = get_frac (tmp2, mpq_denref (num),
style, "", &d);
- p=appendstr(p,p2);
+ p=gel_appendstr(p,p2);
g_free(p2);
if (postfix != NULL &&
*postfix != '\0') {
if (style == GEL_OUTPUT_LATEX)
- p = appendstr (p, "\\right)");
+ p = gel_appendstr (p, "\\right)");
else if (style == GEL_OUTPUT_TROFF)
- p = appendstr (p, " right )~");
+ p = gel_appendstr (p, " right )~");
else
- p = appendstr (p, ")");
- p = appendstr (p, postfix);
+ p = gel_appendstr (p, ")");
+ p = gel_appendstr (p, postfix);
}
CLEAR_FREE_MPZ (tmp1);
@@ -3080,7 +3080,7 @@
mpfr_free_str (mp);
}
p = str_format_float (p, e, max_digits, scientific_notation);
- p = appendstr (p, postfix);
+ p = gel_appendstr (p, postfix);
return p;
}
@@ -3412,7 +3412,7 @@
return mpwl_sgn(op->r);
} else {
gel_errorout (_("Can't compare complex numbers"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
return 0;
}
@@ -3715,7 +3715,7 @@
if (MPW_IS_REAL (op1) && MPW_IS_REAL (op2)) {
if G_UNLIKELY (mpwl_zero_p (op2->r)) {
gel_errorout (_("Division by zero!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
MAKE_REAL(rop);
@@ -3734,7 +3734,7 @@
MpwRealNum *i2;
if G_UNLIKELY (mpwl_zero_p (op2->r) && mpwl_zero_p (op2->i)) {
gel_errorout (_("Division by zero!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -3791,7 +3791,7 @@
{
if G_UNLIKELY (i==0) {
gel_errorout (_("Division by zero!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
if (rop != op) {
@@ -3820,7 +3820,7 @@
if (MPW_IS_REAL (op)) {
if G_UNLIKELY (mpwl_zero_p (op->r)) {
gel_errorout (_("Division by zero!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
MAKE_REAL(rop);
@@ -3837,7 +3837,7 @@
MpwRealNum *i;
if G_UNLIKELY (mpwl_zero_p (op->r) && mpwl_zero_p (op->i)) {
gel_errorout (_("Division by zero!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -3886,7 +3886,7 @@
if G_LIKELY (MPW_IS_REAL (op1) && MPW_IS_REAL (op2)) {
if G_UNLIKELY (mpwl_zero_p (op2->r)) {
gel_errorout (_("Division by zero!"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
MAKE_REAL(rop);
@@ -3897,7 +3897,7 @@
}
mpwl_mod(rop->r,op1->r,op2->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't modulo complex numbers"));
}
}
@@ -3920,7 +3920,7 @@
types */
n1 = mpwl_getstring_for_error (op1->r);
n2 = mpwl_getstring_for_error (mod->r);
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Inverse of %s modulo "
"%s not found!"),
n1, n2);
@@ -3929,7 +3929,7 @@
}
}
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't do modulo invert on complex numbers"));
}
}
@@ -3946,7 +3946,7 @@
}
mpwl_gcd(rop->r,op1->r,op2->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't GCD complex numbers"));
}
}
@@ -3958,7 +3958,7 @@
mpwl_init_type (&gcd, MPW_INTEGER);
mpwl_gcd (&gcd, op1->r, op2->r);
- if G_UNLIKELY (error_num == NUMERICAL_MPW_ERROR) {
+ if G_UNLIKELY (gel_error_num == GEL_NUMERICAL_MPW_ERROR) {
mpwl_clear (&gcd);
return;
}
@@ -3975,7 +3975,7 @@
if (mpwl_sgn (rop->r) < 0)
mpwl_neg (rop->r, rop->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't LCM complex numbers"));
}
}
@@ -3992,7 +3992,7 @@
}
mpwl_jacobi(rop->r,op1->r,op2->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't get jacobi symbols of complex numbers"));
}
}
@@ -4008,7 +4008,7 @@
}
mpwl_legendre(rop->r,op1->r,op2->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't get legendre symbols complex numbers"));
}
}
@@ -4024,7 +4024,7 @@
}
mpwl_kronecker(rop->r,op1->r,op2->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't get jacobi symbol with Kronecker extension for complex numbers"));
}
}
@@ -4040,7 +4040,7 @@
}
mpwl_lucnum (rop->r, op->r);
} else {
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't get lucas number for complex numbers"));
}
}
@@ -4056,7 +4056,7 @@
}
mpwl_nextprime (rop->r, op->r);
} else {
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("Can't get next prime for complex numbers"));
}
}
@@ -4066,7 +4066,7 @@
if G_LIKELY (MPW_IS_REAL (op)) {
return mpwl_perfect_square(op->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("%s: can't work on complex numbers"),
"perfect_square");
return FALSE;
@@ -4078,7 +4078,7 @@
if G_LIKELY (MPW_IS_REAL (op)) {
return mpwl_perfect_power(op->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("%s: can't work on complex numbers"),
"perfect_power");
return FALSE;
@@ -4090,7 +4090,7 @@
if G_LIKELY (MPW_IS_REAL (op)) {
return mpwl_even_p(op->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("%s: can't work on complex numbers"),
"even_p");
return FALSE;
@@ -4102,7 +4102,7 @@
if G_LIKELY (MPW_IS_REAL (op)) {
return mpwl_odd_p(op->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("%s: can't work on complex numbers"),
"odd_p");
return FALSE;
@@ -4224,7 +4224,7 @@
MPW_IS_COMPLEX (mod)) {
gel_errorout (_("%s: Bad types for mod power"),
"powm");
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -4245,7 +4245,7 @@
MPW_IS_COMPLEX (mod)) {
gel_errorout (_("%s: Bad types for mod power"),
"powm");
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -4334,7 +4334,7 @@
if G_UNLIKELY (mpwl_zero_p (op->r)) {
gel_errorout (_("%s: can't take logarithm of 0"),
"ln");
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -4412,7 +4412,7 @@
if G_UNLIKELY (mpwl_zero_p (op->r)) {
gel_errorout (_("%s: can't take logarithm of 0"),
"log2");
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -4477,7 +4477,7 @@
if G_UNLIKELY (mpwl_zero_p (op->r)) {
gel_errorout (_("%s: can't take logarithm of 0"),
"log10");
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return;
}
@@ -4746,7 +4746,7 @@
mpwl_neg(ai->r,ai->r);
- error_num = 0;
+ gel_error_num = 0;
mpw_init(tmp1);
mpw_set_ui(tmp1,1);
@@ -4760,14 +4760,14 @@
mpw_div(tmp1,tmp1,tmp2);
mpw_clear(tmp2);
- if G_UNLIKELY (error_num) {
+ if G_UNLIKELY (gel_error_num) {
mpw_clear(tmp1);
return;
}
mpw_ln(tmp1,tmp1);
- if G_UNLIKELY (error_num) {
+ if G_UNLIKELY (gel_error_num) {
mpw_clear(tmp1);
return;
}
@@ -4803,7 +4803,7 @@
}
mpwl_arctan2(rop->r,op1->r,op2->r);
} else {
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
gel_errorout (_("arctan2 not defined for complex numbers"));
}
}
@@ -4853,7 +4853,7 @@
{
if G_UNLIKELY (MPW_IS_COMPLEX (op)) {
gel_errorout (_("Can't make random integer out of a complex number"));
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
MAKE_REAL (rop);
@@ -4936,7 +4936,7 @@
}
} else {
gel_errorout (_("Can't compare complex numbers"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
}
}
@@ -4958,7 +4958,7 @@
}
} else {
gel_errorout (_("Can't compare complex numbers"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
}
}
@@ -5015,7 +5015,7 @@
mpwl_fac(rop->r,op->r);
} else {
gel_errorout (_("Can't make factorials of complex numbers"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
}
@@ -5032,7 +5032,7 @@
mpwl_dblfac (rop->r, op->r);
} else {
gel_errorout (_("Can't make factorials of complex numbers"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
}
@@ -5049,7 +5049,7 @@
mpwl_bin_ui(rop->r,op->r,r);
} else {
gel_errorout (_("Can't make binomials of complex numbers"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
}
}
@@ -5428,7 +5428,7 @@
{
if G_UNLIKELY (MPW_IS_COMPLEX (op)) {
gel_errorout (_("Can't determine type of a complex number"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return FALSE;
}
return op->r->type == MPW_INTEGER;
@@ -5439,7 +5439,7 @@
{
if G_UNLIKELY (MPW_IS_COMPLEX (op)) {
gel_errorout (_("Can't determine type of a complex number"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return FALSE;
}
return op->r->type == MPW_RATIONAL;
@@ -5450,7 +5450,7 @@
{
if G_UNLIKELY (MPW_IS_COMPLEX (op)) {
gel_errorout (_("Can't determine type of a complex number"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return FALSE;
}
return op->r->type == MPW_FLOAT;
@@ -5542,17 +5542,17 @@
int ex = MPWL_EXCEPTION_NO_EXCEPTION;
if G_UNLIKELY (MPW_IS_COMPLEX (op)) {
gel_errorout (_("Can't convert complex number into integer"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
}
r = mpwl_get_long(op->r,&ex);
if G_UNLIKELY (ex == MPWL_EXCEPTION_CONVERSION_ERROR) {
gel_errorout (_("Can't convert real number to integer"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
} else if G_UNLIKELY (ex == MPWL_EXCEPTION_NUMBER_TOO_LARGE) {
gel_errorout (_("Integer too large for this operation"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
}
return r;
@@ -5565,17 +5565,17 @@
int ex = MPWL_EXCEPTION_NO_EXCEPTION;
if G_UNLIKELY (MPW_IS_COMPLEX (op)) {
gel_errorout (_("Can't convert complex number into integer"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
}
r = mpwl_get_ulong(op->r,&ex);
if G_UNLIKELY (ex == MPWL_EXCEPTION_CONVERSION_ERROR) {
gel_errorout (_("Can't convert real number to integer"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
} else if G_UNLIKELY (ex == MPWL_EXCEPTION_NUMBER_TOO_LARGE) {
gel_errorout (_("Integer too large for this operation"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
}
return r;
@@ -5588,7 +5588,7 @@
int ex = MPWL_EXCEPTION_NO_EXCEPTION;
if G_UNLIKELY (MPW_IS_COMPLEX (op)) {
gel_errorout (_("Can't convert complex number into a double"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
}
r = mpwl_get_double (op->r, &ex);
@@ -5597,13 +5597,13 @@
#if 0
if G_UNLIKELY (ex == MPWL_EXCEPTION_CONVERSION_ERROR) {
gel_errorout (_("Can't convert real number to double"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
} else
#endif
if G_UNLIKELY (ex == MPWL_EXCEPTION_NUMBER_TOO_LARGE) {
gel_errorout (_("Number too large for this operation"));
- error_num=NUMERICAL_MPW_ERROR;
+ gel_error_num=GEL_NUMERICAL_MPW_ERROR;
return 0;
}
return r;
@@ -5620,7 +5620,7 @@
gel_errorout (_("Number too large for this operation"));
*r = 0.0;
*i = 0.0;
- error_num = NUMERICAL_MPW_ERROR;
+ gel_error_num = GEL_NUMERICAL_MPW_ERROR;
return;
}
}
@@ -5638,7 +5638,7 @@
mpwl_denominator (&r1, op->r);
mpwl_denominator (&r2, op->i);
- if G_UNLIKELY (error_num != NO_ERROR) {
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
mpwl_clear (&r1);
mpwl_clear (&r2);
return;
@@ -5687,7 +5687,7 @@
mpwl_numerator (&n1, op->r);
mpwl_numerator (&n2, op->i);
- if G_UNLIKELY (error_num != NO_ERROR) {
+ if G_UNLIKELY (gel_error_num != GEL_NO_ERROR) {
mpwl_clear (&r1);
mpwl_clear (&r2);
mpwl_clear (&n1);
Modified: trunk/src/mpzextra.c
==============================================================================
--- trunk/src/mpzextra.c (original)
+++ trunk/src/mpzextra.c Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2008 Jiri (George) Lebl
+ * Copyright (C) 1997-2009 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -24,12 +24,10 @@
#include <string.h>
#include <glib.h>
-#include "calc.h" /* for evalnode_hook and i18n stuff */
+#include "calc.h" /* for gel_evalnode_hook and i18n stuff */
#include "mpzextra.h"
-extern gboolean interrupted;
-
/* The strong pseudoprime test code copied from GMP */
static int
@@ -162,10 +160,10 @@
break;
}
mpz_add_ui (b, b, 1L);
- if (evalnode_hook != NULL) {
- (*evalnode_hook)();
+ if (gel_evalnode_hook != NULL) {
+ (*gel_evalnode_hook)();
}
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
is_prime = 0;
break;
}
@@ -241,9 +239,9 @@
if (mpz_cmp (n, test) <= 0)
return 1;
- if (evalnode_hook != NULL)
- (*evalnode_hook)();
- if G_UNLIKELY (interrupted)
+ if (gel_evalnode_hook != NULL)
+ (*gel_evalnode_hook)();
+ if G_UNLIKELY (gel_interrupted)
return 0;
return mpz_millerrabin (n, miller_rabin_reps-1);
@@ -380,14 +378,14 @@
while (mpz_cmp_ui (n, 1) != 0)
{
S2:
- if (evalnode_hook != NULL) {
+ if (gel_evalnode_hook != NULL) {
static int i = 0;
- if G_UNLIKELY ((i++ & RUN_HOOK_EVERY_MASK) == RUN_HOOK_EVERY_MASK) {
- (*evalnode_hook)();
+ if G_UNLIKELY ((i++ & GEL_RUN_HOOK_EVERY_MASK) == GEL_RUN_HOOK_EVERY_MASK) {
+ (*gel_evalnode_hook)();
i = 0;
}
}
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
mpz_set_ui (n, 1);
continue;
}
@@ -523,7 +521,7 @@
mpz_clear (n);
- if G_UNLIKELY (interrupted) {
+ if G_UNLIKELY (gel_interrupted) {
mympz_factorization_free (fact);
return NULL;
}
Modified: trunk/src/parse.y
==============================================================================
--- trunk/src/parse.y (original)
+++ trunk/src/parse.y Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2004 Jiri (George) Lebl
+ * Copyright (C) 1997-2009 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -36,14 +36,7 @@
extern GSList *gel_parsestack;
-extern int return_ret; /*should the lexer return on \n*/
-extern char *loadfile;
-extern char *loadfile_glob;
-extern char *changedir;
-extern char *changedir_glob;
-extern gboolean pwd_command;
-extern gboolean ls_command;
-extern char *load_plugin;
+extern gboolean gel_return_ret; /*should the lexer return on \n*/
/* prototype for yylex */
int yylex(void);
@@ -132,8 +125,8 @@
| STARTTOK LOAD_PLUGIN '\n' { gel_command = GEL_LOADPLUGIN; gel_command_arg = $<id>2; YYACCEPT; }
| STARTTOK '\n' { YYACCEPT; }
| STARTTOK expr SEPAR '\n' { gp_push_null(); PUSH_ACT(E_SEPAR); YYACCEPT; }
- | error '\n' { return_ret = TRUE; yyclearin; YYABORT; }
- | error { return_ret = TRUE; }
+ | error '\n' { gel_return_ret = TRUE; yyclearin; YYABORT; }
+ | error { gel_return_ret = TRUE; }
;
expr: expr SEPAR expr { PUSH_ACT(E_SEPAR); }
@@ -145,8 +138,8 @@
mpw_init (i);
mpw_i (i);
gp_push_spacer();
- stack_push(&gel_parsestack,
- gel_makenum_use(i));
+ gel_stack_push(&gel_parsestack,
+ gel_makenum_use(i));
PUSH_ACT(E_MUL); }
| expr EQUALS expr { PUSH_ACT(E_EQUALS); }
| expr DEFEQUALS expr { PUSH_ACT(E_DEFEQUALS); }
@@ -258,8 +251,8 @@
| EXCEPTION { PUSH_ACT(E_EXCEPTION); }
| CONTINUE { PUSH_ACT(E_CONTINUE); }
| BREAK { PUSH_ACT(E_BREAK); }
- | NUMBER { stack_push(&gel_parsestack,
- gel_makenum_use($<val>1)); }
+ | NUMBER { gel_stack_push(&gel_parsestack,
+ gel_makenum_use($<val>1)); }
| STRING { PUSH_CONST_STRING($<id>1); }
| '.' { gp_push_null(); }
;
Modified: trunk/src/parseutil.c
==============================================================================
--- trunk/src/parseutil.c (original)
+++ trunk/src/parseutil.c Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2004 Jiri (George) Lebl
+ * Copyright (C) 1997-2009 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -45,13 +45,13 @@
GSList * list = NULL;
int i = 0;
- val = stack_pop(&gel_parsestack);
+ val = gel_stack_pop(&gel_parsestack);
if(!val)
return FALSE;
for(;;) {
- tree = stack_pop(&gel_parsestack);
+ tree = gel_stack_pop(&gel_parsestack);
if(tree && tree->type==EXPRLIST_START_NODE) {
gel_freetree(tree);
break;
@@ -69,14 +69,14 @@
i++;
}
- GET_NEW_NODE(tree);
+ GEL_GET_NEW_NODE(tree);
tree->type = FUNCTION_NODE;
tree->func.func = d_makeufunc(NULL,val,list,i, NULL);
tree->func.func->context = -1;
tree->func.func->vararg = vararg;
- stack_push(&gel_parsestack,tree);
+ gel_stack_push(&gel_parsestack,tree);
return TRUE;
}
@@ -91,19 +91,19 @@
/* FIXME: setfunc not yet implemented */
g_assert ( ! setfunc);
- val = stack_pop (&gel_parsestack);
+ val = gel_stack_pop (&gel_parsestack);
if (val == NULL)
return FALSE;
- ident = stack_pop (&gel_parsestack);
+ ident = gel_stack_pop (&gel_parsestack);
if (ident == NULL)
return FALSE;
func = gel_makenum_null ();
- stack_push (&gel_parsestack, func);
- stack_push (&gel_parsestack, ident);
- stack_push (&gel_parsestack, val);
+ gel_stack_push (&gel_parsestack, func);
+ gel_stack_push (&gel_parsestack, ident);
+ gel_stack_push (&gel_parsestack, val);
return TRUE;
}
@@ -114,8 +114,8 @@
{
GelETree *e1, *e2;
- e2 = stack_pop (&gel_parsestack);
- e1 = stack_pop (&gel_parsestack);
+ e2 = gel_stack_pop (&gel_parsestack);
+ e1 = gel_stack_pop (&gel_parsestack);
if (e2->type == OPERATOR_NODE &&
e2->op.oper == E_REGION_SEP) {
@@ -125,14 +125,14 @@
a2->any.next = NULL;
e2->op.args = NULL;
gel_freetree (e2);
- stack_push (&gel_parsestack, e1);
- stack_push (&gel_parsestack, a1);
- stack_push (&gel_parsestack, a2);
+ gel_stack_push (&gel_parsestack, e1);
+ gel_stack_push (&gel_parsestack, a1);
+ gel_stack_push (&gel_parsestack, a2);
return TRUE;
} else {
- stack_push (&gel_parsestack, e1);
- stack_push (&gel_parsestack, e2);
+ gel_stack_push (&gel_parsestack, e1);
+ gel_stack_push (&gel_parsestack, e2);
return FALSE;
}
@@ -143,16 +143,16 @@
gboolean
gp_push_marker(GelETreeType markertype)
{
- GelETree * last_expr = stack_pop(&gel_parsestack);
+ GelETree * last_expr = gel_stack_pop(&gel_parsestack);
GelETree * tree;
if(!last_expr)
return FALSE;
- GET_NEW_NODE(tree);
+ GEL_GET_NEW_NODE(tree);
tree->type = markertype;
- stack_push(&gel_parsestack,tree);
- stack_push(&gel_parsestack,last_expr);
+ gel_stack_push(&gel_parsestack,tree);
+ gel_stack_push(&gel_parsestack,last_expr);
return TRUE;
}
@@ -161,9 +161,9 @@
gp_push_marker_simple(GelETreeType markertype)
{
GelETree *tree;
- GET_NEW_NODE(tree);
+ GEL_GET_NEW_NODE(tree);
tree->type = markertype;
- stack_push(&gel_parsestack,tree);
+ gel_stack_push(&gel_parsestack,tree);
}
/*puts a spacer into the tree, spacers are just useless nodes to be removed
@@ -171,18 +171,18 @@
gboolean
gp_push_spacer(void)
{
- GelETree * last_expr = stack_pop(&gel_parsestack);
+ GelETree * last_expr = gel_stack_pop(&gel_parsestack);
if(!last_expr)
return FALSE;
else if(last_expr->type == SPACER_NODE)
- stack_push(&gel_parsestack,last_expr);
+ gel_stack_push(&gel_parsestack,last_expr);
else {
GelETree * tree;
- GET_NEW_NODE(tree);
+ GEL_GET_NEW_NODE(tree);
tree->type = SPACER_NODE;
tree->sp.arg = last_expr;
- stack_push(&gel_parsestack,tree);
+ gel_stack_push(&gel_parsestack,tree);
}
return TRUE;
}
@@ -196,7 +196,7 @@
GelETree *row = NULL;
int i=0;
for(;;) {
- tree = stack_pop(&gel_parsestack);
+ tree = gel_stack_pop(&gel_parsestack);
/*we have gone all the way to the top and haven't found a
marker*/
if(!tree) {
@@ -215,12 +215,12 @@
row = tree;
i++;
}
- GET_NEW_NODE(tree);
+ GEL_GET_NEW_NODE(tree);
tree->type = MATRIX_ROW_NODE;
tree->row.args = row;
tree->row.nargs = i;
- stack_push(&gel_parsestack,tree);
+ gel_stack_push(&gel_parsestack,tree);
return TRUE;
}
@@ -242,7 +242,7 @@
rows=0;
cols=0;
for(;;) {
- tree = stack_pop(&gel_parsestack);
+ tree = gel_stack_pop(&gel_parsestack);
/*we have gone all the way to the top and haven't found a
marker*/
if(!tree) {
@@ -305,12 +305,12 @@
}
g_slist_free(rowl);
- GET_NEW_NODE(tree);
+ GEL_GET_NEW_NODE(tree);
tree->type = MATRIX_NODE;
tree->mat.matrix = gel_matrixw_new_with_matrix(matrix);
tree->mat.quoted = quoted ? 1 : 0;
- stack_push(&gel_parsestack,tree);
+ gel_stack_push(&gel_parsestack,tree);
return TRUE;
}
@@ -320,10 +320,10 @@
gp_push_null(void)
{
GelETree *tree;
- GET_NEW_NODE(tree);
+ GEL_GET_NEW_NODE(tree);
tree->type = NULL_NODE;
- stack_push(&gel_parsestack,tree);
+ gel_stack_push(&gel_parsestack,tree);
}
void
@@ -331,7 +331,7 @@
{
GelETree *val;
- val = stack_peek (&gel_parsestack);
+ val = gel_stack_peek (&gel_parsestack);
if (val == NULL ||
val->type != IDENTIFIER_NODE) {
/**/g_warning ("NO IDENTIFIER TO CONVERT TO TRY TO CONVERT BOOL");
Modified: trunk/src/parseutil.h
==============================================================================
--- trunk/src/parseutil.h (original)
+++ trunk/src/parseutil.h Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2004 Jiri (George) Lebl
+ * Copyright (C) 1997-2009 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -55,24 +55,24 @@
#define SYNTAX_ERROR {yyerror("syntax error"); YYERROR;}
#define PUSH_ACT(ACT) { \
- GelETree *tree = makeoperator((ACT),&gel_parsestack); \
+ GelETree *tree = gel_makeoperator((ACT),&gel_parsestack); \
if(!tree) {SYNTAX_ERROR;} \
- stack_push(&gel_parsestack,tree); \
+ gel_stack_push(&gel_parsestack,tree); \
}
#define PUSH_IDENTIFIER(ID) { \
GelETree * tree; \
- GET_NEW_NODE(tree); \
+ GEL_GET_NEW_NODE(tree); \
tree->type = IDENTIFIER_NODE; \
tree->id.id = d_intern(ID); \
- stack_push(&gel_parsestack,tree); \
+ gel_stack_push(&gel_parsestack,tree); \
g_free (ID); \
}
#define PUSH_CONST_STRING(ID) { \
GelETree * tree; \
tree = gel_makenum_string_constant (ID); \
- stack_push(&gel_parsestack,tree); \
+ gel_stack_push(&gel_parsestack,tree); \
g_free (ID); \
}
Modified: trunk/src/structs.h
==============================================================================
--- trunk/src/structs.h (original)
+++ trunk/src/structs.h Mon Mar 9 21:48:32 2009
@@ -429,4 +429,6 @@
int force_chop;
};
+typedef void (*GelHookFunc) (void);
+
#endif /* STRUCTS_H */
Modified: trunk/src/symbolic.c
==============================================================================
--- trunk/src/symbolic.c (original)
+++ trunk/src/symbolic.c Mon Mar 9 21:48:32 2009
@@ -40,8 +40,6 @@
#include "funclibhelper.cP"
-extern calcstate_t calcstate;
-
static GelETree * differentiate_expr (GelETree *expr, GelToken *xtok);
static GelETree * gel_differentiate_func1_expr (GelToken *tok);
@@ -258,7 +256,7 @@
expr->id.id != xtok)) {
return TRUE;
}
- if (eval_find_identifier (expr, xtok, FALSE /* funcbody */))
+ if (gel_eval_find_identifier (expr, xtok, FALSE /* funcbody */))
return FALSE;
else
return TRUE;
@@ -325,7 +323,7 @@
if (mpw_zero_p (val)) {
n = gel_makenum_ui (1);
} else if (mpw_eql_ui (val, 1)) {
- n = copynode (PARSE ("2*x"));
+ n = gel_copynode (PARSE ("2*x"));
} else {
n = PARSE ("y*x^ymo");
ymo = gel_makenum (val);
@@ -412,7 +410,7 @@
/* FIXME: */
return NULL;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = expr->op.oper;
n->op.args = nn;
@@ -428,10 +426,10 @@
/* FIXME: */
return NULL;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = expr->op.oper;
- n->op.args = copynode (expr->op.args);
+ n->op.args = gel_copynode (expr->op.args);
n->op.args->any.next = nnn;
n->op.args->any.next->any.next = NULL;
n->op.nargs = 2;
@@ -442,11 +440,11 @@
/* FIXME: */
return NULL;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = expr->op.oper;
n->op.args = nn;
- n->op.args->any.next = copynode (expr->op.args->any.next);
+ n->op.args->any.next = gel_copynode (expr->op.args->any.next);
n->op.args->any.next->any.next = NULL;
n->op.nargs = 2;
return n;
@@ -477,11 +475,11 @@
/* FIXME: */
return NULL;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = expr->op.oper;
n->op.args = nn;
- n->op.args->any.next = copynode (expr->op.args->any.next);
+ n->op.args->any.next = gel_copynode (expr->op.args->any.next);
n->op.args->any.next->any.next = NULL;
n->op.nargs = 2;
return n;
@@ -520,7 +518,7 @@
/* FIXME: */
return NULL;
}
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = OPERATOR_NODE;
n->op.oper = expr->op.oper;
n->op.args = nn;
@@ -580,7 +578,7 @@
return gel_makenum_ui (0);
}
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = OPERATOR_NODE;
n->op.oper = E_MUL;
n->op.args = nn;
@@ -602,12 +600,12 @@
static GelETree *
differentiate_expr (GelETree *expr, GelToken *xtok)
{
- if (evalnode_hook != NULL) {
+ if (gel_evalnode_hook != NULL) {
static int i = 0;
- if G_UNLIKELY ((i++ & RUN_HOOK_EVERY_MASK) == RUN_HOOK_EVERY_MASK) {
- (*evalnode_hook)();
+ if G_UNLIKELY ((i++ & GEL_RUN_HOOK_EVERY_MASK) == GEL_RUN_HOOK_EVERY_MASK) {
+ (*gel_evalnode_hook)();
i = 0;
- if G_UNLIKELY (interrupted)
+ if G_UNLIKELY (gel_interrupted)
return NULL;
}
}
@@ -695,7 +693,7 @@
if (rf == NULL &&
gel_derivative_silent <= 0 &&
- ! interrupted) {
+ ! gel_interrupted) {
gel_errorout (_("%s: Cannot differentiate the '%s' function"),
"SymbolicDerivative",
f->id ? f->id->token : "anonymous");
@@ -728,7 +726,7 @@
rf = gel_differentiate_func (f);
if (rf != NULL) {
- GET_NEW_NODE (n);
+ GEL_GET_NEW_NODE (n);
n->type = FUNCTION_NODE;
n->func.func = rf;
return n;
@@ -781,7 +779,7 @@
{
GelEFunc *f;
- new_category ("symbolic", N_("Symbolic Operations"), TRUE /* internal */);
+ gel_new_category ("symbolic", N_("Symbolic Operations"), TRUE /* internal */);
FUNC (SymbolicDerivative, 1, "f", "symbolic",
N_("Attempt to symbolically differentiate the function f, "
Modified: trunk/src/testplugin.c
==============================================================================
--- trunk/src/testplugin.c (original)
+++ trunk/src/testplugin.c Mon Mar 9 21:48:32 2009
@@ -10,7 +10,7 @@
static GelETree *
TestPluginFunction_op (GelCtx *ctx, GelETree * * a, int *exception)
{
- gel_output_printf (main_out, _("This is the test-plugin function\n"));
+ gel_output_printf (gel_main_out, _("This is the test-plugin function\n"));
/* return a null */
return gel_makenum_null ();
@@ -21,24 +21,24 @@
{
GelEFunc *f;
- gel_output_printf (main_out, _("You have opened test plugin!\n\n"
+ gel_output_printf (gel_main_out, _("You have opened test plugin!\n\n"
"Will evaluate 2+2 as a demonstration\n"
"2+2 = "));
- gel_evalexp ("2+2", NULL, main_out, NULL, TRUE, NULL);
+ gel_evalexp ("2+2", NULL, gel_main_out, NULL, TRUE, NULL);
- gel_output_printf (main_out, _("For my next trick I will add a "
+ gel_output_printf (gel_main_out, _("For my next trick I will add a "
"function named "
"TestPluginFunction\n\n"));
f = d_addfunc (d_makebifunc (d_intern ("TestPluginFunction"),
TestPluginFunction_op, 0));
d_add_named_args (f, "");
- add_category ("TestPluginFunction" , "misc");
- add_description ("TestPluginFunction",
+ gel_add_category ("TestPluginFunction" , "misc");
+ gel_add_description ("TestPluginFunction",
"This is a test function added by the test plugin");
- gel_output_printf (main_out, _("That's it, isn't this fun\n\n"));
+ gel_output_printf (gel_main_out, _("That's it, isn't this fun\n\n"));
}
static gboolean
Modified: trunk/src/util.c
==============================================================================
--- trunk/src/util.c (original)
+++ trunk/src/util.c Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2002 George Lebl
+ * Copyright (C) 1997-2009 George Lebl
*
* Author: George Lebl
*
@@ -30,7 +30,7 @@
/*shift the sring to the right by n*/
void
-shiftstr(char *s,int n)
+gel_shiftstr(char *s,int n)
{
char *p;
if(!s || n<=0)
@@ -42,7 +42,7 @@
/*allocate new space in s for p and append it*/
char *
-appendstr (char *s,const char *p)
+gel_appendstr (char *s,const char *p)
{
if (p == NULL || *p == '\0')
return s;
@@ -58,7 +58,7 @@
/*allocate new space in s for p and prepend it*/
char *
-prependstr(char *s,const char *p)
+gel_prependstr(char *s,const char *p)
{
char *p2;
if (p == NULL || *p == '\0')
@@ -78,14 +78,14 @@
void
-stack_push(GSList **stack, gpointer data)
+gel_stack_push(GSList **stack, gpointer data)
{
g_return_if_fail (stack != NULL);
*stack = g_slist_prepend(*stack,data);
}
gpointer
-stack_pop(GSList **stack)
+gel_stack_pop(GSList **stack)
{
gpointer data;
GSList *p;
@@ -105,7 +105,7 @@
}
gpointer
-stack_peek (GSList **stack)
+gel_stack_peek (GSList **stack)
{
gpointer data;
@@ -121,7 +121,7 @@
}
char *
-unescape_string(char *s,char *end,char *nounescape)
+gel_unescape_string(char *s,char *end,char *nounescape)
{
char *n;
char *p;
@@ -157,7 +157,7 @@
/*escape also "'s and \'s*/
char *
-escape_string(char *s)
+gel_escape_string(char *s)
{
char *n;
char *p;
Modified: trunk/src/util.h
==============================================================================
--- trunk/src/util.h (original)
+++ trunk/src/util.h Mon Mar 9 21:48:32 2009
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2002 George Lebl
+ * Copyright (C) 1997-2009 George Lebl
*
* Author: George Lebl
*
@@ -19,29 +19,29 @@
* USA.
*/
-#ifndef _UTIL_H_
-#define _UTIL_H_
+#ifndef _GENIUS_UTIL_H_
+#define _GENIUS_UTIL_H_
#include <stdlib.h>
/*shift the sring to the right by n*/
-void shiftstr(char *s,int n);
+void gel_shiftstr(char *s,int n);
/*allocate new space in s for p and append it*/
-char * appendstr(char *s,const char *p);
+char * gel_appendstr(char *s,const char *p);
/*allocate new space in s for p and prepend it*/
-char * prependstr(char *s,const char *p);
+char * gel_prependstr(char *s,const char *p);
/*stack operations using GSList*/
-void stack_push(GSList **stack, gpointer data);
-gpointer stack_pop(GSList **stack);
-gpointer stack_peek(GSList **stack);
+void gel_stack_push(GSList **stack, gpointer data);
+gpointer gel_stack_pop(GSList **stack);
+gpointer gel_stack_peek(GSList **stack);
/*escape/unescape \n\t\r\b\a\"\\ ... unescape also \<anything>==<anything>,
nounescape means characters which to leave escaped*/
-char *unescape_string(char *s, char *end, char *nounescape);
+char *gel_unescape_string(char *s, char *end, char *nounescape);
/*escape also "'s and \'s*/
-char *escape_string(char *s);
+char *gel_escape_string(char *s);
#endif
Modified: trunk/src/utype.c
==============================================================================
--- trunk/src/utype.c (original)
+++ trunk/src/utype.c Mon Mar 9 21:48:32 2009
@@ -146,7 +146,7 @@
ut = g_array_index(types_ar,UserType *,type);
if(!ut) return NULL;
- GET_NEW_NODE(n);
+ GEL_GET_NEW_NODE(n);
n->type = USERTYPE_NODE;
n->ut.next = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]