gv patch

View: New views
3 Messages — Rating Filter:   Alert me  

gv patch

by Andrew.Hamilton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I would love to see the attached patch integrated into gv.

The main purpose of the patch is to fix gv when input comes from stdin,
such as
cat <file1.ps> <file2.ps> | gv -

However, the patch also fixes several bugs that have crept into gv
over the years (I have been patching my local version of gv for
more than a decade).

Bug fixes:

1. A few years back gv was updated to use the standard gnu getopt.
This is fine, but the update overrode getopt's built-in option counter,
with an
opt_counter++
for each option.  This is not only bad programming practice, but breaks
getopt's built-in behaviour in some circumstances, such as when
there are multiple arguments.

2. Broken --arguments fixed.
   Broken --safer fixed.

3. The - argument, indicating input from stdin, which has been broken
for many years, is fixed.   Indeed, it has been broken for so long
that the man page no longer documents it.  However, the - argument
is implemented in gv, and should not be allowed to disappear for
lack of attention.

Andrew Hamilton



gv-3.6.6-interpret.patch (18K) Download Attachment

Re: gv patch

by Markus Steinborn-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andrew.Hamilton@... wrote:
> I would love to see the attached patch integrated into gv.
>  

Hi Andrew,

thanks for sending us your patch. I am testing it. If it works as
expected, I'll include it in the next release of GNU gv.


Greetings from Germany

Markus Steinborn





gv patch

by Andrew.Hamilton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Markus,

> thanks for sending us your patch. I am testing it. If it works as
> expected, I'll include it in the next release of GNU gv.

Thanks.  Warning: you will find that a PostScript file <file.ps>
containing Document Structuring Conventions (DSC) will NOT work in
cat <file.ps> | gv -
Currently only vanilla PostScript files work (e.g. a single PostScript graphic).

The reason for the failure is a bug in gs, the fix for which is
documented in the patch file:
+    if (gvw->ghostview.filename && !strcmp(gvw->ghostview.filename,"-")) {
+       /* The ghostscript documentation states that the "-" argument
+         tells gs that input is coming from a pipe rather than from stdin.
+         One of the side effects of the "-" argument is that gs does not
+         flush output at each line of input, but rather accumulates input
+         and flushes only when the buffer is full.  Since we want gs to
+         flush output at each line of input, we therefore cannot send "-".
+         Unfortunately not sending "-" has the side effect that gs no
+         longer reads correctly through either multiple PostScript files
+         or PostScript files with multiple pages.  Ah well.
+         Should gs ever acquire a -DFLUSH argument, then send gs that argument,
+         and uncomment the following line.  */
+       /* argv[argc++] = "-"; */

So please don't reject the patch just because it fails in this case.
The problem is not with gv or the patch, but rather with gs.

Thanks, Andrew