home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name stpword -- Extract next word from a string
- *
- * Synopsis presult = stpword(ptarget,psource,tarsize);
- *
- * char *presult Pointer to next character in source
- * char *ptarget Pointer to target string
- * char *psource Pointer to source string
- * int tarsize Size of target string (including space
- * for trailing NUL ('\0'))
- *
- * Description This function skips any leading white space in the
- * source string and copies the succeeding characters from
- * the source to the target until more white space or the
- * end of the source is encountered or until the target
- * string is full. A pointer to the next character in the
- * source string is returned. If no nonwhite characters
- * are found then the target string will be the null string
- * (zero length).
- *
- * White space (blanks, tabs, newlines, etc.) is defined by
- * the isspace() function or macro.
- *
- * Returns presult Pointer to next character in source
- * *ptarget Next string of nonblanks from source
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1986
- *
- **/
-
- #include <ctype.h>
- #include <bstring.h>
-
- #define BLANK ' '
-
- char *stpword(ptarget,psource,tarsize)
- register char *ptarget;
- char *psource;
- int tarsize;
- {
- while (isspace(*psource)) /* Step past leading white */
- psource++; /* space in source. */
-
- while ( --tarsize > 0 /* While target not full */
- && *psource /* and source not exhausted */
- && !(isspace(*psource)))
- *ptarget++ = *psource++; /* copy nonblanks. */
-
- *ptarget = '\0';
-
- return psource;
- }