Bug - Fixed Error on to_item(string) for " "

ckb

Minion
Staff member
More scripting fun has lead to another error on to_item() for strings that contain only spaces.
ash to_string(" ") will return this error. So seemingly will any string that contains multiple spaces: " ", " ", " ", etc.

ckb


Edit: in my script, for my string it_s, adding the line
Code:
 while (index_of(it_s," ") == 0) { it_s = substring(it_s,1,length(it_s)); }
seems to fix the problem... though this is not ideal obviously.
 

Attachments

  • DEBUG_20110908.txt
    2.4 KB · Views: 35
Last edited:

matt.chugg

Moderator
Does ash have a trim function?


I'm afraid i'm not completly up to speed on the kolmafia source, but the below patch seems to fix this for me.
Code:
Index: src/net/sourceforge/kolmafia/textui/DataTypes.java
===================================================================
--- src/net/sourceforge/kolmafia/textui/DataTypes.java	(revision 9815)
+++ src/net/sourceforge/kolmafia/textui/DataTypes.java	(working copy)
@@ -262,7 +262,7 @@
 
 	public static final Value parseItemValue( String name, final boolean returnDefault )
 	{
-		if ( name == null || name.equals( "" )	)
+		if ( name == null || name.trim().equals( "" )	)
 		{
 			return returnDefault ? DataTypes.ITEM_INIT : null;
 		}
 
Top