no PCRE_* constants

Q&A's, tips, howto's
Locked
conan
Posts: 52
Joined: Sat Oct 22, 2011 12:14 pm

no PCRE_* constants

Post by conan »

I found this topic:

http://newlispfanclub.alh.net/forum/vie ... =PCRE_UTF8

But, I tested both v10.3.3 and v.10.3.6 by doing:

./configure && make -f makefile_linuxLP64_utf8

and I got:

Code: Select all

$ ./newlisp -e '(replace { } " x x x " {-} 0x8000)'
"-x x x "
$ ./newlisp -e '(replace { } " x x x " {-} REPLACE_ONCE)'

ERR: value expected in function replace : REPLACE_ONCE
Also, shouldn't be REPLACE_ONCE and PRECOMPILED constants names better be prefixed with PCRE_ like the rest?

I hope it's ok to report this in this section, I didn't found any "bug reports" section.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: no PCRE_* constants

Post by Lutz »

REPLACE_ONCE and PRECOMPILED are both added by newLISP. The others starting with PCR_ are used in the PCRE documentation: http://www.newlisp.org/downloads/pcrepattern.html

These constants are not built in and when used, they often get combined using a bit-or '|'. Many people use the numbers instead of the PCRE defined symbols.

There are not used that frequently that they should be pre defined in the newLISP executable. Decisions like that keep newLISP small.

If you find bugs, just post them here. Then everybody knows about it. If serious bugs are found in the stable release, they are sometimes announced on a special page on newlisp.org.

conan
Posts: 52
Joined: Sat Oct 22, 2011 12:14 pm

Re: no PCRE_* constants

Post by conan »

Sorry about the fuss then, I shouldn't wave the bug-flag so carelessly.

I misunderstood this statement: "The following constants can be used for int-option" in http://www.newlisp.org/downloads/newlis ... html#regex , just above the table a couple of pages below the anchor.

I thought I could use them like this:

Code: Select all

(replace {x} " x X x " {y} (| PCRE_CASELESS REPLACE_ONCE))
instead of having to do:

Code: Select all

(replace {x} " x X x " {y} (| 1 0x800))
Many people use the numbers instead of the PCRE defined symbols.
There are not used that frequently that they should be pre defined in the newLISP executable. Decisions like that keep newLISP small.
I fully support not bloating newlisp. However I believe it's considered good practice to code like the first snippet. If asked, I'll vote for adding the constants, although I don't know the cost, they add clarity.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Re: no PCRE_* constants

Post by Lutz »

I agree that using pre-defined constants makes for much better readability and maintainability of source code. You could pre-define constants either in your program or put them in $HOME/.init.lsp

Locked