Skip to content

Commit 47b98c3

Browse files
committed
utf8_to_bytes() Move failure code out of loop
This is for clarity. All this very-unlikely-to-be-used code was in the middle of what is really going on, creating a distraction.
1 parent 2dad945 commit 47b98c3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

utf8.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,6 +2534,17 @@ Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *lenp)
25342534
continue;
25352535
}
25362536

2537+
goto cant_convert;
2538+
}
2539+
2540+
/* Success! */
2541+
*d = '\0';
2542+
*lenp = d - save;
2543+
2544+
return save;
2545+
2546+
cant_convert: ;
2547+
25372548
/* Here, it is malformed. This shouldn't happen on EBCDIC, and on ASCII
25382549
* platforms, we know that the only start bytes in the text are C2 and C3,
25392550
* and the code above has made sure that it doesn't end with a start byte.
@@ -2580,13 +2591,6 @@ Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *lenp)
25802591

25812592
*lenp = ((STRLEN) -1);
25822593
return NULL;
2583-
}
2584-
2585-
/* Success! */
2586-
*d = '\0';
2587-
*lenp = d - save;
2588-
2589-
return save;
25902594
}
25912595

25922596
/*

0 commit comments

Comments
 (0)