Skip to content

Commit c3980b7

Browse files
authored
patch split_str_once (#7093)
1 parent 5d78e3e commit c3980b7

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

code/parse/parselo.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3627,6 +3627,7 @@ void display_parse_diagnostics()
36273627
char *split_str_once(char *src, int max_pixel_w, float scale)
36283628
{
36293629
char *brk = nullptr;
3630+
char *word_brk = nullptr; // if we fail, break here (even if its in the middle of a word)
36303631
bool last_was_white = false;
36313632

36323633
Assert(src);
@@ -3651,6 +3652,9 @@ char *split_str_once(char *src, int max_pixel_w, float scale)
36513652
return src + i + 1;
36523653
}
36533654
}
3655+
else if (word_brk == nullptr) {
3656+
word_brk = src + i;
3657+
}
36543658

36553659
if (is_white_space(src[i])) {
36563660
if (!last_was_white) {
@@ -3672,10 +3676,9 @@ char *split_str_once(char *src, int max_pixel_w, float scale)
36723676
}
36733677

36743678
// if we are over max pixel width and weren't able to come up with a good non-word
3675-
// split then just return the original src text and the calling function should
3676-
// have to handle the result
3679+
// split then just split the word
36773680
if ( (w > max_pixel_w) && ((i == 0) || !brk) ) {
3678-
return src;
3681+
return word_brk;
36793682
}
36803683

36813684
if (!brk) {

0 commit comments

Comments
 (0)