[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323
Bernhard R. Link
brlink at debian.org
Tue Apr 24 15:53:56 UTC 2012
The following commit has been merged in the cleanedupstream branch:
commit 53bbbe7975a3e745615e793c84f4099fb8c3c69d
Author: Hans Schoenemann <hannes at mathematik.uni-kl.de>
Date: Fri Mar 2 10:39:19 2012 +0100
chg: consider lists with only DEF_CMD as empty lists (print, delete)
diff --git a/Singular/iparith.cc b/Singular/iparith.cc
index 1b05c6d..a464029 100644
--- a/Singular/iparith.cc
+++ b/Singular/iparith.cc
@@ -3614,7 +3614,7 @@ static BOOLEAN jjCOUNT_N(leftv res, leftv v)
static BOOLEAN jjCOUNT_L(leftv res, leftv v)
{
lists l=(lists)v->Data();
- res->data = (char *)(long)(l->nr+1);
+ res->data = (char *)(long)(lSize(l)+1);
return FALSE;
}
static BOOLEAN jjCOUNT_M(leftv res, leftv v)
diff --git a/Singular/lists.cc b/Singular/lists.cc
index 7554460..15daae1 100644
--- a/Singular/lists.cc
+++ b/Singular/lists.cc
@@ -1,7 +1,6 @@
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
/*
* ABSTRACT: handling of the list type
*/
@@ -21,6 +20,13 @@
omBin slists_bin = omGetSpecBin(sizeof(slists));
+int lSize(lists L)
+{
+ int n=L->nr;
+ while ((n>=0)&&(L->m[n].rtyp==DEF_CMD)) n--;
+ return n;
+}
+
lists lCopy(lists L)
{
lists N=(lists)omAlloc0Bin(slists_bin);
@@ -154,15 +160,16 @@ BOOLEAN lDelete(leftv res, leftv u, leftv v)
{
lists ul=(lists)u->Data();
int VIndex=(int)(long)v->Data()-1;
+ int EndIndex=lSize(ul);
if((0<=VIndex)&&(VIndex<=ul->nr))
{
ul=(lists)u->CopyD();
int i,j;
lists l=(lists) omAllocBin(slists_bin);
- l->Init(ul->nr);
+ l->Init(EndIndex+(VIndex>EndIndex));
- for(i=j=0;i<=ul->nr;i++,j++)
+ for(i=j=0;i<=EndIndex;i++,j++)
{
if (i!=VIndex)
{
diff --git a/Singular/lists.h b/Singular/lists.h
index a47ccc4..73eca73 100644
--- a/Singular/lists.h
+++ b/Singular/lists.h
@@ -3,7 +3,6 @@
/****************************************
* Computer Algebra System SINGULAR *
****************************************/
-/* $Id$ */
/*
* ABSTRACT: handling of the list type
*/
@@ -47,6 +46,7 @@ class slists
sleftv *m; /* field of sleftv */
};
+int lSize(lists L);
lists lCopy(lists L);
lists lInsert0(lists ul, leftv v, int pos);
BOOLEAN lInsert(leftv res, leftv u, leftv v);
diff --git a/Singular/subexpr.cc b/Singular/subexpr.cc
index e59f274..aa22f30 100644
--- a/Singular/subexpr.cc
+++ b/Singular/subexpr.cc
@@ -215,7 +215,7 @@ void sleftv::Print(leftv store, int spaces)
case LIST_CMD:
{
lists l=(lists)d;
- if (l->nr<0)
+ if (lSize(l)<0)
{
PrintNSpaces(spaces);
PrintS("empty list\n");
@@ -941,11 +941,11 @@ int sleftv::Typ()
{
lists l;
if (rtyp==IDHDL) l=IDLIST((idhdl)data);
- else if (rtyp==ALIAS_CMD)
- {
- idhdl h=(idhdl)data;
- l=(lists)(((idhdl)h->data.ustring)->data.ustring);
- }
+ else if (rtyp==ALIAS_CMD)
+ {
+ idhdl h=(idhdl)data;
+ l=(lists)(((idhdl)h->data.ustring)->data.ustring);
+ }
else l=(lists)data;
if ((0<e->start)&&(e->start<=l->nr+1))
{
--
an open source computer algebra system
More information about the debian-science-commits
mailing list