This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Regex: Will re_nsub be zero if REG_NOSUB was passed to regcomp?


>> 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]