Message ID | 1372590906-75089-3-git-send-email-andreas.devel@googlemail.com |
---|---|
State | Superseded |
Headers | show |
Hello Andreas, On 06/30/2013 01:15 PM, Andreas Bießmann wrote: > BSD (like OS X) variants of regex.h do not declare REG_NOERROR, add a simple > define for them. > > Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> > --- > > +#ifndef REG_NOERROR > +/* BSD regex.h do not expose REG_NOERROR */ > +# define REG_NOERROR 0 > +#endif > + I think a neater solutions is to actually remove the REG_NOERROR. From man regexec, GNU 2011-09-27: "regexec() returns zero for a successful match or REG_NOMATCH for failure.". Opengroup specs will mention the same. REG_NOERROR is not mentioned at all. e.g.: if (err) { regex_report_error(&item->regex, err, "match", item->name); break; } should do the job in a portable way (and reads a bit better, as well). But this is only a cosmetic comment, the patch by itself should do the job. Regards, Jeroen p.s. Strictly speaking it is dead code actually...
> BSD (like OS X) variants of regex.h do not declare REG_NOERROR, add a simple > define for them. > > Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> > --- Tested-by: Lubomir Popov <lpopov@mm-sol.com>
Hello Andreas, On 07/01/2013 08:45 PM, Jeroen Hofstee wrote: > Hello Andreas, > > On 06/30/2013 01:15 PM, Andreas Bießmann wrote: >> BSD (like OS X) variants of regex.h do not declare REG_NOERROR, add a >> simple >> define for them. >> >> Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> >> --- >> +#ifndef REG_NOERROR >> +/* BSD regex.h do not expose REG_NOERROR */ >> +# define REG_NOERROR 0 >> +#endif >> + > I think a neater solutions is to actually remove the REG_NOERROR. > From man regexec, GNU 2011-09-27: "regexec() returns zero for a > successful match or REG_NOMATCH for failure.". Opengroup specs > will mention the same. REG_NOERROR is not mentioned at all. > > e.g.: > > if (err) { > regex_report_error(&item->regex, err, "match", > item->name); > break; > } > > should do the job in a portable way (and reads a bit better, > as well). But this is only a cosmetic comment, the patch by > itself should do the job. > Just realized this is more then cosmetic. Also GNU will not have REG_NOERROR defined since it is an enum, so it will always take the #ifndef REG_NOERROR road, which boils down to !! 0. So this needs a new version instead of hiding how this works. Regards, Jeroe p.s. Simon, Andreas sorry for spamming, selected the wrong email...
Hi Jeroen, On 01.07.13 22:12, Jeroen Hofstee wrote: > Hello Andreas, > > On 07/01/2013 08:45 PM, Jeroen Hofstee wrote: >> Hello Andreas, >> >> On 06/30/2013 01:15 PM, Andreas Bießmann wrote: >>> BSD (like OS X) variants of regex.h do not declare REG_NOERROR, add a >>> simple >>> define for them. >>> >>> Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> >>> --- >>> +#ifndef REG_NOERROR >>> +/* BSD regex.h do not expose REG_NOERROR */ >>> +# define REG_NOERROR 0 >>> +#endif >>> + >> I think a neater solutions is to actually remove the REG_NOERROR. >> From man regexec, GNU 2011-09-27: "regexec() returns zero for a >> successful match or REG_NOMATCH for failure.". Opengroup specs >> will mention the same. REG_NOERROR is not mentioned at all. >> >> e.g.: >> >> if (err) { >> regex_report_error(&item->regex, err, "match", >> item->name); >> break; >> } >> >> should do the job in a portable way (and reads a bit better, >> as well). But this is only a cosmetic comment, the patch by >> itself should do the job. >> > Just realized this is more then cosmetic. Also GNU will not have > REG_NOERROR defined since it is an enum, so it will always > take the #ifndef REG_NOERROR road, which boils down to !! 0. > > So this needs a new version instead of hiding how this works. you are right, v2 is on the way ... > p.s. Simon, Andreas sorry for spamming, selected the wrong email... Ouch, sorry! Just realized that I took the wrong mail too. Best regards Andreas Bießmann
diff --git a/tools/proftool.c b/tools/proftool.c index a48ed28..d910b50 100644 --- a/tools/proftool.c +++ b/tools/proftool.c @@ -35,6 +35,11 @@ #define MAX_LINE_LEN 500 +#ifndef REG_NOERROR +/* BSD regex.h do not expose REG_NOERROR */ +# define REG_NOERROR 0 +#endif + enum { FUNCF_TRACE = 1 << 0, /* Include this function in trace */ };
BSD (like OS X) variants of regex.h do not declare REG_NOERROR, add a simple define for them. Signed-off-by: Andreas Bießmann <andreas.devel@googlemail.com> --- tools/proftool.c | 5 +++++ 1 file changed, 5 insertions(+)