Repository navigation
Conversation
| #include "re1.5/re1.5.h" | ||
|
|
||
| #define FLAG_DEBUG 0x1000 | ||
| #define FLAG_IGNORECASE 0x0100 |
There was a problem hiding this comment.
@dmazzella it looks like IGNORECASE is not used. Do you use it in any of your scripts?
| group = ++repl_p; | ||
|
|
||
| if (*group != 0 && *group == 'g') { | ||
| // search group with syntax "\g<number>" |
There was a problem hiding this comment.
@dmazzella is there a need to provide support for both "\g<number>" and "\number"? Surely only one format is needed?
| if (n_args > 3) { | ||
| count = mp_obj_get_int(args[3]); | ||
| if (n_args > 4) { | ||
| flags = mp_obj_get_int(args[4]); |
There was a problem hiding this comment.
@dmazzella FYI I removed the keyword argument handling from this function and just made count and flags optionally positional args.
|
Thanks for the feedback @dmazzella . I updated this PR with your suggested changes. Except, I didn't remove the So "g" is more general than just a plain integer, but for most cases a plain integer is enough and you don't want tho hassle of writing out the "g" and the angle brackets. Maybe there is a way to allow both with minimal code size... |
If add this check at https://github.com/dpgeorge/micropython/blob/36f45ced8608822b8c22ea6907e52bb4658a6596/extmod/modure.c#L345: fix |
|
Hi Damian, the special |
Yes. But for now I just wanted to simplify the existing code to make it more compact, without changing the functionality (at least not changing it too much).
I'm not sure we can support octal number escapes here... |
|
Hi Damien, this patch octal_number_support.zip implements all needs by: |
|
this is a little test for these features: the output for upy and cpy are identicals. |
|
Hi @dpgeorge, |
I had a look at it, the patch that adds support for octal numbers. There's quite a lot of code added for this feature which is probably rarely used. And you can already achieve the same thing (inserting arbitrary bytes) by using the non-r form of a string. For example, if you want to do this: re.sub(r'(123)', r'456\072\1', 'abc123def')then you can instead write it like this, which doesn't require support for interpreting octals in the regex code: re.sub(r'(123)', '456\072\\1', 'abc123def')(note the subtle change: "r" is gone in the 2nd string and there's a double backslash before the "1") So I'd say we shouldn't add octal support, to keep code size down. |
39d62ff to
b5b0c20
Compare
|
@dpgeorge the only modification i can suggest is that the special |
In what way do you mean? At the moment |
Total size increase for all new ure features is now:
bare-arm: +0
minimal x86: +0
unix x64: +2048 [incl +320(data)]
unix nanbox: +2068 [incl +160(data)]
stm32: +852
cc3200: +768
esp8266: +1132
esp32: +844 [incl +152(data)]
8c87f0d to
41db665
Compare
something like that: for test: the output in cPy: the output in uPy: or removing: the output in uPy: |
|
with the current implementation there is a problem of "Segmentation fault" in the construction of the number from the string. with a group like: to avoid this I suggest adding control over the maximum of acceptable groups (99) like this: cPy: in uPy we can add: |
I don't think there's a need to support
Thanks for pointing this out, I've now fixed it in the latest set of commits in this PR. Simplest solution was to make |
|
I have tried this but the error differ from cPy and uPy. cPy refer to group number 19 use of something like: produce the same group number. |
|
4294967295 is 0xffffffff |
IMO that's not an issue. At least uPy raises an error in this case, and doesn't error out when there's not an error. |
|
I further optimised this set of commits for space and heap usage, updated docs, and merged in 1f86460 through 4727bd1 Thanks @dmazzella for the original patch for these features! |
Use $(PYTHON3) instead of $(PYTHON) in make actions
Original patch provided by @dmazzella, see #3770. A few code-size reductions have been applied to that patch.
Code size increase when enable all features is roughly 3000 bytes for unix and 1200 bytes for bare-metal ports.