C++ compilability - avoid 'goto' across a variable initialization

C++ is pickier about when a 'goto' can cross a variable being delcared.
The fix is to just add a set of braces to restrict the variable's scope.
Without this, g++ will fail with:

  regcomp.c:3057: error: jump to label 'set_call_attr'
  regcomp.c:3087: error:   from here
  regcomp.c:3041: error:   skips initialization of 'int gnum'
This commit is contained in:
Mitchell Blank Jr
2012-05-20 00:26:49 -07:00
parent 1ad7a1e3d8
commit 606a1665c5
+12 -10
View File
@@ -3038,19 +3038,21 @@ setup_subexp_call(Node* node, ScanEnv* env)
Node** nodes = SCANENV_MEM_NODES(env);
if (cn->group_num != 0) {
int gnum = cn->group_num;
{
int gnum = cn->group_num;
#ifdef USE_NAMED_GROUP
if (env->num_named > 0 &&
IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
!ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_CAPTURE_GROUP)) {
return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
}
if (env->num_named > 0 &&
IS_SYNTAX_BV(env->syntax, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP) &&
!ONIG_IS_OPTION_ON(env->option, ONIG_OPTION_CAPTURE_GROUP)) {
return ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED;
}
#endif
if (gnum > env->num_mem) {
onig_scan_env_set_error_string(env,
ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
return ONIGERR_UNDEFINED_GROUP_REFERENCE;
if (gnum > env->num_mem) {
onig_scan_env_set_error_string(env,
ONIGERR_UNDEFINED_GROUP_REFERENCE, cn->name, cn->name_end);
return ONIGERR_UNDEFINED_GROUP_REFERENCE;
}
}
#ifdef USE_NAMED_GROUP