| Revision 1104,
1.4 KB
checked in by Freddie Akeroyd, 4 years ago
(diff) |
|
Minor code changes to allow compilation with MS Visual Studio 2005. refs #112.
|
-
Property svn:eol-style set to
native
-
Property svn:executable set to
*
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | /* |
|---|
| 2 | ** stptok() -- public domain by Ray Gardner, modified by Bob Stout |
|---|
| 3 | ** |
|---|
| 4 | ** You pass this function a string to parse, a buffer to receive the |
|---|
| 5 | ** "token" that gets scanned, the length of the buffer, and a string of |
|---|
| 6 | ** "break" characters that stop the scan. It will copy the string into |
|---|
| 7 | ** the buffer up to any of the break characters, or until the buffer is |
|---|
| 8 | ** full, and will always leave the buffer null-terminated. It will |
|---|
| 9 | ** return a pointer to the first non-breaking character after the one |
|---|
| 10 | ** that stopped the scan. |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | #include <string.h> |
|---|
| 14 | #include <stdlib.h> |
|---|
| 15 | #include "nx_stptok.h" |
|---|
| 16 | |
|---|
| 17 | char *stptok(const char *s, char *tok, size_t toklen, char *brk) |
|---|
| 18 | { |
|---|
| 19 | char *lim, *b; |
|---|
| 20 | |
|---|
| 21 | if (!*s) |
|---|
| 22 | return NULL; |
|---|
| 23 | |
|---|
| 24 | lim = tok + toklen - 1; |
|---|
| 25 | while ( *s && tok < lim ) |
|---|
| 26 | { |
|---|
| 27 | for ( b = brk; *b; b++ ) |
|---|
| 28 | { |
|---|
| 29 | if ( *s == *b ) |
|---|
| 30 | { |
|---|
| 31 | *tok = 0; |
|---|
| 32 | return (char *)(s+1); |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | *tok++ = *s++; |
|---|
| 36 | } |
|---|
| 37 | *tok = 0; |
|---|
| 38 | return (char *)s; |
|---|
| 39 | } |
|---|
| 40 | /*---------------------------------------------------------------------------*/ |
|---|
| 41 | static char *SkipSpace(char *pText) |
|---|
| 42 | { |
|---|
| 43 | char *pRes; |
|---|
| 44 | |
|---|
| 45 | pRes = pText; |
|---|
| 46 | while(*pRes) |
|---|
| 47 | { |
|---|
| 48 | if( (*pRes != ' ') && (*pRes != '\t') && (*pRes != '\r') ) |
|---|
| 49 | { |
|---|
| 50 | return pRes; |
|---|
| 51 | } |
|---|
| 52 | pRes++; |
|---|
| 53 | } |
|---|
| 54 | return NULL; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.