summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog37
-rw-r--r--MORE.STUFF17
-rw-r--r--src/roff/troff/env.cc33
-rw-r--r--src/roff/troff/env.h1
-rw-r--r--src/roff/troff/input.cc88
-rw-r--r--src/roff/troff/node.cc197
-rw-r--r--src/roff/troff/node.h76
7 files changed, 305 insertions, 144 deletions
diff --git a/ChangeLog b/ChangeLog
index 21997571..5e82b960 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,40 @@
+2001-02-13 Werner LEMBERG <wl@gnu.org>
+
+ Redesigned the `unformat' request. It is no longer connected with
+ `asciify' but rather uses new `reread()' methods if the `unformat'
+ flag is set. Additionally, the handling of space characters after
+ unformatting has been fixed so that they retain their width.
+
+ * src/roff/troff/node.h (width_list): New structure to store
+ original widths of spaces.
+ (node): Added `unformat' member.
+ Replaced `num_spaces' variable with `orig_width' list.
+ * src/roff/troff/node.cc (*node::asciify,
+ asciify_reverse_node_list): Removed `unformat_only' flag and related
+ code.
+ (word_space_node::asciify, word_space_node::word_space_node): Use
+ `orig_width'.
+ (word_space_node::~word_space_node): New destructor.
+ (word_space_node::copy): Updated to handle `orig_width'.
+ (hmotion_node::copy, unbreakable_space_node::copy): Updated.
+ (*node::merge_space): Update `orig_width' list if necessary.
+ (*node::set_unformat_flag): New methods to set the `unformat' flag.
+ * src/roff/troff/enc.cc (environment::space_newline): Use
+ `width_list'.
+ (environment::space): Added method to handle space width and
+ sentence space width as parameters. Use `width_list'.
+ (environment::make_tab_node): Updated.
+ * src/roff/troff/env.h: Updated.
+ * src/roff/troff/input.cc (word_space_node::reread,
+ unbreakable_space_node::reread, hmotion_node::reread): New methods
+ to handle nodes specially if `unformat' flag is set.
+ (do_asciify_macro): Renamed back to ...
+ (asciify_macro): This.
+ (unformat_macro): New implementation to simply set the `unformat'
+ flag.
+
+ * MORE.STUFF: Added more info about deroff.
+
2001-02-08 Werner LEMBERG <wl@gnu.org>
* src/roff/troff/node.h (unbreakable_space_node, hmotion_node,
diff --git a/MORE.STUFF b/MORE.STUFF
index d7de46df..ae8cc21e 100644
--- a/MORE.STUFF
+++ b/MORE.STUFF
@@ -86,15 +86,24 @@ available from
deroff
------
-Deroff version 1.6 compiled with DJGPP is available from
+Deroff removes roff constructs from documents for the purpose of indexing,
+spell checking etc.
+
+Michael Haardt's <michael@moria.de> implementation is a little smarter than
+traditional implementations, because it knows about certain -man and
+-mm macros. It is able to generate a word list for spell checking tools
+or omit headers for sentence analysis tools. It can further generate
+cpp-style #line lines.
+
+ http://www.moria.de/deroff/
+
+Version 1.6 compiled with DJGPP (for MS-DOS and all Win32 systems, i.e.
+Win95, Win98, WinNT) is available from
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2apps/
and its mirrors.
-Deroff removes troff, tbl, eqn and pic constructs from documents. This
-version works on MS-DOS and all Win32-systems (Win95, Win98, WinNT).
-
miscellaneous
-------------
diff --git a/src/roff/troff/env.cc b/src/roff/troff/env.cc
index ffd692f9..bae4fc5d 100644
--- a/src/roff/troff/env.cc
+++ b/src/roff/troff/env.cc
@@ -377,47 +377,56 @@ void environment::space_newline()
if (interrupted)
return;
hunits x = H0;
+ hunits sw = env_space_width(this);
+ hunits ssw = env_sentence_space_width(this);
if (!translate_space_to_dummy) {
- x = env_space_width(this);
+ x = sw;
if (node_list_ends_sentence(line) == 1)
- x += env_sentence_space_width(this);
+ x += ssw;
}
- int num_spaces = 1;
+ width_list *w = new width_list(sw, ssw);
if (node_list_ends_sentence(line) == 1)
- num_spaces++;
- if (line != 0 && line->merge_space(x)) {
+ w->next = new width_list(sw, ssw);
+ if (line != 0 && line->merge_space(x, sw, ssw)) {
width_total += x;
return;
}
- add_node(new word_space_node(x, num_spaces));
+ add_node(new word_space_node(x, w));
possibly_break_line(0, spread_flag);
spread_flag = 0;
}
void environment::space()
{
+ space(env_space_width(this), env_sentence_space_width(this));
+}
+
+void environment::space(hunits space_width, hunits sentence_space_width)
+{
if (interrupted)
return;
if (current_field && padding_indicator_char == 0) {
add_padding();
return;
}
- hunits x = translate_space_to_dummy ? H0 : env_space_width(this);
+ hunits x = translate_space_to_dummy ? H0 : space_width;
node *p = current_tab ? tab_contents : line;
hunits *tp = current_tab ? &tab_width : &width_total;
if (p && p->nspaces() == 1 && p->width() == x
&& node_list_ends_sentence(p->next) == 1) {
- hunits xx = translate_space_to_dummy ? H0 : env_sentence_space_width(this);
- if (p->merge_space(xx)) {
+ hunits xx = translate_space_to_dummy ? H0 : sentence_space_width;
+ if (p->merge_space(xx, space_width, sentence_space_width)) {
*tp += xx;
return;
}
}
- if (p && p->merge_space(x)) {
+ if (p && p->merge_space(x, space_width, sentence_space_width)) {
*tp += x;
return;
}
- add_node(new word_space_node(x, 1));
+ add_node(new word_space_node(x,
+ new width_list(space_width,
+ sentence_space_width)));
possibly_break_line(0, spread_flag);
spread_flag = 0;
}
@@ -2621,7 +2630,7 @@ node *environment::make_tab_node(hunits d, node *next)
leader_node = 0;
}
if (!leader_node)
- return new hmotion_node(d, 1, next);
+ return new hmotion_node(d, 1, 0, next);
node *n = new hline_node(d, leader_node, next);
leader_node = 0;
return n;
diff --git a/src/roff/troff/env.h b/src/roff/troff/env.h
index ef0230ae..a6060d56 100644
--- a/src/roff/troff/env.h
+++ b/src/roff/troff/env.h
@@ -286,6 +286,7 @@ public:
void add_hyphen_indicator();
void add_italic_correction();
void space();
+ void space(hunits, hunits);
void space_newline();
const char *get_font_family_string();
const char *get_name_string();
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index 0263d8fe..a1673855 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -682,7 +682,7 @@ static symbol read_long_escape_name()
}
if (i + 2 > buf_size) {
if (buf == abuf) {
- buf = new char [ABUF_SIZE*2];
+ buf = new char[ABUF_SIZE*2];
memcpy(buf, abuf, buf_size);
buf_size = ABUF_SIZE*2;
}
@@ -1914,7 +1914,7 @@ symbol get_long_name(int required)
for (;;) {
if (i + 1 > buf_size) {
if (buf == abuf) {
- buf = new char [ABUF_SIZE*2];
+ buf = new char[ABUF_SIZE*2];
memcpy(buf, abuf, buf_size);
buf_size = ABUF_SIZE*2;
}
@@ -2131,6 +2131,30 @@ int diverted_copy_file_node::reread(int *bolp)
return 1;
}
+int word_space_node::reread(int *bolp)
+{
+ if (unformat) {
+ for (width_list *w = orig_width; w; w = w->next)
+ curenv->space(w->width, w->sentence_width);
+ return 1;
+ }
+ return 0;
+}
+
+int unbreakable_space_node::reread(int *)
+{
+ return 0;
+}
+
+int hmotion_node::reread(int *bolp)
+{
+ if (unformat && was_tab) {
+ curenv->handle_tab(0);
+ return 1;
+ }
+ return 0;
+}
+
void process_input_stack()
{
int_stack trap_bol_stack;
@@ -2246,7 +2270,8 @@ void process_input_stack()
else {
push_token(tok);
curenv->do_break();
- curenv->add_node(new hmotion_node(curenv->get_space_width()*nspaces));
+ curenv->add_node(new hmotion_node(curenv->get_space_width()
+ * nspaces));
bol = 0;
}
}
@@ -2796,7 +2821,8 @@ void *small_temp_iterator::operator new(size_t n)
{
assert(n == sizeof(small_temp_iterator));
if (!free_list) {
- free_list = (small_temp_iterator *)new char[sizeof(small_temp_iterator)*BLOCK];
+ free_list =
+ (small_temp_iterator *)new char[sizeof(small_temp_iterator)*BLOCK];
for (int i = 0; i < BLOCK - 1; i++)
free_list[i].next = free_list + i + 1;
free_list[BLOCK-1].next = 0;
@@ -3676,7 +3702,7 @@ void length_macro()
set_number_reg(ret, len);
}
-void do_asciify_macro(int unformat_only)
+void asciify_macro()
{
symbol s = get_name(1);
if (!s.is_null()) {
@@ -3695,7 +3721,7 @@ void do_asciify_macro(int unformat_only)
if (c != 0)
am.append(c);
else
- nd->asciify(&am, unformat_only);
+ nd->asciify(&am);
}
*m = am;
}
@@ -3703,14 +3729,33 @@ void do_asciify_macro(int unformat_only)
skip_line();
}
-void asciify_macro()
-{
- do_asciify_macro(0);
-}
-
void unformat_macro()
{
- do_asciify_macro(1);
+ symbol s = get_name(1);
+ if (!s.is_null()) {
+ request_or_macro *p = lookup_request(s);
+ macro *m = p->to_macro();
+ if (!m)
+ error("cannot unformat request");
+ else {
+ macro am;
+ string_iterator iter(*m);
+ for (;;) {
+ node *nd;
+ int c = iter.get(&nd);
+ if (c == EOF)
+ break;
+ if (c != 0)
+ am.append(c);
+ else {
+ nd->set_unformat_flag();
+ am.append(nd);
+ }
+ }
+ *m = am;
+ }
+ }
+ skip_line();
}
static void interpolate_environment_variable(symbol nm)
@@ -3906,7 +3951,7 @@ static symbol get_delim_name()
for (;;) {
if (i + 1 > buf_size) {
if (buf == abuf) {
- buf = new char [ABUF_SIZE*2];
+ buf = new char[ABUF_SIZE*2];
memcpy(buf, abuf, buf_size);
buf_size = ABUF_SIZE*2;
}
@@ -5285,6 +5330,8 @@ void check_missing_character()
tok.description());
}
+// this is for \Z
+
int token::add_to_node_list(node **pp)
{
hunits w;
@@ -6322,10 +6369,14 @@ void init_input_requests()
number_reg_dictionary.define("lly", new variable_reg(&lly_reg_contents));
number_reg_dictionary.define("urx", new variable_reg(&urx_reg_contents));
number_reg_dictionary.define("ury", new variable_reg(&ury_reg_contents));
- number_reg_dictionary.define("opminx", new variable_reg(&output_reg_minx_contents));
- number_reg_dictionary.define("opminy", new variable_reg(&output_reg_miny_contents));
- number_reg_dictionary.define("opmaxx", new variable_reg(&output_reg_maxx_contents));
- number_reg_dictionary.define("opmaxy", new variable_reg(&output_reg_maxy_contents));
+ number_reg_dictionary.define("opminx",
+ new variable_reg(&output_reg_minx_contents));
+ number_reg_dictionary.define("opminy",
+ new variable_reg(&output_reg_miny_contents));
+ number_reg_dictionary.define("opmaxx",
+ new variable_reg(&output_reg_maxx_contents));
+ number_reg_dictionary.define("opmaxy",
+ new variable_reg(&output_reg_maxy_contents));
}
object_dictionary request_dictionary(501);
@@ -6362,7 +6413,8 @@ node *charinfo_to_node_list(charinfo *ci, const environment *envp)
curenv->set_composite();
token old_tok = tok;
input_stack::add_boundary();
- string_iterator *si = new string_iterator(*mac, "composite character", ci->nm);
+ string_iterator *si =
+ new string_iterator(*mac, "composite character", ci->nm);
input_stack::push(si);
// we don't use process_input_stack, because we don't want to recognise
// requests
diff --git a/src/roff/troff/node.cc b/src/roff/troff/node.cc
index 89fc3679..02db5b56 100644
--- a/src/roff/troff/node.cc
+++ b/src/roff/troff/node.cc
@@ -349,10 +349,10 @@ void font_info::set_constant_space(constant_space_type type, units x)
{
if (type != is_constant_spaced
|| (type != CONSTANT_SPACE_NONE && x != constant_space)) {
- flush();
- is_constant_spaced = type;
- constant_space = x;
- }
+ flush();
+ is_constant_spaced = type;
+ constant_space = x;
+ }
}
void font_info::set_track_kern(track_kerning_function &tk)
@@ -1549,7 +1549,7 @@ public:
hyphen_list *get_hyphen_list(hyphen_list *ss = 0);
node *add_self(node *, hyphen_list **);
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
int character_type();
int same(node *);
const char *type();
@@ -1573,7 +1573,7 @@ public:
node *add_self(node *, hyphen_list **);
hyphen_list *get_hyphen_list(hyphen_list *ss = 0);
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
int same(node *);
const char *type();
int force_tprint();
@@ -1599,7 +1599,7 @@ public:
hyphenation_type get_hyphenation_type();
int ends_sentence();
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
int same(node *);
const char *type();
int force_tprint();
@@ -1628,7 +1628,7 @@ public:
void split(int, node **, node **);
hyphenation_type get_hyphenation_type();
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
int same(node *);
const char *type();
int force_tprint();
@@ -2189,7 +2189,7 @@ public:
~italic_corrected_node();
node *copy();
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
hunits width();
node *last_char_node();
void vertical_extent(vunits *, vunits *);
@@ -2336,7 +2336,7 @@ public:
void tprint(troff_output_file *);
void zero_width_tprint(troff_output_file *);
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
hyphenation_type get_hyphenation_type();
int overlaps_vertically();
int overlaps_horizontally();
@@ -2453,7 +2453,7 @@ node *vertical_size_node::copy()
node *hmotion_node::copy()
{
- return new hmotion_node(n, was_tab);
+ return new hmotion_node(n, was_tab, unformat);
}
node *space_char_hmotion_node::copy()
@@ -2639,7 +2639,7 @@ int node::nspaces()
return 0;
}
-int node::merge_space(hunits)
+int node::merge_space(hunits, hunits, hunits)
{
return 0;
}
@@ -2702,7 +2702,7 @@ int space_node::nspaces()
return set ? 0 : 1;
}
-int space_node::merge_space(hunits h)
+int space_node::merge_space(hunits h, hunits, hunits)
{
n += h;
return 1;
@@ -2849,6 +2849,10 @@ vunits vmotion_node::vertical_width()
return n;
}
+void node::set_unformat_flag()
+{
+}
+
int node::character_type()
{
return 0;
@@ -2973,85 +2977,77 @@ void space_char_hmotion_node::ascii_print(ascii_output_file *ascii)
/* asciify methods */
-void node::asciify(macro *m, int)
+void node::asciify(macro *m)
{
m->append(this);
}
-void glyph_node::asciify(macro *m, int unformat_only)
+void glyph_node::asciify(macro *m)
{
- if (unformat_only)
- m->append(this);
- else {
- unsigned char c = ci->get_ascii_code();
- if (c != 0) {
- m->append(c);
- delete this;
- }
- else
- m->append(this);
+ unsigned char c = ci->get_ascii_code();
+ if (c != 0) {
+ m->append(c);
+ delete this;
}
+ else
+ m->append(this);
}
-void kern_pair_node::asciify(macro *m, int unformat_only)
+void kern_pair_node::asciify(macro *m)
{
- n1->asciify(m, unformat_only);
- n2->asciify(m, unformat_only);
+ n1->asciify(m);
+ n2->asciify(m);
n1 = n2 = 0;
delete this;
}
-static void asciify_reverse_node_list(macro *m, node *n, int unformat_only)
+static void asciify_reverse_node_list(macro *m, node *n)
{
if (n == 0)
return;
- asciify_reverse_node_list(m, n->next, unformat_only);
- n->asciify(m, unformat_only);
+ asciify_reverse_node_list(m, n->next);
+ n->asciify(m);
}
-void dbreak_node::asciify(macro *m, int unformat_only)
+void dbreak_node::asciify(macro *m)
{
- asciify_reverse_node_list(m, none, unformat_only);
+ asciify_reverse_node_list(m, none);
none = 0;
delete this;
}
-void ligature_node::asciify(macro *m, int unformat_only)
+void ligature_node::asciify(macro *m)
{
- n1->asciify(m, unformat_only);
- n2->asciify(m, unformat_only);
+ n1->asciify(m);
+ n2->asciify(m);
n1 = n2 = 0;
delete this;
}
-void break_char_node::asciify(macro *m, int unformat_only)
+void break_char_node::asciify(macro *m)
{
- if (unformat_only)
- m->append(this);
- else {
- ch->asciify(m, 0);
- ch = 0;
- delete this;
- }
+ ch->asciify(m);
+ ch = 0;
+ delete this;
}
-void italic_corrected_node::asciify(macro *m, int unformat_only)
+void italic_corrected_node::asciify(macro *m)
{
- n->asciify(m, unformat_only);
+ n->asciify(m);
n = 0;
delete this;
}
-void left_italic_corrected_node::asciify(macro *m, int unformat_only)
+void left_italic_corrected_node::asciify(macro *m)
{
if (n) {
- n->asciify(m, unformat_only);
+ n->asciify(m);
n = 0;
}
delete this;
}
-void hmotion_node::asciify(macro *m, int)
+void hmotion_node::asciify(macro *m)
{
if (was_tab) {
m->append('\t');
@@ -3066,13 +3062,13 @@ space_char_hmotion_node::space_char_hmotion_node(hunits i, node *next)
{
}
-void space_char_hmotion_node::asciify(macro *m, int)
+void space_char_hmotion_node::asciify(macro *m)
{
m->append(ESCAPE_SPACE);
delete this;
}
-void space_node::asciify(macro *m, int)
+void space_node::asciify(macro *m)
{
if (was_escape_colon) {
m->append(ESCAPE_COLON);
@@ -3082,25 +3078,25 @@ void space_node::asciify(macro *m, int)
m->append(this);
}
-void word_space_node::asciify(macro *m, int)
+void word_space_node::asciify(macro *m)
{
- for (int i = 0; i < num_spaces; i++)
+ for (width_list *w = orig_width; w; w = w->next)
m->append(' ');
delete this;
}
-void unbreakable_space_node::asciify(macro *m, int)
+void unbreakable_space_node::asciify(macro *m)
{
m->append(ESCAPE_TILDE);
delete this;
}
-void line_start_node::asciify(macro *, int)
+void line_start_node::asciify(macro *)
{
delete this;
}
-void vertical_size_node::asciify(macro *, int)
+void vertical_size_node::asciify(macro *)
{
delete this;
}
@@ -3564,7 +3560,7 @@ public:
void tprint(troff_output_file *);
hyphenation_type get_hyphenation_type();
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
hyphen_list *get_hyphen_list(hyphen_list *tail);
node *add_self(node *, hyphen_list **);
tfont *get_tfont();
@@ -3628,19 +3624,15 @@ hyphenation_type composite_node::get_hyphenation_type()
return HYPHEN_MIDDLE;
}
-void composite_node::asciify(macro *m, int unformat_only)
+void composite_node::asciify(macro *m)
{
- if (unformat_only)
- m->append(this);
- else {
- unsigned char c = ci->get_ascii_code();
- if (c != 0) {
- m->append(c);
- delete this;
- }
- else
- m->append(this);
+ unsigned char c = ci->get_ascii_code();
+ if (c != 0) {
+ m->append(c);
+ delete this;
}
+ else
+ m->append(this);
}
void composite_node::ascii_print(ascii_output_file *ascii)
@@ -3695,19 +3687,55 @@ void composite_node::vertical_extent(vunits *min, vunits *max)
n = reverse_node_list(n);
}
-word_space_node::word_space_node(hunits d, int n, node *x)
-: space_node(d, x), num_spaces(n)
+width_list::width_list(hunits w, hunits s)
+: width(w), sentence_width(s), next(0)
+{
+}
+
+width_list::width_list(width_list *w)
+: width(w->width), sentence_width(w->sentence_width), next(0)
+{
+}
+
+word_space_node::word_space_node(hunits d, width_list *w, node *x)
+: space_node(d, x), orig_width(w), unformat(0)
{
}
-word_space_node::word_space_node(hunits d, int s, int n, node *x)
-: space_node(d, s, 0, x), num_spaces(n)
+word_space_node::word_space_node(hunits d, int s, width_list *w,
+ int flag, node *x)
+: space_node(d, s, 0, x), orig_width(w), unformat(flag)
{
}
+word_space_node::~word_space_node()
+{
+ width_list *w = orig_width;
+ while (w != 0) {
+ width_list *tmp = w;
+ w = w->next;
+ delete tmp;
+ }
+}
+
node *word_space_node::copy()
{
- return new word_space_node(n, set, num_spaces);
+ assert(orig_width != 0);
+ width_list *w_old_curr = orig_width;
+ width_list *w_new_curr = new width_list(w_old_curr);
+ width_list *w_new = w_new_curr;
+ w_old_curr = w_old_curr->next;
+ while (w_old_curr != 0) {
+ w_new_curr->next = new width_list(w_old_curr);
+ w_new_curr = w_new_curr->next;
+ w_old_curr = w_old_curr->next;
+ }
+ return new word_space_node(n, set, w_new, unformat);
+}
+
+void word_space_node::set_unformat_flag()
+{
+ unformat = 1;
}
void word_space_node::tprint(troff_output_file *out)
@@ -3716,26 +3744,30 @@ void word_space_node::tprint(troff_output_file *out)
space_node::tprint(out);
}
-int word_space_node::merge_space(hunits h)
+int word_space_node::merge_space(hunits h, hunits sw, hunits ssw)
{
n += h;
- num_spaces++;
+ assert(orig_width != 0);
+ width_list *w = orig_width;
+ for (; w->next; w = w->next)
+ ;
+ w->next = new width_list(sw, ssw);
return 1;
}
unbreakable_space_node::unbreakable_space_node(hunits d, node *x)
-: word_space_node(d, 1, x)
+: word_space_node(d, 0, x)
{
}
-unbreakable_space_node::unbreakable_space_node(hunits d, int s, int n, node *x)
-: word_space_node(d, s, n, x)
+unbreakable_space_node::unbreakable_space_node(hunits d, int s, node *x)
+: word_space_node(d, s, 0, 0, x)
{
}
node *unbreakable_space_node::copy()
{
- return new unbreakable_space_node(n, set, num_spaces);
+ return new unbreakable_space_node(n, set);
}
int unbreakable_space_node::force_tprint()
@@ -3759,7 +3791,7 @@ void unbreakable_space_node::split(int, node **, node **)
assert(0);
}
-int unbreakable_space_node::merge_space(hunits)
+int unbreakable_space_node::merge_space(hunits, hunits, hunits)
{
return 0;
}
@@ -4379,6 +4411,11 @@ const char *hmotion_node::type()
return "hmotion_node";
}
+void hmotion_node::set_unformat_flag()
+{
+ unformat = 1;
+}
+
int hmotion_node::force_tprint()
{
return 0;
diff --git a/src/roff/troff/node.h b/src/roff/troff/node.h
index ebb53690..ac80b967 100644
--- a/src/roff/troff/node.h
+++ b/src/roff/troff/node.h
@@ -57,14 +57,15 @@ struct node {
virtual ~node();
virtual node *copy() = 0;
- virtual int force_tprint () = 0;
+ virtual void set_unformat_flag();
+ virtual int force_tprint() = 0;
virtual hunits width();
virtual hunits subscript_correction();
virtual hunits italic_correction();
virtual hunits left_italic_correction();
virtual hunits skew();
virtual int nspaces();
- virtual int merge_space(hunits);
+ virtual int merge_space(hunits, hunits, hunits);
virtual vunits vertical_width();
virtual node *last_char_node();
virtual void vertical_extent(vunits *min, vunits *max);
@@ -76,7 +77,7 @@ struct node {
virtual node *add_self(node *, hyphen_list **);
virtual hyphen_list *get_hyphen_list(hyphen_list *s = 0);
virtual void ascii_print(ascii_output_file *);
- virtual void asciify(macro *, int);
+ virtual void asciify(macro *);
virtual int discardable();
virtual void spread_space(int *, hunits *);
virtual void freeze_space();
@@ -137,7 +138,7 @@ public:
int same(node *);
int force_tprint();
const char *type();
- void asciify(macro *, int);
+ void asciify(macro *);
};
class space_node : public node {
@@ -162,10 +163,10 @@ public:
int nspaces();
hunits width();
int discardable();
- int merge_space(hunits);
+ int merge_space(hunits, hunits, hunits);
void freeze_space();
void is_escape_colon();
- void spread_space(int*, hunits*);
+ void spread_space(int *, hunits *);
void tprint(troff_output_file *);
breakpoint *get_breakpoints(hunits width, int nspaces, breakpoint *rest = 0,
int is_inner = 0);
@@ -173,40 +174,53 @@ public:
void split(int, node **, node **);
void ascii_print(ascii_output_file *);
int same(node *);
- void asciify(macro *, int);
+ void asciify(macro *);
const char *type();
int force_tprint();
};
+struct width_list {
+ width_list *next;
+ hunits width;
+ hunits sentence_width;
+ width_list(hunits, hunits);
+ width_list(width_list *);
+};
+
class word_space_node : public space_node {
protected:
- int num_spaces;
- word_space_node(hunits, int, int, node * = 0);
+ width_list *orig_width;
+ unsigned char unformat;
+ word_space_node(hunits, int, width_list *, int, node * = 0);
public:
- word_space_node(hunits, int, node * = 0);
+ word_space_node(hunits, width_list *, node * = 0);
+ ~word_space_node();
node *copy();
+ int reread(int *);
+ void set_unformat_flag();
void tprint(troff_output_file *);
int same(node *);
- void asciify(macro *, int);
+ void asciify(macro *);
const char *type();
- int merge_space(hunits);
+ int merge_space(hunits, hunits, hunits);
int force_tprint();
};
class unbreakable_space_node : public word_space_node {
- unbreakable_space_node(hunits, int, int, node * = 0);
+ unbreakable_space_node(hunits, int, node * = 0);
public:
unbreakable_space_node(hunits, node * = 0);
node *copy();
+ int reread(int *);
int same(node *);
- void asciify(macro *, int);
+ void asciify(macro *);
const char *type();
int force_tprint();
breakpoint *get_breakpoints(hunits width, int nspaces, breakpoint *rest = 0,
int is_inner = 0);
int nbreaks();
void split(int, node **, node **);
- int merge_space(hunits);
+ int merge_space(hunits, hunits, hunits);
node *add_self(node *, hyphen_list **);
hyphen_list *get_hyphen_list(hyphen_list *ss = 0);
hyphenation_type get_hyphenation_type();
@@ -251,7 +265,7 @@ class vertical_size_node : public node {
public:
vertical_size_node(vunits i) : n(i) {}
void set_vertical_size(vertical_size *);
- void asciify(macro *, int);
+ void asciify(macro *);
node *copy();
int same(node *);
const char *type();
@@ -261,13 +275,17 @@ public:
class hmotion_node : public node {
protected:
hunits n;
- int was_tab;
+ unsigned char was_tab;
+ unsigned char unformat;
public:
- hmotion_node(hunits i, node *next = 0) : node(next), n(i), was_tab(0) {}
- hmotion_node(hunits i, int flag, node *next = 0)
- : node(next), n(i), was_tab(flag) {}
+ hmotion_node(hunits i, node *next = 0)
+ : node(next), n(i), was_tab(0), unformat(0) {}
+ hmotion_node(hunits i, int flag1, int flag2, node *next = 0)
+ : node(next), n(i), was_tab(flag1), unformat(flag2) {}
node *copy();
- void asciify(macro *, int);
+ int reread(int *);
+ void set_unformat_flag();
+ void asciify(macro *);
void tprint(troff_output_file *);
hunits width();
void ascii_print(ascii_output_file *);
@@ -284,7 +302,7 @@ public:
space_char_hmotion_node(hunits i, node *next = 0);
node *copy();
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
int same(node *);
const char *type();
int force_tprint();
@@ -380,7 +398,7 @@ public:
~left_italic_corrected_node();
void tprint(troff_output_file *);
void ascii_print(ascii_output_file *);
- void asciify(macro *, int);
+ void asciify(macro *);
node *copy();
int same(node *);
const char *type();
@@ -453,10 +471,10 @@ public:
};
class suppress_node : public node {
- int is_on;
- int emit_limits; // must we issue the extent of the area written out?
- symbol filename;
- char position;
+ int is_on;
+ int emit_limits; // must we issue the extent of the area written out?
+ symbol filename;
+ char position;
public:
suppress_node(int, int);
suppress_node(symbol f, char p);
@@ -474,7 +492,6 @@ private:
struct hvpair {
hunits h;
vunits v;
-
hvpair();
};
@@ -533,7 +550,7 @@ public:
virtual void begin_page(int pageno, vunits page_length) = 0;
virtual void copy_file(hunits x, vunits y, const char *filename) = 0;
virtual int is_printing() = 0;
- virtual void put_filename (const char *filename);
+ virtual void put_filename(const char *filename);
virtual void on();
virtual void off();
#ifdef COLUMN
@@ -554,7 +571,6 @@ class font_family {
int map_size;
public:
const symbol nm;
-
font_family(symbol);
~font_family();
int make_definite(int);