groff
[Top][All Lists]
Advanced

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

Re: [Groff] Announcing 1.18


From: Colin Watson
Subject: Re: [Groff] Announcing 1.18
Date: Sun, 21 Jul 2002 18:52:08 +0100
User-agent: Mutt/1.3.28i

On Sun, Jul 21, 2002 at 04:49:41PM +0100, Colin Watson wrote:
> What do you think about extending the papersize DESC keyword to accept
> "papersize /etc/papersize a4" for this kind of thing? Sorry I didn't
> think about this earlier.

Here is one possible patch. It should be backward-compatible.

--- groff-1.18.orig/src/libs/libgroff/font.cc
+++ groff-1.18/src/libs/libgroff/font.cc
@@ -985,15 +985,21 @@
        t.error("papersize command requires an argument");
        return 0;
       }
-      double unscaled_paperwidth, unscaled_paperlength;
-      if (!scan_papersize(p, &papersize, &unscaled_paperlength,
-                         &unscaled_paperwidth)) {
+      int found_paper = 0;
+      while (p) {
+       double unscaled_paperwidth, unscaled_paperlength;
+       if (scan_papersize(p, &papersize, &unscaled_paperlength,
+                          &unscaled_paperwidth)) {
+         paperwidth = int(unscaled_paperwidth * res + 0.5);
+         paperlength = int(unscaled_paperlength * res + 0.5);
+         found_paper = 1;
+         break;
+       }
+       p = strtok(0, WS);
+      }
+      if (!found_paper) {
        t.error("bad paper size");
        return 0;
-      }
-      else {
-       paperwidth = int(unscaled_paperwidth * res + 0.5);
-       paperlength = int(unscaled_paperlength * res + 0.5);
       }
     }
     else if (strcmp("pass_filenames", p) == 0)
--- groff-1.18.orig/src/preproc/html/pre-html.cc
+++ groff-1.18/src/preproc/html/pre-html.cc
@@ -238,12 +238,13 @@
       char *p = linebuf + 9;
       while (*p == ' ' || *p == '\t')
        p++;
-      if (font::scan_papersize(p, 0, &length, 0)) {
-       fclose(f);
-       return int(length * postscriptRes + 0.5);
+      for (p = strtok(p, " \t"); p; p = strtok(0, " \t")) {
+       if (font::scan_papersize(p, 0, &length, 0)) {
+         fclose(f);
+         return int(length * postscriptRes + 0.5);
+       }
       }
-      else
-       fatal("bad argument to `papersize' keyword in devps/DESC");
+      fatal("bad argument to `papersize' keyword in devps/DESC");
     }
   }
   fatal("can't find `papersize' or `paperlength' keyword in devps/DESC");

Also, I noticed that font::scan_papersize() currently fails if a
papersize file ends with a newline. Here is a patch to correct that.

--- groff-1.18.orig/src/libs/libgroff/font.cc
+++ groff-1.18/src/libs/libgroff/font.cc
@@ -554,7 +554,7 @@
        fgets(line, 254, f);
        fclose(f);
        test_file = 0;
-       char *linep = line;
+       char *linep = strchr(line, '\0');
        // skip final newline, if any
        if (*(--linep) == '\n')
          *linep = '\0';

Cheers,

-- 
Colin Watson                                  address@hidden

reply via email to

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