Posted By: Error014
str_trim on "edge cases" - 08/03/16 23:15
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:
Relevant part of the acklog.txt output:
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!
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!