groff
[Top][All Lists]
Advanced

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

[Groff] replacement patch for the previous grohtml/image/filename proble


From: Gaius Mulley
Subject: [Groff] replacement patch for the previous grohtml/image/filename problem
Date: Thu, 27 Jan 2000 01:04:26 +0000 (GMT)

Hi Werner,

Please discard my previous patch - I forgot to test the
result of malloc. Here it is again with the correction.
If you have already applied the previous email patch
you might want to insert the three lines of code
below "malloc" in remember_filename below.

Sorry about this oversight,

cheers Gaius

--- groff-cvs/ChangeLog Mon Jan 24 14:57:45 2000
+++ groff-html/ChangeLog        Wed Jan 26 19:56:49 2000
@@ -1,3 +1,9 @@
+2000-01-26  Gaius Mulley <address@hidden>
+
+       completed the pass_filenames implementation in troff.
+       * libdriver/input.cc will read the new 'F` tcommand.
+       * troff/node.cc will issue the new 'F` tcommand.
+       
 2000-01-24  Werner Lemberg  <address@hidden>
 
        * doc/homepage.ms: Updated for new tmac.arkup.
diff -aruN groff-cvs/troff/input.cc groff-html/troff/input.cc
--- groff-cvs/troff/input.cc    Fri Jan 21 22:59:53 2000
+++ groff-html/troff/input.cc   Wed Jan 26 19:51:23 2000
@@ -266,6 +266,11 @@
 file_iterator::file_iterator(FILE *f, const char *fn, int po)
 : fp(f), lineno(1), filename(fn), popened(po), newline_flag(0)
 {
+  if ((font::use_charnames_in_special) && (fn != 0)) {
+    if (!the_output)
+      init_output();
+    the_output->put_filename(fn);
+  }
 }
 
 file_iterator::~file_iterator()
@@ -366,8 +371,12 @@
 
 int file_iterator::set_location(const char *f, int ln)
 {
-  if (f)
+  if (f) {
     filename = f;
+    if (!the_output)
+      init_output();
+    the_output->put_filename(f);
+  }
   lineno = ln;
   return 1;
 }
