[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [glob2-devel] :/ i was evil
From: |
Stéphane Magnenat |
Subject: |
Re: [glob2-devel] :/ i was evil |
Date: |
Sun, 8 Jan 2006 17:14:12 +0100 |
User-agent: |
KMail/1.9.1 |
On Saturday 07 January 2006 02:12, Leo Wandersleb wrote:
> hi guys
>
> nct just told me i had removed a needed line and left irc
> before i could answer.
> compiler told me the line was not needed. sorry for
> believing my compiler :((
>
> IRC.cpp:280: strtok(NULL, " =");
>
> but what are the required side-effects? Again: I feel
> terribly sorry to have caused confusion, but i'd like to know.
man strtok ;-)
More seriously, strtok, when called with a non NULL first parameter, take this
string and return the first token, by adding a trailing 0 at the end of the
token (so in the middle of the input string). When called with NULL, it
continues on the same input string, returning the next token, and put a
trailing 0 at the end of the token (so probably still in the middle of the
input string). So if you remove a strtok, the next strtok will not return the
same token.
This sad, strtok is a bad function because of this side effect thing. It is
thus also non thread-safe.
Steph
--
http://nct.ysagoon.com