dMZX Forums: Setting $str.length never sets the string's length to the value you attempt to set it to -> Archived MegaZeux Bugs -> Tracker

Jump to content

Report ID 436 Title Setting $str.length never sets the string's length to the value you attempt to set it to
Product Archived MegaZeux Bugs Status Fixed (Severity 3 - Medium)
Version 2.83 Fixed in 2.84
Introduced In Version 2.82bOperating System Windows XP SP2

Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Report ID #436: Setting $str.length never sets the string's length to the value you attempt to set it to

#1 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,943
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 17 April 2012 - 09:12 AM

set "$str" to "Hello world!"
set "LOCAL" "$str.length"
set "$str.length" to 12
* "LOCAL: &LOCAL&  Str length: &$str.length&"


LOCAL is properly set to the length of the string, 12, but after setting $str.length to anything else, $str.length will actually be set to the next highest power of 2 if it is equal to the current string length or greater. If it is smaller, it returns the value you've just tried to set it to plus 1. Will edit once I've had a chance to check the GIT.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository


Page 1 of 1  
  • Cannot start a new Issue
  • Closed Issue This issue is locked

Replies (1 - 5)

#2 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,943
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 17 April 2012 - 09:33 AM

Updating status to: Confirmed
Updating version to: GIT
Updating Introduced In Version to: 2.82b

MegaZeux has behaved this way since version 2.82b, when setting $str.length was added. Prior to this, "$str.length" in a set command would be interpretted as "$str.0". This behavior persists into the latest GIT. Notably, the help file says that setting $str.length will "will now truncate or enlarge the string to the size specified", and while decreasing $str.length does truncate the string, it fails to set the length to the correct value, so this can definitely be classified as misbehavior from a user perspective in both cases.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#3 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,943
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 18 May 2012 - 07:14 AM

Updating status to: Proposed Fix
Updating version to: GIT

Issue fixed in: 2.84


/* As a kind of unnecessary optimisation, if the string already exists
 * and we're asking to extend its length, increase the length by a power
 * ( of two rather than just by the amount necessary.
 */


Yeeaaaaaaaaaahhhhhhh except that's not really what the user should ever expect or want, and it was publicly advertised as setting the length to what the user told it to be. I get what was trying to be done here, would having a separate attribute keeping track of how big the allocated space is hurt performance/memory much?

The proposed fix is version locked to prevent any 2.82b to 2.83 worlds from misbehaving if they had relied on this, and is available in my fork.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#4 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,943
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 19 May 2012 - 01:02 AM

Updating severity to: 3 - Medium

I have an alternate fix proposal that possibly makes the most sense. Since force_string_length only allocates the string and wipes the newly allocated space, the 2^x value could be passed there and then the length setting code could simply make sure to set the length attribute to the given value.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#5 User is offline  
Lachesis 

  • the pinnacle of human emotion
  • Group: DigiStaff
  • Posts: 3,943
  • Joined: 17-July 04
  • Gender:Female
  • Location:Sealand

Posted 24 May 2012 - 01:04 AM

Updating status to: Fixed
Updating version to: 2.83


Any further changes to the string allocation will have to wait for the next version.
"Let's just say I'm a GOOD hacker, AND virus maker. I'm sure you wouldn't like to pay for another PC would you?"

xx̊y (OST) - HELLQUEST (OST) - Zeux I: Labyrinth of Zeux (OST) (DOS OST)
w/ Lancer-X and/or asgromo: Pandora's Gate - Thanatos Insignia - no True(n) - For Elise OST
MegaZeux: Online Help File - Keycode Guide - Joystick Guide - Official GIT Repository

#6 User is offline  
Terryn 

  • ******
  • Group: DigiStaff
  • Posts: 2,966
  • Joined: 12-October 00
  • Gender:Male

Posted 27 May 2012 - 07:30 PM

Moving to: Archived MegaZeux Bugs


Page 1 of 1
  • Cannot start a new Issue
  • Closed Issue This issue is locked

0 User(s) are reading this issue
0 Guests and 0 Anonymous Users


Powered by IP.Tracker 1.3.2 © 2025  IPS, Inc.