Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,103 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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


Moderated by  jcl, Nems, Spirit, Tobias 

Gamestudio download | chip programmers | 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