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/ro...


From: Werner LEMBERG
Subject: [Groff-commit] groff ChangeLog src/roff/troff/input.cpp src/ro...
Date: Thu, 07 May 2009 16:22:18 +0000

CVSROOT:        /cvsroot/groff
Module name:    groff
Changes by:     Werner LEMBERG <wl>     09/05/07 16:22:17

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

Log message:
        Accept \0 and friends within \o.
        Reported by Doug McIlroy <address@hidden>.
        
        * src/roff/troff/token.h (token): Add TOKEN_HORIZONTAL_SPACE
        enumeration value together with `horizontal_space' member function.
        Add `do_overstrike' as a friend.
        
        * src/roff/troff/input.cpp: Use TOKEN_HORIZONTAL_SPACE for \0, \|,
        \^, and \h.
        Update all affected places.
        (do_overstrike): Remove `static' attribute.
        Accept all escapes which produce a fixed horizontal space.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/groff/ChangeLog?cvsroot=groff&r1=1.1203&r2=1.1204
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/input.cpp?cvsroot=groff&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/groff/src/roff/troff/token.h?cvsroot=groff&r1=1.17&r2=1.18

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/groff/groff/ChangeLog,v
retrieving revision 1.1203
retrieving revision 1.1204
diff -u -b -r1.1203 -r1.1204
--- ChangeLog   24 Apr 2009 20:43:19 -0000      1.1203
+++ ChangeLog   7 May 2009 16:22:16 -0000       1.1204
@@ -1,3 +1,18 @@
+2009-05-07  Werner LEMBERG  <address@hidden>
+
+       Accept \0 and friends within \o.
+       Reported by Doug McIlroy <address@hidden>.
+
+       * src/roff/troff/token.h (token): Add TOKEN_HORIZONTAL_SPACE
+       enumeration value together with `horizontal_space' member function.
+       Add `do_overstrike' as a friend.
+
+       * src/roff/troff/input.cpp: Use TOKEN_HORIZONTAL_SPACE for \0, \|,
+       \^, and \h.
+       Update all affected places.
+       (do_overstrike): Remove `static' attribute.
+       Accept all escapes which produce a fixed horizontal space.
+
 2009-04-24  Werner LEMBERG  <address@hidden>
 
        Use straight quotes where appropriate.

Index: src/roff/troff/input.cpp
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/input.cpp,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- src/roff/troff/input.cpp    21 Feb 2009 07:40:22 -0000      1.59
+++ src/roff/troff/input.cpp    7 May 2009 16:22:17 -0000       1.60
@@ -1434,7 +1434,7 @@
   skip_line();
 }
 
-static node *do_overstrike()
+node *do_overstrike()
 {
   token start;
   overstrike_node *on = new overstrike_node;
@@ -1450,6 +1450,15 @@
     if (tok == start
        && (compatible_flag || input_stack::get_level() == start_level))
       break;
+    if (tok.horizontal_space())
+      on->overstrike(tok.nd->copy());
+    else if (tok.unstretchable_space())
+    {
+      node *n = new hmotion_node(curenv->get_space_width(),
+                                curenv->get_fill_color());
+      on->overstrike(n);
+    }
+    else {
     charinfo *ci = tok.get_char(1);
     if (ci) {
       node *n = curenv->make_char_node(ci);
@@ -1457,6 +1466,7 @@
        on->overstrike(n);
     }
   }
+  }
   return on;
 }
 
@@ -1799,13 +1809,13 @@
        goto handle_escape_char;
       case ESCAPE_BAR:
       ESCAPE_BAR:
-       type = TOKEN_NODE;
+       type = TOKEN_HORIZONTAL_SPACE;
        nd = new hmotion_node(curenv->get_narrow_space_width(),
                              curenv->get_fill_color());
        return;
       case ESCAPE_CIRCUMFLEX:
       ESCAPE_CIRCUMFLEX:
-       type = TOKEN_NODE;
+       type = TOKEN_HORIZONTAL_SPACE;
        nd = new hmotion_node(curenv->get_half_narrow_space_width(),
                              curenv->get_fill_color());
        return;
