Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 10/15/25 20:44
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
4 registered members (TipmyPip, Quad, AndrewAMD, 1 invisible), 6,298 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 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,028
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

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