diff options
Diffstat (limited to 'gnu/dist/groff/src/roff/troff/node.cpp')
| -rw-r--r-- | gnu/dist/groff/src/roff/troff/node.cpp | 110 |
1 files changed, 57 insertions, 53 deletions
diff --git a/gnu/dist/groff/src/roff/troff/node.cpp b/gnu/dist/groff/src/roff/troff/node.cpp index 9c6a0a3e080..464a81c8116 100644 --- a/gnu/dist/groff/src/roff/troff/node.cpp +++ b/gnu/dist/groff/src/roff/troff/node.cpp @@ -1,7 +1,7 @@ -/* $NetBSD: node.cpp,v 1.1.1.1 2003/06/30 17:52:09 wiz Exp $ */ +/* $NetBSD: node.cpp,v 1.1.1.2 2004/07/30 14:44:56 wiz Exp $ */ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003 +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -27,7 +27,6 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <unistd.h> #endif -#include "symbol.h" #include "dictionary.h" #include "hvunits.h" #include "env.h" @@ -114,7 +113,7 @@ struct conditional_bold { conditional_bold(int, hunits, conditional_bold * = 0); }; -struct tfont; +class tfont; class font_info { tfont *last_tfont; @@ -402,11 +401,11 @@ symbol get_font_name(int fontno, environment *env) return f; } -hunits font_info::get_space_width(font_size fs, int space_size) +hunits font_info::get_space_width(font_size fs, int space_sz) { if (is_constant_spaced == CONSTANT_SPACE_NONE) return scale(hunits(fm->get_space_width(fs.to_scaled_points())), - space_size, 12); + space_sz, 12); else if (is_constant_spaced == CONSTANT_SPACE_ABSOLUTE) return constant_space; else @@ -989,7 +988,7 @@ void troff_output_file::put_char_width(charinfo *ci, tfont *tf, return; } set_font(tf); - char c = ci->get_ascii_code(); + unsigned char c = ci->get_ascii_code(); if (c == '\0') { glyph_color(gcol); fill_color(fcol); @@ -1067,7 +1066,7 @@ void troff_output_file::put_char(charinfo *ci, tfont *tf, if (!is_on()) return; set_font(tf); - char c = ci->get_ascii_code(); + unsigned char c = ci->get_ascii_code(); if (c == '\0') { glyph_color(gcol); fill_color(fcol); @@ -1458,13 +1457,14 @@ void troff_output_file::really_begin_page(int pageno, vunits page_length) put('\n'); } -void troff_output_file::really_copy_file(hunits x, vunits y, const char *filename) +void troff_output_file::really_copy_file(hunits x, vunits y, + const char *filename) { moveto(x, y); flush_tbuf(); do_motion(); errno = 0; - FILE *ifp = fopen(filename, "r"); + FILE *ifp = include_search_path.open_file_cautious(filename); if (ifp == 0) error("can't open `%1': %2", filename, strerror(errno)); else { @@ -2439,9 +2439,9 @@ hunits dbreak_node::width() node *dbreak_node::last_char_node() { for (node *n = none; n; n = n->next) { - node *last = n->last_char_node(); - if (last) - return last; + node *last_node = n->last_char_node(); + if (last_node) + return last_node; } return 0; } @@ -2484,7 +2484,7 @@ public: int force_tprint(); }; -node *node::add_italic_correction(hunits *width) +node *node::add_italic_correction(hunits *wd) { hunits ic = italic_correction(); if (ic.is_zero()) @@ -2492,7 +2492,7 @@ node *node::add_italic_correction(hunits *width) else { node *next1 = next; next = 0; - *width += ic; + *wd += ic; return new italic_corrected_node(this, ic, next1); } } @@ -2883,16 +2883,16 @@ bracket_node::~bracket_node() node *bracket_node::copy() { bracket_node *on = new bracket_node; - node *last = 0; + node *last_node = 0; node *tem; if (list) list->last = 0; for (tem = list; tem; tem = tem->next) { if (tem->next) tem->next->last = tem; - last = tem; + last_node = tem; } - for (tem = last; tem; tem = tem->last) + for (tem = last_node; tem; tem = tem->last) on->bracket(tem->copy()); return on; } @@ -2996,20 +2996,20 @@ void node::spread_space(int*, hunits*) { } -void space_node::spread_space(int *nspaces, hunits *desired_space) +void space_node::spread_space(int *n_spaces, hunits *desired_space) { if (!set) { - assert(*nspaces > 0); - if (*nspaces == 1) { + assert(*n_spaces > 0); + if (*n_spaces == 1) { n += *desired_space; *desired_space = H0; } else { - hunits extra = *desired_space / *nspaces; + hunits extra = *desired_space / *n_spaces; *desired_space -= extra; n += extra; } - *nspaces -= 1; + *n_spaces -= 1; set = 1; } } @@ -3340,8 +3340,8 @@ void hmotion_node::asciify(macro *m) } space_char_hmotion_node::space_char_hmotion_node(hunits i, color *c, - node *next) -: hmotion_node(i, c, next) + node *nxt) +: hmotion_node(i, c, nxt) { } @@ -3395,14 +3395,14 @@ int node::nbreaks() return 0; } -breakpoint *space_node::get_breakpoints(hunits width, int ns, +breakpoint *space_node::get_breakpoints(hunits wd, int ns, breakpoint *rest, int is_inner) { - if (next->discardable()) + if (next && next->discardable()) return rest; breakpoint *bp = new breakpoint; bp->next = rest; - bp->width = width; + bp->width = wd; bp->nspaces = ns; bp->hyphenated = 0; if (is_inner) { @@ -3419,7 +3419,7 @@ breakpoint *space_node::get_breakpoints(hunits width, int ns, int space_node::nbreaks() { - if (next->discardable()) + if (next && next->discardable()) return 0; else return 1; @@ -3439,12 +3439,12 @@ static breakpoint *node_list_get_breakpoints(node *p, hunits *widthp, return rest; } -breakpoint *dbreak_node::get_breakpoints(hunits width, int ns, +breakpoint *dbreak_node::get_breakpoints(hunits wd, int ns, breakpoint *rest, int is_inner) { breakpoint *bp = new breakpoint; bp->next = rest; - bp->width = width; + bp->width = wd; for (node *tem = pre; tem != 0; tem = tem->next) bp->width += tem->width(); bp->nspaces = ns; @@ -3458,7 +3458,7 @@ breakpoint *dbreak_node::get_breakpoints(hunits width, int ns, bp->nd = this; bp->index = 0; } - return node_list_get_breakpoints(none, &width, ns, bp); + return node_list_get_breakpoints(none, &wd, ns, bp); } int dbreak_node::nbreaks() @@ -3763,10 +3763,10 @@ void suppress_node::tprint(troff_output_file *out) if (is_on == 2) { // remember position and filename last_position = position; - const char *tem = last_image_filename; + char *tem = (char *)last_image_filename; last_image_filename = strsave(filename.contents()); if (tem) - a_delete(tem); + a_delete tem; last_image_id = image_id; // printf("start of image and page = %d\n", current_page); } @@ -3776,7 +3776,10 @@ void suppress_node::tprint(troff_output_file *out) char name[8192]; // remember that the filename will contain a %d in which the // last_image_id is placed - sprintf(name, last_image_filename, last_image_id); + if (last_image_filename == (char *) 0) + *name = '\0'; + else + sprintf(name, last_image_filename, last_image_id); if (is_html) { switch (last_position) { case 'c': @@ -3985,10 +3988,10 @@ node *reverse_node_list(node *n) return r; } -void composite_node::vertical_extent(vunits *min, vunits *max) +void composite_node::vertical_extent(vunits *minimum, vunits *maximum) { n = reverse_node_list(n); - node_list_vertical_extent(n, min, max); + node_list_vertical_extent(n, minimum, maximum); n = reverse_node_list(n); } @@ -4780,9 +4783,9 @@ int hmotion_node::force_tprint() return 0; } -node *hmotion_node::add_self(node *n, hyphen_list **p) +node *hmotion_node::add_self(node *nd, hyphen_list **p) { - next = n; + next = nd; hyphen_list *pp = *p; *p = (*p)->next; delete pp; @@ -4810,9 +4813,9 @@ int space_char_hmotion_node::force_tprint() return 0; } -node *space_char_hmotion_node::add_self(node *n, hyphen_list **p) +node *space_char_hmotion_node::add_self(node *nd, hyphen_list **p) { - next = n; + next = nd; hyphen_list *pp = *p; *p = (*p)->next; delete pp; @@ -4937,8 +4940,8 @@ int italic_corrected_node::force_tprint() return 0; } -left_italic_corrected_node::left_italic_corrected_node(node *x) -: node(x), n(0) +left_italic_corrected_node::left_italic_corrected_node(node *xx) +: node(xx), n(0) { } @@ -5013,12 +5016,13 @@ hunits left_italic_corrected_node::width() return n ? n->width() + x : H0; } -void left_italic_corrected_node::vertical_extent(vunits *min, vunits *max) +void left_italic_corrected_node::vertical_extent(vunits *minimum, + vunits *maximum) { if (n) - n->vertical_extent(min, max); + n->vertical_extent(minimum, maximum); else - node::vertical_extent(min, max); + node::vertical_extent(minimum, maximum); } hunits left_italic_corrected_node::skew() @@ -5307,9 +5311,9 @@ const char *unbreakable_space_node::type() return "unbreakable_space_node"; } -node *unbreakable_space_node::add_self(node *n, hyphen_list **p) +node *unbreakable_space_node::add_self(node *nd, hyphen_list **p) { - next = n; + next = nd; hyphen_list *pp = *p; *p = (*p)->next; delete pp; @@ -5557,13 +5561,13 @@ void font_family::invalidate_fontno(int n) { assert(n >= 0 && n < font_table_size); dictionary_iterator iter(family_dictionary); - symbol nm; + symbol nam; font_family *fam; - while (iter.get(&nm, (void **)&fam)) { - int map_size = fam->map_size; - if (n < map_size) + while (iter.get(&nam, (void **)&fam)) { + int mapsize = fam->map_size; + if (n < mapsize) fam->map[n] = -1; - for (int i = 0; i < map_size; i++) + for (int i = 0; i < mapsize; i++) if (fam->map[i] == n) fam->map[i] = -1; } |
