Gamestudio Links
Zorro Links
Newest Posts
How to select between IB accounts by script?
by AndrewAMD. 06/13/26 15:44
Zorro tutorial ideas?
by AndrewAMD. 06/13/26 15:01
Zorro 3.01 recoded MMI function issue
by 11honza11. 06/13/26 11:40
Max Number of Strategies in /Strategy folder
by Martin_HH. 06/12/26 08:50
Stooq now requires an API key
by AndrewAMD. 06/11/26 17:55
Z9 getting Error 058
by k_ivan. 06/10/26 14:38
ZorroGPT
by TipmyPip. 06/10/26 13:07
Z12 live performance
by alx. 06/09/26 20:42
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 2,164 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Student_64151, Koti, curry, DeepxKalsi, Samed
19219 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
str_trim on "edge cases" #461408
08/03/16 23:15
08/03/16 23:15
Joined: Jul 2002
Posts: 3,208
Germany
Error014 Offline OP
Expert
Error014  Offline OP
Expert

Joined: Jul 2002
Posts: 3,208
Germany
Hello,

str_trim does not work as expected for "strange strings", such as a string filled with only white spaces or a string starting with any number of spaces followed by just a single character. Here's some test code that works without assets:

Code:
#include "strio.c"

void main() {
	STRING* test_str;
	
	//Check empty string + 1 char (does not work)
	test_str=str_create("   .");
	diag("\n\"");
	diag(test_str);
	diag("\" -> \"");
	str_trim(test_str);
	diag(test_str);
	diag("\"\n\n");
	
	//Check empty string + 2 chars (works)
	str_cpy(test_str,"    ..");	
	diag("\n\"");
	diag(test_str);
	diag("\" -> \"");
	str_trim(test_str);
	diag(test_str);
	diag("\"\n\n");

	//Check empty string (does not work)
	str_cpy(test_str,"      ");	
	diag("\n\"");
	diag(test_str);
	diag("\" -> \"");
	str_trim(test_str);
	diag(test_str);
	diag("\"\n\n");


	sys_exit(NULL);	
}



Relevant part of the acklog.txt output:

Code:
"   ." -> "   ."


"    .." -> ".."


"      " -> "      "




Not a big deal, granted, but noteworthy nonetheless. Looking at strio.c, it also doesn't seem like a very hard thing to fix.

Best wishes!


Perhaps this post will get me points for originality at least.

Check out Dungeon Deities! It's amazing and will make you happy, successful and almost certainly more attractive! It might be true!
Re: str_trim on "edge cases" [Re: Error014] #461412
08/04/16 13:54
08/04/16 13:54
Joined: Jul 2000
Posts: 28,101
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,101
Frankfurt
Thanks for the info. A fixed strio.c will be included in the next update.


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1