groff
[Top][All Lists]
Advanced

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

[Groff] Re: problem with pre-grohtml


From: Gaius Mulley
Subject: [Groff] Re: problem with pre-grohtml
Date: Mon, 16 Jul 2001 15:09:23 +0100

> Consider the following call in the groff directory after a build:

>  PATH=/bin ./test-groff -p -e -t -P-D -Pdoc -Thtml -U -ms

shouldn't this read
  PATH=/bin ./test-groff -p -e -t -P-Ddoc -Thtml -U -ms
?

anyway here are some patches to implement your suggestion:

> Now my question: Instead of calling `troff -Thtml' (from within
> pre-grohtml) wouldn't it be easier to call `groff -Thtml -Z'?  This
> assures that GROFF_BIN_PATH is checked.  And it simplifies the code in
> pre-html.cc since it is no longer necessary to check `troff'
> vs. `gtroff'.

thanks for the suggestion..

Gaius



--- groff-cvs/src/preproc/html/pre-html.cc      Mon Jul 16 03:08:56 2001
+++ groff-html/src/preproc/html/pre-html.cc     Mon Jul 16 14:50:06 2001
@@ -72,6 +72,7 @@
 #define PS_TEMPLATE_LONG "-ps-"
 #define REGION_TEMPLATE_SHORT "rg"
 #define REGION_TEMPLATE_LONG "-regions-"
+#define TROFF_COMMAND "troff"
 
 #if 0
 #   define  DEBUGGING
@@ -102,7 +103,6 @@
 static char *image_template = NULL;             // image template filename
 static int   troff_arg      = 0;                // troff arg index
 static char *command_prefix = NULL;             // optional prefix for some 
installations.
-static char *troff_command  = NULL;
 static char *image_dir      = NULL;             // user specified image 
directory
 #if defined(DEBUGGING)
 static int   debug          = FALSE;
@@ -1119,7 +1119,7 @@
  *  alterDeviceTo - if toImage is set then the arg list is altered to include
  *                     IMAGE_DEVICE and we invoke groff rather than troff.
  *                  else 
- *                     set -Thtml and troff
+ *                     set -Thtml and groff
  */
 
 static void alterDeviceTo (int argc, char *argv[], int toImage)
@@ -1141,11 +1141,37 @@
       }
       i++;
     }
-    argv[troff_arg] = troff_command;  /* use troff */
+    argv[troff_arg] = "groff";   /* use groff -Z */
   }
 }
 
 /*
+ *  addZ - appends -Z onto the command list for groff.
+ */
+
+char **addZ (int argc, char *argv[])
+{
+  char **new_argv = (char **)malloc((argc+2)*sizeof(char *));
+  int   i=0;
+
+  if (new_argv == NULL)
+    sys_fatal("malloc");
+
+  while (i<troff_arg) {
+    new_argv[i] = argv[i];
+    i++;
+  }
+  new_argv[i] = "-Z";
+  while (i<argc) {
+    new_argv[i+1] = argv[i];
+    i++;
+  }
+  argc++;
+  new_argv[argc] = NULL;
+  return( new_argv );
+}
+
+/*
  *  do_html - sets the troff number htmlflip and
  *            writes out the buffer to troff -Thtml
  */
@@ -1159,8 +1185,10 @@
     sys_fatal("pipe");
 
   alterDeviceTo(argc, argv, 0);
-  argv += troff_arg;   // skip all arguments up to troff/groff
+  argv += troff_arg;   // skip all arguments up to groff
   argc -= troff_arg;
+  argv = addZ(argc, argv);
+  argc++;
 
 #if defined(DEBUG_HTML)
   write_file_html();
@@ -1327,7 +1355,7 @@
               || (strcmp(argv[i], "-?") == 0)) {
       usage(stdout);
       exit(0);
-    } else if (strcmp(argv[i], troff_command) == 0) {
+    } else if (strcmp(argv[i], TROFF_COMMAND) == 0) {
       /* remember troff argument number */
       troff_arg = i;
 #if defined(DEBUGGING)
@@ -1391,25 +1419,6 @@
 #endif
 }
 
-/*
- *  findPrefix - finds the optional prefix to the groff utilities.
- *               It also builds the 'troff' executable name.
- */
-
-static void findPrefix (void)
-{
-  command_prefix = getenv("GROFF_COMMAND_PREFIX");
-  if (!command_prefix)
-    command_prefix = PROG_PREFIX;
-  troff_command = (char *)malloc(strlen("troff")+strlen(command_prefix)+1);
-  if (troff_command == NULL)
-    sys_fatal("malloc");
-
-  strcpy(troff_command, command_prefix);
-  strcat(troff_command, "troff");
-}
-
-
 int main(int argc, char **argv)
 {
   program_name = argv[0];
@@ -1417,7 +1426,6 @@
   int found=0;
   int ok=1;
 
-  findPrefix();
   i = scanArguments(argc, argv);
   checkImageDir();
   makeFileName();
--- groff-cvs/src/roff/groff/groff.cc   Fri Apr 20 14:35:05 2001
+++ groff-html/src/roff/groff/groff.cc  Mon Jul 16 14:44:55 2001
@@ -281,7 +281,7 @@
   if (!postdriver)
     fatal("no `postpro' command in DESC file for device `%1'", device);
 
-  if (predriver) {
+  if (predriver && (! zflag)) {
     commands[TROFF_INDEX].insert_arg(commands[TROFF_INDEX].get_name());
     const char *p = Pargs.contents();
     const char *end = p + Pargs.length();

reply via email to

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