One of C's less frequently used features is automatic string literal
concatenation. The expression
"AB" "cd"
will be compiled as
"ABcd"
as long as the components (could be more than two) are separated only by white
space.
So if the problem really is related to line length (your line has 74
characters), you could break it up into as many shorter literals as you like
with each on a new line (and even indented for easier reading).
> -----Original Message-----
> From: IBM Mainframe Discussion List <[email protected]> On
> Behalf Of Kirk Wolf
> Sent: Monday, October 05, 2020 8:41 AM
> To: [email protected]
> Subject: C RTL regcomp() fails with more than 9 (groups)
>
> Can be demonstrated with the following test program. This works fine with
> regcomp() on linux and other RE platforms (PCRE, javascript, python, etc).
>
> /* test regcomp with more than 9 (groups).
> On z/OS V2R3, fails with:
> Invalid regular expression '...' - (rc=8) \( \) or ( ) imbalance
>
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <regex.h>
>
> int main(int argc, char** argv) {
>
> int failed = 0;
> char buf[100];
> regex_t rx;
> const char* testRE =
> "(^a1$)|(^a2$)|(^a3$)|(^a4$)|(^a5$)|(^a6$)|(^a7$)|(^a8$)|(^a9$)|(^a10$)";
> int rc = regcomp(&rx, testRE, REG_EXTENDED | REG_NOSUB);
> if (rc) {
> regerror(rc, &rx, buf, sizeof(buf));
> fprintf(stderr, "Invalid regular expression '%s' - (rc=%d) %s\n",
> testRE, rc, buf);
> failed = 1;
> }
> return failed;
> }
>
> Switching to BREs, doesn't help. Something probably didn't fit in 80 bytes
> :-)
> Really sucks.
>
> Kirk Wolf
> Dovetailed Technologies
> http://dovetail.com
>
> PS> I can find no documented limit of "9" groups here:
> https://pubs.opengroup.org/onlinepubs/007904875/basedefs/xbd_chap09.html
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN