summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwlemb <wlemb>2001-05-06 23:29:20 +0000
committerwlemb <wlemb>2001-05-06 23:29:20 +0000
commit2cb0df330838a0f76209415679eae40517857968 (patch)
tree51957b3659d56e6b5868cb2ac44edc20155d54ff /src
parent3fcb4709050e965ef5b6c9b9df63909f6192fc25 (diff)
downloadgroff-2cb0df330838a0f76209415679eae40517857968.tar.gz
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).
Diffstat (limited to 'src')
-rw-r--r--src/roff/troff/input.cc57
-rw-r--r--src/roff/troff/input.h4
-rw-r--r--src/roff/troff/troff.man16
3 files changed, 69 insertions, 8 deletions
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@),