@@ -3930,7 +3939,7 @@
 static void encode_char (macro *mac, char c)
 {
   if (c == '\0') {
-    if (tok.special() && (font::use_charnames_in_special)) {
+    if ((font::use_charnames_in_special) && tok.special()) {
       charinfo *ci=tok.get_char(1);
       const char *s=ci->get_symbol()->contents();
 
diff -aruN groff-cvs/troff/node.cc groff-html/troff/node.cc
--- groff-cvs/troff/node.cc     Sat Jan 15 11:35:25 2000
+++ groff-html/troff/node.cc    Wed Jan 26 19:51:59 2000
@@ -630,6 +630,7 @@
                                 vunits before, vunits after) = 0;
   virtual void really_begin_page(int pageno, vunits page_length) = 0;
   virtual void really_copy_file(hunits x, vunits y, const char *filename);
+  virtual void really_put_filename(const char *filename);
 protected:
   FILE *fp;
 public:
@@ -639,6 +640,7 @@
   void transparent_char(unsigned char);
   void print_line(hunits x, vunits y, node *n, vunits before, vunits after);
   void begin_page(int pageno, vunits page_length);
+  void put_filename(const char *filename);
   int is_printing();
   void copy_file(hunits x, vunits y, const char *filename);
 };
@@ -718,6 +720,7 @@
   void really_print_line(hunits x, vunits y, node *n, vunits before, vunits 
after);
   void really_begin_page(int pageno, vunits page_length);
   void really_copy_file(hunits x, vunits y, const char *filename);
+  void really_put_filename(const char *filename);
   void draw(char, hvpair *, int, font_size);
   int get_hpos() { return hpos; }
   int get_vpos() { return vpos; }
@@ -1066,6 +1069,14 @@
   put('\n');
 }
 
+void troff_output_file::really_put_filename(const char *filename)
+{
+  flush_tbuf();
+  put("F ");
+  put(filename);
+  put('\n');
+}
+
 void troff_output_file::really_begin_page(int pageno, vunits page_length)
 {
   flush_tbuf();
@@ -1174,6 +1185,11 @@
 {
 }
 
+
+void output_file::put_filename(const char *filename)
+{
+}
+
 real_output_file::real_output_file()
 : printing(0)
 {
@@ -1266,6 +1282,14 @@
   // do nothing
 }
 
+void real_output_file::put_filename(const char *filename)
+{
+  really_put_filename(filename);
+}
+
+void real_output_file::really_put_filename(const char *filename)
+{
+}
 
 /* ascii_output_file */
 
diff -aruN groff-cvs/troff/node.h groff-html/troff/node.h
--- groff-cvs/troff/node.h      Wed Jan 12 14:16:55 2000
+++ groff-html/troff/node.h     Sun Jan 23 02:01:35 2000
@@ -466,6 +466,7 @@
   virtual void begin_page(int pageno, vunits page_length) = 0;
   virtual void copy_file(hunits x, vunits y, const char *filename) = 0;
   virtual int is_printing() = 0;
+  virtual void put_filename (const char *filename);
 #ifdef COLUMN
   virtual void vjustify(vunits, symbol);
 #endif /* COLUMN */
diff -aruN groff-cvs/grohtml/ChangeLog groff-html/grohtml/ChangeLog
--- groff-cvs/grohtml/ChangeLog Mon Jan 24 08:00:20 2000
+++ groff-html/grohtml/ChangeLog        Wed Jan 26 19:54:45 2000
@@ -1,3 +1,7 @@
+2000-01-26  Gaius Mulley  <address@hidden>
+
+       * html.cc: added support for the new tcommand 'F`
+       
 2000-01-24  Gaius Mulley  <address@hidden>
 
        * design.ms: Revised.  Removed TODO stuff.
diff -aruN groff-cvs/grohtml/TODO groff-html/grohtml/TODO
--- groff-cvs/grohtml/TODO      Mon Jan 24 08:00:54 2000
+++ groff-html/grohtml/TODO     Wed Jan 26 19:17:44 2000
@@ -1,6 +1,6 @@
 
-To do list
-
+------------------------------------------------------------------
+                       T O   D O   L I S T
 ------------------------------------------------------------------
 finish working out the max and min x, y, extents for splines.
 ------------------------------------------------------------------
@@ -46,34 +46,6 @@
 
 gaius> this should be straight forward. (Not done yet though)
 ------------------------------------------------------------------
-Werner writes:
-
-Gaius,
-
-checking a weird man page written by myself in German (using German
-hyphenation patterns also :-), I found some more bugs:
-
-.) Look at the following:
- 
-[\c
-...\^\c
-] 
-[\c
-.BI -P \ \%Plattform-ID\^\c
-]
-
-   This translates to
-
-[<font size=3><B>-E</B> <font size=3><I>Kodierungs-ID</I> <font size=3>]
-                                                         ^
-   (groff breaks the line after the final `]'.)
-
-   There are two errors in it: First of all, the `\ ' command should
-   be translated to `&nbsp;'.  Secondly, a blank has crept in (marked
-   with `^'.  Apparently, this is related to whether it is the last
-   item of a line or not.
-
---fixed-- 4 01 2000
 
 .) The command `\(->', translates to the `registered' sign (or rather
    the character `0xAE') instead of a right arrow.
@@ -85,24 +57,6 @@
 gaius>   etc. Otherwise I guess we could translate this character into ->
 gaius>   in tmac.html ?
 
-.) The following code produces ugly results -- is it possible to make
-   the HTML result similar to the ascii output?
-
-.in +4m
-.ta 3iC
-.I "Plattform  Plattform-ID (pid)"
-\&.sp
-.ta 3iR
-Apple Unicode  0
-.br
-Macintosh      1
-.br
-ISO    2
-.br
-Microsoft      3
-.PP
-
---fixed--  14/01/2000
 ------------------------------------------------------------------
 
 Werner writes:
@@ -145,24 +99,50 @@
 
 .) The indentation in the `FILES' section is inconsistent.  The same
    is true for `-V, --version' a few lines above.
-------------------------------------------------------------------
 
+.) The formatting of the paragraph after the first table is completely
+   wrong.  It appears that the first few words are set in two columns;
+   additionally, the indentation is incorrect.
+
+.) Similarly, the description of `-l' in the OPTIONS section is
+   idented incorrectly.  Wrong indentations happen still quite
+   frequently.
+
+.) In the description of the `-D' option, there is a blank line in the
+   middle of a paragraph.
+
+
+     Werner
+
+------------------------------------------------------------------
 Werner writes:
 
-PNGs created by grohtml have apparently a white background -- isn't it
-possible to make the background transparent optionally?
+Gaius,
 
-Another suggestion: What do you think about calling the PNG files
-<groff_input_file>-<index>.png or something like this?  I can't see an
-advantage in the current naming scheme except for debugging purposes
-where it may be necessary to stay with the old files.
+checking a weird man page written by myself in German (using German
+hyphenation patterns also :-), I found some more bugs:
 
---fixed-- 04 01 2000
+.) Look at the following:
+ 
+[\c
+...\^\c
+] 
+[\c
+.BI -P \ \%Plattform-ID\^\c
+]
 
-gaius> however I've had to retain a default grohtml-pid-index.png for all
-gaius> stdin as we don't know the filename.. sadly looks like everything..
-gaius> Nearly done by including a new tcommand 'F filename'
+   This translates to
+
+[<font size=3><B>-E</B> <font size=3><I>Kodierungs-ID</I> <font size=3>]
+                                                         ^
+   (groff breaks the line after the final `]'.)
+
+   There are two errors in it: First of all, the `\ ' command should
+   be translated to `&nbsp;'.  Secondly, a blank has crept in (marked
+   with `^'.  Apparently, this is related to whether it is the last
+   item of a line or not.
 
+--fixed-- 4 01 2000
 ------------------------------------------------------------------
 
 from Steve Blinkhorn <address@hidden>
@@ -177,6 +157,9 @@
 
 gaius>  should be interesting - if we can generate PS then GS it
 gaius>  we should be in business
+
+------------------------------------------------------------------
+                        D O N E   L I S T
 ------------------------------------------------------------------
 the logical place and name for a file describing tmac.arkup is
 groff_markup.man placed into the `tmac' subdirectory, and your html.ms
@@ -242,22 +225,9 @@
    problems here...
 
    (IIRC, I've sent you this man.1 file a few weeks ago).
-gaius> Werner fixed this by adding .cflags 0 -\(hy\(em\(en to tmac.html
-
-.) The formatting of the paragraph after the first table is completely
-   wrong.  It appears that the first few words are set in two columns;
-   additionally, the indentation is incorrect.
-
-.) Similarly, the description of `-l' in the OPTIONS section is
-   idented incorrectly.  Wrong indentations happen still quite
-   frequently.
-
-.) In the description of the `-D' option, there is a blank line in the
-   middle of a paragraph.
-
 
+gaius> Werner fixed this by adding .cflags 0 -\(hy\(em\(en to tmac.html
 
-     Werner
 -----------------------------------------------------------------
 from Werner and Eddie
 > > > .LP
@@ -282,3 +252,43 @@
 > .URL ...
 
 gaius> fixed by adding \& to HTML as per Werner's suggestion
+
+
+Werner writes:
+
+PNGs created by grohtml have apparently a white background -- isn't it
+possible to make the background transparent optionally?
+
+Another suggestion: What do you think about calling the PNG files
+<groff_input_file>-<index>.png or something like this?  I can't see an
+advantage in the current naming scheme except for debugging purposes
+where it may be necessary to stay with the old files.
+
+--fixed-- 04 01 2000
+
+gaius> however I've had to retain a default grohtml-pid-index.png for all
+gaius> stdin as we don't know the filename.. sadly looks like everything..
+gaius> Nearly done by including a new tcommand 'F filename'
+
+--fixed-- 26 01 2000
+------------------------------------------------------------------
+
+.) The following code produces ugly results -- is it possible to make
+   the HTML result similar to the ascii output?
+
+.in +4m
+.ta 3iC
+.I "Plattform  Plattform-ID (pid)"
+\&.sp
+.ta 3iR
+Apple Unicode  0
+.br
+Macintosh      1
+.br
+ISO    2
+.br
+Microsoft      3
+.PP
+
+--fixed--  14/01/2000
+------------------------------------------------------------------
diff -aruN groff-cvs/grohtml/html.cc groff-html/grohtml/html.cc
--- groff-cvs/grohtml/html.cc   Fri Jan 21 22:55:10 2000
+++ groff-html/grohtml/html.cc  Tue Jan 25 11:53:27 2000
@@ -1071,7 +1071,7 @@
   int   is_whole_line_bold            (text_glob *g);
   int   is_a_header                   (text_glob *g);
   int   processed_header              (text_glob *g);
-  void  make_new_image_name           (char *extension);
+  void  make_new_image_name           (void);
   void  create_temp_name              (char *name, char *extension);
   void  calculate_region_margins      (region_glob *r);
   void  remove_redundant_regions      (void);
@@ -1542,17 +1542,16 @@
 
 /*
  *  make_new_image_name - creates a new file name ready for a image file.
- *                        it leaves the extension off.
  */
 
-void html_printer::make_new_image_name (char *extension)
+void html_printer::make_new_image_name (void)
 {
   image_number++;
   if ((strcmp(current_filename, "<standard input>") == 0) ||
-      (strcmp(extension, "troff") == 0)) {
+      (strcmp(current_filename, "-") == 0)) {
     sprintf(image_name, "grohtml-%d-%ld", image_number, (long)getpid());
   } else {
-    sprintf(image_name, "%s-%d", current_filename, image_number);
+    sprintf(image_name, "%s-%d-%ld", current_filename, image_number, 
(long)getpid());
   }
 }
 
@@ -2471,8 +2470,8 @@
 
 void html_printer::create_temp_name (char *name, char *extension)
 {
-  make_new_image_name(extension);
-  sprintf(name, "/tmp/%s.%s", image_name, extension);
+  make_new_image_name();
+  sprintf(name, "/tmp/grohtml-%d-%ld.%s", image_number, (long)getpid(), 
extension);
 }
 
 void html_printer::display_globs (int is_to_html)
diff -aruN groff-cvs/libdriver/input.cc groff-html/libdriver/input.cc
--- groff-cvs/libdriver/input.cc        Sat Sep 11 21:32:20 1999
+++ groff-html/libdriver/input.cc       Thu Jan 27 00:47:13 2000
@@ -22,7 +22,7 @@
 #include "device.h"
 #include "cset.h"
 
-const char *current_filename;
+const char *current_filename=0;
 int current_lineno;
 const char *device = 0;
 FILE *current_file;
@@ -49,11 +49,31 @@
   return getc(current_file);
 }
 
+/*
+ *  remember_filename - is needed as get_string might overwrite the
+ *                      filename eventually.
+ */
+
+void remember_filename (const char *filename)
+{
+  if (current_filename != 0) {
+    free((char *)current_filename);
+  }
+  if (strcmp(filename, "-") == 0) {
+    filename = "<standard input>";
+  }
+  current_filename = (const char *)malloc(strlen(filename)+1);
+  if (current_filename == 0) {
+    fatal("can't malloc space for filename");
+  }
+  strcpy((char *)current_filename, (char *)filename);
+}
+
 void do_file(const char *filename)
 {
   int npages = 0;
   if (filename[0] == '-' && filename[1] == '\0') {
-    current_filename = "<standard input>";
+    remember_filename(filename);
     current_file = stdin;
   }
   else {
@@ -63,7 +83,7 @@
       error("can't open `%1'", filename);
       return;
     }
-    current_filename = filename;
+    remember_filename(filename);
   }
   environment env;
   env.vpos = -1;
@@ -129,6 +149,9 @@
       break;
     case 'f':
       env.fontno = get_integer();
+      break;
+    case 'F':
+      remember_filename(get_string());
       break;
     case 'C':
       {


reply via email to

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