From 2cb0df330838a0f76209415679eae40517857968 Mon Sep 17 00:00:00 2001 From: wlemb Date: Sun, 6 May 2001 23:29:20 +0000 Subject: Added two new requests `de1' and `am1' which are similar to `de' and `am' with the difference that compatibility mode is saved on entry, switched off during macro execution, and restored on exit. * src/roff/troff/input.h: Added two new special characters (COMPATIBLE_SAVE, COMPATIBLE_RESTORE). * src/roff/troff/input.cc (input_iterator): Added two member functions `save_compatible_flag' and `get_compatible_flag'. (input_stack): Ditto. (string_iterator): Ditto. Also add private member `saved_compatible_flag'. (token::next): Use COMPATIBLE_SAVE and COMPATIBLE_RESTORE. (calling_mode): New enumeration. (do_define_macro): Use it. Insert COMPATIBLE_SAVE and COMPATIBLE_RESTORE at the beginning and end of macro, respectively. (define_macro, define_indirect_macro, append_macro, ignore): Use `calling_mode'. (define_nocomp_macro, append_nocomp_macro): New functions. (init_input_requests): Updated. (do_request): Rename local variable `saved_compatible_flag' to `old_compatible_flag'. * NEWS, src/roff/troff/troff.man, man/groff.man: Document it. * tmac/an-old.tmac: Use `de1' instead of `de' request for all public and trap-invoked macros. As a consequence, the man macros work in compatibility mode also. * Makefile.in: Use $(mandir). --- ChangeLog | 33 ++++++++++++++++++++++++++++ Makefile.in | 3 ++- NEWS | 6 ++++- man/groff.man | 29 ++++++++++++++++++++++-- src/roff/troff/input.cc | 57 +++++++++++++++++++++++++++++++++++++++++------- src/roff/troff/input.h | 4 ++++ src/roff/troff/troff.man | 16 ++++++++++++++ tmac/an-old.tmac | 54 ++++++++++++++++++++++----------------------- 8 files changed, 162 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index f3021271..60cebd2c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2001-05-06 Werner LEMBERG + + Added two new requests `de1' and `am1' which are similar to `de' and + `am' with the difference that compatibility mode is saved on entry, + switched off during macro execution, and restored on exit. + + * src/roff/troff/input.h: Added two new special characters + (COMPATIBLE_SAVE, COMPATIBLE_RESTORE). + * src/roff/troff/input.cc (input_iterator): Added two member + functions `save_compatible_flag' and `get_compatible_flag'. + (input_stack): Ditto. + (string_iterator): Ditto. Also add private member + `saved_compatible_flag'. + (token::next): Use COMPATIBLE_SAVE and COMPATIBLE_RESTORE. + (calling_mode): New enumeration. + (do_define_macro): Use it. Insert COMPATIBLE_SAVE and + COMPATIBLE_RESTORE at the beginning and end of macro, respectively. + (define_macro, define_indirect_macro, append_macro, ignore): Use + `calling_mode'. + (define_nocomp_macro, append_nocomp_macro): New functions. + (init_input_requests): Updated. + (do_request): Rename local variable `saved_compatible_flag' to + `old_compatible_flag'. + * NEWS, src/roff/troff/troff.man, man/groff.man: Document it. + + * tmac/an-old.tmac: Use `de1' instead of `de' request for all + public and trap-invoked macros. As a consequence, the man macros + work in compatibility mode also. + +2001-05-06 Solar Designer + + * Makefile.in: Use $(mandir). + 2001-05-06 Alexios Zavras * src/utils/afmtodit/afmtodit.pl: Fix serious typo. diff --git a/Makefile.in b/Makefile.in index 63073ec3..e3349d9f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -158,7 +158,8 @@ indexname=Ind common_words_file=$(datasubdir)/eign # manroot is the root of the man page directory tree. -manroot=@mandir@ +mandir=@mandir@ +manroot=$(mandir) # man1ext is the man section for user commands. man1ext=1 diff --git a/NEWS b/NEWS index 65f65538..d7c64b85 100644 --- a/NEWS +++ b/NEWS @@ -5,11 +5,15 @@ described. There are more details in the man pages. VERSION 1.17.1 ============== -This is a bug-fixing release. +This is mainly a bug-fixing release. Troff ----- +o Two new requests `de1' and `am1' which are similar to `de' and `am' but + with compatibility mode disabled during expansion of macros defined by + them. + o Added request `brp'. This is the same as `\p'. o New read-only number register `.ns'. Returns 1 in no-space mode (if in diff --git a/man/groff.man b/man/groff.man index d5d38768..c2a66661 100644 --- a/man/groff.man +++ b/man/groff.man @@ -4,7 +4,7 @@ groff.7 This file is part of groff, the GNU roff type-setting system. -Copyright (C) 2000 Free Software Foundation, Inc. +Copyright (C) 2000, 2001 Free Software Foundation, Inc. written by Bernd Warken Last update: 17 May 2000 @@ -866,6 +866,16 @@ until .request .end is called. . +.REQ .am1 macro +Same as +.request .am +but with compatibility mode switched off during macro expansion. +. +.REQ .am1 macro end +Same as +.request .am +but with compatibility mode switched off during macro expansion. +. .REQ .as stringvar anything Append .argument anything @@ -892,6 +902,9 @@ Embolden Special Font when current font is .argument font . . +.REQ .blm +Unset the blank line macro. +. .REQ .blm macro Set the blank line macro to .argument macro . @@ -924,6 +937,8 @@ Line break. . .REQ .brp Break and spread output line. +Same as +.esc p . . .REQ .break Break out of a while loop. @@ -1032,6 +1047,16 @@ until .request .end is called. . +.REQ .de1 macro +Same as +.request .de +but with compatibility mode switched off during macro expansion. +. +.REQ .de1 macro end +Same as +.request .de +but with compatibility mode switched off during macro expansion. +. .REQ .dei macro Define or redefine a macro whose name is contained in the string register .argument macro @@ -1057,7 +1082,7 @@ Divert to .REQ .do name Interpret .request .name -with compatibility mode enabled. +with compatibility mode disabled. . .REQ .ds stringvar anything Set diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc index 9171ecc7..ee7833b4 100644 --- a/src/roff/troff/input.cc +++ b/src/roff/troff/input.cc @@ -208,6 +208,8 @@ private: virtual int internal_level() { return 0; } virtual int is_file() { return 0; } virtual int is_macro() { return 0; } + virtual void save_compatible_flag(int) {} + virtual int get_compatible_flag() { return 0; } }; input_iterator::input_iterator() @@ -408,6 +410,8 @@ public: static int get_level(); static void clear(); static void pop_macro(); + static void save_compatible_flag(int); + static int get_compatible_flag(); static int limit; private: @@ -628,6 +632,16 @@ void input_stack::pop_macro() add_return_boundary(); } +inline void input_stack::save_compatible_flag(int f) +{ + top->save_compatible_flag(f); +} + +inline int input_stack::get_compatible_flag() +{ + return top->get_compatible_flag(); +} + void backtrace_request() { input_stack::backtrace_all(); @@ -1274,6 +1288,13 @@ void token::next() if (cc != escape_char || escape_char == 0) { handle_normal_char: switch(cc) { + case COMPATIBLE_SAVE: + input_stack::save_compatible_flag(compatible_flag); + compatible_flag = 0; + continue; + case COMPATIBLE_RESTORE: + compatible_flag = input_stack::get_compatible_flag(); + continue; case EOF: type = TOKEN_EOF; return; @@ -2051,14 +2072,14 @@ static void trapping_blank_line() void do_request() { - int saved_compatible_flag = compatible_flag; + int old_compatible_flag = compatible_flag; compatible_flag = 0; symbol nm = get_name(); if (nm.is_null()) skip_line(); else interpolate_macro(nm); - compatible_flag = saved_compatible_flag; + compatible_flag = old_compatible_flag; } inline int possibly_handle_first_page_transition() @@ -2703,6 +2724,7 @@ class string_iterator : public input_iterator { char_block *bp; int count; // of characters remaining node *nd; + int saved_compatible_flag; protected: symbol nm; string_iterator(); @@ -2712,6 +2734,8 @@ public: int peek(); int get_location(int, const char **, int *); void backtrace(); + void save_compatible_flag(int f) { saved_compatible_flag = f; } + int get_compatible_flag() { return saved_compatible_flag; } }; string_iterator::string_iterator(const macro &m, const char *p, symbol s) @@ -3449,11 +3473,12 @@ void handle_initial_title() static symbol dot_symbol("."); enum define_mode { DEFINE_NORMAL, DEFINE_APPEND, DEFINE_IGNORE }; +enum calling_mode { CALLING_NORMAL, CALLING_INDIRECT, CALLING_DISABLE_COMP }; -void do_define_macro(define_mode mode, int indirect) +void do_define_macro(define_mode mode, calling_mode calling) { symbol nm, term; - if (indirect) { + if (calling == CALLING_INDIRECT) { symbol temp1 = get_name(1); if (temp1.is_null()) { skip_line(); @@ -3499,6 +3524,8 @@ void do_define_macro(define_mode mode, int indirect) mac = *mm; } int bol = 1; + if (calling == CALLING_DISABLE_COMP) + mac.append(COMPATIBLE_SAVE); for (;;) { while (c == ESCAPE_NEWLINE) { if (mode == DEFINE_NORMAL || mode == DEFINE_APPEND) @@ -3528,6 +3555,8 @@ void do_define_macro(define_mode mode, int indirect) mm = new macro; request_dictionary.define(nm, mm); } + if (calling == CALLING_DISABLE_COMP) + mac.append(COMPATIBLE_RESTORE); *mm = mac; } if (term != dot_symbol) { @@ -3577,23 +3606,33 @@ void do_define_macro(define_mode mode, int indirect) void define_macro() { - do_define_macro(DEFINE_NORMAL, 0); + do_define_macro(DEFINE_NORMAL, CALLING_NORMAL); +} + +void define_nocomp_macro() +{ + do_define_macro(DEFINE_NORMAL, CALLING_DISABLE_COMP); } void define_indirect_macro() { - do_define_macro(DEFINE_NORMAL, 1); + do_define_macro(DEFINE_NORMAL, CALLING_INDIRECT); } void append_macro() { - do_define_macro(DEFINE_APPEND, 0); + do_define_macro(DEFINE_APPEND, CALLING_NORMAL); +} + +void append_nocomp_macro() +{ + do_define_macro(DEFINE_APPEND, CALLING_DISABLE_COMP); } void ignore() { ignoring = 1; - do_define_macro(DEFINE_IGNORE, 0); + do_define_macro(DEFINE_IGNORE, CALLING_NORMAL); ignoring = 0; } @@ -6349,7 +6388,9 @@ void init_input_requests() init_request("as", append_string); init_request("de", define_macro); init_request("dei", define_indirect_macro); + init_request("de1", define_nocomp_macro); init_request("am", append_macro); + init_request("am1", append_nocomp_macro); init_request("ig", ignore); init_request("rm", remove_macro); init_request("rn", rename_macro); diff --git a/src/roff/troff/input.h b/src/roff/troff/input.h index 525e1ef6..8d06574e 100644 --- a/src/roff/troff/input.h +++ b/src/roff/troff/input.h @@ -54,6 +54,8 @@ const int LAST_PAGE_EJECTOR = 0205; const int ESCAPE_RIGHT_PARENTHESIS = 0206; const int ESCAPE_TILDE = 0207; const int ESCAPE_COLON = 0210; +const int COMPATIBLE_SAVE = 0211; +const int COMPATIBLE_RESTORE = 0212; #else /* IS_EBCDIC_HOST */ @@ -88,5 +90,7 @@ const int LAST_PAGE_EJECTOR = 065; const int ESCAPE_RIGHT_PARENTHESIS = 066; const int ESCAPE_TILDE = 067; const int ESCAPE_COLON = 070; +const int COMPATIBLE_SAVE = 071; +const int COMPATIBLE_RESTORE = 072; #endif /* IS_EBCDIC_HOST */ diff --git a/src/roff/troff/troff.man b/src/roff/troff/troff.man index c4830821..5f888866 100644 --- a/src/roff/troff/troff.man +++ b/src/roff/troff/troff.man @@ -739,6 +739,12 @@ requests only create a new object if the name of the macro, diversion or string diversion is currently undefined or if it is defined to be a request; normally they modify the value of an existing object. .TP +.BI .am1\ xx\ yy +Similar to +.BR .am , +but compatibility mode is switched off during execution. +On entry, the current compatibility mode is saved and restored at exit. +.TP .BI .asciify\ xx This request `unformats' the diversion .I xx @@ -970,6 +976,12 @@ is equivalent to \&.de aa bb .RE .TP +.BI .de1\ xx\ yy +Similar to +.BR .de , +but compatibility mode is switched off during execution. +On entry, the current compatibility mode is saved and restored at exit. +.TP .BI .do\ xxx Interpret .I .xxx @@ -2455,6 +2467,10 @@ necessary. .SH "SEE ALSO" . . +.BR groff (@MAN7EXT@) +-- This is a short but complete reference of all requests, registers, and +escapes. +.PP .BR groff (@MAN1EXT@), .BR @g@tbl (@MAN1EXT@), .BR @g@pic (@MAN1EXT@), diff --git a/tmac/an-old.tmac b/tmac/an-old.tmac index caa1fa4e..75c1ff16 100644 --- a/tmac/an-old.tmac +++ b/tmac/an-old.tmac @@ -62,9 +62,7 @@ .. . .\" .TH title section extra1 extra2 extra3 -.de TH -. cp 0 -. +.de1 TH . if \\n[an-html] \{\ . HTML-TAG ".tl" \\$1 @@ -135,16 +133,16 @@ . \} .. . -.de DT +.de1 DT . ta T .5i \" This sets tabs every .5 inches .. . -.de PD +.de1 PD . ie \\n[.$] .nr PD (v;\\$1) . el .nr PD (.4v >? \n[.V]) .. . -.de an-header +.de1 an-header . an-init . ev 1 . ps \\n[PS]u @@ -164,13 +162,13 @@ . ns .. . -.de an-footer +.de1 an-footer ' bp .. . .af an-page-letter a . -.de an-p-footer +.de1 an-p-footer . ev 1 . ps \\n[PS]u . vs \\n[VS]u @@ -202,7 +200,7 @@ . ev .. . -.de an-end +.de1 an-end . nr % 1 . pl +3v . fl @@ -213,7 +211,7 @@ . .if \n[cR] .em an-end . -.de SH +.de1 SH . sp \\n[PD]u . nr an-level 1 . set-an-margin @@ -231,7 +229,7 @@ . if \\n[.$] \&\\$* .. . -.de SS +.de1 SS . sp \\n[PD]u . nr an-level 1 . set-an-margin @@ -248,32 +246,32 @@ . if \\n[.$] \&\\$* .. . -.de B +.de1 B . it 1 an-trap . ft B . if \\n[.$] \&\\$* .. . -.de I +.de1 I . it 1 an-trap . ft I . if \\n[.$] \&\\$* .. . -.de SM +.de1 SM . it 1 an-trap . ps -1 . if \\n[.$] \&\\$* .. . -.de SB +.de1 SB . it 1 an-trap . ps -1 . ft B . if \\n[.$] \&\\$* .. . -.de TP +.de1 TP . sp \\n[PD]u . if \\n[.$] .nr an-prevailing-indent (n;\\$1) . it 1 an-trap @@ -286,7 +284,7 @@ . nr an-div? 1 .. . -.de an-trap +.de1 an-trap . ft R . ps \\n[PS]u . vs \\n[VS]u @@ -322,7 +320,7 @@ . \} .. . -.de LP +.de1 LP . br . sp \\n[PD]u . ps \\n[PS]u @@ -335,7 +333,7 @@ .als PP LP .als P LP . -.de IP +.de1 IP . ie !\\n[.$] \{\ . ps \\n[PS]u . vs \\n[VS]u @@ -351,7 +349,7 @@ . \} .. . -.de HP +.de1 HP . ps \\n[PS]u . vs \\n[VS]u . ft R @@ -364,7 +362,7 @@ . .ds an-empty \" this is referenced to avoid looping on eg .RB ( \\ ) . -.de RI +.de1 RI . if \\n[.$] \{\ . ds an-result \&\\$1 . shift @@ -377,7 +375,7 @@ . \} .. . -.de IR +.de1 IR . if \\n[.$] \{\ . ds an-result \&\f[I]\\$1\f[R] . shift @@ -390,7 +388,7 @@ . \} .. . -.de IB +.de1 IB . if \\n[.$] \{\ . ds an-result \&\f[I]\\$1 . shift @@ -404,7 +402,7 @@ . \} .. . -.de BI +.de1 BI . if \\n[.$] \{\ . ds an-result \&\f[B]\\$1 . shift @@ -418,7 +416,7 @@ . \} .. . -.de RB +.de1 RB . ds an-result \& . while (\\n[.$] >= 2) \{\ . as an-result \f[R]\\$1\f[B]\\$2\\*[an-empty] @@ -429,7 +427,7 @@ . ft R .. . -.de BR +.de1 BR . ds an-result \& . while (\\n[.$] >= 2) \{\ . as an-result \f[B]\\$1\f[R]\\$2\\*[an-empty] @@ -440,7 +438,7 @@ . ft R .. . -.de RS +.de1 RS . br . nr an-saved-margin\\n[an-level] \\n[an-margin] . nr an-saved-prevailing-indent\\n[an-level] \\n[an-prevailing-indent] @@ -451,7 +449,7 @@ . nr an-level +1 .. . -.de RE +.de1 RE . br . ie \\n[.$] .nr an-level ((;\\$1)