Skip to content

Commit

Permalink
S_bool_setlocale_2008_i: Separate out failure code
Browse files Browse the repository at this point in the history
This causes the failure to be handled by going to effectively a
tail-call spot.  This is in preparation for it being used in another
place.
  • Loading branch information
khwilliamson committed May 12, 2023
1 parent efd5651 commit b3f9f32
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions locale.c
Expand Up @@ -1983,18 +1983,8 @@ S_bool_setlocale_2008_i(pTHX_
caller_line, basis_obj, GET_ERRNO));

/* Failed. Likely this is because the proposed new locale isn't
* valid on this system. But we earlier switched to the LC_ALL=>C
* locale in anticipation of it succeeding, Now have to switch
* back to the state upon entry */
if (! uselocale(entry_obj)) {
setlocale_failure_panic_i(index, "switching back to",
locale_on_entry, __LINE__,
caller_line);
NOT_REACHED; /* NOTREACHED */
}

SET_EINVAL;
return false;
* valid on this system. */
goto must_restore_state;
}

DEBUG_Lv(PerlIO_printf(Perl_debug_log,
Expand Down Expand Up @@ -2062,6 +2052,17 @@ S_bool_setlocale_2008_i(pTHX_
# endif

return true;

must_restore_state:

/* We earlier switched to the LC_ALL => C locale in anticipation of it
* succeeding, Now have to switch back to the state upon entry. */
if (! uselocale(entry_obj)) {
setlocale_failure_panic_i(index, "switching back to",
locale_on_entry, __LINE__, caller_line);
}

return false;
}

/*---------------------------------------------------------------------------*/
Expand Down

0 comments on commit b3f9f32

Please sign in to comment.