https://bugs.exim.org/show_bug.cgi?id=2673

            Bug ID: 2673
           Summary: Regex cannot be compiled if source compiled with
                    std=c18
           Product: PCRE
           Version: 10.33 (PCRE2)
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: bug
          Priority: medium
         Component: Code
          Assignee: philip.ha...@gmail.com
          Reporter: shif...@nanotek.info
                CC: pcre-dev@exim.org

Hi,

I'm using a regex that do not work if I compile with the latest C version
(c18). I used the following example:

http://pcre.org/current/doc/html/pcre2demo.html

With the following regex:

"^((?<scheme>[^:/?#]+):)?(?<authority>//(((?<userinfo>[^/?#]*)@)?(?<host>[^/?#:]*)(?:(?<port>[^/?#]*))?))?(?<path>[^?#]*)(\?(?<query>[^#]*))?(#(?<fragment>.*))?"

If compiled with gnu11 I modified the regex as below:

static const char pattern[] =
R"("^((?<scheme>[^:/?#]+):)?(?<authority>//(((?<userinfo>[^/?#]*)@)?(?<host>[^/?#:]*)(?:(?<port>[^/?#]*))?))?(?<path>[^?#]*)(\?(?<query>[^#]*))?(#(?<fragment>.*))?)";

( R"()" ) <- for raw string.

And then I build the source:

$ gcc test.c `pkg-config --libs --cflags libpcre2-8` -o test 

Everything works fine.

But when using c18 as below I got an error for the exact same regex:

static const char pattern[] =
"^((?<scheme>[^:/?#]+):)?(?<authority>//(((?<userinfo>[^/?#]*)@)?(?<host>[^/?#:]*)(?:(?<port>[^/?#]*))?))?(?<path>[^?#]*)(\?(?<query>[^#]*))?(#(?<fragment>.*))?";

$ gcc -std=c18 test.c `pkg-config --libs --cflags libpcre2-8` -o test
$ ./test
PCRE2 compilation failed at offset 122: assertion expected after (?( or (?(?C)

is there any workaround ?

Thx

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-- 
## List details at https://lists.exim.org/mailman/listinfo/pcre-dev 

Reply via email to