From 231f434da74cd4ab44baa62e5b481d8e9e5e120d Mon Sep 17 00:00:00 2001 From: wl Date: Mon, 7 Jan 2013 08:54:28 +0000 Subject: [tbl] Allow characters #, `, and ' as eqn delimiters. While problems ` and ' have been unintentionally introduced rather recently, the limitation regarding # was there from the beginning. At the same time, fix a small bug causing `.lf' requests not starting a line. * src/preproc/tbl/table.cpp (table::init_output, table::compute_expand_width, table::compute_separation_factor, table::define_bottom_macro, table::do_bottom): Temporarily switch off eqn delimiters, wrapping the code into a `.ig' block. This uses the new functionality just added to eqn. * src/preproc/eqn/eqn.man, src/preproc/tbl/tbl.man: Updated. --- src/preproc/eqn/eqn.man | 11 ------- src/preproc/tbl/table.cpp | 76 +++++++++++++++++++++++++++++++++++++++++------ src/preproc/tbl/tbl.man | 12 +------- 3 files changed, 68 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/preproc/eqn/eqn.man b/src/preproc/eqn/eqn.man index 203d9033..61df4e64 100644 --- a/src/preproc/eqn/eqn.man +++ b/src/preproc/eqn/eqn.man @@ -1187,17 +1187,6 @@ A type of causes a character to be set in roman type. . . -.SH "INTERACTION WITH @G@TBL" -It is not advisable to use the hash character (#) as a delimiter for in-line -equations in -.B eqn -since -.BR @g@tbl (@MAN1EXT@) -uses a macro called -.BR .T# , -causing a clash. -. -. .SH FILES .Tp \w'\fB@MACRODIR@/eqnrc'u+2n .B @MACRODIR@/eqnrc diff --git a/src/preproc/tbl/table.cpp b/src/preproc/tbl/table.cpp index 64f5ab40..9a7789ce 100644 --- a/src/preproc/tbl/table.cpp +++ b/src/preproc/tbl/table.cpp @@ -1819,6 +1819,12 @@ void table::init_output() ".in 0\n" ".\\}\n" "..\n" + // protect # in macro name against eqn + ".ig\n" + ".EQ\n" + "delim off\n" + ".EN\n" + "..\n" ".de " RELEASE_MACRO_NAME "\n" ".if \\n[" SECTION_DIVERSION_FLAG_REG "] \\{" ".di\n" @@ -1850,6 +1856,11 @@ void table::init_output() ".rm " SECTION_DIVERSION_NAME "\n" ".\\}\n" "..\n" + ".ig\n" + ".EQ\n" + "delim on\n" + ".EN\n" + "..\n" ".nr " TABLE_DIVERSION_FLAG_REG " 0\n" ".de " TABLE_KEEP_MACRO_NAME "\n" ".if '\\n[.z]'' \\{" @@ -2113,12 +2124,24 @@ void table::compute_expand_width() if (total_separation) printfs("-%1n", as_string(total_separation)); prints("\n"); - prints(".if \\n[" EXPAND_REG "]<0 \\{"); + prints(".if \\n[" EXPAND_REG "]<0 \\{\\\n"); entry_list->set_location(); - if (!(flags & NOWARN)) + if (!(flags & NOWARN)) { + // protect ` and ' in warning message against eqn + prints(".ig\n" + ".EQ\n" + "delim off\n" + ".EN\n" + "..\n"); prints(".tm1 \"warning: file `\\n[.F]', around line \\n[.c]:\n" - ".tm1 \" table wider than line width\n" - ".nr " EXPAND_REG " 0\n"); + ".tm1 \" table wider than line width\n"); + prints(".ig\n" + ".EQ\n" + "delim on\n" + ".EN\n" + "..\n"); + prints(".nr " EXPAND_REG " 0\n"); + } prints(".\\}\n"); if (colcount > 1) printfs(".nr " EXPAND_REG " \\n[" EXPAND_REG "]/%1\n", @@ -2153,18 +2176,31 @@ void table::compute_separation_factor() for (int i = 0; i < ncolumns; i++) printfs("-\\n[%1]", span_width_reg(i, i)); printfs("/%1\n", as_string(total_separation)); - prints(".ie \\n[" SEPARATION_FACTOR_REG "]<=0 \\{"); + prints(".ie \\n[" SEPARATION_FACTOR_REG "]<=0 \\{\\\n"); entry_list->set_location(); - if (!(flags & NOWARN)) + if (!(flags & NOWARN)) { + // protect ` and ' in warning message against eqn + prints(".ig\n" + ".EQ\n" + "delim off\n" + ".EN\n" + "..\n"); prints(".tm1 \"warning: file `\\n[.F]', around line \\n[.c]:\n" ".tm1 \" column separation set to zero\n" ".nr " SEPARATION_FACTOR_REG " 0\n"); + } prints(".\\}\n" - ".el .if \\n[" SEPARATION_FACTOR_REG "]<1n \\{"); + ".el .if \\n[" SEPARATION_FACTOR_REG "]<1n \\{\\\n"); entry_list->set_location(); - if (!(flags & NOWARN)) + if (!(flags & NOWARN)) { prints(".tm1 \"warning: file `\\n[.F]', around line \\n[.c]:\n" ".tm1 \" table squeezed horizontally to fit line length\n"); + prints(".ig\n" + ".EQ\n" + "delim on\n" + ".EN\n" + "..\n"); + } prints(".\\}\n"); } @@ -2602,6 +2638,12 @@ void table::build_vrule_list() void table::define_bottom_macro() { prints(".eo\n" + // protect # in macro name against eqn + ".ig\n" + ".EQ\n" + "delim off\n" + ".EN\n" + "..\n" ".de T#\n" ".if !\\n[" SUPPRESS_BOTTOM_REG "] \\{" "." REPEATED_VPT_MACRO " 0\n" @@ -2636,6 +2678,11 @@ void table::define_bottom_macro() "." REPEATED_VPT_MACRO " 1\n" ".\\}\n" "..\n" + ".ig\n" + ".EQ\n" + "delim on\n" + ".EN\n" + "..\n" ".ec\n"); } @@ -2882,7 +2929,18 @@ void table::do_bottom() printfs(".mk %1\n", row_top_reg(nrows)); prints(".nr " NEED_BOTTOM_RULE_REG " 1\n" ".nr T. 1\n" - ".T#\n"); + // protect # in macro name against eqn + ".ig\n" + ".EQ\n" + "delim off\n" + ".EN\n" + "..\n" + ".T#\n" + ".ig\n" + ".EQ\n" + "delim on\n" + ".EN\n" + "..\n"); if (!(flags & NOKEEP) && (flags & (BOX | DOUBLEBOX | ALLBOX))) prints("." TABLE_RELEASE_MACRO_NAME "\n"); else diff --git a/src/preproc/tbl/tbl.man b/src/preproc/tbl/tbl.man index 3aafe246..9c7be498 100644 --- a/src/preproc/tbl/tbl.man +++ b/src/preproc/tbl/tbl.man @@ -1,6 +1,6 @@ '\" t .ig -Copyright (C) 1989-1995, 2001-2004, 2006-2012 +Copyright (C) 1989-1995, 2001-2004, 2006-2013 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of @@ -742,16 +742,6 @@ should always be called before .RB ( groff (@MAN1EXT@) automatically takes care of the correct order of preprocessors). . -.LP -It is not advisable to use the hash character (#) as a delimiter for in-line -equations in -.BR @g@eqn (@MAN1EXT@) -since -.B @g@tbl -uses a macro called -.BR .T# , -causing a clash. -. . .SH "GNU TBL ENHANCEMENTS" There is no limit on the number of columns in a table, nor any limit on the -- cgit v1.2.1