[PATCH] strtok() -> strsep() patch, Part 2.2

Ingo Oeser (ingo.oeser@informatik.tu-chemnitz.de)
Mon, 12 Jul 1999 20:03:21 +0200 (CEST)


Hi all,

This patch requires appliance of Part 2.1 of that patch.

Part 2.2 of a patch (against 2.3.10) that is going to remove
strtok() entirely.

Modifications done:

* removed strtoke() in several *fb.c drivers, because
strsep() can handle this

* replaced every occurance of strtok() with strsepe()
This will be strsep() too later, but I have to check the
parsing details of each driver first, which means hell a
lot of work.

Dear maintainers: Please help if possible!

* Rewritten some smaller parts of the ibmmca scsi driver,
because it used strtok() a more sophisticated way.

Dear maintainer of the IBMMCA SCSI driver: Please look over
my code if it is what you mean.

Thanks and regards

Ingo Oeser

diff -ru linux-2.3.10.vanilla/arch/alpha/kernel/setup.c linux/arch/alpha/kernel/setup.c
--- linux-2.3.10.vanilla/arch/alpha/kernel/setup.c Sat Jun 26 02:36:13 1999
+++ linux/arch/alpha/kernel/setup.c Sun Jul 11 19:29:54 1999
@@ -170,7 +170,7 @@
* Process command-line arguments.
*/

- for (p = strtok(command_line, " \t"); p ; p = strtok(NULL, " \t")) {
+ for (p = strsepe(&command_line, " \t"); p ; p = strsepe(&command_line, " \t")) {
#ifndef alpha_use_srm_setup
/* Allow a command-line option to respect the
SRM's configuration. */
@@ -191,7 +191,7 @@
}
}

- /* Replace the command line, not that we've killed it with strtok. */
+ /* Replace the command line, not that we've killed it with strsepe. */
strcpy(command_line, saved_command_line);

/*
diff -ru linux-2.3.10.vanilla/arch/m68k/atari/config.c linux/arch/m68k/atari/config.c
--- linux-2.3.10.vanilla/arch/m68k/atari/config.c Tue Jan 19 19:58:26 1999
+++ linux/arch/m68k/atari/config.c Sun Jul 11 19:30:06 1999
@@ -203,13 +203,13 @@
char *p;
int ovsc_shift;

- /* copy string to local array, strtok works destructively... */
+ /* copy string to local array, strsepe works destructively... */
strncpy( switches, str, len );
switches[len] = 0;
atari_switches = 0;

/* parse the options */
- for( p = strtok( switches, "," ); p; p = strtok( NULL, "," ) ) {
+ for( p = strsepe( &switches, "," ); p; p = strsepe( &switches, "," ) ) {
ovsc_shift = 0;
if (strncmp( p, "ov_", 3 ) == 0) {
p += 3;
diff -ru linux-2.3.10.vanilla/drivers/scsi/aic7xxx.c linux/drivers/scsi/aic7xxx.c
--- linux-2.3.10.vanilla/drivers/scsi/aic7xxx.c Tue Jul 6 04:56:46 1999
+++ linux/drivers/scsi/aic7xxx.c Sun Jul 11 19:29:24 1999
@@ -1519,7 +1519,7 @@

end = strchr(s, '\0');

- for (p = strtok(s, ",."); p; p = strtok(NULL, ",."))
+ for (p = strsepe(&s, ",."); p; p = strsepe(&s, ",."))
{
for (i = 0; i < NUMBER(options); i++)
{
@@ -1601,7 +1601,7 @@
}
}
while((p != base) && (p != NULL))
- p = strtok(NULL, ",.");
+ p = strsepe(&s, ",.");
}
}
else if (p[n] == ':')
diff -ru linux-2.3.10.vanilla/drivers/scsi/ibmmca.c linux/drivers/scsi/ibmmca.c
--- linux-2.3.10.vanilla/drivers/scsi/ibmmca.c Mon May 10 22:00:10 1999
+++ linux/drivers/scsi/ibmmca.c Sun Jul 11 19:29:25 1999
@@ -1385,7 +1385,7 @@

if (str)
{
- token = strtok(str,",");
+ token = strsepe(&str,",");
j = 0;
while (token)
{
@@ -1421,7 +1421,7 @@
}
j++;
}
- token = strtok(NULL,",");
+ token = strsepe(&str,",");
}
}
else if (ints)
diff -ru linux-2.3.10.vanilla/drivers/scsi/tmscsim.c linux/drivers/scsi/tmscsim.c
--- linux-2.3.10.vanilla/drivers/scsi/tmscsim.c Sat Dec 26 01:41:39 1998
+++ linux/drivers/scsi/tmscsim.c Sun Jul 11 19:29:28 1999
@@ -2101,68 +2101,61 @@
* '-' means no change
*******************************************************************/

-static int dc390_scanf (char** p1, char** p2, int* var)
-{
- *p2 = *p1;
- *var = simple_strtoul (*p2, p1, 10);
- if (*p2 == *p1) return -1;
- *p1 = strtok (0, " \t\n:=,;.");
- return 0;
-};
-
#define SCANF(p1, p2, var, min, max) \
-if (dc390_scanf (&p1, &p2, &var)) goto einv; \
-else if (var<min || var>max) goto einv2
-
-static int dc390_yesno (char** p, char* var, char bmask)
-{
- switch (**p)
- {
- case 'Y': *var |= bmask; break;
- case 'N': *var &= ~bmask; break;
- case '-': break;
- default: return -1;
- }
- *p = strtok (0, " \t\n:=,;");
- return 0;
-};
+p2 = p1; \
+var = simple_strtoul (p2, &p1, 10); \
+if (p2 == p1) goto einv; \
+else { \
+ p1 = strsepe (&buffer, " \t\n:=,;."); \
+ if (var<min || var>max) goto einv2; \
+}

