On 03/23/2017 11:57 AM, Bernhard Voelker wrote: > On 03/23/2017 05:27 PM, Andrei Borzenkov wrote: >> If RE_ENABLE_I18N is not defined, FALLTHROUGH will be attributed to >> wrong branch. If someone happens to add case label before #ifdef, it >> will be rather hard to spot. > > What about this? > > diff --git a/lib/regexec.c b/lib/regexec.c > index ef52b243a..107a5c035 100644 > --- a/lib/regexec.c > +++ b/lib/regexec.c > @@ -4079,7 +4079,10 @@ check_node_accept (const re_match_context_t *mctx, > const re_token_t *node, > if (ch >= ASCII_CHARS) > return false; > /* FALLTHROUGH */ > + goto FALLTHRU_TO_OP_PERIOD; > #endif > + > +FALLTHRU_TO_OP_PERIOD: > case OP_PERIOD: > if ((ch == '\n' && !(mctx->dfa->syntax & RE_DOT_NEWLINE)) > || (ch == '\0' && (mctx->dfa->syntax & RE_DOT_NOT_NULL))) > > > Okay, some consider goto as ugly ... but it is explicit and > probably efficient as well in this case. ;-)
Then you get a warning about an unused label. But how about:
#ifdef RE_ENABLE_I18N
case OP_UTF8_PERIOD:
if (ch >= ASCII_CHARS)
return false;
goto FALLTHROUGH_TO_OP_PERIOD;
FALLTHROUGH_TO_OP_PERIOD:
#endif
case OP_PERIOD:
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
