[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff-commit] groff ChangeLog src/roff/troff/input.cpp src/ro...
From: |
Werner LEMBERG |
Subject: |
[Groff-commit] groff ChangeLog src/roff/troff/input.cpp src/ro... |
Date: |
Mon, 29 Sep 2008 21:56:06 +0000 |
CVSROOT: /cvsroot/groff
Module name: groff
Changes by: Werner LEMBERG <wl> 08/09/29 21:56:05
Modified files:
. : ChangeLog
src/roff/troff : input.cpp request.h
Log message:
Make \\*[xxx]\\ within a macro (with `xxx' a macro too) work as
expected. Without the patch,
.de aaa
\\*[bbb]\\
. tm \\$*
..
.de bbb
. shift
..
.aaa 1 2 3
prints `2 3' instead of `1 2 3'.
* src/roff/troff/input.cpp (input_iterator, input_stack,
macro_iterator): Add `get_arg_list' member function.
(macro): Add `is_a_string', `is_string', and `clear_string_flag'
members.
Update constructors and operators.
(arg_list): Add copy constructor.
(macro_iterator): Add optional argument to constructor to indicate
whether arguments shall be inherited from calling macro.
(interpolate_string): If string argument is a macro, push a macro
iterator on the stack.
(do_define_macro): Call clear_string_flag if macro data contains a
newline.
* src/roff/troff/request.h: Updated.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.1144&r2=1.1145
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/input.cpp?cvsroot=groff&r1=1.52&r2=1.53
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/request.h?cvsroot=groff&r1=1.12&r2=1.13
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.1144
retrieving revision 1.1145
diff -u -b -r1.1144 -r1.1145
--- ChangeLog 29 Sep 2008 09:24:09 -0000 1.1144
+++ ChangeLog 29 Sep 2008 21:56:05 -0000 1.1145
@@ -1,3 +1,34 @@
+2008-09-29 Werner LEMBERG <address@hidden>
+
+ Make \\*[xxx]\\ within a macro (with `xxx' a macro too) work as
+ expected. Without the patch,
+
+ .de aaa
+ \\*[bbb]\\
+ . tm \\$*
+ ..
+ .de bbb
+ . shift
+ ..
+ .aaa 1 2 3
+
+ prints `2 3' instead of `1 2 3'.
+
+ * src/roff/troff/input.cpp (input_iterator, input_stack,
+ macro_iterator): Add `get_arg_list' member function.
+ (macro): Add `is_a_string', `is_string', and `clear_string_flag'
+ members.
+ Update constructors and operators.
+ (arg_list): Add copy constructor.
+ (macro_iterator): Add optional argument to constructor to indicate
+ whether arguments shall be inherited from calling macro.
+ (interpolate_string): If string argument is a macro, push a macro
+ iterator on the stack.
+ (do_define_macro): Call clear_string_flag if macro data contains a
+ newline.
+
+ * src/roff/troff/request.h: Updated.
+
2008-09-29 Eric S. Raymond <address@hidden>
* doc/pic.ms: Fold in documentation of pic2plot(1) capabilities.
Index: src/roff/troff/input.cpp
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/input.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -b -r1.52 -r1.53
--- src/roff/troff/input.cpp 28 Sep 2008 14:39:44 -0000 1.52
+++ src/roff/troff/input.cpp 29 Sep 2008 21:56:05 -0000 1.53
@@ -198,6 +198,8 @@
skip_line();
}
+struct arg_list;
+
class input_iterator {
public:
input_iterator();
@@ -217,6 +219,7 @@
virtual int has_args() { return 0; }
virtual int nargs() { return 0; }
virtual input_iterator *get_arg(int) { return 0; }
+ virtual arg_list *get_arg_list() { return 0; }
virtual int space_follows_arg(int) { return 0; }
virtual int get_break_flag() { return 0; }
virtual int get_location(int, const char **, int *) { return 0; }
@@ -418,6 +421,7 @@
static int peek();
static void push(input_iterator *);
static input_iterator *get_arg(int);
+ static arg_list *get_arg_list();
static int space_follows_arg(int);
static int get_break_flag();
static int nargs();
@@ -626,6 +630,15 @@
return 0;
}
+arg_list *input_stack::get_arg_list()
+{
+ input_iterator *p;
+ for (p = top; p != 0; p = p->next)
+ if (p->has_args())
+ return p->get_arg_list();
+ return 0;
+}
+
int input_stack::space_follows_arg(int i)
{
input_iterator *p;
@@ -3185,7 +3198,7 @@
}
macro::macro()
-: is_a_diversion(0)
+: is_a_diversion(0), is_a_string(1)
{
if (!input_stack::get_location(1, &filename, &lineno)) {
filename = 0;
@@ -3198,14 +3211,15 @@
macro::macro(const macro &m)
: filename(m.filename), lineno(m.lineno), len(m.len),
- empty_macro(m.empty_macro), is_a_diversion(m.is_a_diversion), p(m.p)
+ empty_macro(m.empty_macro), is_a_diversion(m.is_a_diversion),
+ is_a_string(m.is_a_string), p(m.p)
{
if (p != 0)
p->count++;
}
macro::macro(int is_div)
- : is_a_diversion(is_div)
+: is_a_diversion(is_div)
{
if (!input_stack::get_location(1, &filename, &lineno)) {
filename = 0;
@@ -3213,6 +3227,7 @@
}
len = 0;
empty_macro = 1;
+ is_a_string = 1;
p = 0;
}
@@ -3221,6 +3236,16 @@
return is_a_diversion;
}
+int macro::is_string()
+{
+ return is_a_string;
+}
+
+void macro::clear_string_flag()
+{
+ is_a_string = 0;
+}
+
macro ¯o::operator=(const macro &m)
{
// don't assign object
@@ -3234,6 +3259,7 @@
len = m.len;
empty_macro = m.empty_macro;
is_a_diversion = m.is_a_diversion;
+ is_a_string = m.is_a_string;
return *this;
}
@@ -3608,6 +3634,7 @@
int space_follows;
arg_list *next;
arg_list(const macro &, int);
+ arg_list(const arg_list *);
~arg_list();
};
@@ -3615,6 +3642,20 @@
{
}
+arg_list::arg_list(const arg_list *al)
+: next(0)
+{
+ mac = al->mac;
+ space_follows = al->space_follows;
+ arg_list **a = &next;
+ arg_list *p = al->next;
+ while (p) {
+ *a = new arg_list(p->mac, p->space_follows);
+ p = p->next;
+ a = &(*a)->next;
+ }
+}
+
arg_list::~arg_list()
{
}
@@ -3624,11 +3665,12 @@
int argc;
int with_break; // whether called as .foo or 'foo
public:
- macro_iterator(symbol, macro &, const char *how_invoked = "macro");
+ macro_iterator(symbol, macro &, const char * = "macro", int = 0);
macro_iterator();
~macro_iterator();
int has_args() { return 1; }
input_iterator *get_arg(int);
+ arg_list *get_arg_list();
int space_follows_arg(int);
int get_break_flag() { return with_break; }
int nargs() { return argc; }
@@ -3654,6 +3696,11 @@
return 0;
}
+arg_list *macro_iterator::get_arg_list()
+{
+ return args;
+}
+
int macro_iterator::space_follows_arg(int i)
{
if (i > 0 && i <= argc) {
@@ -3883,9 +3930,17 @@
return empty_macro == 1;
}
-macro_iterator::macro_iterator(symbol s, macro &m, const char *how_called)
+macro_iterator::macro_iterator(symbol s, macro &m, const char *how_called,
+ int init_args)
: string_iterator(m, how_called, s), args(0), argc(0), with_break(break_flag)
{
+ if (init_args) {
+ arg_list *al = input_stack::get_arg_list();
+ if (al) {
+ args = new arg_list(al);
+ argc = input_stack::nargs();
+ }
+ }
}
macro_iterator::macro_iterator() : args(0), argc(0), with_break(break_flag)
@@ -4134,12 +4189,12 @@
mac.append((unsigned char)c);
c = get_copy(&n);
}
+ if (comp == COMP_DISABLE || comp == COMP_ENABLE)
+ mac.append(POP_GROFFCOMP_MODE);
if (!mm) {
mm = new macro;
request_dictionary.define(nm, mm);
}
- if (comp == COMP_DISABLE || comp == COMP_ENABLE)
- mac.append(POP_GROFFCOMP_MODE);
*mm = mac;
tok.next();
}
@@ -4252,9 +4307,15 @@
if (!m)
error("you can only invoke a string or macro using \\*");
else {
+ if (m->is_string()) {
string_iterator *si = new string_iterator(*m, "string", nm);
input_stack::push(si);
}
+ else {
+ macro_iterator *mi = new macro_iterator(nm, *m, "string", 1);
+ input_stack::push(mi);
+ }
+ }
}
static void interpolate_string_with_args(symbol s)
@@ -4442,6 +4503,8 @@
else if (comp == COMP_ENABLE)
mac.append(PUSH_COMP_MODE);
for (;;) {
+ if (c == '\n')
+ mac.clear_string_flag();
while (c == ESCAPE_NEWLINE) {
if (mode == DEFINE_NORMAL || mode == DEFINE_APPEND)
mac.append(c);
Index: src/roff/troff/request.h
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/request.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- src/roff/troff/request.h 25 Sep 2008 07:47:38 -0000 1.12
+++ src/roff/troff/request.h 29 Sep 2008 21:56:05 -0000 1.13
@@ -50,6 +50,7 @@
int len;
int empty_macro;
int is_a_diversion;
+ int is_a_string; // if it contains no newline
public:
macro_header *p;
macro();
@@ -70,6 +71,8 @@
void print_size();
int empty();
int is_diversion();
+ int is_string();
+ void clear_string_flag();
friend class string_iterator;
friend void chop_macro();
friend void substring_request();
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Groff-commit] groff ChangeLog src/roff/troff/input.cpp src/ro...,
Werner LEMBERG <=