diff options
author | wlemb <wlemb> | 2002-03-15 21:56:23 +0000 |
---|---|---|
committer | wlemb <wlemb> | 2002-03-15 21:56:23 +0000 |
commit | e68e47984bd71dd6a23618a6bd55dc1feea9d4e2 (patch) | |
tree | 6c0acc91e3e6ebdf6b25c3aa6a3b55afff31b3d3 | |
parent | 6b7180658989cef0e717899601b0d47ee3dab8a2 (diff) | |
download | groff-e68e47984bd71dd6a23618a6bd55dc1feea9d4e2.tar.gz |
Add request `trin' (translate input) to make `.asciify' work
correctly. This is necessary since `charXXX' entity names are no
longer hardcoded in font definition files.
* src/roff/troff/charinfo.h (charinfo): Add `asciify_code' and
`translate_input' members.
(charinfo::set_asciify_code, charinfo::get_asciify_code,
charinfo::set_translation_input): New methods.
(charinfo::set_translation): Add third argument.
* src/roff/troff/input.cc (charinfo:set_translation): Set
`asciify_code'.
(do_translate): Add second argument.
(translate_input): New function.
(init_input_requests): Updated.
* src/roff/troff/node.cc (glyph_node::asciify,
composite_node::asciify): Use `get_asciify_code'.
* tmac/cp1047.tmac, tmac/latin1.tmac: Use `trin'.
* NEWS, man/groff.man, man/groff_diff.man: Updated.
-rw-r--r-- | ChangeLog | 29 | ||||
-rw-r--r-- | NEWS | 16 | ||||
-rw-r--r-- | doc/groff.texinfo | 36 | ||||
-rw-r--r-- | man/groff.man | 124 | ||||
-rw-r--r-- | man/groff_diff.man | 39 | ||||
-rw-r--r-- | src/roff/troff/charinfo.h | 23 | ||||
-rw-r--r-- | src/roff/troff/input.cc | 35 | ||||
-rw-r--r-- | src/roff/troff/node.cc | 8 | ||||
-rw-r--r-- | tmac/cp1047.tmac | 2 | ||||
-rw-r--r-- | tmac/latin1.tmac | 2 |
10 files changed, 235 insertions, 79 deletions
@@ -1,3 +1,32 @@ +2002-03-15 Werner LEMBERG <wl@gnu.org> + + * man/groff.man: Add writem request. + + Add request `trin' (translate input) to make `.asciify' work + correctly. This is necessary since `charXXX' entity names are no + longer hardcoded in font definition files. + + * src/roff/troff/charinfo.h (charinfo): Add `asciify_code' and + `translate_input' members. + (charinfo::set_asciify_code, charinfo::get_asciify_code, + charinfo::set_translation_input): New methods. + (charinfo::set_translation): Add third argument. + * src/roff/troff/input.cc (charinfo:set_translation): Set + `asciify_code'. + (do_translate): Add second argument. + (translate_input): New function. + (init_input_requests): Updated. + * src/roff/troff/node.cc (glyph_node::asciify, + composite_node::asciify): Use `get_asciify_code'. + + * tmac/cp1047.tmac, tmac/latin1.tmac: Use `trin'. + + * NEWS, man/groff.man, man/groff_diff.man: Updated. + +2002-03-14 Larry Kollar <kollar@alltel.net> + + * doc/groff.texinfo: Improve documentation of .RS and .RE. + 2002-03-14 Werner LEMBERG <wl@gnu.org> Add a new request `sizes' similar to the `sizes' command in DESC @@ -87,6 +87,22 @@ o The new request `sizes' is similar to the `sizes' command in DESC files. It expects the same syntax; the data must be on a single line, and the final `0' can be omitted. +o `trin' (translate input) is a new request which is similar to `tr' with + the exception that the `asciify' request will use the character code (if + any) before the character translation. Example: + + .trin ax + .di xxx + a + .br + .di + .xxx + .trin aa + .asciify xxx + .xxx + + The result is `x a'. Using `tr', the result would be `x x'. + o A new escape sequence `\O' is available (mainly for internal use with grohtml). Please see groff_diff.7 and groff.texinfo for more details. diff --git a/doc/groff.texinfo b/doc/groff.texinfo index d2d0b348..dc68e8a0 100644 --- a/doc/groff.texinfo +++ b/doc/groff.texinfo @@ -2910,6 +2910,7 @@ Examples include paragraphs, sections, and other groups. * Headings in ms:: * Highlighting in ms:: * Lists in ms:: +* Indents in ms:: * Tabstops in ms:: * ms Displays and Keeps:: * ms Insertions:: @@ -3096,7 +3097,7 @@ Prints all text following in the normal point size @c --------------------------------------------------------------------- -@node Lists in ms, Tabstops in ms, Highlighting in ms, ms Body Text +@node Lists in ms, Indents in ms, Highlighting in ms, ms Body Text @subsubsection Lists @cindex @file{ms}, list macros @@ -3248,15 +3249,10 @@ Gotta pay for those lawyers and guns! @sp 1 To set nested lists, use the @code{RS} and @code{RE} macros. +@xref{Indents in ms}, for more information. @cindex @file{ms}, nested lists @cindex Nested lists (ms) -@DefmacList {RS, , ms} -@DefmacListEnd {RE, , ms} -These macros begin and end a section indented to line -up with the body of an @code{IP} macro. -@endDefmac - For example: @Example @@ -3292,7 +3288,29 @@ o Guns @c --------------------------------------------------------------------- -@node Tabstops in ms, ms Displays and Keeps, Lists in ms, ms Body Text +@node Indents in ms, Tabstops in ms, Lists in ms, ms Body Text +@subsubsection Indents + +In many situations, +you may need to indent a section of text +while still wrapping and filling. +@xref{Lists in ms}, +for an example of nested lists. + +@DefmacList {RS, , ms} +@DefmacListEnd {RE, , ms} +These macros begin and end an indented section. +The @code{PI} register controls the amount of indent, +allowing the indented text to line up under hanging +and indented paragraphs. +@endDefmac + +@xref{ms Displays and Keeps}, +for macros to indent and turn off filling. + +@c --------------------------------------------------------------------- + +@node Tabstops in ms, ms Displays and Keeps, Indents in ms, ms Body Text @subsubsection Tab Stops Use the @code{ta} request to define tab stops as needed. @@ -9036,7 +9054,7 @@ The @code{als} request can make a macro have more than one name. This would be called as @Example -.vl $Id: groff.texinfo,v 1.105 2002/03/14 06:10:53 wlemb Exp $ +.vl $Id: groff.texinfo,v 1.106 2002/03/15 21:56:23 wlemb Exp $ @endExample @endDefesc diff --git a/man/groff.man b/man/groff.man index 43ef42a8..14f64599 100644 --- a/man/groff.man +++ b/man/groff.man @@ -2,7 +2,7 @@ .ig groff.man -Last update: 6 Jan 2002 +Last update: 15 Mar 2002 This file is part of groff, the GNU roff type-setting system. @@ -84,7 +84,7 @@ FDL in the main directory of the groff source package. . shift . \} . \*[@m] \*[@s]\f[R] -. ft P \" to make \c happy +. ft P \" to make \c happy . rm @m . rm @s . rm @a @@ -491,7 +491,7 @@ backslash . .P The user can define her own formatting commands using the -.request .de +.request de request. . These commands are called @@ -516,7 +516,7 @@ variables as well. variables store character sequences. . They are set with the -.request .ds +.request ds request and retrieved by the .esc * escape sequences. @@ -527,7 +527,7 @@ variables can store numerical values, numbers with a scale unit, and occasionally string-like objects. . They are set with the -.request .nr +.request nr request and retrieved by the .esc n escape sequences. @@ -538,7 +538,7 @@ allow the user to temporarily store global formatting parameters like line length, font size, etc.\& for later reuse. . This is done by the -.request .ev +.request ev request. . .P @@ -546,7 +546,7 @@ request. are identified either by a name or by an internal number. . The current font is chosen by the -.request .ft +.request ft request or by the .esc f escape sequences. @@ -606,11 +606,11 @@ task in certain conditions. .character . A dot is only special at the beginning of a line or after the condition in the requests -.request .if , -.request .ie , -.request .el , +.request if , +.request ie , +.request el , and -.request .while . +.request while . There it is the control character that introduces a request (or macro). . The special behavior can be delayed by using the @@ -618,7 +618,7 @@ The special behavior can be delayed by using the escape. . By using the -.request .cc +.request cc request, the control character can be set to a different character, making the dot .squoted_char . @@ -640,7 +640,7 @@ That means that it introduces a request like the dot, but with the additional property that this request doesn't cause a linebreak. . By using the -.request .c2 +.request c2 request, the non-break control character can be set to a different character. . @@ -660,9 +660,9 @@ escape sequence. .character \[dq] The double quote is used to enclose arguments in requests and macros. In the -.request .ds +.request ds and -.request .as +.request as requests, a leading double quote in the argument will be stripped off, making everything else afterwards the string to be defined (enabling leading whitespace). @@ -931,10 +931,10 @@ For details see the groff info file. . .B Conditions occur in tests raised by the -.request .if , -.request .ie , +.request if , +.request ie , and the -.request .while +.request while requests. . The following table characterizes the different types of conditions. @@ -1151,8 +1151,8 @@ Create alias name for request, string, macro, or diversion Append to .I macro until -.request .. -is called. +.B ..\& +is encountered. . .REQ .am macro end Append to @@ -1165,8 +1165,8 @@ is called. Append to a macro whose name is contained in the string register .I macro until -.request .. -is called. +.B ..\& +is encountered. . .REQ .ami macro end Append to a macro indirectly. @@ -1352,8 +1352,8 @@ Divert and append to Define or redefine .I macro until -.request .. -is called. +.B ..\& +is encountered. . .REQ .de macro end Define or redefine @@ -1399,8 +1399,8 @@ can't be redefined. Define or redefine a macro whose name is contained in the string register .I macro until -.request .. -is called. +.B ..\& +is encountered. . .REQ .dei macro end Define or redefine a macro indirectly. @@ -1456,7 +1456,7 @@ Save current escape character. . .REQ .el anything Else part for if-else (\c -.request .ie ) +.request ie ) request. . .REQ .em macro @@ -1544,6 +1544,7 @@ will be special. Return to previous font. Same as .request \[rs]fP . +. .REQ .ft font Change to font name or number .IR font ; @@ -1623,8 +1624,8 @@ otherwise do nothing. . .REQ .ig Ignore text until -.request .. -is called. +.B ..\& +is encountered. . .REQ .ig end Ignore text until @@ -1812,7 +1813,7 @@ but append to it. . .REQ .os Output vertical distance that was saved by the -.request .sv +.request sv request. . .REQ .pc @@ -1875,7 +1876,7 @@ Get the bounding box of a PostScript image . .REQ .pso command This behaves like the -.request .so +.request so request except that input comes from the standard output of .IR command . . @@ -2005,7 +2006,7 @@ of vertical space. Save the vertical distance .I N for later output with -.request .os +.request os request. . .REQ .sy command-line @@ -2092,9 +2093,17 @@ etc.\& on output. Transparently output the contents of file .IR filename . . +.REQ .trin abcd.\|.\|.\& +This is the same as the +.request tr +request except that the +.B asciify +request will use the character code (if any) before the character +translation. +. .REQ .trnt abcd.\|.\|.\& This is the same as the -.request .tr +.request tr request except that the translations do not apply to text that is transparently throughput into a diversion with .esc ! . @@ -2154,6 +2163,12 @@ Write to the stream named .IR stream . . +.REQ .writem stream xx +Write contents of macro or string +.I xx +to the stream named +.IR stream . +. .PD . .P @@ -2237,7 +2252,7 @@ construct are used for special characters predefined by the roff system. Escapes sequences with names of more than two characters .esc[] "" name denote user defined named characters (see the -.request .char +.request char request). . . @@ -2283,7 +2298,7 @@ The string stored in the string variable with arbitrary length name The name by which the current macro was invoked. . The -.request .als +.request als request can make a macro have more than one name. . .ESC $ x @@ -2485,6 +2500,7 @@ Return format of register with name .I reg suitable for .request .af . +. Alternative forms .escarg g( xy and @@ -2554,7 +2570,7 @@ Typeset the character with code in the current font, no special fonts are searched. . Useful for adding characters to a font using the -.request .char +.request char request. . .ESCq o abc.\|.\|.\& @@ -2604,7 +2620,7 @@ Note the alternative forms .Text , .escarg s \[+-]x . Same as -.request .ps +.request ps request. . .ESCq S N @@ -2767,7 +2783,7 @@ Plus-minus sign .\" -------------------------------------------------------------------- . Strings are defined by the -.request .ds +.request ds request and can be retrieved by the .esc * escape sequence. @@ -2799,7 +2815,7 @@ above), but some can also hold a string value. .P Each register is given a name. Arbitrary registers can be defined and set with the request -.request .nr +.request nr .IR register . . .P @@ -2862,7 +2878,7 @@ It is positive if the character extends below the baseline. . .REG .ce The number of lines remaining to be centered, as set by the -.request .ce +.request ce request. . .REG .cht @@ -2915,22 +2931,22 @@ The number of immediately preceding consecutive hyphenated lines. .REG .hlm The maximum allowed number of consecutive hyphenated lines, as set by the -.request .hlm +.request hlm request. . .REG .hy The current hyphenation flags (as set by the -.request .hy +.request hy request). . .REG .hym The current hyphenation margin (as set by the -.request .hym +.request hym request). . .REG .hys The current hyphenation space (as set by the -.request .hys +.request hys request). . .REG .i @@ -2951,12 +2967,12 @@ Current line length. . .REG .lg The current ligature mode (as set by the -.request .lg +.request lg request). . .REG .linetabs The current line-tabs mode (as set by the -.request .linetabs +.request linetabs request). . .REG .ll @@ -2964,7 +2980,7 @@ The line length that applies to the current output line. . .REG .lt The title length (as set by the -.request .lt +.request lt request). . .REG .n @@ -2972,7 +2988,7 @@ Length of text portion on previous output line. . .REG .ne The amount of space that was needed in the last -.request .ne +.request ne request that caused a trap to be sprung. . Useful in conjunction with @@ -2989,7 +3005,7 @@ Current page length. . .REG .pn The number of the next page: either the value set by a -.request .pn +.request pn request, or the number of the current page plus\ 1. . .REG .ps @@ -3020,13 +3036,13 @@ is used. .REG .tabs A string representation of the current tab settings suitable for use as an argument to the -.request .ta +.request ta request. . .REG .trunc The amount of vertical space truncated by the most recently sprung vertical position trap, or, if the trap was sprung by a -.request .ne +.request ne request, minus the amount of vertical motion produced by .request .ne . . @@ -3040,12 +3056,12 @@ register. . .REG .ss The value of the parameters set by the first argument of the -.request .ss +.request ss request. . .REG .sss The value of the parameters set by the second argument of the -.request .ss +.request ss request. . .REG .u @@ -3173,7 +3189,7 @@ Height of string above base line (generated by width function The return value of the .I system() function executed by the last -.request .sy +.request sy request. . .REG urx diff --git a/man/groff_diff.man b/man/groff_diff.man index 2fafc6f5..923742c7 100644 --- a/man/groff_diff.man +++ b/man/groff_diff.man @@ -1928,7 +1928,44 @@ request, the file cannot contain characters such as that are not legal troff input characters. . .TP -.B .trnt abcd +.BI .trin\ abcd +This is the same as the +.B tr +request except that the +.B asciify +request will use the character code (if any) before the character +translation. +. +Example: +. +.RS +.IP +.nf +.ft CB +.Text .trin ax +.Text .di xxx +.Text a +.Text .br +.Text .di +.Text .xxx +.Text .trin aa +.Text .asciify xxx +.Text .xxx +.fi +.ft +.RE +. +.IP +The result is +.BR x\ a . +. +Using +.BR tr , +the result would be +.BR x\ x . +. +.TP +.BI .trnt\ abcd This is the same as the .B tr request except that the translations do not apply to text that is diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h index 048d6266..68ae25eb 100644 --- a/src/roff/troff/charinfo.h +++ b/src/roff/troff/charinfo.h @@ -1,5 +1,6 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2001 Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2001, 2002 + Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. @@ -30,9 +31,12 @@ class charinfo { unsigned char hyphenation_code; unsigned char flags; unsigned char ascii_code; + unsigned char asciify_code; char not_found; - char transparent_translate; // non-zero means translation applies to + char transparent_translate; // non-zero means translation applies // to transparent throughput + char translate_input; // non-zero means that asciify_code is + // active for .asciify (set by .trin) char fallback; public: enum { @@ -62,10 +66,13 @@ public: int transparent(); unsigned char get_hyphenation_code(); unsigned char get_ascii_code(); + unsigned char get_asciify_code(); void set_hyphenation_code(unsigned char); void set_ascii_code(unsigned char); + void set_asciify_code(unsigned char); + void set_translation_input(); charinfo *get_translation(int = 0); - void set_translation(charinfo *, int); + void set_translation(charinfo *, int, int); void set_flags(unsigned char); void set_special_translation(int, int); int get_special_translation(int = 0); @@ -140,6 +147,11 @@ inline unsigned char charinfo::get_ascii_code() return ascii_code; } +inline unsigned char charinfo::get_asciify_code() +{ + return (translate_input ? asciify_code : 0); +} + inline void charinfo::set_flags(unsigned char c) { flags = c; @@ -150,6 +162,11 @@ inline int charinfo::get_index() return index; } +inline void charinfo::set_translation_input() +{ + translate_input = 1; +} + inline int charinfo::get_special_translation(int transparent_throughput) { return (transparent_throughput && !transparent_translate diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc index ba60eb38..c7389888 100644 --- a/src/roff/troff/input.cc +++ b/src/roff/troff/input.cc @@ -5598,7 +5598,7 @@ static void init_charset_table() page_character = charset_table['%']; } -static void do_translate(int translate_transparent) +static void do_translate(int translate_transparent, int translate_input) { tok.skip(); while (!tok.newline() && !tok.eof()) { @@ -5637,9 +5637,9 @@ static void do_translate(int translate_transparent) if (ci2 == 0) break; if (ci1 == ci2) - ci1->set_translation(0, translate_transparent); + ci1->set_translation(0, translate_transparent, translate_input); else - ci1->set_translation(ci2, translate_transparent); + ci1->set_translation(ci2, translate_transparent, translate_input); } tok.next(); } @@ -5648,12 +5648,17 @@ static void do_translate(int translate_transparent) void translate() { - do_translate(1); + do_translate(1, 0); } void translate_no_transparent() { - do_translate(0); + do_translate(0, 0); +} + +void translate_input() +{ + do_translate(1, 1); } void char_flags() @@ -6725,6 +6730,7 @@ void init_input_requests() init_request("blm", blank_line_macro); init_request("tr", translate); init_request("trnt", translate_no_transparent); + init_request("trin", translate_input); init_request("ab", abort_request); init_request("pi", pipe_output); init_request("cf", copy_file); @@ -7152,8 +7158,9 @@ int charinfo::next_index = 0; charinfo::charinfo(symbol s) : translation(0), mac(0), special_translation(TRANSLATE_NONE), - hyphenation_code(0), flags(0), ascii_code(0), not_found(0), - transparent_translate(1), fallback(0), nm(s) + hyphenation_code(0), flags(0), ascii_code(0), asciify_code(0), + not_found(0), transparent_translate(1), translate_input(0), + fallback(0), nm(s) { index = next_index++; } @@ -7163,9 +7170,16 @@ void charinfo::set_hyphenation_code(unsigned char c) hyphenation_code = c; } -void charinfo::set_translation(charinfo *ci, int tt) +void charinfo::set_translation(charinfo *ci, int tt, int ti) { translation = ci; + if (ci && ti) { + if (asciify_code != 0) + ci->set_asciify_code(asciify_code); + else if (ascii_code != 0) + ci->set_asciify_code(ascii_code); + ci->set_translation_input(); + } special_translation = TRANSLATE_NONE; transparent_translate = tt; } @@ -7182,6 +7196,11 @@ void charinfo::set_ascii_code(unsigned char c) ascii_code = c; } +void charinfo::set_asciify_code(unsigned char c) +{ + asciify_code = c; +} + macro *charinfo::set_macro(macro *m, int f) { macro *tem = mac; diff --git a/src/roff/troff/node.cc b/src/roff/troff/node.cc index e894736a..76db8cad 100644 --- a/src/roff/troff/node.cc +++ b/src/roff/troff/node.cc @@ -3171,7 +3171,9 @@ void node::asciify(macro *m) void glyph_node::asciify(macro *m) { - unsigned char c = ci->get_ascii_code(); + unsigned char c = ci->get_asciify_code(); + if (c == 0) + c = ci->get_ascii_code(); if (c != 0) { m->append(c); delete this; @@ -3893,7 +3895,9 @@ hyphenation_type composite_node::get_hyphenation_type() void composite_node::asciify(macro *m) { - unsigned char c = ci->get_ascii_code(); + unsigned char c = ci->get_asciify_code(); + if (c == 0) + c = ci->get_ascii_code(); if (c != 0) { m->append(c); delete this; diff --git a/tmac/cp1047.tmac b/tmac/cp1047.tmac index e87630df..c16d921d 100644 --- a/tmac/cp1047.tmac +++ b/tmac/cp1047.tmac @@ -3,7 +3,7 @@ .nr _C \n(.C .cp 0 .de cp1047-tr -. if c\\$2 .if !c\\$1 .tr \\$1\\$2 +. if c\\$2 .if !c\\$1 .trin \\$1\\$2 .. . .cp1047-tr \[char66] \[^a] diff --git a/tmac/latin1.tmac b/tmac/latin1.tmac index 2bdad89a..ae7509ca 100644 --- a/tmac/latin1.tmac +++ b/tmac/latin1.tmac @@ -3,7 +3,7 @@ .nr _C \n(.C .cp 0 .de latin1-tr -. if c\\$2 .if !c\\$1 .tr \\$1\\$2 +. if c\\$2 .if !c\\$1 .trin \\$1\\$2 .. . .latin1-tr \[char161] \(r! |