summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwlemb <wlemb>2004-07-03 07:18:58 +0000
committerwlemb <wlemb>2004-07-03 07:18:58 +0000
commit3b9aa46bb67602a46cb2c73c722fe63c9bae0384 (patch)
treea5ba69568a004c1ae4c96fdbc45276b3d5f18227
parentde8f08d275148f55e2c36927239779b8281613b7 (diff)
downloadgroff-3b9aa46bb67602a46cb2c73c722fe63c9bae0384.tar.gz
* src/roff/troff/input.h: s/COMPATIBLE_SAVE/PUSH_GROFF_MODE/.
s/COMPATIBLE_RESTORE/POP_GROFFCOMP_MODE/. Update all users. (PUSH_COMP_MODE): New internal character constant. Update all users. * src/roff/troff/input.cpp (get_copy): Handle PUSH_GROFF_MODE, PUSH_COMP_MODE, and POP_GROFFCOMP_MODE. (token::next, macro::append): Handle PUSH_COMP_MODE. (decode_args): Add PUSH_GROFF_MODE or PUSH_COMP_MODE before and POP_GROFFCOMP after each of the decoded arguments to make them independent from the compatibility mode status. (comp_mode): Add `COMP_ENABLE'. (do_define_string, do_define_macro): Handle COMP_ENABLE. (define_string, append_string, define_macro, define_indirect_macro, append_macro, append_indirect_macro): Handle `compatible_flag'. (chop_macro, substring_request, asciify): Handle PUSH_COMP_MODE. * man/groff_diff.man, doc/groff.texinfo: Updated.
-rw-r--r--ChangeLog22
-rw-r--r--doc/groff.texinfo41
-rw-r--r--man/groff_diff.man20
-rw-r--r--src/roff/troff/input.cpp94
-rw-r--r--src/roff/troff/input.h12
5 files changed, 150 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index a3647860..bd9f6fc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2004-07-02 Werner LEMBERG <wl@gnu.org>
+
+ * src/roff/troff/input.h: s/COMPATIBLE_SAVE/PUSH_GROFF_MODE/.
+ s/COMPATIBLE_RESTORE/POP_GROFFCOMP_MODE/.
+ Update all users.
+ (PUSH_COMP_MODE): New internal character constant.
+ Update all users.
+
+ * src/roff/troff/input.cpp (get_copy): Handle PUSH_GROFF_MODE,
+ PUSH_COMP_MODE, and POP_GROFFCOMP_MODE.
+ (token::next, macro::append): Handle PUSH_COMP_MODE.
+ (decode_args): Add PUSH_GROFF_MODE or PUSH_COMP_MODE before and
+ POP_GROFFCOMP after each of the decoded arguments to make them
+ independent from the compatibility mode status.
+ (comp_mode): Add `COMP_ENABLE'.
+ (do_define_string, do_define_macro): Handle COMP_ENABLE.
+ (define_string, append_string, define_macro, define_indirect_macro,
+ append_macro, append_indirect_macro): Handle `compatible_flag'.
+ (chop_macro, substring_request, asciify): Handle PUSH_COMP_MODE.
+
+ * man/groff_diff.man, doc/groff.texinfo: Updated.
+
2004-07-01 Werner LEMBERG <wl@gnu.org>
* doc/groff.texinfo: Improve documentation of `hcode'.
diff --git a/doc/groff.texinfo b/doc/groff.texinfo
index bb5165d0..524c99ec 100644
--- a/doc/groff.texinfo
+++ b/doc/groff.texinfo
@@ -9426,6 +9426,7 @@ roman glyph without any intervening space. This small amount of
space is also called @dfn{italic correction}.
@iftex
+@c can't use @Example...@endExample here
@example
@group
\f[I]f\f[R])
@@ -9452,6 +9453,7 @@ space could be called @dfn{left italic correction}, but this term
isn't used widely.
@iftex
+@c can't use @Example...@endExample here
@example
@group
q\f[I]f
@@ -9496,14 +9498,12 @@ an input line.
It prevents kerning between two glyphs.
@ifnotinfo
-@example
-@group
+@Example
VA
@result{} @r{VA}
V\&A
@result{} @r{V@w{}A}
-@end group
-@end example
+@endExample
@end ifnotinfo
@item
@@ -10560,7 +10560,7 @@ The value of xxx ix \\n[xxx].
.cp 1
.
.aa
- @result{} warning: number register ' not defined
+ @result{} warning: number register `[' not defined
@result{} The value of xxx is 0xxx].
.bb
@result{} The value of xxx ix 12345.
@@ -10588,6 +10588,13 @@ is equivalent to:
The @code{dei1} request is similar to @code{dei} but with compatibility
mode switched off during execution of the defined macro.
+If compatibility mode is on, @code{de} (and @code{dei}) behave similar to
+@code{de1} (and @code{dei1}): A `compatibility save' token is inserted at
+the beginning, and a `compatibility restore' token at the end, with
+compatibility mode switched on during execution. @xref{Gtroff Internals},
+for more information on switching compatibility mode on and off in a
+single document.
+
@pindex trace.tmac
Using @file{trace.tmac}, you can trace calls to @code{de} and @code{de1}.
@@ -13040,6 +13047,30 @@ in special fonts, we must call @code{rchar} to remove the definition
of the fallback glyph. Anyway, the translation is still active;
@samp{x} now maps to the real glyph @samp{foo}.
+@cindex compatibility mode
+@cindex mode, compatibility
+Macro arguments preserve the compatibility mode:
+
+@Example
+.cp 1 \" switch to compatibility mode
+.de xx
+\\$1
+..
+.cp 0 \" switch compatibility mode off
+.xx caf\['e]
+ @result{} café
+@endExample
+
+@noindent
+Since compatibility mode is on while @code{de} is called, the macro
+@code{xx} activates compatibility mode while executing. Argument
+@code{$1} can still be handled properly because it inherits the
+compatibility mode status which was active at the point where @code{xx}
+is called.
+
+After expansion of the macro arguments, the compatibility save and restore
+tokens are removed.
+
@c =====================================================================
diff --git a/man/groff_diff.man b/man/groff_diff.man
index 19e9a600..45f34774 100644
--- a/man/groff_diff.man
+++ b/man/groff_diff.man
@@ -3,7 +3,7 @@
.ig
groff_diff.man
-Last update : 29 Jun 2004
+Last update : 02 Jul 2004
This file is part of groff, the GNU roff type-setting system.
It is the source of the man-page groff_diff(7).
@@ -2471,6 +2471,24 @@ there is a current diversion; this behaviour is so anomalous that it
must be considered a bug.
.
.TP
+.BI .de\ xx\ yy
+.TQ
+.BI .am\ xx\ yy
+.TQ
+.BI .ds\ xx\ yy
+.TQ
+.BI .as\ xx\ yy
+In compatibility mode, these requests behaves similar to
+.BR .de1 ,
+.BR .am1 ,
+.BR .ds1 ,
+and
+.BR .as1 ,
+respectively: A `compatibility save' token is inserted at the
+beginning, and a `compatibility restore' token at the end, with
+compatibility mode switched on during execution.
+.
+.TP
.BI .ev\ xx
If
.I xx
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 2bcb579c..5ad1c745 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -836,6 +836,20 @@ static int get_copy(node **nd, int defining)
{
for (;;) {
int c = input_stack::get(nd);
+ if (c == PUSH_GROFF_MODE) {
+ input_stack::save_compatible_flag(compatible_flag);
+ compatible_flag = 0;
+ continue;
+ }
+ if (c == PUSH_COMP_MODE) {
+ input_stack::save_compatible_flag(compatible_flag);
+ compatible_flag = 1;
+ continue;
+ }
+ if (c == POP_GROFFCOMP_MODE) {
+ compatible_flag = input_stack::get_compatible_flag();
+ continue;
+ }
if (c == ESCAPE_NEWLINE) {
if (defining)
return c;
@@ -1559,11 +1573,15 @@ void token::next()
if (cc != escape_char || escape_char == 0) {
handle_normal_char:
switch(cc) {
- case COMPATIBLE_SAVE:
+ case PUSH_GROFF_MODE:
input_stack::save_compatible_flag(compatible_flag);
compatible_flag = 0;
continue;
- case COMPATIBLE_RESTORE:
+ case PUSH_COMP_MODE:
+ input_stack::save_compatible_flag(compatible_flag);
+ compatible_flag = 1;
+ continue;
+ case POP_GROFFCOMP_MODE:
compatible_flag = input_stack::get_compatible_flag();
continue;
case EOF:
@@ -3032,7 +3050,7 @@ void macro::append(unsigned char c)
}
p->cl.append(c);
++len;
- if (c != COMPATIBLE_SAVE && c != COMPATIBLE_RESTORE)
+ if (c != PUSH_GROFF_MODE && c != PUSH_COMP_MODE && c != POP_GROFFCOMP_MODE)
empty_macro = 0;
}
@@ -3521,12 +3539,13 @@ static void decode_args(macro_iterator *mi)
macro arg;
int quote_input_level = 0;
int done_tab_warning = 0;
- if (c == '\"') {
+ if (c == '"') {
quote_input_level = input_stack::get_level();
c = get_copy(&n);
}
+ arg.append(compatible_flag ? PUSH_COMP_MODE : PUSH_GROFF_MODE);
while (c != EOF && c != '\n' && !(c == ' ' && quote_input_level == 0)) {
- if (quote_input_level > 0 && c == '\"'
+ if (quote_input_level > 0 && c == '"'
&& (compatible_flag
|| input_stack::get_level() == quote_input_level)) {
c = get_copy(&n);
@@ -3550,6 +3569,7 @@ static void decode_args(macro_iterator *mi)
c = get_copy(&n);
}
}
+ arg.append(POP_GROFFCOMP_MODE);
mi->add_arg(arg);
}
}
@@ -3571,14 +3591,14 @@ static void decode_string_args(macro_iterator *mi)
macro arg;
int quote_input_level = 0;
int done_tab_warning = 0;
- if (c == '\"') {
+ if (c == '"') {
quote_input_level = input_stack::get_level();
c = get_copy(&n);
}
while (c != EOF && c != '\n'
&& !(c == ']' && quote_input_level == 0)
&& !(c == ' ' && quote_input_level == 0)) {
- if (quote_input_level > 0 && c == '\"'
+ if (quote_input_level > 0 && c == '"'
&& input_stack::get_level() == quote_input_level) {
c = get_copy(&n);
if (c == '"') {
@@ -3830,7 +3850,7 @@ void read_request()
enum define_mode { DEFINE_NORMAL, DEFINE_APPEND, DEFINE_IGNORE };
enum calling_mode { CALLING_NORMAL, CALLING_INDIRECT };
-enum comp_mode { COMP_IGNORE, COMP_DISABLE };
+enum comp_mode { COMP_IGNORE, COMP_DISABLE, COMP_ENABLE };
void do_define_string(define_mode mode, comp_mode comp)
{
@@ -3863,7 +3883,9 @@ void do_define_string(define_mode mode, comp_mode comp)
if (mode == DEFINE_APPEND && mm)
mac = *mm;
if (comp == COMP_DISABLE)
- mac.append(COMPATIBLE_SAVE);
+ mac.append(PUSH_GROFF_MODE);
+ else if (comp == COMP_ENABLE)
+ mac.append(PUSH_COMP_MODE);
while (c != '\n' && c != EOF) {
if (c == 0)
mac.append(n);
@@ -3875,15 +3897,16 @@ void do_define_string(define_mode mode, comp_mode comp)
mm = new macro;
request_dictionary.define(nm, mm);
}
- if (comp == COMP_DISABLE)
- mac.append(COMPATIBLE_RESTORE);
+ if (comp == COMP_DISABLE || comp == COMP_ENABLE)
+ mac.append(POP_GROFFCOMP_MODE);
*mm = mac;
tok.next();
}
void define_string()
{
- do_define_string(DEFINE_NORMAL, COMP_IGNORE);
+ do_define_string(DEFINE_NORMAL,
+ compatible_flag ? COMP_ENABLE: COMP_IGNORE);
}
void define_nocomp_string()
@@ -3893,7 +3916,8 @@ void define_nocomp_string()
void append_string()
{
- do_define_string(DEFINE_APPEND, COMP_IGNORE);
+ do_define_string(DEFINE_APPEND,
+ compatible_flag ? COMP_ENABLE : COMP_IGNORE);
}
void append_nocomp_string()
@@ -4150,7 +4174,9 @@ void do_define_macro(define_mode mode, calling_mode calling, comp_mode comp)
}
int bol = 1;
if (comp == COMP_DISABLE)
- mac.append(COMPATIBLE_SAVE);
+ mac.append(PUSH_GROFF_MODE);
+ else if (comp == COMP_ENABLE)
+ mac.append(PUSH_COMP_MODE);
for (;;) {
while (c == ESCAPE_NEWLINE) {
if (mode == DEFINE_NORMAL || mode == DEFINE_APPEND)
@@ -4186,8 +4212,8 @@ void do_define_macro(define_mode mode, calling_mode calling, comp_mode comp)
mm = new macro;
request_dictionary.define(nm, mm);
}
- if (comp == COMP_DISABLE)
- mac.append(COMPATIBLE_RESTORE);
+ if (comp == COMP_DISABLE || comp == COMP_ENABLE)
+ mac.append(POP_GROFFCOMP_MODE);
*mm = mac;
}
if (term != dot_symbol) {
@@ -4237,7 +4263,8 @@ void do_define_macro(define_mode mode, calling_mode calling, comp_mode comp)
void define_macro()
{
- do_define_macro(DEFINE_NORMAL, CALLING_NORMAL, COMP_IGNORE);
+ do_define_macro(DEFINE_NORMAL, CALLING_NORMAL,
+ compatible_flag ? COMP_ENABLE : COMP_IGNORE);
}
void define_nocomp_macro()
@@ -4247,7 +4274,8 @@ void define_nocomp_macro()
void define_indirect_macro()
{
- do_define_macro(DEFINE_NORMAL, CALLING_INDIRECT, COMP_IGNORE);
+ do_define_macro(DEFINE_NORMAL, CALLING_INDIRECT,
+ compatible_flag ? COMP_ENABLE : COMP_IGNORE);
}
void define_indirect_nocomp_macro()
@@ -4257,7 +4285,8 @@ void define_indirect_nocomp_macro()
void append_macro()
{
- do_define_macro(DEFINE_APPEND, CALLING_NORMAL, COMP_IGNORE);
+ do_define_macro(DEFINE_APPEND, CALLING_NORMAL,
+ compatible_flag ? COMP_ENABLE : COMP_IGNORE);
}
void append_nocomp_macro()
@@ -4267,7 +4296,8 @@ void append_nocomp_macro()
void append_indirect_macro()
{
- do_define_macro(DEFINE_APPEND, CALLING_INDIRECT, COMP_IGNORE);
+ do_define_macro(DEFINE_APPEND, CALLING_INDIRECT,
+ compatible_flag ? COMP_ENABLE : COMP_IGNORE);
}
void append_indirect_nocomp_macro()
@@ -4332,11 +4362,12 @@ void chop_macro()
// we have to check for additional save/restore pairs which could be
// there due to empty am1 requests.
for (;;) {
- if (m->get(m->len - 1) != COMPATIBLE_RESTORE)
+ if (m->get(m->len - 1) != POP_GROFFCOMP_MODE)
break;
have_restore = 1;
m->len -= 1;
- if (m->get(m->len - 1) != COMPATIBLE_SAVE)
+ if (m->get(m->len - 1) != PUSH_GROFF_MODE
+ && m->get(m->len - 1) != PUSH_COMP_MODE)
break;
have_restore = 0;
m->len -= 1;
@@ -4347,7 +4378,7 @@ void chop_macro()
error("cannot chop empty macro");
else {
if (have_restore)
- m->set(COMPATIBLE_RESTORE, m->len - 1);
+ m->set(POP_GROFFCOMP_MODE, m->len - 1);
else
m->len -= 1;
}
@@ -4372,7 +4403,9 @@ void substring_request()
string_iterator iter1(*m);
for (int l = 0; l < m->len; l++) {
int c = iter1.get(0);
- if (c == COMPATIBLE_SAVE || c == COMPATIBLE_RESTORE)
+ if (c == PUSH_GROFF_MODE
+ || c == PUSH_COMP_MODE
+ || c == POP_GROFFCOMP_MODE)
continue;
if (c == EOF)
break;
@@ -4414,7 +4447,9 @@ void substring_request()
int i;
for (i = 0; i < start; i++) {
int c = iter.get(0);
- while (c == COMPATIBLE_SAVE || c == COMPATIBLE_RESTORE)
+ while (c == PUSH_GROFF_MODE
+ || c == PUSH_COMP_MODE
+ || c == POP_GROFFCOMP_MODE)
c = iter.get(0);
if (c == EOF)
break;
@@ -4423,7 +4458,9 @@ void substring_request()
for (; i <= end; i++) {
node *nd = 0; // pacify compiler
int c = iter.get(&nd);
- while (c == COMPATIBLE_SAVE || c == COMPATIBLE_RESTORE)
+ while (c == PUSH_GROFF_MODE
+ || c == PUSH_COMP_MODE
+ || c == POP_GROFFCOMP_MODE)
c = iter.get(0);
if (c == EOF)
break;
@@ -5781,8 +5818,9 @@ const char *asciify(int c)
case ESCAPE_COLON:
buf[1] = ':';
break;
- case COMPATIBLE_SAVE:
- case COMPATIBLE_RESTORE:
+ case PUSH_GROFF_MODE:
+ case PUSH_COMP_MODE:
+ case POP_GROFFCOMP_MODE:
buf[0] = '\0';
break;
default:
diff --git a/src/roff/troff/input.h b/src/roff/troff/input.h
index 8d06574e..e9b0104c 100644
--- a/src/roff/troff/input.h
+++ b/src/roff/troff/input.h
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2004 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -54,8 +54,9 @@ 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;
+const int PUSH_GROFF_MODE = 0211;
+const int PUSH_COMP_MODE = 0212;
+const int POP_GROFFCOMP_MODE = 0213;
#else /* IS_EBCDIC_HOST */
@@ -90,7 +91,8 @@ 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;
+const int PUSH_GROFF_MODE = 071;
+const int PUSH_COMP_MODE = 072;
+const int POP_GROFFCOMP_MODE = 073;
#endif /* IS_EBCDIC_HOST */