[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[groff] 08/09: src/roff/troff/env.cpp: Avoid infinite loop.
From: |
G. Branden Robinson |
Subject: |
[groff] 08/09: src/roff/troff/env.cpp: Avoid infinite loop. |
Date: |
Wed, 21 Oct 2020 02:44:46 -0400 (EDT) |
gbranden pushed a commit to branch master
in repository groff.
commit bcdf2f4c7c28328c711c6a7ac2ea17f2ecd5cdd4
Author: G. Branden Robinson <g.branden.robinson@gmail.com>
AuthorDate: Wed Oct 21 00:29:24 2020 +1100
src/roff/troff/env.cpp: Avoid infinite loop.
* src/roff/troff/env.cpp (environment::possibly_break_line): Emit break
warning and return if the output width is not positive. The code
assumes that it will be and loops infinitely if it isn't. I _think_
this is because we're not able to get width data for (some?) CJK
glyphs. Based on a patch by Osamu Sayama.
Fixes <https://savannah.gnu.org/bugs/index.php?44018>.
---
ChangeLog | 15 +++++++++++++++
src/roff/troff/env.cpp | 14 ++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index ce0b7ea..d9ccebc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2020-10-20 G. Branden Robinson <g.branden.robinson@gmail.com>
+ * src/roff/troff/env.cpp (environment::possibly_break_line):
+ Emit break warning and return if the output width is not
+ positive. The code assumes that it will be and loops infinitely
+ if it isn't. I _think_ this is because we're not able to get
+ width data for (some?) CJK glyphs. Based on a patch by Osamu
+ Sayama.
+
+ * src/roff/groff/tests/\
+ do_not_loop_infinitely_when_breaking_cjk.sh: Test it.
+ * src/roff/groff/groff.am: Run test.
+
+ Fixes <https://savannah.gnu.org/bugs/index.php?44018>.
+
+2020-10-20 G. Branden Robinson <g.branden.robinson@gmail.com>
+
* src/preproc/tbl/table.cpp (table::init_output): Save the value
of \n[.tabs] when starting a table. In the reset macro, restore
the saved value.
diff --git a/src/roff/troff/env.cpp b/src/roff/troff/env.cpp
index 9cbc130..cb6b1b1 100644
--- a/src/roff/troff/env.cpp
+++ b/src/roff/troff/env.cpp
@@ -2142,6 +2142,14 @@ void environment::possibly_break_line(int start_here,
int forced)
}
distribute_space(pre, bp->nspaces, extra_space_width);
hunits output_width = bp->width + extra_space_width;
+ // This should become an assert() when we can get reliable width
+ // data from CJK glyphs. See Savannah #44018.
+ if (output_width <= 0) {
+ double output_width_in_ems = output_width.to_units();
+ output_warning(WARN_BREAK, "line has non-positive width %1m",
+ output_width_in_ems);
+ return;
+ }
input_line_start -= output_width;
if (bp->hyphenated)
hyphen_line_count++;
@@ -4107,3 +4115,9 @@ void init_hyphen_requests()
init_request("hpfa", hyphenation_patterns_file_append);
number_reg_dictionary.define(".hla", new hyphenation_language_reg);
}
+
+// Local Variables:
+// fill-column: 72
+// mode: C++
+// End:
+// vim: set cindent noexpandtab shiftwidth=2 textwidth=72:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [groff] 08/09: src/roff/troff/env.cpp: Avoid infinite loop.,
G. Branden Robinson <=