Re: strtok
- Posted by Christian.CUVIER at agriculture.gouv.fr Jun 10, 2003
- 453 views
> From: gertie at visionsix.com > Subject: strtok > > > Anyone using strtok v2 should upgrade to v2.1 asap. I was running an app > that used v2, and it was missing random data in parse(). I changed to v2.1 > and experience no problems. > > Kat Actually, this answers another recent post about strtok. Why don't these generic text/sequence handling routines get too much attention? I think EuRegExp got even less feedback. My tentative answer is: actually, these routines are very powerful, since you can do about everything with them putting the right params in it. And most people, including myself, find it easier to code their own stuff for the specific need they have. For instance: I needed to separate off the args of a generic routine call. Including ugly things like: MyProc({3,5,s2},sort(f(x,y)),(x=0)) Just parsing on ',' doesn't help, right? So I devised a level function (seq=level(sequence source, atom open_del,atom close_del) to get the parentheses and brace nesting level of all chars in source sequence, and a split function which parses for ',' in the 0-level part of source and returns tokens of original string (seq=split(sequence to_parse,sequence on_what, sequence token_source). to_parse and token_source must have the same length. The return is a sequence of {token,start_pos}. Could I do it using strtok? Likely, given its genericity and sheer power, but for this I'd need to study the docs to find the right combination, and possibly have to understand your code. That's an overhead compared to writing my own routines (they didn't take too long to debug). Just my own experience. Some people may just feel it the other way. CChris