On 7/29/2015 19:40, Kyle Huey wrote:
On Wed, Jul 29, 2015 at 7:15 AM, Honza Bambas <hbam...@mozilla.com> wrote:
I've recently introduced a class making parsing string inputs much safer and
simpler. Please see xpcom/ds/Tokenizer.h. It's simplification of a lexical
analyzer and it successfully hides boundary checks on the input buffer from
consumers. From now on this simple parser class should be used instead of
any complicated strstr/strchr/Find/Substring unreadable and dangerous
constructions.
Tokenizer is simply constructed with a string. It then automatically cuts
and converts the input for you to words, numbers, white spaces and special
characters as you read it, be it a simple while loop or a complex recursive
descent.
For details and examples see my post at
http://www.janbambas.cz/string-parsing-made-simple-with-mozillatokenizer/
It's brand new, any suggestions on its API greatly welcomed :)
Cheers
-hb-
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform
Can we rewrite nsCharSeparatedTokenizer on top of this?
Hmm.. we definitely could, nsCharSeparatedTokenizer would then become
just an adapter over Tokenizer. nsCharSeparatedTokenizer seems to be
widely used, that prevents me from saying "let's convert all places to
use Tokenizer". That seems like a bigger task. nsCharSeparatedTokenizer
is simpler with simpler (but IMO not perfect) API. Hence the migration
might end up with a more complicated code. I'll go through it case by
case quickly and see. Filed
https://bugzilla.mozilla.org/show_bug.cgi?id=1188991 on it.
-hb-
- Kyle
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform