groff
[Top][All Lists]
Advanced

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

[Groff] Patch for two grohtml bug fixes..


From: Gaius Mulley
Subject: [Groff] Patch for two grohtml bug fixes..
Date: Mon, 08 Oct 2001 18:48:20 +0100

Hi Werner,

> But there is still a bug in pic.ms :-)
> Below figure 16-1, the syntax for the `for' statement appears as
>   for variable = expr1 to expr2
>                                 [by [*]expr3] do X body X
> instead of 
>   for variable = expr1 to expr2 [by [*]expr3] do X body X

thanks for spotting this bug. Fixed in the patch below I believe.
I've also solved the grohtml centered text bug which manifests itself
in pic.ms if no .LP follows a .CE.

Also modified is the constant 65535 to MAX_COLOR_VAL, for what it is
worth.. :-)

BTW  also many thanks for the superb job you did in correcting the
bugs in the previous patch I sent and the numerous improvements..

Gaius

--- groff-cvs/src/roff/troff/input.cc   Fri Oct  5 15:12:24 2001
+++ groff-html/src/roff/troff/input.cc  Mon Oct  8 12:06:35 2001
@@ -248,6 +248,8 @@
   const char *filename;
   int popened;
   int newline_flag;
+  int suppress_newline_flag;  // used by html
+  int seen_escape;
   enum { BUF_SIZE = 512 };
   unsigned char buf[BUF_SIZE];
   void close();
@@ -264,7 +266,7 @@
 };
 
 file_iterator::file_iterator(FILE *f, const char *fn, int po)
-: fp(f), lineno(1), filename(fn), popened(po), newline_flag(0)
+  : fp(f), lineno(1), filename(fn), popened(po), newline_flag(0), 
suppress_newline_flag(0), seen_escape(0)
 {
   if ((font::use_charnames_in_special) && (fn != 0)) {
     if (!the_output)
@@ -302,6 +304,8 @@
   fp = f;
   lineno = 1;
   newline_flag = 0;
+  suppress_newline_flag = 0;
+  seen_escape = 0;
   popened = 0;
   ptr = 0;
   eptr = 0;
@@ -310,11 +314,12 @@
 
 int file_iterator::fill(node **)
 {
-  if (newline_flag) {
+  if (newline_flag && (!suppress_newline_flag)) {
     curenv->add_html_tag_eol();
     lineno++;
   }
   newline_flag = 0;
+  suppress_newline_flag = 0;
   unsigned char *p = buf;
   ptr = p;
   unsigned char *e = p + BUF_SIZE;
@@ -327,9 +332,13 @@
     else {
       *p++ = c;
       if (c == '\n') {
+       if (seen_escape && is_html)
+         suppress_newline_flag = 1;
+       seen_escape = 0;
        newline_flag = 1;
        break;
       }
+      seen_escape = (c == '\\');
     }
   }
   if (p > buf) {
@@ -1073,9 +1082,9 @@
     warning(WARN_RANGE, "%1 cannot be negative: set to 0", color);
     return 0;
   }
-  if (val > 65536) {
+  if (val > color::MAX_COLOR_VAL) {
     warning(WARN_RANGE, "%1 cannot be greater than 1", color);
-    return 65535;      // this is 0xffff
+    return color::MAX_COLOR_VAL;
   }
   return (unsigned int)val;
 }
@@ -2968,6 +2977,7 @@
   macro mac;
   const char *how_invoked;
   int newline_flag;
+  int suppress_newline_flag;  // used by html
   int lineno;
   char_block *bp;
   int count;                   // of characters remaining
@@ -2987,7 +2997,7 @@
 };
 
 string_iterator::string_iterator(const macro &m, const char *p, symbol s)
-: mac(m), how_invoked(p), newline_flag(0), lineno(1), nm(s)
+: mac(m), how_invoked(p), newline_flag(0), suppress_newline_flag(0), 
lineno(1), nm(s)
 {
   count = mac.length;
   if (count != 0) {
@@ -3008,6 +3018,7 @@
   nd = 0;
   ptr = eptr = 0;
   newline_flag = 0;
+  suppress_newline_flag = 0;
   how_invoked = 0;
   lineno = 1;
   count = 0;
@@ -3041,6 +3052,8 @@
     unsigned char c = *p;
     if (c == '\n' || c == ESCAPE_NEWLINE) {
       newline_flag = 1;
+      if (is_html && c == ESCAPE_NEWLINE)
+       suppress_newline_flag = 1;
       p++;
       break;
     }
--- groff-cvs/src/roff/troff/env.cc     Fri Oct  5 15:12:24 2001
+++ groff-html/src/roff/troff/env.cc    Mon Oct  8 18:28:01 2001
@@ -633,7 +633,6 @@
 #ifdef WIDOW_CONTROL
   widow_control(0),
 #endif /* WIDOW_CONTROL */
-  need_eol(0),
   ignore_next_eol(0),
   emitted_node(0),
   cur_glyph_color(0),
@@ -723,7 +722,6 @@
 #ifdef WIDOW_CONTROL
   widow_control(e->widow_control),
 #endif /* WIDOW_CONTROL */
-  need_eol(0),
   ignore_next_eol(0),
   cur_glyph_color(e->cur_glyph_color),
   prev_glyph_color(e->prev_glyph_color),
@@ -1195,7 +1193,6 @@
 
   curenv->fill = 0;
   curenv->add_html_tag(".nf");
-  curenv->ignore_next_eol = 1;
   curenv->add_html_tag(".po", topdiv->get_page_offset().to_units());
   tok.next();
 }
@@ -1609,6 +1606,8 @@
     hunits x = target_text_length - width_total;
     if (x > H0)
       saved_indent += x/2;
+
+    add_html_tag("eol.ce");
     to_be_output = line;
     to_be_output_width = width_total;
     line = 0;
@@ -2069,14 +2068,11 @@
   if (is_html) {
     if (ignore_next_eol > 0)
       ignore_next_eol--;
-    else if (need_eol > 0) {
-      need_eol--;
-      add_html_tag("eol");
-    }
-    else if (!fill && emitted_node) {
-      add_html_tag("eol");
-      emitted_node = 0;
-    }
+    else
+      if (!fill && emitted_node) {
+       add_html_tag("eol");
+       emitted_node = 0;
+      }
   }
 }
 
@@ -2100,6 +2096,8 @@
       if (!illegal_input_char((unsigned char)*p))
        m->append(*p);
     add_node(new special_node(*m));
+    if (strcmp(name, ".nf") == 0)
+      curenv->ignore_next_eol = 1;
   }
 }
 
@@ -2112,15 +2110,6 @@
 void environment::add_html_tag(const char *name, int i)
 {
   if (is_html) {
-    if (strcmp(name, ".ce") == 0) {
-      if (i == 0)
-       need_eol = 0;
-      else {
-       need_eol = i;
-       ignore_next_eol = 1;  // since the .ce creates an eol
-      }
-    }
-
     /*
      * need to emit tag for post-grohtml
      * but we check to see whether we can emit specials
--- groff-cvs/src/devices/grohtml/post-html.cc  Fri Oct  5 22:42:30 2001
+++ groff-html/src/devices/grohtml/post-html.cc Mon Oct  8 15:45:05 2001
@@ -357,6 +357,7 @@
   int         is_eol      (void);
   int         is_auto_img (void);
   int         is_br       (void);
+  int         is_eol_ce   (void);
 
   style           text_style;
   char           *text_string;
@@ -420,6 +421,15 @@
 }
 
 /*
+ *  is_eol_ce - returns TRUE if glob contains the tag eol.ce
+ */
+
+int text_glob::is_eol_ce (void)
+{
+  return( is_tag && (strcmp(text_string, "html-tag:eol.ce") == 0) );
+}
+
+/*
  *  is_raw - returns TRUE if glob contains raw html.
  */
 
@@ -1071,6 +1081,7 @@
   int   end_subscript                 (text_glob *g);
   int   start_superscript             (text_glob *g);
   int   end_superscript               (text_glob *g);
+  void  outstanding_eol               (int n);
 
   // ADD HERE
 
@@ -1279,6 +1290,18 @@
 }
 
 /*
+ *  outstanding_eol - call do_eol, n, times.
+ */
+
+void html_printer::outstanding_eol (int n)
+{
+  while (n > 0) {
+    do_eol();
+    n--;
+  }
+}
+
+/*
  *  do_title - handle the .tl commands from troff.
  */
 
@@ -1286,6 +1309,7 @@
 {
   text_glob    *t;
   int           removed_from_head;
+  int           eol_ce = 0;
   char          buf[MAX_STRING_LENGTH];
 
   if (page_number == 1) {
@@ -1313,16 +1337,23 @@
          /* skip raw commands
           */
          page_contents->glyphs.sub_move_right();         /* move onto next 
word */
+       } else if (t->is_eol_ce()) {
+         /*  process the eol associated with .ce
+          */
+         eol_ce++;
+         page_contents->glyphs.sub_move_right();         /* move onto next 
word */
        } else if (t->is_eol()) {
          /* end of title found
           */
          title.has_been_found = TRUE;
+         outstanding_eol(eol_ce);
          return;
        } else if (t->is_a_tag()) {
          /* end of title found, but move back so that we read this tag and 
process it
           */
          page_contents->glyphs.move_left();           /* move backwards to 
last word */
          title.has_been_found = TRUE;
+         outstanding_eol(eol_ce);
          return;
        } else if (found_title_start) {
            strcat(title.text, " ");
@@ -1342,7 +1373,7 @@
        }
       } while ((! page_contents->glyphs.is_equal_to_head()) || 
(removed_from_head));
     }
-    // page_contents->glyphs.move_left();           /* move backwards to last 
word */
+    outstanding_eol(eol_ce);
   }
 }
 
@@ -1744,6 +1775,8 @@
   char *t=(char *)g->text_string+9;
 
   if (g->is_eol()) {
+    do_eol();
+  } else if (g->is_eol_ce()) {
     do_eol();
   } else if (strncmp(t, ".sp", 3) == 0) {
     current_paragraph->do_space();

reply via email to

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