? groff/junk ? groff/test-groff ? groff/arch/misc/shdeps.sed ? groff/contrib/mom/examples/stamp ? groff/src/devices/grolj4/lj4_font.n ? groff/src/preproc/eqn/y.output ? groff/tmac/an-wrap ? groff/tmac/ansun-wrap ? groff/tmac/bib-wrap ? groff/tmac/m-wrap ? groff/tmac/s-wrap ? groff/tmac/v-wrap ? groff/tmac/vgrind-wrap ? groff/tmac/www.tmac-sed Index: groff/src/preproc/tbl/main.cpp =================================================================== RCS file: /cvsroot/groff/groff/src/preproc/tbl/main.cpp,v retrieving revision 1.6 diff -u -r1.6 main.cpp --- groff/src/preproc/tbl/main.cpp 13 Sep 2004 08:13:48 -0000 1.6 +++ groff/src/preproc/tbl/main.cpp 17 Sep 2004 01:52:29 -0000 @@ -519,7 +519,7 @@ } entry_modifier::entry_modifier() -: vertical_alignment(CENTER), zero_width(0), stagger(0) +: vertical_alignment(CENTER), zero_width(0), stagger(0), expand_col(0) { vertical_spacing.inc = vertical_spacing.val = 0; point_size.inc = point_size.val = 0; @@ -616,6 +616,7 @@ struct format { int nrows; int ncolumns; + int expand_column; int *separation; string *width; char *equal; @@ -627,7 +628,7 @@ void add_rows(int n); }; -format::format(int nr, int nc) : nrows(nr), ncolumns(nc) +format::format(int nr, int nc) : nrows(nr), ncolumns(nc), expand_column(-1) { int i; separation = ncolumns > 1 ? new int[ncolumns - 1] : 0; @@ -837,6 +838,11 @@ int success = 1; do { switch (c) { + case 'y': + case 'Y': + c = in.get(); + list->expand_col = 1; + break; case 't': case 'T': c = in.get(); @@ -1138,6 +1144,14 @@ } col = 0; for (tem = list; tem; tem = tem->next) { + if (tem->expand_col) { + if (f->expand_column >= 0 && f->expand_column != col) { + error("X modifier can only be applied to one column"); + } + else { + f->expand_column = col; + } + } f->entry[row][col] = *tem; if (col < ncolumns-1) { // use the greatest separation @@ -1174,6 +1188,9 @@ else col++; } + if (f->expand_column >= 0) { + opt->flags |= table::EXPAND; + } free_input_entry_format_list(list); for (col = 0; col < ncolumns; col++) { entry_format *e = f->entry[f->nrows-1] + col; @@ -1199,7 +1216,7 @@ int give_up = 0; enum { DATA_INPUT_LINE, TROFF_INPUT_LINE, SINGLE_HLINE, DOUBLE_HLINE } type; table *tbl = new table(ncolumns, opt->flags, opt->linesize, - opt->decimal_point_char); + opt->decimal_point_char, f->expand_column); if (opt->delim[0] != '\0') tbl->set_delim(opt->delim[0], opt->delim[1]); for (;;) { Index: groff/src/preproc/tbl/table.cpp =================================================================== RCS file: /cvsroot/groff/groff/src/preproc/tbl/table.cpp,v retrieving revision 1.5 diff -u -r1.5 table.cpp --- groff/src/preproc/tbl/table.cpp 13 Sep 2004 08:13:48 -0000 1.5 +++ groff/src/preproc/tbl/table.cpp 17 Sep 2004 01:52:29 -0000 @@ -138,6 +138,15 @@ class double_line_entry; class simple_entry; +struct expand_divert { + int nrows; + int expand_column; + unsigned flags; + int right_separation; + int left_separation; + char **vline; +}; + class table_entry { friend class table; table_entry *next; @@ -153,7 +162,7 @@ void set_location(); table_entry(const entry_modifier *); virtual ~table_entry(); - virtual int divert(int ncols, const string *mw, int *sep); + virtual int divert(int ncols, const string *mw, int *sep, const expand_divert *xdiv); virtual void do_width(); virtual void do_depth(); virtual void print() = 0; @@ -289,13 +298,14 @@ }; class block_entry : public table_entry { +friend class table; char *contents; protected: - void do_divert(int alphabetic, int ncols, const string *mw, int *sep); + void do_divert(int alphabetic, int ncols, const string *mw, int *sep, const expand_divert *xdiv); public: block_entry(char *s, const entry_modifier *m); ~block_entry(); - int divert(int ncols, const string *mw, int *sep); + int divert(int ncols, const string *mw, int *sep, const expand_divert *xdiv); void do_width(); void do_depth(); void position_vertically(); @@ -324,7 +334,7 @@ public: alphabetic_block_entry(char *s, const entry_modifier *m); void print(); - int divert(int ncols, const string *mw, int *sep); + int divert(int ncols, const string *mw, int *sep, const expand_divert *xdiv); }; table_entry::table_entry(const entry_modifier *m) @@ -337,7 +347,7 @@ { } -int table_entry::divert(int, const string *, int *) +int table_entry::divert(int, const string *, int *, const expand_divert *) { return 0; } @@ -651,42 +661,76 @@ prints(".sp -.5v\n"); } -int block_entry::divert(int ncols, const string *mw, int *sep) +int block_entry::divert(int ncols, const string *mw, int *sep, const expand_divert *xdiv) { - do_divert(0, ncols, mw, sep); + do_divert(0, ncols, mw, sep, xdiv); return 1; } void block_entry::do_divert(int alphabetic, int ncols, const string *mw, - int *sep) + int *sep, const expand_divert *xdiv) { printfs(".di %1\n", block_diversion_name(start_row, start_col)); prints(".if \\n[" SAVED_FILL_REG "] .fi\n" ".in 0\n"); - prints(".ll "); - int i; - for (i = start_col; i <= end_col; i++) - if (mw[i].empty()) - break; - if (i > end_col) { - // Every column spanned by this entry has a minimum width. - for (int j = start_col; j <= end_col; j++) { - if (j > start_col) { - if (sep) - printfs("+%1n", as_string(sep[j - 1])); - prints('+'); + + if (xdiv->expand_column >= 0 && start_col == xdiv->expand_column) { + int left_separation = xdiv->left_separation; + int right_separation = xdiv->right_separation; + if (xdiv->flags & (table::ALLBOX|table::BOX|table::DOUBLEBOX)) + left_separation = right_separation = 1; + else { + for (int i = 0; i < xdiv->nrows; i++) { + if (xdiv->vline[i][0] > 0) + left_separation = 1; + if (xdiv->vline[i][ncols] > 0) + right_separation = 1; + } + } + int total_sep = left_separation + right_separation; + if (sep) { + int i; + for (i = 0; i < ncols - 1; i++) + total_sep += sep[i]; + if (total_sep != 0) { + printfs(".nr %1 \\n[.l]-\\n[.i]", + span_width_reg(xdiv->expand_column, xdiv->expand_column)); + for (i = 0; i < ncols; i++) + if (i < start_col || i > end_col ) + printfs("-\\n[%1]", span_width_reg(i,i)); + else if ( i != end_col ) + printfs("+%1n", as_string(sep[i])); } - printfs("(n;%1)", mw[j]); + prints("\n"); } - printfs(">?\\n[%1]u", span_width_reg(start_col, end_col)); + printfs(".ll \\n[%1]u", span_width_reg(xdiv->expand_column, xdiv->expand_column)); + } + else { + printfs(".ll "); + int i; + for (i = start_col; i <= end_col; i++) + if (mw[i].empty()) + break; + if (i > end_col) { + // Every column spanned by this entry has a minimum width. + for (int j = start_col; j <= end_col; j++) { + if (j > start_col) { + if (sep) + printfs("+%1n", as_string(sep[j - 1])); + prints('+'); + } + printfs("(n;%1)", mw[j]); + } + printfs(">?\\n[%1]u", span_width_reg(start_col, end_col)); + } + else + printfs("(u;\\n[%1]>?(\\n[.l]*%2/%3))", + span_width_reg(start_col, end_col), + as_string(end_col - start_col + 1), + as_string(ncols + 1)); + if (alphabetic) + prints("-2n"); } - else - printfs("(u;\\n[%1]>?(\\n[.l]*%2/%3))", - span_width_reg(start_col, end_col), - as_string(end_col - start_col + 1), - as_string(ncols + 1)); - if (alphabetic) - prints("-2n"); prints("\n"); prints(".cp \\n(" COMPATIBLE_REG "\n"); set_modifier(mod); @@ -772,9 +816,9 @@ { } -int alphabetic_block_entry::divert(int ncols, const string *mw, int *sep) +int alphabetic_block_entry::divert(int ncols, const string *mw, int *sep, const expand_divert *xdiv) { - do_divert(1, ncols, mw, sep); + do_divert(1, ncols, mw, sep, xdiv); return 1; } @@ -1196,8 +1240,8 @@ } } -table::table(int nc, unsigned f, int ls, char dpc) -: flags(f), nrows(0), ncolumns(nc), linesize(ls), decimal_point_char(dpc), +table::table(int nc, unsigned f, int ls, char dpc, int ec) +: flags(f), nrows(0), ncolumns(nc), linesize(ls), expand_column(ec), decimal_point_char(dpc), vrule_list(0), stuff_list(0), span_list(0), entry_list(0), entry_list_tailp(&entry_list), entry(0), vline(0), row_is_all_lines(0), left_separation(0), right_separation(0), @@ -2022,11 +2066,23 @@ for (i = 0; i < ncolumns - 1; i++) total_sep += column_separation[i]; if (total_sep != 0) { - // Don't let the separation factor be negative. - prints(".nr " SEPARATION_FACTOR_REG " \\n[.l]-\\n[.i]"); - for (i = 0; i < ncolumns; i++) - printfs("-\\n[%1]", span_width_reg(i, i)); - printfs("/%1>?0\n", as_string(total_sep)); + if (expand_column >= 0) { + printfs(".nr %1 \\n[.l]-\\n[.i]", + span_width_reg(expand_column, expand_column)); + for (i = 0; i < ncolumns; i++) { + if ( i != expand_column ) { + printfs("-\\n[%1]", span_width_reg(i, i)); + } + } + printfs("-%1\n", as_string(total_sep)); + } + else { + // Don't let the separation factor be negative. + prints(".nr " SEPARATION_FACTOR_REG " \\n[.l]-\\n[.i]"); + for (i = 0; i < ncolumns; i++) + printfs("-\\n[%1]", span_width_reg(i, i)); + printfs("/%1>?0\n", as_string(total_sep)); + } } } } @@ -2118,9 +2174,16 @@ sum_columns(p->start_col, p->end_col); int had_spanning_block = 0; int had_equal_block = 0; + struct expand_divert xdiv; + xdiv.nrows = nrows; + xdiv.expand_column = expand_column; + xdiv.flags = flags; + xdiv.right_separation = right_separation; + xdiv.left_separation = left_separation; + xdiv.vline = vline; for (q = entry_list; q; q = q->next) if (q->divert(ncolumns, minimum_width, - (flags & EXPAND) ? column_separation : 0)) { + ((flags & EXPAND) ? column_separation : 0), &xdiv )) { if (q->end_col > q->start_col) had_spanning_block = 1; for (i = q->start_col; i <= q->end_col && !had_equal_block; i++) Index: groff/src/preproc/tbl/table.h =================================================================== RCS file: /cvsroot/groff/groff/src/preproc/tbl/table.h,v retrieving revision 1.7 diff -u -r1.7 table.h --- groff/src/preproc/tbl/table.h 13 Sep 2004 08:13:48 -0000 1.7 +++ groff/src/preproc/tbl/table.h 17 Sep 2004 01:52:29 -0000 @@ -53,6 +53,7 @@ enum { CENTER, TOP, BOTTOM } vertical_alignment; char zero_width; char stagger; + char expand_col; entry_modifier(); ~entry_modifier(); @@ -88,6 +89,7 @@ int nrows; int ncolumns; int linesize; + int expand_column; char delim[2]; char decimal_point_char; vertical_rule *vrule_list; @@ -140,7 +142,7 @@ NOKEEP = 040, NOSPACES = 0100 }; - table(int nc, unsigned flags, int linesize, char decimal_point_char); + table(int nc, unsigned flags, int linesize, char decimal_point_char, int expand_col); ~table(); void add_text_line(int r, const string &, const char *, int);