Questions regarding regexp module
Daniel Jour <[email protected]>
| Newsgroups | gmane.lisp.clisp.devel |
|---|---|
| Message-ID | <CACZHyTN3ofyj86c_d2LzeL39=eccGtzKAjybZfnku0SwR+JoPA@mail.gmail.com> |
I'm currently working on the regexp module (I'm still here in case
anyone wondered). I've a few questions / suggestions:
I think it would be good to have regexp-exec fail when there are more
matches than the number of possible return values and it was specified
to return the matches as multiple values. Currently, regexp-exec then
just returns the results as a list:
// ...
switch (rettype) {
case ret_values:
if (re_count < fixnum_to_V(Symbol_value(S(multiple_values_limit)))) {
STACK_to_mv(re_count);
break;
} /* else FALLTHROUGH */
case ret_list: VALUES1(listof(re_count)); break;
// ...
This could lead to surprises, when e.g. calling:
(multiple-value-list (match some-pattern some-string))
When match returns multiple values, one get's a list with the
matches. But when - because of a different pattern - there are more
matches then suddenly this returns a list with the list of matches,
which could confuse code using the result. It's probably not that
critical as one needs to have a pattern with 127 sub-expressions
or more, though.
Next, currently regex-compile returns a foreign-pointer, and
regex-exec expects a foreign pointer. Thus I could supply regexp-exec
with a foreign pointer acquire from some other function, resulting in
undefined behavior (because regexp-exec blindly assumes it to be a
regex_t * ). AFAIK the policy for CLISP is to not just crash on such
errors. As solution, I'd wrap the foreign pointer in a (defstruct
pattern pointer). Are there any objections against this?
------------------------------------------------------------------------------
What NetFlow Analyzer can do for you? Monitors network bandwidth and traffic
patterns at an interface-level. Reveals which users, apps, and protocols are
consuming the most bandwidth. Provides multi-vendor support for NetFlow,
J-Flow, sFlow and other flows. Make informed decisions using capacity planning
reports. http://sdm.link/zohomanageengine
_______________________________________________
clisp-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-devel