> Some eager person may wish to replace the strchr() calls with inline
> code. The only compiler I'm really familiar with w.r.t. code
> generation will replace strchr() with inline code but I suspect that
> is not the case with most compilers.
Macros decided not to play nice.
If this works for you, lemme know, and I'll commit it.
Index: apr_strtok.c
===================================================================
RCS file: /home/cvs/apr/strings/apr_strtok.c,v
retrieving revision 1.1
diff -u -d -r1.1 apr_strtok.c
--- apr_strtok.c 2001/05/23 14:15:44 1.1
+++ apr_strtok.c 2001/05/23 17:42:32
@@ -59,19 +59,26 @@
#include "apr.h"
#include "apr_strings.h"
-#define APR_WANT_STRFUNC /* for strchr() */
-#include "apr_want.h"
-
APR_DECLARE(char *) apr_strtok(char *str, const char *sep, char **last)
{
char *token;
+ char *tmpcmp;
if (!str) /* subsequent call */
str = *last; /* start where we left off */
/* skip characters in sep (will terminate at '\0') */
- while (*str && strchr(sep, *str))
- ++str;
+ while (*str) {
+ tmpcmp = sep;
+ do {
+ if (*tmpcmp == *str)
+ break;
+ } while (*tmpcmp++)
+ if (*tmpcmp)
+ ++str;
+ else
+ break;
+ }
if (!*str) /* no more tokens */
return NULL;
@@ -82,8 +89,17 @@
* prepare for the next call (will terminate at '\0)
*/
*last = token + 1;
- while (**last && !strchr(sep, **last))
- ++*last;
+ while (**last) {
+ tmpcmp = sep;
+ do {
+ if (*tmpcmp == **last)
+ break;
+ } while (*tmpcmp++)
+ if (*tmpcmp)
+ break;
+ else
+ ++*last;
+ }
if (**last) {
**last = '\0';
Victor
--
Victor J. Orlikowski
======================
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[EMAIL PROTECTED]