changeset 127:2d47a53a5736

strtok functions now return null if end of string is all delimiters
author Jonathan Pevarnek <pevarnj@gmail.com>
date Fri, 24 Jun 2011 11:04:54 -0400
parents de391a7d85b1
children ca9f01e6e2bf
files src/os/string.c
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/os/string.c	Fri Jun 24 10:50:09 2011 -0400
+++ b/src/os/string.c	Fri Jun 24 11:04:54 2011 -0400
@@ -66,7 +66,8 @@
 	if(str) track = str;
 	if(!track) return track; //return null if done
 	while(isChar(*track, delimiters)) track++;
-	ret = track; //first non-deliminator character, start of string
+	if(*track) ret = track; //first non-deliminator character, start of string
+	else ret = NULL; //if it ends with delimiters, don't return nothingness
 	while(*track && !isChar(*track, delimiters)) track++;
 	if(!*track) track = NULL;
 	else *track++ = '\0';