Closed
Bug 106372
Opened 24 years ago
Closed 24 years ago
Need PR_strtok_r()
Categories
(NSPR :: NSPR, enhancement, P1)
Tracking
(Not tracked)
RESOLVED
FIXED
4.2
People
(Reporter: roland.mainz, Assigned: roland.mainz)
References
Details
Attachments
(1 file, 1 obsolete file)
6.62 KB,
patch
|
roland.mainz
:
review+
|
Details | Diff | Splinter Review |
We _urgendly_ need a NSPR version of strtok_r().
Some code already uses strtok_r() and strtok().
But the first one is not available on all platforms we support (per cls) and the
2nd one (strtok()) should be avoided in multithreaded apps. as it is not
thread-safe on all platforms.
Patch in bug 100069 has a version of strtok_r(). Just grab it and rename it to
PR_strtok_r() ... :-)
Updated•24 years ago
|
Severity: critical → enhancement
Status: NEW → ASSIGNED
Comment 1•24 years ago
|
||
I just found out today that xpcom/ds/nsCRT.cpp has a supposedly threadsafe
version of strtok. You might want to try it.
Assignee | ||
Comment 2•24 years ago
|
||
1. |strtok()| does not help because I use strtok_r() in a "nested way"
(|for|-loop using strtok_r() which calls function which itself uses strtok_r()).
|strtok()| won't help... see [3]
2. The function sits in XPCOM, not in NSPR. I think it would be very usefull to
have POSIX-like |strtok_r()| in NSPR (use own if OS does not provide one - but
use the OS version if present).
3. It looks that xpcom/ds/nsCRT.cpp#nsCRT::strtok() is a completly different
beast than POSIX strtok_r() (just looking at comments like "Unlike regular
strtok, the first argument cannot be null." and "too many delimiters"... ewww...
;-( ).
Assignee | ||
Updated•24 years ago
|
Assignee | ||
Comment 3•24 years ago
|
||
Stealing this from wtc...
Assignee: wtc → Roland.Mainz
Status: ASSIGNED → NEW
Comment 5•24 years ago
|
||
This should be added to mozilla/nsprpub/lib/libc.
The function should use the PL_ prefix, that is,
it should be renamed PL_strtok_r().
If PL_strtok_r calls strtok_r where strtok_r is
present, PL_strtok_r may need to have the same
signature as strtok_r (in parcular, with respect
to the use of const) for the best performance.
char *strtok_r(char *s, const char *sep, char **lasts);
Assignee | ||
Comment 6•24 years ago
|
||
Assignee | ||
Comment 7•24 years ago
|
||
> This should be added to mozilla/nsprpub/lib/libc.
> The function should use the PL_ prefix, that is,
> it should be renamed PL_strtok_r().
Done, see patch.
> If PL_strtok_r calls strtok_r where strtok_r is
> present, PL_strtok_r may need to have the same
> signature as strtok_r (in parcular, with respect
> to the use of const) for the best performance
I would prefer a simple |#define PL_foobar(arg1, arg2) foobar(arg1, arg2)| to
save the function call overhead (for example I _hate_ X.org code which wastes a
lot of time in such wrapper code).
However, the whole "use native function if OS has it" can be done in a later
step...
----
Requesting r=/sr= ...
Comment 8•24 years ago
|
||
cc'ing a potential nspr reviewer.
Assignee | ||
Comment 9•24 years ago
|
||
cc'ing some potential nspr reviewers.
Updated•24 years ago
|
Attachment #55285 -
Attachment is obsolete: true
Attachment #55285 -
Flags: needs-work+
Comment 10•24 years ago
|
||
Comment 11•24 years ago
|
||
Roland, I edited your patch to indent by four spaces,
avoid the goto statement, and use for loops. I also
added comments in plstr.h to document the new function
and added a test case for PL_strtok_r.
Assignee | ||
Comment 12•24 years ago
|
||
Comment on attachment 55868 [details] [diff] [review]
Roland Mainz's patch, edited, added comments and a test.
Thanks for the new patch... :-)
r=Roland.Mainz@informatik.med.uni-giessen.de
Attachment #55868 -
Flags: review+
Assignee | ||
Comment 13•24 years ago
|
||
wtc:
Wanna check this in for me, please ?
I do not have CVS checkin permission ....
Comment 14•24 years ago
|
||
Roland, I will try to do that later today.
This bug won't be marked fixed until I find
someone to help me add the new file to the
Mac project file.
Comment 15•24 years ago
|
||
I checked in my patch (with minor editing) on the tip
of NSPRPUB_PRE_4_2_CLIENT_BRANCH of NSPR.
Simon, could you please add mozilla/nsprpub/lib/libc/src/strtok.c
to NSPR's Mac project file on the NSPRPUB_PRE_4_2_CLIENT_BRANCH?
Priority: -- → P1
Target Milestone: --- → 4.2
Comment 16•24 years ago
|
||
Sorry, I meant to say
I checked in my patch (with minor editing) on the tip
and the NSPRPUB_PRE_4_2_CLIENT_BRANCH of NSPR.
^^^
Comment 17•24 years ago
|
||
Done. So I should do the mac project on the NSPR tip too?
Comment 18•24 years ago
|
||
Simon Fraser wrote:
> So I should do the mac project on the NSPR tip too?
Yes, please. I did not dare to ask because I could
copy the file to the NSPR tip and check it in.
Thanks! :-)
Comment 19•24 years ago
|
||
Mac project fixed on the NSPR tip.
Comment 20•24 years ago
|
||
Marked the bug fixed.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 21•24 years ago
|
||
Filed bug 109177 as a follow-up to kill the |strtok()|-clones from the tree and
replace them all with |PL_strtok_r()| ...
You need to log in
before you can comment on or make changes to this bug.
Description
•