groff-commit
[Top][All Lists]
Advanced

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

[Groff-commit] groff ./ChangeLog src/roff/troff/input.cpp src/...


From: Werner LEMBERG
Subject: [Groff-commit] groff ./ChangeLog src/roff/troff/input.cpp src/...
Date: Mon, 27 Sep 2004 02:16:15 -0400

CVSROOT:        /cvsroot/groff
Module name:    groff
Branch:         
Changes by:     Werner LEMBERG <address@hidden> 04/09/27 06:09:40

Modified files:
        .              : ChangeLog 
        src/roff/troff : input.cpp input.h 

Log message:
        Fix \$@ and \$* to handle any number of arguments.
        
        * src/roff/troff/input.h (BEGIN_QUOTE, END_QUOTE): New special
        characters.
        
        * src/roff/troff/input.cpp (input_iterator::internal_level):
        Removed.
        (input_stack): New member functions `increase_level' and
        `decrease_level'.
        (input_stack::get_level): Don't use `internal_level'.
        (get_copy, token::next): Handle BEGIN_QUOTE and END_QUOTE.
        (end_quote_iterator): Completely removed.
        (interpolate_arg): Build string for \$@ and \$* which is then
        pushed onto the input stack.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/ChangeLog.diff?tr1=1.739&tr2=1.740&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/roff/troff/input.cpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/groff/groff/src/roff/troff/input.h.diff?tr1=1.5&tr2=1.6&r1=text&r2=text

Patches:
Index: groff/ChangeLog
diff -u groff/ChangeLog:1.739 groff/ChangeLog:1.740
--- groff/ChangeLog:1.739       Thu Sep 23 11:54:24 2004
+++ groff/ChangeLog     Mon Sep 27 06:09:39 2004
@@ -1,3 +1,20 @@
+2004-09-26  Werner LEMBERG  <address@hidden>
+
+       Fix \$@ and \$* to handle any number of arguments.
+
+       * src/roff/troff/input.h (BEGIN_QUOTE, END_QUOTE): New special
+       characters.
+
+       * src/roff/troff/input.cpp (input_iterator::internal_level):
+       Removed.
+       (input_stack): New member functions `increase_level' and
+       `decrease_level'.
+       (input_stack::get_level): Don't use `internal_level'.
+       (get_copy, token::next): Handle BEGIN_QUOTE and END_QUOTE.
+       (end_quote_iterator): Completely removed.
+       (interpolate_arg): Build string for \$@ and \$* which is then
+       pushed onto the input stack.
+
 2004-09-23  Keith Marshall  <address@hidden>
 
        * tmac/groff_ms.man, doc/groff.texinfo: Document changes from
Index: groff/src/roff/troff/input.cpp
diff -u groff/src/roff/troff/input.cpp:1.18 groff/src/roff/troff/input.cpp:1.19
--- groff/src/roff/troff/input.cpp:1.18 Sat Jul  3 07:19:01 2004
+++ groff/src/roff/troff/input.cpp      Mon Sep 27 06:09:40 2004
@@ -214,7 +214,6 @@
   virtual int next_file(FILE *, const char *) { return 0; }
   virtual void shift(int) {}
   virtual int is_boundary() {return 0; }
-  virtual int internal_level() { return 0; }
   virtual int is_file() { return 0; }
   virtual int is_macro() { return 0; }
   virtual void save_compatible_flag(int) {}
@@ -416,6 +415,8 @@
   static int is_return_boundary();
   static void remove_boundary();
   static int get_level();
+  static void increase_level();
+  static void decrease_level();
   static void clear();
   static void pop_macro();
   static void save_compatible_flag(int);
@@ -436,7 +437,17 @@
 
 inline int input_stack::get_level()
 {
-  return level + top->internal_level();
+  return level;
+}
+
+inline void input_stack::increase_level()
+{
+  level++;
+}
+
+inline void input_stack::decrease_level()
+{
+  level--;
 }
 
 inline int input_stack::get(node **np)
@@ -850,6 +861,14 @@
       compatible_flag = input_stack::get_compatible_flag();
       continue;
     }