#define YESNO(p, var, bmask) \
-if (dc390_yesno (&p, &var, bmask)) goto einv; \
-else dc390_updateDCB (pACB, pDCB); \
+switch (*p) \
+ { \
+ case 'Y': var |= bmask; break; \
+ case 'N': var &= ~bmask; break; \
+ case '-': break; \
+ default: goto einv; \
+ } \
+p = strsepe (&buffer, " \t\n:=,;"); \
+dc390_updateDCB (pACB, pDCB); \
if (!p) goto ok

-static int dc390_search (char **p1, char **p2, char *var, char* txt, int max, int scale, char* ign)
+static int dc390_search (char **where, char **p1, char **p2, char *var, char* txt, int max, int scale, char* ign)
{
int dum;
if (! memcmp (*p1, txt, strlen(txt)))
{
- *p2 = strtok (0, " \t\n:=,;");
+ *p2 = strsepe (where, " \t\n:=,;");
if (!*p2) return -1;
dum = simple_strtoul (*p2, p1, 10);
if (*p2 == *p1) return -1;
if (dum >= 0 && dum <= max)
{ *var = (dum * 100) / scale; }
else return -2;
- *p1 = strtok (0, " \t\n:=,;");
+ *p1 = strsepe (where, " \t\n:=,;");
if (*ign && *p1 && strlen(*p1) >= strlen(ign) &&
!(memcmp (*p1, ign, strlen(ign))))
- *p1 = strtok (0, " \t\n:=,;");
+ *p1 = strsepe (where, " \t\n:=,;");

}
return 0;
};

-#define SEARCH(p1, p2, var, txt, max) \
-if (dc390_search (&p1, &p2, (PUCHAR)(&var), txt, max, 100, "")) goto einv2; \
+#define SEARCH(where, p1, p2, var, txt, max) \
+if (dc390_search (&where, &p1, &p2, (PUCHAR)(&var), txt, max, 100, "")) \
+goto einv2; \
else if (!p1) goto ok2

-#define SEARCH2(p1, p2, var, txt, max, scale) \
-if (dc390_search (&p1, &p2, &var, txt, max, scale, "")) goto einv2; \
+#define SEARCH2(where, p1, p2, var, txt, max, scale) \
+if (dc390_search (&where, &p1, &p2, &var, txt, max, scale, "")) \
+goto einv2; \
else if (!p1) goto ok2

-#define SEARCH3(p1, p2, var, txt, max, scale, ign) \
-if (dc390_search (&p1, &p2, &var, txt, max, scale, ign)) goto einv2; \
+#define SEARCH3(where, p1, p2, var, txt, max, scale, ign) \
+if (dc390_search (&where, &p1, &p2, &var, txt, max, scale, ign)) \
+goto einv2; \
else if (!p1) goto ok2


@@ -2198,11 +2191,12 @@
while (*pos)
{ if (*pos >='a' && *pos <= 'z') *pos = *pos + 'A' - 'a'; pos++; };

- /* We should protect __strtok ! */
+ /* We should protect __strtok !
+ * ... but since we use strsepe now, it's not needed anyway -ioe */
/* spin_lock (strtok_lock); */

/* Remove WS */
- pos = strtok (buffer, " \t:\n=,;");
+ pos = strsepe (&buffer, " \t:\n=,;");
if (!pos) goto ok;

next:
@@ -2260,9 +2254,9 @@
pDCB->NegoPeriod = dum >> 2;
if (pDCB->NegoPeriod != olddevmode) needs_inquiry++;
if (!pos) goto ok;
- if (memcmp (pos, "NS", 2) == 0) pos = strtok (0, " \t\n:=,;.");
+ if (memcmp (pos, "NS", 2) == 0) pos = strsepe (&buffer, " \t\n:=,;.");
}
- else pos = strtok (0, " \t\n:=,;.");
+ else pos = strsepe (&buffer, " \t\n:=,;.");
if (!pos) goto ok;

/* Speed: NegoPeriod */
@@ -2281,12 +2275,12 @@
pDCB->NegoPeriod = (100000/(100*dumold + dum)) >> 2;
if (pDCB->NegoPeriod < 19) pDCB->NegoPeriod = 19;
if (pDCB->NegoPeriod != olddevmode) needs_inquiry++;
- pos = strtok (0, " \t\n:=,;");
+ pos = strsepe (&buffer, " \t\n:=,;");
if (!pos) goto ok;
};
- if (*pos == 'M') pos = strtok (0, " \t\n:=,;");
+ if (*pos == 'M') pos = strsepe (&buffer, " \t\n:=,;");
}
- else pos = strtok (0, " \t\n:=,;");
+ else pos = strsepe (&buffer, " \t\n:=,;");
/* dc390_updateDCB (pACB, pDCB); */
if (!pos) goto ok;

