This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Regex: Will re_nsub be zero if REG_NOSUB was passed to regcomp?
- From: "frank ernest" <doark at mail dot com>
- To: libc-help at sourceware dot org
- Date: Fri, 22 Aug 2014 05:30:56 +0200
- Subject: Re: Regex: Will re_nsub be zero if REG_NOSUB was passed to regcomp?
- Authentication-results: sourceware.org; auth=none
- Sensitivity: Normal
>> Regex: Will re_nsub be zero if REG_NOSUB was passed to regcomp?
>
> From a programming portability perspective, the value of re_nsub in this
> case could be either zero or the number of subexpressions, or anything
> in between; you've told regcomp you don't care about anything but
> pass/fail. You should not be checking this value and expecting a
> consistent or portable result.
>
> Is there a context in which having this be determinate is of value?
Yes, if I gave the user the ability to choose to get infomation out of the regex match or to save memory by not recording the information then I could check the value of re_nsub to determine which option was selected. If there is no information I thought that re_nsub might not ever be set, but I don't know. Currently, I'm using an ifdef, but it's not what I would call ideal. I could find this out and offer the option globally through a global variable, but I wanted to check about this, I'm curious.
Thanks, David