@@ -1926,7 +1936,7 @@
       case '0':
        nd = new hmotion_node(curenv->get_digit_width(),
                              curenv->get_fill_color());
-       type = TOKEN_NODE;
+       type = TOKEN_HORIZONTAL_SPACE;
        return;
       case '|':
        goto ESCAPE_BAR;
@@ -2061,7 +2071,7 @@
       case 'h':
        if (!get_delim_number(&x, 'm'))
          break;
-       type = TOKEN_NODE;
+       type = TOKEN_HORIZONTAL_SPACE;
        nd = new hmotion_node(x, curenv->get_fill_color());
        return;
       case 'H':
@@ -2216,7 +2226,7 @@
       case 'z':
        {
          next();
-         if (type == TOKEN_NODE)
+         if (type == TOKEN_NODE || type == TOKEN_HORIZONTAL_SPACE)
            nd = new zero_width_node(nd);
          else {
            charinfo *ci = get_char(1);
@@ -2346,6 +2356,7 @@
   case TOKEN_SPACE:
   case TOKEN_STRETCHABLE_SPACE:
   case TOKEN_UNSTRETCHABLE_SPACE:
+  case TOKEN_HORIZONTAL_SPACE:
   case TOKEN_TAB:
   case TOKEN_NEWLINE:
     if (err)
@@ -2402,6 +2413,8 @@
     return "`\\~'";
   case TOKEN_UNSTRETCHABLE_SPACE:
     return "`\\ '";
+  case TOKEN_HORIZONTAL_SPACE:
+    return "a horizontal space";
   case TOKEN_TAB:
     return "a tab character";
   case TOKEN_TRANSPARENT:
@@ -2951,6 +2964,7 @@
     case token::TOKEN_EOF:
       return;
     case token::TOKEN_NODE:
+    case token::TOKEN_HORIZONTAL_SPACE:
       {
        if (possibly_handle_first_page_transition())
          ;
@@ -6796,6 +6810,7 @@
     set_number_reg(nm, curenv->get_input_line_position().to_units());
     break;
   case TOKEN_NODE:
+  case TOKEN_HORIZONTAL_SPACE:
     n = nd;
     nd = 0;
     break;
@@ -6888,6 +6903,7 @@
     curenv->newline();
     break;
   case TOKEN_NODE:
+  case TOKEN_HORIZONTAL_SPACE:
     curenv->add_node(nd);
     nd = 0;
     break;

Index: src/roff/troff/token.h
===================================================================
RCS file: /cvsroot/groff/groff/src/roff/troff/token.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- src/roff/troff/token.h      5 Jan 2009 20:11:13 -0000       1.17
+++ src/roff/troff/token.h      7 May 2009 16:22:17 -0000       1.18
@@ -54,6 +54,7 @@
     TOKEN_SPREAD,              // \p -- break and spread output line 
     TOKEN_STRETCHABLE_SPACE,   // \~
     TOKEN_UNSTRETCHABLE_SPACE, // `\ '
+    TOKEN_HORIZONTAL_SPACE,    // \|, \^, \0, \h
     TOKEN_TAB,                 // tab
     TOKEN_TRANSPARENT,         // \!
     TOKEN_TRANSPARENT_DUMMY,   // \)
@@ -73,6 +74,7 @@
   int space();                 // is the current token a space?
   int stretchable_space();     // is the current token a stretchable space?
   int unstretchable_space();   // is the current token an unstretchable space?
+  int horizontal_space();      // is the current token a horizontal space?
   int white_space();           // is the current token space or tab?
   int special();               // is the current token a special character?
   int newline();               // is the current token a newline?
@@ -99,6 +101,7 @@
   const char *description();
 
   friend void process_input_stack();
+  friend node *do_overstrike();
 };
 
 extern token tok;              // the current token
@@ -155,6 +158,11 @@
   return type == TOKEN_UNSTRETCHABLE_SPACE;
 }
 
+inline int token::horizontal_space()
+{
+  return type == TOKEN_HORIZONTAL_SPACE;
+}
+
 inline int token::special()
 { 
   return type == TOKEN_SPECIAL;




reply via email to

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