[genius] Mon Apr 09 21:12:40 2012 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Mon Apr 09 21:12:40 2012 Jiri (George) Lebl <jirka 5z com>
- Date: Tue, 10 Apr 2012 02:17:10 +0000 (UTC)
commit a0faf21c638d3eca1fba10b83c732a6fa0014907
Author: Jiri (George) Lebl <jirka 5z com>
Date: Mon Apr 9 21:17:01 2012 -0500
Mon Apr 09 21:12:40 2012 Jiri (George) Lebl <jirka 5z com>
* src/matop.c: forgotten nargs setting led to a crash when
adding fake conj.
* src/compil.c, src/matop.c: correctly set uninitialized flag
for identifiers.
* src/eval.[ch]: avoid some uninitialized compilation warnings.
ChangeLog | 10 ++++++
NEWS | 1 +
TODO | 8 +----
src/compil.c | 8 ++++-
src/eval.c | 87 ++++++++++++++++++++++++++++++++++-----------------------
src/eval.h | 7 ++++-
src/matop.c | 4 ++-
7 files changed, 80 insertions(+), 45 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e62c6c2..2bf2858 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Mon Apr 09 21:12:40 2012 Jiri (George) Lebl <jirka 5z com>
+
+ * src/matop.c: forgotten nargs setting led to a crash when
+ adding fake conj.
+
+ * src/compil.c, src/matop.c: correctly set uninitialized flag
+ for identifiers.
+
+ * src/eval.[ch]: avoid some uninitialized compilation warnings.
+
Mon Apr 09 20:44:03 2012 Jiri (George) Lebl <jirka 5z com>
* src/eval.c, src/structs.h: Store state of "uninitialized"
diff --git a/NEWS b/NEWS
index 14e56f2..368e3ca 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,7 @@ Changes to 1.0.16
* Fix possible uninitialized crash when reading badly formed standard library
(should never happen but ...)
* Fix LinearRecursiveSequence and allow it to take vector for n
+* Fix crash on uninitialized variables in conjugate transpose
* Avoid double error about uninitialized variables
* Spelling fixes and documentation fixes (me, LucPionchon)
diff --git a/TODO b/TODO
index 99ab6eb..07593b2 100644
--- a/TODO
+++ b/TODO
@@ -1,12 +1,8 @@
-! [1,i]'*[1,i] crashes!
-
-
-
--- document new things in 1.0.7
-
+-- document new things in 1.0.7 -- FIXME: DID WE?
+* Decimal arithmetic
* Logfiles and/or save session
* Whack the readline nonsense in the GUI
* Native polynomial operation
diff --git a/src/compil.c b/src/compil.c
index 74d8515..398395f 100644
--- a/src/compil.c
+++ b/src/compil.c
@@ -1,7 +1,7 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2011 George Lebl
+ * Copyright (C) 1997-2012 Jiri (George) Lebl
*
- * Author: George Lebl
+ * Author: Jiri (George) Lebl
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -344,6 +344,10 @@ gel_decompile_node(char **ptrptr)
GEL_GET_NEW_NODE(n);
n->type = GEL_IDENTIFIER_NODE;
n->id.id = d_intern(p);
+ /* never compile the uninitialized state,
+ * we simply forget that we already gave an
+ * error here and will warn again */
+ n->id.uninitialized = FALSE;
return n;
case GEL_STRING_NODE:
p = strtok_r (NULL, ";", ptrptr);
diff --git a/src/eval.c b/src/eval.c
index 9dcfc45..2f2dfef 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -124,6 +124,17 @@ ge_remove_stack_array(GelCtx *ctx)
(pointer) = NULL; \
} \
}
+#define GE_POP_STACKNF(thectx,pointer) { \
+ if((thectx)->topstack != (gpointer *)(thectx)->stack || \
+ ge_remove_stack_array(ctx)) { \
+ -- (thectx)->topstack; \
+ *((thectx)->topstack) = NULL; \
+ (pointer) = *(-- (thectx)->topstack); \
+ *((thectx)->topstack) = NULL; \
+ } else { \
+ (pointer) = NULL; \
+ } \
+}
#else /* MEM_DEBUG_FRIENDLY */
#define GE_POP_STACK(thectx,pointer,flag) { \
if G_LIKELY ((thectx)->topstack != (gpointer *)(thectx)->stack || \
@@ -135,6 +146,15 @@ ge_remove_stack_array(GelCtx *ctx)
(pointer) = NULL; \
} \
}
+#define GE_POP_STACKNF(thectx,pointer) { \
+ if G_LIKELY ((thectx)->topstack != (gpointer *)(thectx)->stack || \
+ ge_remove_stack_array(ctx)) { \
+ -- (thectx)->topstack; \
+ (pointer) = *(-- (thectx)->topstack); \
+ } else { \
+ (pointer) = NULL; \
+ } \
+}
#endif /* MEM_DEBUG_FRIENDLY */
#define GE_PEEK_STACK(thectx,pointer,flag) { \
@@ -4447,10 +4467,9 @@ iter_push_matrix(GelCtx *ctx, GelETree *n, GelMatrixW *m)
}
}
if (pushed) {
- int flag;
ctx->post = FALSE;
/* will pop the last thing which was t in PRE mode */
- GE_POP_STACK (ctx, ctx->current, flag);
+ GE_POP_STACKNF (ctx, ctx->current);
ctx->whackarg = FALSE;
} else {
/*if we haven't pushed ourselves,
@@ -5545,8 +5564,8 @@ iter_equalsop(GelETree *n)
}
} else if(l->op.oper == GEL_E_GET_ELEMENT) {
GelMatrixW *mat;
- GelETree *m, *index1, *index2;
- GEL_GET_LRR (l, m, index1, index2);
+ GelETree *index1, *index2;
+ GEL_GET_XRR (l, index1, index2);
if (index1->type == GEL_VALUE_NODE &&
index2->type == GEL_VALUE_NODE) {
@@ -5609,8 +5628,8 @@ iter_equalsop(GelETree *n)
}
} else if(l->op.oper == GEL_E_GET_VELEMENT) {
GelMatrixW *mat;
- GelETree *m, *index;
- GEL_GET_LR (l, m, index);
+ GelETree *index;
+ GEL_GET_XR (l, index);
if (index->type == GEL_VALUE_NODE) {
int i;
@@ -5653,8 +5672,8 @@ iter_equalsop(GelETree *n)
}
} else /*l->data.oper == GEL_E_GET_COL_REGION GEL_E_GET_ROW_REGION*/ {
GelMatrixW *mat;
- GelETree *m, *index;
- GEL_GET_LR (l, m, index);
+ GelETree *index;
+ GEL_GET_XR (l, index);
if (index->type == GEL_VALUE_NODE ||
index->type == GEL_MATRIX_NODE) {
@@ -5836,8 +5855,8 @@ iter_incrementop (GelETree *n)
}
} else if(l->op.oper == GEL_E_GET_ELEMENT) {
GelMatrixW *mat;
- GelETree *m, *index1, *index2;
- GEL_GET_LRR (l, m, index1, index2);
+ GelETree *index1, *index2;
+ GEL_GET_XRR (l, index1, index2);
if (index1->type == GEL_VALUE_NODE &&
index2->type == GEL_VALUE_NODE) {
@@ -5884,8 +5903,8 @@ iter_incrementop (GelETree *n)
}
} else if(l->op.oper == GEL_E_GET_VELEMENT) {
GelMatrixW *mat;
- GelETree *m, *index;
- GEL_GET_LR (l, m, index);
+ GelETree *index;
+ GEL_GET_XR (l, index);
if (index->type == GEL_VALUE_NODE) {
int i;
@@ -5921,8 +5940,8 @@ iter_incrementop (GelETree *n)
}
} else /*l->data.oper == GEL_E_GET_COL_REGION GEL_E_GET_ROW_REGION*/ {
GelMatrixW *mat;
- GelETree *m, *index;
- GEL_GET_LR (l, m, index);
+ GelETree *index;
+ GEL_GET_XR (l, index);
if (index->type == GEL_VALUE_NODE ||
index->type == GEL_MATRIX_NODE) {
@@ -6000,8 +6019,8 @@ do_swapwithop (GelETree *l, GelETree *r)
rf->data.user = tmp;
} else if(r->op.oper == GEL_E_GET_ELEMENT) {
GelMatrixW *mat;
- GelETree *m, *index1, *index2;
- GEL_GET_LRR (r, m, index1, index2);
+ GelETree *index1, *index2;
+ GEL_GET_XRR (r, index1, index2);
if (index1->type == GEL_VALUE_NODE &&
index2->type == GEL_VALUE_NODE) {
@@ -6035,8 +6054,8 @@ do_swapwithop (GelETree *l, GelETree *r)
}
} else if(r->op.oper == GEL_E_GET_VELEMENT) {
GelMatrixW *mat;
- GelETree *m, *index;
- GEL_GET_LR (r, m, index);
+ GelETree *index;
+ GEL_GET_XR (r, index);
if (index->type == GEL_VALUE_NODE) {
int i, x, y;
@@ -6085,8 +6104,8 @@ do_swapwithop (GelETree *l, GelETree *r)
return;
if (l->op.oper == GEL_E_GET_ELEMENT) {
- GelETree *m, *index1, *index2;
- GEL_GET_LRR (l, m, index1, index2);
+ GelETree *index1, *index2;
+ GEL_GET_XRR (l, index1, index2);
if (index1->type == GEL_VALUE_NODE &&
index2->type == GEL_VALUE_NODE) {
@@ -6101,8 +6120,8 @@ do_swapwithop (GelETree *l, GelETree *r)
return;
}
} else if (l->op.oper == GEL_E_GET_VELEMENT) {
- GelETree *m, *index;
- GEL_GET_LR (l, m, index);
+ GelETree *index;
+ GEL_GET_XR (l, index);
if (index->type == GEL_VALUE_NODE) {
int i;
@@ -6119,8 +6138,8 @@ do_swapwithop (GelETree *l, GelETree *r)
}
if (r->op.oper == GEL_E_GET_ELEMENT) {
- GelETree *m, *index1, *index2;
- GEL_GET_LRR (r, m, index1, index2);
+ GelETree *index1, *index2;
+ GEL_GET_XRR (r, index1, index2);
if (index1->type == GEL_VALUE_NODE &&
index2->type == GEL_VALUE_NODE) {
@@ -6135,8 +6154,8 @@ do_swapwithop (GelETree *l, GelETree *r)
return;
}
} else if(r->op.oper == GEL_E_GET_VELEMENT) {
- GelETree *m, *index;
- GEL_GET_LR (r, m, index);
+ GelETree *index;
+ GEL_GET_XR (r, index);
if (index->type == GEL_VALUE_NODE) {
int i;
@@ -6196,9 +6215,9 @@ iter_swapwithop(GelETree *n)
static void
iter_parameterop (GelETree *n)
{
- GelETree *l,*r,*rr;
+ GelETree *r,*rr;
- GEL_GET_LRR (n, l, r, rr);
+ GEL_GET_XRR (n, r, rr);
/* FIXME: l should be the set func */
@@ -6226,14 +6245,14 @@ iter_parameterop (GelETree *n)
static inline void
iter_push_indexes_and_arg(GelCtx *ctx, GelETree *n)
{
- GelETree *l,*ident;
+ GelETree *l;
GEL_GET_L(n,l);
if (l->op.oper == GEL_E_GET_ELEMENT) {
GelETree *ll,*rr;
- GEL_GET_LRR(l,ident,ll,rr);
+ GEL_GET_XRR(l,ll,rr);
GE_PUSH_STACK(ctx,n->op.args->any.next,GE_PRE);
GE_PUSH_STACK(ctx,rr,GE_PRE);
@@ -6245,7 +6264,7 @@ iter_push_indexes_and_arg(GelCtx *ctx, GelETree *n)
l->op.oper == GEL_E_GET_ROW_REGION) {
GelETree *ll;
- GEL_GET_LR(l,ident,ll);
+ GEL_GET_XR(l,ll);
GE_PUSH_STACK(ctx,n->op.args->any.next,GE_PRE);
ctx->post = FALSE;
@@ -6261,12 +6280,10 @@ iter_push_indexes_and_arg(GelCtx *ctx, GelETree *n)
static inline void
iter_do_push_index (GelCtx *ctx, GelETree *l)
{
- GelETree *ident;
-
if (l->op.oper == GEL_E_GET_ELEMENT) {
GelETree *ll,*rr;
- GEL_GET_LRR(l,ident,ll,rr);
+ GEL_GET_XRR(l,ll,rr);
GE_PUSH_STACK(ctx,rr,GE_PRE);
GE_PUSH_STACK(ctx,ll,GE_PRE);
@@ -6275,7 +6292,7 @@ iter_do_push_index (GelCtx *ctx, GelETree *l)
l->op.oper == GEL_E_GET_ROW_REGION) {
GelETree *ll;
- GEL_GET_LR(l,ident,ll);
+ GEL_GET_XR(l,ll);
GE_PUSH_STACK(ctx,ll,GE_PRE);
}
}
diff --git a/src/eval.h b/src/eval.h
index f093a5d..ea16529 100644
--- a/src/eval.h
+++ b/src/eval.h
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2009 Jiri (George) Lebl
+ * Copyright (C) 1997-2012 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -172,7 +172,12 @@ gboolean gel_eqlnodes (GelETree *l, GelETree *r);
(r) = (n)->op.args->any.next; \
(rr) = (n)->op.args->any.next->any.next; \
}
+#define GEL_GET_XRR(n,r,rr) { \
+ (r) = (n)->op.args->any.next; \
+ (rr) = (n)->op.args->any.next->any.next; \
+}
#define GEL_GET_LR(n,l,r) { (l) = (n)->op.args; (r) = (n)->op.args->any.next; }
+#define GEL_GET_XR(n,r) { (r) = (n)->op.args->any.next; }
#define GEL_GET_L(n,l) { (l) = (n)->op.args; }
extern GelETree *gel_free_trees;
diff --git a/src/matop.c b/src/matop.c
index b19a17a..5d99471 100644
--- a/src/matop.c
+++ b/src/matop.c
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2009 Jiri (George) Lebl
+ * Copyright (C) 1997-2012 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -222,10 +222,12 @@ gel_matrix_conjugate_transpose (GelMatrixW *m)
GEL_GET_NEW_NODE (nn);
nn->type = GEL_OPERATOR_NODE;
nn->op.oper = GEL_E_DIRECTCALL;
+ nn->op.nargs = 2;
GEL_GET_NEW_NODE (nn->op.args);
nn->op.args->type = GEL_IDENTIFIER_NODE;
nn->op.args->id.id = d_intern ("conj");
+ nn->op.args->id.uninitialized = FALSE;
nn->op.args->any.next = n;
n->any.next = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]