From 26f207e650fdf86f9240553a590e30748fc4a363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20L=C3=BCbeck?= Date: Wed, 27 Apr 2016 16:02:38 +0200 Subject: [PATCH 1/2] Fix kernel method for 'Remove' with one argument This fixes the following problem (reported to the support list): gap> L:=[1,2,,,3]; [ 1, 2,,, 3 ] gap> Remove(L); 3 gap> L; [ 1, 2,, ] that is, the length was not reduced to the position of the last bound entry. --- src/listfunc.c | 6 ++++-- tst/teststandard/bugfix.tst | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/listfunc.c b/src/listfunc.c index 4bded1da83..31a7c771c7 100644 --- a/src/listfunc.c +++ b/src/listfunc.c @@ -232,8 +232,10 @@ Obj RemPlist ( } removed = ELM_PLIST(list, pos); SET_ELM_PLIST(list, pos, (Obj)0L); - SET_LEN_PLIST(list, pos-1); - if ( pos == 1 ) { + pos--; + while ( 1 <= pos && ELM_PLIST( list, pos ) == 0 ) { pos--; } + SET_LEN_PLIST(list, pos); + if ( pos == 0 ) { RetypeBag(list, T_PLIST_EMPTY); } if (4*pos*sizeof(Obj) < 3*SIZE_BAG(list)) diff --git a/tst/teststandard/bugfix.tst b/tst/teststandard/bugfix.tst index b6c703cede..cda3760e44 100644 --- a/tst/teststandard/bugfix.tst +++ b/tst/teststandard/bugfix.tst @@ -3045,6 +3045,13 @@ gap> Size(Stabilizer(g, [ [1,2], [3,4] ], OnSetsSets)); gap> G:=Group((1,2,3,4));;Factorization(G,Elements(G)[1]); +#2016/04/27 (FL, bug reported on support list) +gap> l := [1,,,5];; +gap> Remove(l); +5 +gap> l; +[ 1 ] + ############################################################################# gap> STOP_TEST( "bugfix.tst", 831990000); From 89dd0110e3dec94bc88e439c6175f4dd2d58894a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20L=C3=BCbeck?= Date: Thu, 28 Apr 2016 12:27:46 +0200 Subject: [PATCH 2/2] Some more tests for the fixed `Remove` method. --- tst/teststandard/bugfix.tst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tst/teststandard/bugfix.tst b/tst/teststandard/bugfix.tst index cda3760e44..b514aac51f 100644 --- a/tst/teststandard/bugfix.tst +++ b/tst/teststandard/bugfix.tst @@ -3049,8 +3049,18 @@ gap> G:=Group((1,2,3,4));;Factorization(G,Elements(G)[1]); gap> l := [1,,,5];; gap> Remove(l); 5 -gap> l; -[ 1 ] +gap> [l, Length(l)]; +[ [ 1 ], 1 ] +gap> l := [,,,"x"];; +gap> Remove(l); +"x" +gap> [l, Length(l)]; +[ [ ], 0 ] +gap> l := [1,2,,[],"x"];; +gap> Remove(l); +"x" +gap> [l, Length(l)]; +[ [ 1, 2,, [ ] ], 4 ] ############################################################################# gap> STOP_TEST( "bugfix.tst", 831990000);