lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> On Mon, 12 Nov 2001, Philippe Lhoste wrote:
> > I wrote, in an answer to Volkan Civelek:
> > > [...]
> > > A way to get the result you expect is to rewrite the tinsert function
> > > follow:
> > > [...]
> > > "size", it becomes the new size. Works at least with your code, I
> > tested it
> > > thoroughly....
> >
> > Neither Roberto nor Luiz reacted to my post. So I ask again: is my
> > correction completely stupid, or just outside the definition of tinsert?
> > Do you think tinsert function should be improved along the line of my
> > suggestion, or just the documentation improved to handle Volkan's case?
> Sorry about the silence. Probably we will correct tinsert along these
> -- Roberto

No problem, and thank you for the answer.
I just wanted to be sure my mail didn't went unnoticed, in case it would be
useful, or in case I was off base :-)
Since I didn't saw this changed in the latest beta file... But I understand
you still a lot of work to do on this version.

Thank you for your support and hard work!

PS.: while I am here... What you (ML users) think of a C library function,
tentatively named strfindoneof, which will try and find the first occurence of
one of several strings in a given string?
More precisely, it would be something like:
strfindoneof(s, init, "for", "while", "if") or strfindoneof(s, init, {
"for", "while", "if" }, "end").

It will search in s the first keyword from the list it meets. It would be
plain, RE in this case would be overkill and probably not useful. I am aware
that using a RE library (Reuben's rexlib?) with alternation (if I recall
correctly) would give a similar result, but with a lot of overhead.

I can do it is Lua, but I fear that iterating on a string with strsub
comparisons, or doing multiple strfind and taking the lower position would be quite
costly. But I have to benchmark these to be sure.
This function would be useful to parse strings, eg. for a lexer (syntax
highlighting) or for quoted CSV, etc.


Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist

Sent through GMX FreeMail -