#1261 Array LAST() returns wrong info after DELETE()

5.0.0
pending
None
none
1
2015-03-15
2014-04-23
No

The following output seems incorrect.

This test program creates a 17-element array
and then deletes item 8 (the characters _som) four times. The resulting
array should have 13 elements. Instead it
has 14 and the last one is NUL.

The error seems to occur when the first DELETE(8) is
executed. You can see from the output below that array.last
is not decremented the during the first call, but is after calls
2, 3 and 4.

This seems like a bug to me...

rws@rws8 /cygdrive/c/safe-back
$ rexx -v
Open Object Rexx Version 4.2.0
Build date: Feb 22 2014
Addressing Mode: 64

Copyright (c) IBM Corporation 1995, 2004.
Copyright (c) RexxLA 2005-2013.
All Rights Reserved.
This program and the accompanying materials are made available under
the terms of the Common Public License v1.0 which accompanies this
distribution or at
http://www.oorexx.org/license.html

rws@rws8 /cygdrive/c/safe-back
$ rexx sbk_client.rex
Extents: 1 17 Items: 17 Dimension: 17
Array is built

Before: Extents: 1 17 Items: 17 Dimension: 17
del: |-_|
After: Extents: 1 17 Items: 16 Dimension: 16
1 17 above should be 1 16, no?

Before: Extents: 1 17 Items: 16 Dimension: 16
del: |-s|
After: Extents: 1 16 Items: 15 Dimension: 15
Now its decrementing as expected, but the count is already off by 1

Before: Extents: 1 16 Items: 15 Dimension: 15
del: |-o|
After: Extents: 1 15 Items: 14 Dimension: 14

Before: Extents: 1 15 Items: 14 Dimension: 14
del: |-m|
After: Extents: 1 14 Items: 13 Dimension: 13

Extents: 1 14 Items: 13 Dimension: 13
1 14
1 2 |-T|
2 2 |-h|
3 2 |-i|
4 2 |-s|
5 2 |-|
6 2 |-i|
7 2 |-s|
8 2 |-e|
9 2 |-
|
10 2 |-t|
11 2 |-e|
12 2 |-x|
13 2 |-t|
14 14 |The NIL object|


fred=.myclass~new("This_is_some_text")
fred~del(8)
fred~del(8)
fred~del(8)
fred~del(8)
say fred~extents
say fred~ascii
exit

::class myclass

-- init("text") where text is 8-bit ascii
::method init
expose myarray
use arg newtext

-- myarray is an array of 2 or 4 byte elements
myarray=.array~new
len=length(newtext)
do i=1 to len
    myarray[i]='2D'x || substr(newtext,i,1) -- "A" is x'0022'
end
say self~extents
say 'Array is built'
say
return

::method extents
expose myarray
return 'Extents:' myarray~first myarray~last 'Items:' myarray~items 'Dimension:' myarray~dimension(1)

::method del
expose myarray
use arg cnt
say 'Before:' self~extents
say 'del:' '|'myarray~delete(cnt)'|'
say 'After:'  self~extents
say
return ''

-- returns the number of 8-bit octets needed to store the string
::method items
expose myarray
return myarray~items

-- Returns the string as 8-bit ascii characters
::method ascii
expose myarray
say myarray~first myarray~last
do i=myarray~first to myarray~last
   s=myarray[i]
   say i length(s) '|'s'|'
end
return ''

Discussion

  • Rick McGuire

    Rick McGuire - 2014-04-23
    • status: open --> pending
    • assigned_to: Rick McGuire
    • Group: v4.2.0 --> Next_Release
     
  • Rick McGuire

    Rick McGuire - 2014-04-23

    Committed revision 9978.

     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2014-08-28

    This may be another manifestation of ticket 1257.

     
  • Rick McGuire

    Rick McGuire - 2015-03-15
    • Group: Next_Release --> 5.0.0
     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks