Fixed some warnings when building in MSVC
[fw/sdcc] / device / lib / _strtok.c
index 7f00370a78cd31b4b149cc2cec83fcc2c03f7ad1..ab2603698e58f86d45c80d113831ad53d1dcd1d3 100644 (file)
@@ -22,7 +22,6 @@
    what you give them.   Help stamp out software-hoarding!  
 -------------------------------------------------------------------------*/
 #include "string.h" 
-#define NULL (void *)0
 
 #if defined(SDCC_MODEL_LARGE) || defined (SDCC_MODEL_FLAT24)
 #pragma NOINDUCTION
@@ -38,7 +37,16 @@ char * strtok (
 
        if ( str )
                s = str ;
+       if ( !s )
+               return NULL;
 
+       while (*s) {
+               if (strchr(control,*s))
+                       s++;
+               else
+                       break;
+       }
+       
        s1 = s ;
 
        while (*s) {
@@ -48,6 +56,12 @@ char * strtok (
                }
                s++ ;
        }
-       return (NULL);
+
+       s = NULL;
+
+       if (*s1)
+               return s1;
+       else
+               return NULL;
 }