@@ -2298,7 +2292,7 @@
pDCB->SyncOffset = dum;
if (pDCB->SyncOffset > olddevmode) needs_inquiry++;
}
- else pos = strtok (0, " \t\n:=,;");
+ else pos = strsepe (&buffer, " \t\n:=,;");
dc390_updateDCB (pACB, pDCB);
}
else
@@ -2307,13 +2301,13 @@
PARSEDEBUG(printk (KERN_INFO "DC390: chg adapt cfg \"%s\"\n", prstr (pos, &buffer[length]));)
dum = GLITCH_TO_NS (pACB->glitch_cfg);
/* Adapter setting */
- SEARCH (pos, p0, pACB->pScsiHost->max_id, "MAXID", 8);
- SEARCH (pos, p0, pACB->pScsiHost->max_lun, "MAXLUN", 8);
- SEARCH (pos, p0, pACB->pScsiHost->this_id, "ADAPTERID", 7);
- SEARCH (pos, p0, pACB->TagMaxNum, "TAGMAXNUM", 32);
- SEARCH (pos, p0, pACB->ACBFlag, "ACBFLAG", 255);
- SEARCH3 (pos, p0, dum, "GLITCHEATER", 40, 1000, "NS");
- SEARCH3 (pos, p0, pACB->sel_timeout, "SELTIMEOUT", 400, 163, "MS");
+ SEARCH (buffer, pos, p0, pACB->pScsiHost->max_id, "MAXID", 8);
+ SEARCH (buffer, pos, p0, pACB->pScsiHost->max_lun, "MAXLUN", 8);
+ SEARCH (buffer, pos, p0, pACB->pScsiHost->this_id, "ADAPTERID", 7);
+ SEARCH (buffer, pos, p0, pACB->TagMaxNum, "TAGMAXNUM", 32);
+ SEARCH (buffer, pos, p0, pACB->ACBFlag, "ACBFLAG", 255);
+ SEARCH3 (buffer, pos, p0, dum, "GLITCHEATER", 40, 1000, "NS");
+ SEARCH3 (buffer, pos, p0, pACB->sel_timeout, "SELTIMEOUT", 400, 163, "MS");
ok2:
pACB->glitch_cfg = NS_TO_GLITCH (dum);
if (pACB->sel_timeout < 60) pACB->sel_timeout = 60;
@@ -2353,7 +2347,7 @@

