Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 03/06/26 07:18
zorro with ccxt?
by opm. 03/03/26 03:17
WFO Training with parallel cores Zorro64
by Martin_HH. 02/26/26 16:03
Zorro version 3.0 prerelease!
by TipmyPip. 02/25/26 16:38
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
1 registered members (TipmyPip), 5,463 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
the1, alx, ApprenticeInMuc, PatrickH90, USER0328
19200 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,077
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,077
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