* as/z80/z80mch.c: fixed bug #1704376: missing as-z80 errors
[fw/sdcc] / device / lib / _strtok.c
index 7f00370a78cd31b4b149cc2cec83fcc2c03f7ad1..ac4f68c9508fe3833120710c45c47314443ba24f 100644 (file)
    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
-#pragma NOINVARIANT
+#pragma noinduction
+#pragma noinvariant
 #endif
 
 char * strtok (
@@ -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;
 }