[Bf-blender-cvs] [e83e7d49b66] master: Cleanup: use continue instead of goto for 3D text wrapping logic
Campbell Barton
noreply at git.blender.org
Thu Feb 24 02:55:08 CET 2022
Commit: e83e7d49b6637177c1ba16531e4927533f7cb0f4
Author: Campbell Barton
Date: Thu Feb 24 12:53:09 2022 +1100
Branches: master
https://developer.blender.org/rBe83e7d49b6637177c1ba16531e4927533f7cb0f4
Cleanup: use continue instead of goto for 3D text wrapping logic
===================================================================
M source/blender/blenkernel/intern/vfont.c
===================================================================
diff --git a/source/blender/blenkernel/intern/vfont.c b/source/blender/blenkernel/intern/vfont.c
index 7e025c59b6c..5e75088a008 100644
--- a/source/blender/blenkernel/intern/vfont.c
+++ b/source/blender/blenkernel/intern/vfont.c
@@ -905,8 +905,8 @@ static bool vfont_to_curve(Object *ob,
custrinfo[i].flag &= ~(CU_CHINFO_WRAP | CU_CHINFO_SMALLCAPS_CHECK | CU_CHINFO_OVERFLOW);
}
- for (i = 0; i <= slen; i++) {
- makebreak:
+ i = 0;
+ while (i <= slen) {
/* Characters in the list */
info = &custrinfo[i];
ascii = mem[i];
@@ -985,6 +985,7 @@ static bool vfont_to_curve(Object *ob,
}
else if (x_used > x_available) {
// CLOG_WARN(&LOG, "linewidth exceeded: %c%c%c...", mem[i], mem[i+1], mem[i+2]);
+ bool dobreak = false;
for (j = i; (mem[j] != '\n') && (chartransdata[j].dobreak == 0); j--) {
/* Special case when there are no breaks possible. */
@@ -1001,7 +1002,6 @@ static bool vfont_to_curve(Object *ob,
break;
}
- bool dobreak = false;
if (ELEM(mem[j], ' ', '-')) {
ct -= (i - (j - 1));
cnr -= (i - (j - 1));
@@ -1016,8 +1016,9 @@ static bool vfont_to_curve(Object *ob,
ct[1].dobreak = 1;
custrinfo[i + 1].flag |= CU_CHINFO_WRAP;
dobreak = true;
+ break;
}
- else if (chartransdata[j].dobreak) {
+ if (chartransdata[j].dobreak) {
// CLOG_WARN(&LOG, "word too long: %c%c%c...", mem[j], mem[j+1], mem[j+2]);
ct->dobreak = 1;
custrinfo[i + 1].flag |= CU_CHINFO_WRAP;
@@ -1026,14 +1027,17 @@ static bool vfont_to_curve(Object *ob,
i--;
xof = ct->xof;
dobreak = true;
+ break;
}
- if (dobreak) {
- if (tb_scale.h == 0.0f) {
- /* NOTE: If underlined text is truncated away, the extra space is also truncated. */
- custrinfo[i + 1].flag |= CU_CHINFO_OVERFLOW;
- }
- goto makebreak;
+ }
+
+ if (dobreak) {
+ if (tb_scale.h == 0.0f) {
+ /* NOTE: If underlined text is truncated away, the extra space is also truncated. */
+ custrinfo[i + 1].flag |= CU_CHINFO_OVERFLOW;
}
+ /* Since a break was added, re-run this loop with `i` at it's new value. */
+ continue;
}
}
}
@@ -1139,7 +1143,9 @@ static bool vfont_to_curve(Object *ob,
}
}
ct++;
+ i++;
}
+
current_line_length += xof + twidth - MARGIN_X_MIN;
longest_line_length = MAX2(current_line_length, longest_line_length);
More information about the Bf-blender-cvs
mailing list