+    if (c == BEGIN_QUOTE) {
+      input_stack::increase_level();
+      continue;
+    }
+    if (c == END_QUOTE) {
+      input_stack::decrease_level();
+      continue;
+    }
     if (c == ESCAPE_NEWLINE) {
       if (defining)
        return c;
@@ -1584,6 +1603,12 @@
       case POP_GROFFCOMP_MODE:
        compatible_flag = input_stack::get_compatible_flag();
        continue;
+      case BEGIN_QUOTE:
+       input_stack::increase_level();
+       continue;
+      case END_QUOTE:
+       input_stack::decrease_level();
+       continue;
       case EOF:
        type = TOKEN_EOF;
        return;
@@ -4029,26 +4054,6 @@
   }
 }
 
-/* This class is used for the implementation of address@hidden  It is used for
-each of the closing double quotes.  It artificially increases the
-input level by 2, so that the closing double quote will appear to have
-the same input level as the opening quote. */
-
-class end_quote_iterator : public input_iterator {
-  unsigned char buf[1];
-public:
-  end_quote_iterator();
-  ~end_quote_iterator() { }
-  int internal_level() { return 2; }
-};
-
-end_quote_iterator::end_quote_iterator()
-{
-  buf[0] = '"';
-  ptr = buf;
-  eptr = buf + 1;
-}
-
 static void interpolate_arg(symbol nm)
 {
   const char *s = nm.contents();
@@ -4057,17 +4062,39 @@
   else if (s[1] == 0 && csdigit(s[0]))
     input_stack::push(input_stack::get_arg(s[0] - '0'));
   else if (s[0] == '*' && s[1] == '\0') {
-    for (int i = input_stack::nargs(); i > 0; i--) {
-      input_stack::push(input_stack::get_arg(i));
-      if (i != 1)
-       input_stack::push(make_temp_iterator(" "));
+    int limit = input_stack::nargs();
+    string args;
+    for (int i = 1; i <= limit; i++) {
+      input_iterator *p = input_stack::get_arg(i);
+      int c;
+      while ((c = p->get(0)) != EOF)
+       args += c;
+      if (i != limit)
+       args += ' ';
+    }
+    if (limit > 0) {
+      args += '\0';
+      input_stack::push(make_temp_iterator(args.contents()));
     }
   }
   else if (s[0] == '@' && s[1] == '\0') {
-    for (int i = input_stack::nargs(); i > 0; i--) {
-      input_stack::push(new end_quote_iterator);
-      input_stack::push(input_stack::get_arg(i));
-      input_stack::push(make_temp_iterator(i == 1 ? "\"" : " \""));
+    int limit = input_stack::nargs();
+    string args;
+    for (int i = 1; i <= limit; i++) {
+      args += '"';
+      args += BEGIN_QUOTE;
+      input_iterator *p = input_stack::get_arg(i);
+      int c;
+      while ((c = p->get(0)) != EOF)
+       args += c;
+      args += END_QUOTE;
+      args += '"';
+      if (i != limit)
+       args += ' ';
+    }
+    if (limit > 0) {
+      args += '\0';
+      input_stack::push(make_temp_iterator(args.contents()));
     }
   }
   else {
Index: groff/src/roff/troff/input.h
diff -u groff/src/roff/troff/input.h:1.5 groff/src/roff/troff/input.h:1.6
--- groff/src/roff/troff/input.h:1.5    Tue Jul 27 01:29:24 2004
+++ groff/src/roff/troff/input.h        Mon Sep 27 06:09:40 2004
@@ -57,6 +57,8 @@
 const int PUSH_GROFF_MODE = 0211;
 const int PUSH_COMP_MODE = 0212;
 const int POP_GROFFCOMP_MODE = 0213;
+const int BEGIN_QUOTE = 0214;
+const int END_QUOTE = 0215;
 
 #else /* IS_EBCDIC_HOST */
 
@@ -94,6 +96,8 @@
 const int PUSH_GROFF_MODE = 071;
 const int PUSH_COMP_MODE = 072;
 const int POP_GROFFCOMP_MODE = 073;
+const int BEGIN_QUOTE = 074;
+const int END_QUOTE = 075;
 
 #endif /* IS_EBCDIC_HOST */
 




reply via email to

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