[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] Re: groff 1.19.1 complains when formatting its own man pages
From: |
Werner LEMBERG |
Subject: |
[Groff] Re: groff 1.19.1 complains when formatting its own man pages |
Date: |
Wed, 30 Jun 2004 19:55:24 +0200 (CEST) |
> Here's another idea: have compatibility mode apply more "statically"
> than "dynamically". That is, if \n[.C] is 1, then ".de XX" should
> should cause XX to be executed in compatibility mode, restoring the
> old compatibility mode when it exits. (This is sort of the inverse
> of ".de1 XX".) Similarly for ".ds".
OK, I've implemented this, see patch below (for the CVS of today).
Please test whether it works as expected.
I wonder whether this `static' compatibility mode should completely
replace the old behaviour, or whether it should be controlled with a
request.
> I did think of one problem with my suggestion: one couldn't define a
> macro to turn off compatibility mode.
IMHO we can safely ignore this. Having .de and .de1 should be
sufficient.
Werner
======================================================================
--- ./src/roff/troff/input.cpp.old Wed Jun 30 07:55:46 2004
+++ ./src/roff/troff/input.cpp Wed Jun 30 15:46:18 2004
@@ -1559,11 +1559,15 @@
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 +3036,7 @@
}
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;
}
@@ -3830,7 +3834,7 @@
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 +3867,9 @@
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);
@@ -3876,14 +3882,15 @@
request_dictionary.define(nm, mm);
}
if (comp == COMP_DISABLE)
- mac.append(COMPATIBLE_RESTORE);
+ 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 +3900,8 @@
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 +4158,9 @@
}
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)
@@ -4187,7 +4197,7 @@
request_dictionary.define(nm, mm);
}
if (comp == COMP_DISABLE)
- mac.append(COMPATIBLE_RESTORE);
+ mac.append(POP_GROFFCOMP_MODE);
*mm = mac;
}
if (term != dot_symbol) {
@@ -4237,7 +4247,8 @@
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 +4258,8 @@
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 +4269,8 @@
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 +4280,8 @@
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 +4346,12 @@
// 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 +4362,7 @@
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 +4387,9 @@
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 +4431,9 @@
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 +4442,9 @@
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 +5802,9 @@
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:
--- ./src/roff/troff/input.h.old Mon May 7 01:29:21 2001
+++ ./src/roff/troff/input.h Wed Jun 30 15:47:02 2004
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 2001 Free Software Foundation, Inc.
+/* Copyright (C) 2001, 2004 Free Software Foundation, Inc.
Written by James Clark (address@hidden)
This file is part of groff.
@@ -54,8 +54,9 @@
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 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 */
Message not available
- [Groff] Re: groff 1.19.1 complains when formatting its own man pages,
Werner LEMBERG <=