From 606a1665c5cfff42622687d693b9362b6c1b663a Mon Sep 17 00:00:00 2001 From: Mitchell Blank Jr Date: Sun, 20 May 2012 00:26:49 -0700 Subject: 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' --- src/regcomp.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/regcomp.c b/src/regcomp.c index bb45b3db4..523124b26 100644 --- a/src/regcomp.c +++ b/src/regcomp.c @@ -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 -- cgit v1.2.3