groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff-commit] groff ChangeLog doc/groff.texinfo src/roff/trof...


From: Werner LEMBERG
Subject: [Groff-commit] groff ChangeLog doc/groff.texinfo src/roff/trof...
Date: Sun, 28 Sep 2008 14:39:45 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Werner LEMBERG <wl>     08/09/28 14:39:45

Modified files:
        .              : ChangeLog 
        doc            : groff.texinfo 
        src/roff/troff : input.cpp 

Log message:
        If a macro is called as a string, inherit value of \n[.br] from the
        caller.  This is useful for `trace.tmac'.
        
        * src/roff/troff/input.cpp (string_iterator): New members
        `with_break' and `get_break_flag'.
        (string_iterator::string_iterator): Updated.
        
        * doc/groff.texinfo: Improve documentation of \$0 and string syntax
        calling of macros.
        Document behaviour of \n[.br] within strings.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.1141&r2=1.1142
http://cvs.savannah.gnu.org/viewcvs/groff/doc/groff.texinfo?cvsroot=groff&r1=1.270&r2=1.271
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/input.cpp?cvsroot=groff&r1=1.51&r2=1.52

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.1141
retrieving revision 1.1142
diff -u -b -r1.1141 -r1.1142
--- ChangeLog   26 Sep 2008 07:38:31 -0000      1.1141
+++ ChangeLog   28 Sep 2008 14:39:43 -0000      1.1142
@@ -1,3 +1,16 @@
+2008-09-28  Werner LEMBERG  <address@hidden>
+
+       If a macro is called as a string, inherit value of \n[.br] from the
+       caller.  This is useful for `trace.tmac'.
+
+       * src/roff/troff/input.cpp (string_iterator): New members
+       `with_break' and `get_break_flag'.
+       (string_iterator::string_iterator): Updated.
+
+       * doc/groff.texinfo: Improve documentation of \$0 and string syntax
+       calling of macros.
+       Document behaviour of \n[.br] within strings.
+
 2008-09-26  Werner LEMBERG  <address@hidden>
 
        * tmac/trace.tmac: Add copyright message.

Index: doc/groff.texinfo
===================================================================
RCS file: /cvsroot/groff/groff/doc/groff.texinfo,v
retrieving revision 1.270
retrieving revision 1.271
diff -u -b -r1.270 -r1.271
--- doc/groff.texinfo   25 Sep 2008 07:48:15 -0000      1.270
+++ doc/groff.texinfo   28 Sep 2008 14:39:44 -0000      1.271
@@ -5447,6 +5447,9 @@
 
 Using this register outside of a macro makes no sense (it always returns
 zero in such cases).
+
+If a macro is called as a string (this is, using @code{\*}), the value
+of the @code{.br} register is inherited from the calling macro.
 @endDefreg
 
 @menu
@@ -5549,7 +5552,7 @@
 compatibility mode enabled since @code{gtroff} doesn't convert
 @code{\(dq} back to a double quote input character.
 
-Not that this method won't work with @acronym{UNIX} @code{troff} in
+Note that this method won't work with @acronym{UNIX} @code{troff} in
 general since the glyph `dq' isn't defined normally.
 @end itemize
 
@@ -10419,6 +10422,24 @@
     @result{} This is a funny test.
 @endExample
 
+In particular, interpolating a string does not hide existing macro
+arguments.  Thus in a macro, a more efficient way of doing
+
address@hidden
+.xx \\$@@
address@hidden
+
address@hidden
+is
+
address@hidden
+\\*[xx]\\
address@hidden
+
address@hidden
+Note that the latter calling syntax doesn't change the value of
address@hidden, which is then inherited from the calling macro.
+
 Diversions and boxes can be also called with string syntax.
 
 Another consequence is that you can copy one-line diversions or boxes to
@@ -10947,6 +10968,7 @@
 
 A @dfn{macro} is a collection of text and embedded commands which can be
 invoked multiple times.  Use macros to define common operations.
address@hidden, for a (limited) alternative syntax to call macros.
 
 @DefreqList {de, name address@hidden
 @DefreqItem {de1, name address@hidden
@@ -11251,17 +11273,40 @@
 The name used to invoke the current macro.  The @code{als} request can
 make a macro have more than one name.
 
+If a macro is called as a string (within another macro), the value of
address@hidden isn't changed.
+
 @Example
-.de generic-macro
-.  ...
-.  if \\n[error] address@hidden
-.    tm \\$0: Houston, we have a problem.
-.    return
-.  address@hidden
+.de foo
+.  tm \\$0
+..
+.als foo bar
+.
address@hidden
address@hidden
+.de aaa
+.  foo
+..
+.de bbb
+.  bar
+..
+.de ccc
+\\*[foo]\\
+..
+.de ddd
+\\*[bar]\\
 ..
 .
-.als foo generic-macro
-.als bar generic-macro
address@hidden
address@hidden
+.aaa
+    @result{} foo
+.bbb
+    @result{} bar
+.ccc
+    @result{} ccc
+.ddd
+    @result{} ddd
 @endExample
 @endDefesc
 

Index: src/roff/troff/input.cpp
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/input.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -b -r1.51 -r1.52
--- src/roff/troff/input.cpp    25 Sep 2008 07:47:38 -0000      1.51
+++ src/roff/troff/input.cpp    28 Sep 2008 14:39:44 -0000      1.52
@@ -3373,15 +3373,17 @@
   int count;                   // of characters remaining
   node *nd;
   int saved_compatible_flag;
+  int with_break;              // inherited from the caller
 protected:
   symbol nm;
   string_iterator();
 public:
-  string_iterator(const macro &m, const char *p = 0, symbol s = NULL_SYMBOL);
+  string_iterator(const macro &, const char * = 0, symbol = NULL_SYMBOL);
   int fill(node **);
   int peek();
   int get_location(int, const char **, int *);
   void backtrace();
+  int get_break_flag() { return with_break; }
   void save_compatible_flag(int f) { saved_compatible_flag = f; }
   int get_compatible_flag() { return saved_compatible_flag; }
   int is_diversion();
@@ -3402,6 +3404,7 @@
     nd = 0;
     ptr = eptr = 0;
   }
+  with_break = input_stack::get_break_flag();
 }
 
 string_iterator::string_iterator()
@@ -3413,6 +3416,7 @@
   how_invoked = 0;
   lineno = 1;
   count = 0;
+  with_break = input_stack::get_break_flag();
 }
 
 int string_iterator::is_diversion()




reply via email to

[Prev in Thread] Current Thread [Next in Thread]