@@ -376,23 +376,8 @@ Perl_grok_bin_oct_hex(pTHX_ const char *start,
376376 )
377377
378378{
379- const char * s0 = start ;
380- const char * s ;
381- STRLEN len = * len_p ;
382- STRLEN bytes_so_far ; /* How many real digits have been processed */
383- UV value = 0 ;
384- NV value_nv = 0 ;
385- const PERL_UINT_FAST8_T base = 1 << shift ; /* 2, 8, or 16 */
386- const UV max_div = UV_MAX / base ; /* Value above which, the next digit
387- processed would overflow */
388- const I32 input_flags = * flags ;
389- const bool allow_underscores =
390- cBOOL (input_flags & PERL_SCAN_ALLOW_UNDERSCORES );
391- bool overflowed = FALSE;
392-
393- /* In overflows, this keeps track of how much to multiply the overflowed NV
394- * by as we continue to parse the remaining digits */
395- NV factor = 0 ;
379+ PERL_ARGS_ASSERT_GROK_BIN_OCT_HEX ;
380+ ASSUME (inRANGE (shift , 1 , 4 ) && shift != 2 );
396381
397382 /* This function unifies the core of grok_bin, grok_oct, and grok_hex. It
398383 * is optimized for hex conversion. For example, it uses XDIGIT_VALUE to
@@ -410,13 +395,16 @@ Perl_grok_bin_oct_hex(pTHX_ const char *start,
410395 * ...
411396 */
412397
413- PERL_ARGS_ASSERT_GROK_BIN_OCT_HEX ;
414-
415- ASSUME (inRANGE (shift , 1 , 4 ) && shift != 2 );
416-
398+ const I32 input_flags = * flags ;
417399 /* Clear output flags; unlikely to find a problem that sets them */
418400 * flags = 0 ;
419401
402+ const bool allow_underscores =
403+ cBOOL (input_flags & PERL_SCAN_ALLOW_UNDERSCORES );
404+ const char * s = start ;
405+ const char * s0 = s ; /* Where the significant digits start */
406+ STRLEN len = * len_p ;
407+
420408 if (!(input_flags & PERL_SCAN_DISALLOW_PREFIX )) {
421409
422410 /* strip off leading b or 0b; x or 0x.
@@ -435,6 +423,7 @@ Perl_grok_bin_oct_hex(pTHX_ const char *start,
435423 }
436424
437425 s = s0 ; /* s0 potentially advanced from 'start' */
426+ UV value = 0 ;
438427
439428 /* Unroll the loop so that the first 8 digits are branchless except for the
440429 * switch. A ninth hex one overflows a 32 bit word. */
@@ -488,10 +477,20 @@ Perl_grok_bin_oct_hex(pTHX_ const char *start,
488477 break ;
489478 }
490479
491- bytes_so_far = s - s0 ;
492- factor = shift << bytes_so_far ;
480+ /* How many real digits have been processed */
481+ STRLEN bytes_so_far = s - s0 ;
482+
483+ /* In overflows, this keeps track of how much to multiply the overflowed NV
484+ * by as we continue to parse the remaining digits */
485+ NV factor = shift << bytes_so_far ;
493486 len -= bytes_so_far ;
494487
488+ bool overflowed = FALSE;
489+ NV value_nv = 0 ;
490+ const PERL_UINT_FAST8_T base = 1 << shift ; /* 2, 8, or 16 */
491+ const UV max_div = UV_MAX / base ; /* Value above which, the next digit
492+ processed would overflow */
493+
495494 for (; len -- ; s ++ ) {
496495 if (generic_isCC_ (* s , class_bit )) {
497496 /* Write it in this wonky order with a goto to attempt to get the
0 commit comments