inquiry:
{
- pos = strtok (0, " \t\n.:;="); if (!pos) goto einv;
+ pos = strsepe (&buffer, " \t\n.:;="); if (!pos) goto einv;
dev = simple_strtoul (pos, &p0, 10);
if (dev >= pACB->DCBCnt) goto einv_dev;
for (dum = 0; dum < dev; dum++) pDCB = pDCB->pNextDCB;
@@ -2367,7 +2361,7 @@

remove:
{
- pos = strtok (0, " \t\n.:;="); if (!pos) goto einv;
+ pos = strsepe (&buffer, " \t\n.:;="); if (!pos) goto einv;
dev = simple_strtoul (pos, &p0, 10);
if (dev >= pACB->DCBCnt) goto einv_dev;
for (dum = 0; dum < dev; dum++) pDCB = pDCB->pNextDCB;
diff -ru linux-2.3.10.vanilla/drivers/video/acornfb.c linux/drivers/video/acornfb.c
--- linux-2.3.10.vanilla/drivers/video/acornfb.c Thu Jun 17 10:11:35 1999
+++ linux/drivers/video/acornfb.c Sun Jul 11 19:29:45 1999
@@ -1739,7 +1739,7 @@

acornfb_init_fbinfo();

- for (opt = strtok(options, ","); opt; opt = strtok(NULL, ",")) {
+ for (opt = strsepe(&options, ","); opt; opt = strsepe(&options, ",")) {
if (!*opt)
continue;

diff -ru linux-2.3.10.vanilla/drivers/video/amifb.c linux/drivers/video/amifb.c
--- linux-2.3.10.vanilla/drivers/video/amifb.c Tue Jan 19 19:47:48 1999
+++ linux/drivers/video/amifb.c Sun Jul 11 19:35:30 1999
@@ -1208,7 +1208,6 @@
static void get_video_mode(const char *name);
static void check_default_mode(void);
static u_long chipalloc(u_long size);
-static char *strtoke(char *s,const char *ct);

/*
* Hardware routines
@@ -1271,7 +1270,7 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt; this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt; this_opt = strsepe(&options, ",")) {
char *p;

if (!strcmp(this_opt, "inverse")) {
@@ -1347,22 +1346,22 @@
* <H*> horizontal freq. in kHz
*/

- if (!(p = strtoke(mcap_spec, ";")) || !*p)
+ if (!(p = strsep(&mcap_spec, ";")) || !*p)
goto cap_invalid;
vmin = simple_strtoul(p, NULL, 10);
if (vmin <= 0)
goto cap_invalid;
- if (!(p = strtoke(NULL, ";")) || !*p)
+ if (!(p = strsep(&mcap_spec, ";")) || !*p)
goto cap_invalid;
vmax = simple_strtoul(p, NULL, 10);
if (vmax <= 0 || vmax <= vmin)
goto cap_invalid;
- if (!(p = strtoke(NULL, ";")) || !*p)
+ if (!(p = strsep(&mcap_spec, ";")) || !*p)
goto cap_invalid;
hmin = 1000 * simple_strtoul(p, NULL, 10);
if (hmin <= 0)
goto cap_invalid;
- if (!(p = strtoke(NULL, "")) || !*p)
+ if (!(p = strsep(&mcap_spec, "")) || !*p)
goto cap_invalid;
hmax = 1000 * simple_strtoul(p, NULL, 10);
if (hmax <= 0 || hmax <= hmin)
@@ -2101,29 +2100,6 @@
ptr = PAGE_ALIGN(ptr);

return ptr;
-}
-
- /*
- * A strtok which returns empty strings, too
- */
-
-__initfunc(static char *strtoke(char *s,const char *ct))
-{
- char *sbegin, *send;
- static char *ssave = NULL;
-
- sbegin = s ? s : ssave;
- if (!sbegin)
- return NULL;
- if (*sbegin == '\0') {
- ssave = NULL;
- return NULL;
- }
- send = strpbrk(sbegin, ct);
- if (send && *send != '\0')
- *send++ = '\0';
- ssave = send;
- return sbegin;
}

/* --------------------------- Hardware routines --------------------------- */
diff -ru linux-2.3.10.vanilla/drivers/video/atafb.c linux/drivers/video/atafb.c
--- linux-2.3.10.vanilla/drivers/video/atafb.c Thu Feb 25 19:02:11 1999
+++ linux/drivers/video/atafb.c Sun Jul 11 19:42:25 1999
@@ -2870,28 +2870,6 @@
MOD_INC_USE_COUNT;
}

-/* a strtok which returns empty strings, too */
-
-static char * strtoke(char * s,const char * ct)
-{
- char *sbegin, *send;
- static char *ssave = NULL;
-
- sbegin = s ? s : ssave;
- if (!sbegin) {
- return NULL;
- }
- if (*sbegin == '\0') {
- ssave = NULL;
- return NULL;
- }
- send = strpbrk(sbegin, ct);
- if (send && *send != '\0')
- *send++ = '\0';
- ssave = send;
- return sbegin;
-}
-
__initfunc(void atafb_setup( char *options, int *ints ))
{
char *this_opt;
@@ -2909,7 +2887,7 @@
if (!options || !*options)
return;

- for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+ for(this_opt=strsepe(&options,","); this_opt; this_opt=strsepe(&options,",")) {
if (!*this_opt) continue;
if ((temp=get_video_mode(this_opt)))
default_par=temp;
@@ -2966,18 +2944,18 @@
int xres;
char *p;

- if (!(p = strtoke(int_str, ";")) ||!*p) goto int_invalid;
+ if (!(p = strsep(&int_str, ";")) ||!*p) goto int_invalid;
xres = simple_strtoul(p, NULL, 10);
- if (!(p = strtoke(NULL, ";")) || !*p) goto int_invalid;
+ if (!(p = strsep(&int_str, ";")) || !*p) goto int_invalid;
sttt_xres=xres;
tt_yres=st_yres=simple_strtoul(p, NULL, 10);
- if ((p=strtoke(NULL, ";")) && *p) {
+ if ((p=strsep(&int_str, ";")) && *p) {
sttt_xres_virtual=simple_strtoul(p, NULL, 10);
}
- if ((p=strtoke(NULL, ";")) && *p) {
+ if ((p=strsep(&int_str, ";")) && *p) {
sttt_yres_virtual=simple_strtoul(p, NULL, 0);
}
- if ((p=strtoke(NULL, ";")) && *p) {
+ if ((p=strsep(&int_str, ";")) && *p) {
ovsc_offset=simple_strtoul(p, NULL, 0);
}

@@ -3003,20 +2981,20 @@
*
* Even xres_virtual is available, we neither support panning nor hw-scrolling!
*/
- if (!(p = strtoke(ext_str, ";")) ||!*p) goto ext_invalid;
+ if (!(p = strsep(&ext_str, ";")) ||!*p) goto ext_invalid;
xres_virtual = xres = simple_strtoul(p, NULL, 10);
if (xres <= 0) goto ext_invalid;

- if (!(p = strtoke(NULL, ";")) ||!*p) goto ext_invalid;
+ if (!(p = strsep(&ext_str, ";")) ||!*p) goto ext_invalid;
yres = simple_strtoul(p, NULL, 10);
if (yres <= 0) goto ext_invalid;

- if (!(p = strtoke(NULL, ";")) ||!*p) goto ext_invalid;
+ if (!(p = strsep(&ext_str, ";")) ||!*p) goto ext_invalid;
depth = simple_strtoul(p, NULL, 10);
if (depth != 1 && depth != 2 && depth != 4 && depth != 8 &&
depth != 16 && depth != 24) goto ext_invalid;

- if (!(p = strtoke(NULL, ";")) ||!*p) goto ext_invalid;
+ if (!(p = strsep(&ext_str, ";")) ||!*p) goto ext_invalid;
if (*p == 'i')
planes = FB_TYPE_INTERLEAVED_PLANES;
else if (*p == 'p')
@@ -3029,19 +3007,19 @@
goto ext_invalid;


- if (!(p = strtoke(NULL, ";")) ||!*p) goto ext_invalid;
+ if (!(p = strsep(&ext_str, ";")) ||!*p) goto ext_invalid;
addr = simple_strtoul(p, NULL, 0);

- if (!(p = strtoke(NULL, ";")) ||!*p)
+ if (!(p = strsep(&ext_str, ";")) ||!*p)
len = xres*yres*depth/8;
else
len = simple_strtoul(p, NULL, 0);

- if ((p = strtoke(NULL, ";")) && *p) {
+ if ((p = strsep(&ext_str, ";")) && *p) {
external_vgaiobase=simple_strtoul(p, NULL, 0);
}

- if ((p = strtoke(NULL, ";")) && *p) {
+ if ((p = strsep(&ext_str, ";")) && *p) {
external_bitspercol = simple_strtoul(p, NULL, 0);
if (external_bitspercol > 8)
external_bitspercol = 8;
@@ -3049,14 +3027,14 @@
external_bitspercol = 1;
}

- if ((p = strtoke(NULL, ";")) && *p) {
+ if ((p = strsep(&ext_str, ";")) && *p) {
if (!strcmp(p, "vga"))
external_card_type = IS_VGA;
if (!strcmp(p, "mv300"))
external_card_type = IS_MV300;
}

- if ((p = strtoke(NULL, ";")) && *p) {
+ if ((p = strsep(&ext_str, ";")) && *p) {
xres_virtual = simple_strtoul(p, NULL, 10);
if (xres_virtual < xres)
xres_virtual = xres;
@@ -3099,16 +3077,16 @@
* <V*> vertical freq. in Hz
* <H*> horizontal freq. in kHz
*/
- if (!(p = strtoke(mcap_spec, ";")) || !*p) goto cap_invalid;
+ if (!(p = strsep(&mcap_spec, ";")) || !*p) goto cap_invalid;
vmin = simple_strtoul(p, NULL, 10);
if (vmin <= 0) goto cap_invalid;
- if (!(p = strtoke(NULL, ";")) || !*p) goto cap_invalid;
+ if (!(p = strsep(&mcap_spec, ";")) || !*p) goto cap_invalid;
vmax = simple_strtoul(p, NULL, 10);
if (vmax <= 0 || vmax <= vmin) goto cap_invalid;
- if (!(p = strtoke(NULL, ";")) || !*p) goto cap_invalid;
+ if (!(p = strsep(&mcap_spec, ";")) || !*p) goto cap_invalid;
hmin = 1000 * simple_strtoul(p, NULL, 10);
if (hmin <= 0) goto cap_invalid;
- if (!(p = strtoke(NULL, "")) || !*p) goto cap_invalid;
+ if (!(p = strsep(&mcap_spec, "")) || !*p) goto cap_invalid;
hmax = 1000 * simple_strtoul(p, NULL, 10);
if (hmax <= 0 || hmax <= hmin) goto cap_invalid;

@@ -3127,11 +3105,11 @@
char *p;
int xres, yres, depth, temp;

- if (!(p = strtoke(user_mode, ";")) || !*p) goto user_invalid;
+ if (!(p = strsep(&user_mode, ";")) || !*p) goto user_invalid;
xres = simple_strtoul(p, NULL, 10);
- if (!(p = strtoke(NULL, ";")) || !*p) goto user_invalid;
+ if (!(p = strsep(&user_mode, ";")) || !*p) goto user_invalid;
yres = simple_strtoul(p, NULL, 10);
- if (!(p = strtoke(NULL, "")) || !*p) goto user_invalid;
+ if (!(p = strsep(&user_mode, "")) || !*p) goto user_invalid;
depth = simple_strtoul(p, NULL, 10);
if ((temp=get_video_mode("user0"))) {
default_par=temp;
diff -ru linux-2.3.10.vanilla/drivers/video/atyfb.c linux/drivers/video/atyfb.c
--- linux-2.3.10.vanilla/drivers/video/atyfb.c Wed Jun 9 23:44:25 1999
+++ linux/drivers/video/atyfb.c Sun Jul 11 19:44:01 1999
@@ -320,7 +320,6 @@
static struct aty_cursor *aty_init_cursor(struct fb_info_aty *fb);
#ifdef CONFIG_ATARI
static int store_video_par(char *videopar, unsigned char m64_num);
-static char *strtoke(char *s, const char *ct);
#endif

static void reset_engine(const struct fb_info_aty *info);
@@ -3187,8 +3186,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "font:", 5)) {
char *p;
int i;
@@ -3258,13 +3257,13 @@

printk("store_video_par() '%s' \n", video_str);

- if (!(p = strtoke(video_str, ";")) || !*p)
+ if (!(p = strsep(&video_str, ";")) || !*p)
goto mach64_invalid;
vmembase = simple_strtoul(p, NULL, 0);
- if (!(p = strtoke(NULL, ";")) || !*p)
+ if (!(p = strsep(&video_str, ";")) || !*p)
goto mach64_invalid;
size = simple_strtoul(p, NULL, 0);
- if (!(p = strtoke(NULL, ";")) || !*p)
+ if (!(p = strsep(&video_str, ";")) || !*p)
goto mach64_invalid;
guiregbase = simple_strtoul(p, NULL, 0);

@@ -3280,24 +3279,6 @@
return -1;
}

-__initfunc(static char *strtoke(char *s, const char *ct))
-{
- static char *ssave = NULL;
- char *sbegin, *send;
-
- sbegin = s ? s : ssave;
- if (!sbegin)
- return NULL;
- if (*sbegin == '\0') {
- ssave = NULL;
- return NULL;
- }
- send = strpbrk(sbegin, ct);
- if (send && *send != '\0')
- *send++ = '\0';
- ssave = send;
- return sbegin;
-}
#endif /* CONFIG_ATARI */

static int atyfbcon_switch(int con, struct fb_info *fb)
diff -ru linux-2.3.10.vanilla/drivers/video/clgenfb.c linux/drivers/video/clgenfb.c
--- linux-2.3.10.vanilla/drivers/video/clgenfb.c Thu Feb 25 19:02:11 1999
+++ linux/drivers/video/clgenfb.c Sun Jul 11 19:46:34 1999
@@ -1630,26 +1630,6 @@
}


-/* A strtok which returns empty strings, too */
-static char *strtoke(char *s,const char *ct)
-{
- char *sbegin, *send;
- static char *ssave = NULL;
-
- sbegin = s ? s : ssave;
- if (!sbegin)
- return NULL;
- if (*sbegin == '\0') {
- ssave = NULL;
- return NULL;
- }
- send = strpbrk(sbegin, ct);
- if (send && *send != '\0')
- *send++ = '\0';
- ssave = send;
- return sbegin;
-}
-
/*****************************************************************/
/* clgenfb_setup() might be used later for parsing possible */
/* arguments to the video= bootstrap parameter. Right now, there */
diff -ru linux-2.3.10.vanilla/drivers/video/controlfb.c linux/drivers/video/controlfb.c
--- linux-2.3.10.vanilla/drivers/video/controlfb.c Thu Feb 25 19:02:11 1999
+++ linux/drivers/video/controlfb.c Sun Jul 11 19:29:44 1999
@@ -1159,8 +1159,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "font:", 5)) {
char *p;
int i;
diff -ru linux-2.3.10.vanilla/drivers/video/cyberfb.c linux/drivers/video/cyberfb.c
--- linux-2.3.10.vanilla/drivers/video/cyberfb.c Tue Jan 19 19:47:48 1999
+++ linux/drivers/video/cyberfb.c Sun Jul 11 19:29:42 1999
@@ -1100,8 +1100,8 @@
return;
}

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strcmp(this_opt, "inverse")) {
Cyberfb_inverse = 1;
fb_invert_cmaps();
diff -ru linux-2.3.10.vanilla/drivers/video/fm2fb.c linux/drivers/video/fm2fb.c
--- linux-2.3.10.vanilla/drivers/video/fm2fb.c Thu Feb 25 19:02:12 1999
+++ linux/drivers/video/fm2fb.c Sun Jul 11 19:29:46 1999
@@ -473,8 +473,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "pal", 3))
fm2fb_mode = FM2FB_MODE_PAL;
else if (!strncmp(this_opt, "ntsc", 4))
diff -ru linux-2.3.10.vanilla/drivers/video/igafb.c linux/drivers/video/igafb.c
--- linux-2.3.10.vanilla/drivers/video/igafb.c Wed Jun 9 23:44:26 1999
+++ linux/drivers/video/igafb.c Sun Jul 11 19:29:45 1999
@@ -784,8 +784,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "font:", 5)) {
char *p;
int i;
diff -ru linux-2.3.10.vanilla/drivers/video/imsttfb.c linux/drivers/video/imsttfb.c
--- linux-2.3.10.vanilla/drivers/video/imsttfb.c Mon Dec 21 23:48:04 1998
+++ linux/drivers/video/imsttfb.c Sun Jul 11 19:29:44 1999
@@ -1977,8 +1977,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "font:", 5)) {
char *p;
int i;
diff -ru linux-2.3.10.vanilla/drivers/video/macfb.c linux/drivers/video/macfb.c
--- linux-2.3.10.vanilla/drivers/video/macfb.c Mon Dec 21 23:48:04 1998
+++ linux/drivers/video/macfb.c Sun Jul 11 19:29:43 1999
@@ -468,7 +468,7 @@
if (!options || !*options)
return;

- for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+ for(this_opt=strsepe(&options,","); this_opt; this_opt=strsepe(&options,",")) {
if (!*this_opt) continue;

if (! strcmp(this_opt, "inverse"))
diff -ru linux-2.3.10.vanilla/drivers/video/matroxfb.c linux/drivers/video/matroxfb.c
--- linux-2.3.10.vanilla/drivers/video/matroxfb.c Thu Apr 29 21:53:48 1999
+++ linux/drivers/video/matroxfb.c Sun Jul 11 19:29:46 1999
@@ -4903,7 +4903,7 @@
if (!options || !*options)
return;

- for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+ for(this_opt=strsepe(&options,","); this_opt; this_opt=strsepe(&options,",")) {
if (!*this_opt) continue;

dprintk("matroxfb_setup: option %s\n", this_opt);
diff -ru linux-2.3.10.vanilla/drivers/video/platinumfb.c linux/drivers/video/platinumfb.c
--- linux-2.3.10.vanilla/drivers/video/platinumfb.c Thu Oct 1 19:02:21 1998
+++ linux/drivers/video/platinumfb.c Sun Jul 11 19:29:44 1999
@@ -861,8 +861,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "font:", 5)) {
char *p;
int i;
diff -ru linux-2.3.10.vanilla/drivers/video/retz3fb.c linux/drivers/video/retz3fb.c
--- linux-2.3.10.vanilla/drivers/video/retz3fb.c Thu Feb 25 19:02:11 1999
+++ linux/drivers/video/retz3fb.c Sun Jul 11 19:29:43 1999
@@ -1414,8 +1414,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")){
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")){
if (!strcmp(this_opt, "inverse")) {
z3fb_inverse = 1;
fb_invert_cmaps();
diff -ru linux-2.3.10.vanilla/drivers/video/sgivwfb.c linux/drivers/video/sgivwfb.c
--- linux-2.3.10.vanilla/drivers/video/sgivwfb.c Fri Apr 16 17:20:23 1999
+++ linux/drivers/video/sgivwfb.c Sun Jul 11 19:29:46 1999
@@ -928,8 +928,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "font:", 5))
strcpy(fb_info.fontname, this_opt+5);
}
diff -ru linux-2.3.10.vanilla/drivers/video/tgafb.c linux/drivers/video/tgafb.c
--- linux-2.3.10.vanilla/drivers/video/tgafb.c Thu Jul 1 19:57:36 1999
+++ linux/drivers/video/tgafb.c Sun Jul 11 19:29:43 1999
@@ -1001,7 +1001,7 @@
int i;

if (options && *options)
- for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+ for(this_opt=strsepe(&options,","); this_opt; this_opt=strsepe(&options,",")) {
if (!*this_opt) continue;

if (!strncmp(this_opt, "font:", 5))
diff -ru linux-2.3.10.vanilla/drivers/video/valkyriefb.c linux/drivers/video/valkyriefb.c
--- linux-2.3.10.vanilla/drivers/video/valkyriefb.c Thu Oct 1 19:02:21 1998
+++ linux/drivers/video/valkyriefb.c Sun Jul 11 19:29:45 1999
@@ -855,8 +855,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "font:", 5)) {
char *p;
int i;
diff -ru linux-2.3.10.vanilla/drivers/video/vesafb.c linux/drivers/video/vesafb.c
--- linux-2.3.10.vanilla/drivers/video/vesafb.c Tue May 11 18:55:45 1999
+++ linux/drivers/video/vesafb.c Sun Jul 11 19:29:43 1999
@@ -480,7 +480,7 @@
if (!options || !*options)
return;

- for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+ for(this_opt=strsepe(&options,","); this_opt; this_opt=strsepe(&options,",")) {
if (!*this_opt) continue;

if (! strcmp(this_opt, "inverse"))
diff -ru linux-2.3.10.vanilla/drivers/video/vfb.c linux/drivers/video/vfb.c
--- linux-2.3.10.vanilla/drivers/video/vfb.c Thu Oct 1 19:02:21 1998
+++ linux/drivers/video/vfb.c Sun Jul 11 19:29:43 1999
@@ -417,8 +417,8 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt;
- this_opt = strtok(NULL, ",")) {
+ for (this_opt = strsepe(&options, ","); this_opt;
+ this_opt = strsepe(&options, ",")) {
if (!strncmp(this_opt, "font:", 5))
strcpy(fb_info.fontname, this_opt+5);
}
diff -ru linux-2.3.10.vanilla/drivers/video/vga16fb.c linux/drivers/video/vga16fb.c
--- linux-2.3.10.vanilla/drivers/video/vga16fb.c Thu May 27 01:55:40 1999
+++ linux/drivers/video/vga16fb.c Sun Jul 11 19:29:46 1999
@@ -808,7 +808,7 @@
if (!options || !*options)
return;

- for(this_opt=strtok(options,","); this_opt; this_opt=strtok(NULL,",")) {
+ for(this_opt=strsepe(&options,","); this_opt; this_opt=strsepe(&options,",")) {
if (!*this_opt) continue;

if (!strncmp(this_opt, "font:", 5))
diff -ru linux-2.3.10.vanilla/drivers/video/virgefb.c linux/drivers/video/virgefb.c
--- linux-2.3.10.vanilla/drivers/video/virgefb.c Thu Feb 25 19:02:11 1999
+++ linux/drivers/video/virgefb.c Sun Jul 11 19:29:45 1999
@@ -1096,7 +1096,7 @@
if (!options || !*options)
return;

- for (this_opt = strtok(options, ","); this_opt; this_opt = strtok(NULL, ","))
+ for (this_opt = strsepe(&options, ","); this_opt; this_opt = strsepe(&options, ","))
if (!strcmp(this_opt, "inverse")) {
Cyberfb_inverse = 1;
fb_invert_cmaps();
diff -ru linux-2.3.10.vanilla/fs/adfs/super.c linux/fs/adfs/super.c
--- linux-2.3.10.vanilla/fs/adfs/super.c Tue Jun 8 19:47:58 1999
+++ linux/fs/adfs/super.c Sun Jul 11 19:28:28 1999
@@ -114,7 +114,7 @@
if (!options)
return 0;

- for (opt = strtok(options, ","); opt != NULL; opt = strtok(NULL, ",")) {
+ for (opt = strsepe(&options, ","); opt != NULL; opt = strsepe(&options, ",")) {
value = strchr(opt, '=');
if (value)
*value++ = '\0';
diff -ru linux-2.3.10.vanilla/fs/affs/super.c linux/fs/affs/super.c
--- linux-2.3.10.vanilla/fs/affs/super.c Tue Jun 8 19:47:58 1999
+++ linux/fs/affs/super.c Sun Jul 11 19:28:26 1999
@@ -128,7 +128,7 @@
*mount_opts = 0;
if (!options)
return 1;
- for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
+ for (this_char = strsepe(&options,","); this_char; this_char = strsepe(&options,",")) {
f = 0;
if ((value = strchr(this_char,'=')) != NULL)
*value++ = 0;
diff -ru linux-2.3.10.vanilla/fs/autofs/inode.c linux/fs/autofs/inode.c
--- linux-2.3.10.vanilla/fs/autofs/inode.c Tue Jun 8 19:47:58 1999
+++ linux/fs/autofs/inode.c Sun Jul 11 19:28:26 1999
@@ -84,7 +84,7 @@
*pipefd = -1;

if ( !options ) return 1;
- for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
+ for (this_char = strsepe(&options,","); this_char; this_char = strsepe(&options,",")) {
if ((value = strchr(this_char,'=')) != NULL)
*value++ = 0;
if (!strcmp(this_char,"fd")) {
diff -ru linux-2.3.10.vanilla/fs/devpts/inode.c linux/fs/devpts/inode.c
--- linux-2.3.10.vanilla/fs/devpts/inode.c Tue Jun 8 19:47:58 1999
+++ linux/fs/devpts/inode.c Sun Jul 11 19:28:29 1999
@@ -85,8 +85,8 @@

this_char = NULL;
if ( options )
- this_char = strtok(options,",");
- for ( ; this_char; this_char = strtok(NULL,",")) {
+ this_char = strsepe(&options,",");
+ for ( ; this_char; this_char = strsepe(&options,",")) {
if ((value = strchr(this_char,'=')) != NULL)
*value++ = 0;
if (!strcmp(this_char,"uid")) {
diff -ru linux-2.3.10.vanilla/fs/ext2/super.c linux/fs/ext2/super.c
--- linux-2.3.10.vanilla/fs/ext2/super.c Tue Jun 8 19:47:58 1999
+++ linux/fs/ext2/super.c Sun Jul 11 19:28:23 1999
@@ -153,9 +153,9 @@

if (!options)
return 1;
- for (this_char = strtok (options, ",");
+ for (this_char = strsepe (&options, ",");
this_char != NULL;
- this_char = strtok (NULL, ",")) {
+ this_char = strsepe (&options, ",")) {
if ((value = strchr (this_char, '=')) != NULL)
*value++ = 0;
if (!strcmp (this_char, "bsddf"))
diff -ru linux-2.3.10.vanilla/fs/fat/inode.c linux/fs/fat/inode.c
--- linux-2.3.10.vanilla/fs/fat/inode.c Tue Jun 8 19:47:58 1999
+++ linux/fs/fat/inode.c Sun Jul 11 19:28:25 1999
@@ -223,8 +223,8 @@
goto out;
save = 0;
savep = NULL;
- for (this_char = strtok(options,","); this_char;
- this_char = strtok(NULL,",")) {
+ for (this_char = strsepe(&options,","); this_char;
+ this_char = strsepe(&options,",")) {
if ((value = strchr(this_char,'=')) != NULL) {
save = *value;
savep = value;
diff -ru linux-2.3.10.vanilla/fs/hfs/super.c linux/fs/hfs/super.c
--- linux-2.3.10.vanilla/fs/hfs/super.c Tue Jun 8 19:47:58 1999
+++ linux/fs/hfs/super.c Sun Jul 11 19:28:28 1999
@@ -193,8 +193,8 @@
if (!options) {
goto done;
}
- for (this_char = strtok(options,","); this_char;
- this_char = strtok(NULL,",")) {
+ for (this_char = strsepe(&options,","); this_char;
+ this_char = strsepe(&options,",")) {
if ((value = strchr(this_char,'=')) != NULL) {
*value++ = 0;
}
diff -ru linux-2.3.10.vanilla/fs/hpfs/super.c linux/fs/hpfs/super.c
--- linux-2.3.10.vanilla/fs/hpfs/super.c Sun Jun 27 19:10:41 1999
+++ linux/fs/hpfs/super.c Sun Jul 11 19:28:24 1999
@@ -184,7 +184,7 @@

/*printk("Parsing opts: '%s'\n",opts);*/

- for (p = strtok(opts, ","); p != 0; p = strtok(0, ",")) {
+ for (p = strsepe(&opts, ","); p != 0; p = strsepe(&opts, ",")) {
if ((rhs = strchr(p, '=')) != 0)
*rhs++ = '\0';
if (!strcmp(p, "help")) return 2;
diff -ru linux-2.3.10.vanilla/fs/isofs/inode.c linux/fs/isofs/inode.c
--- linux-2.3.10.vanilla/fs/isofs/inode.c Sun Jun 27 19:10:41 1999
+++ linux/fs/isofs/inode.c Sun Jul 11 19:28:22 1999
@@ -304,7 +304,7 @@
popt->session=-1;
popt->sbsector=-1;
if (!options) return 1;
- for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
+ for (this_char = strsepe(&options,","); this_char; this_char = strsepe(&options,",")) {
if (strncmp(this_char,"norock",6) == 0) {
popt->rock = 'n';
continue;
diff -ru linux-2.3.10.vanilla/fs/nfs/nfsroot.c linux/fs/nfs/nfsroot.c
--- linux-2.3.10.vanilla/fs/nfs/nfsroot.c Fri Apr 24 03:12:21 1998
+++ linux/fs/nfs/nfsroot.c Sun Jul 11 19:28:22 1999
@@ -189,7 +189,7 @@

if ((options = strchr(name, ','))) {
*options++ = 0;
- cp = strtok(options, ",");
+ cp = strsepe(&options, ",");
while (cp) {
if ((val = strchr(cp, '='))) {
struct nfs_int_opts *opts = root_int_opts;
@@ -207,7 +207,7 @@
nfs_data.flags |= opts->or_mask;
}
}
- cp = strtok(NULL, ",");
+ cp = strsepe(&options, ",");
}
}
if (name[0] && strcmp(name, "default")) {
diff -ru linux-2.3.10.vanilla/fs/ntfs/fs.c linux/fs/ntfs/fs.c
--- linux-2.3.10.vanilla/fs/ntfs/fs.c Sun Jun 27 19:10:41 1999
+++ linux/fs/ntfs/fs.c Sun Jul 11 19:28:28 1999
@@ -283,7 +283,7 @@
vol->nct=0;
if(!opt)goto done;

- for(opt = strtok(opt,",");opt;opt=strtok(NULL,","))
+ for(opt = strsepe(&opt,",");opt;opt=strsepe(&opt,","))
{
if ((value = strchr(opt, '=')) != NULL)
*value++='\0';
diff -ru linux-2.3.10.vanilla/fs/proc/inode.c linux/fs/proc/inode.c
--- linux-2.3.10.vanilla/fs/proc/inode.c Sun Jul 4 19:18:52 1999
+++ linux/fs/proc/inode.c Sun Jul 11 19:28:21 1999
@@ -120,7 +120,7 @@
*uid = current->uid;
*gid = current->gid;
if (!options) return 1;
- for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
+ for (this_char = strsepe(&options,","); this_char; this_char = strsepe(&options,",")) {
if ((value = strchr(this_char,'=')) != NULL)
*value++ = 0;
if (!strcmp(this_char,"uid")) {
diff -ru linux-2.3.10.vanilla/fs/ufs/super.c linux/fs/ufs/super.c
--- linux-2.3.10.vanilla/fs/ufs/super.c Thu Jul 1 19:45:57 1999
+++ linux/fs/ufs/super.c Sun Jul 11 19:28:25 1999
@@ -255,9 +255,9 @@
if (!options)
return 1;

- for (this_char = strtok (options, ",");
+ for (this_char = strsepe (&options, ",");
this_char != NULL;
- this_char = strtok (NULL, ",")) {
+ this_char = strsepe (&options, ",")) {

if ((value = strchr (this_char, '=')) != NULL)
*value++ = 0;
diff -ru linux-2.3.10.vanilla/fs/vfat/namei.c linux/fs/vfat/namei.c
--- linux-2.3.10.vanilla/fs/vfat/namei.c Sun Jun 27 19:10:41 1999
+++ linux/fs/vfat/namei.c Sun Jul 11 19:28:25 1999
@@ -125,7 +125,7 @@
save = 0;
savep = NULL;
ret = 1;
- for (this_char = strtok(options,","); this_char; this_char = strtok(NULL,",")) {
+ for (this_char = strsepe(&options,","); this_char; this_char = strsepe(&options,",")) {
if ((value = strchr(this_char,'=')) != NULL) {
save = *value;
savep = value;

-- 
Feel the power of the penguin - run linux@your.pc
<esc>:x

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/