tgrap: fclose, error context bug fixes (Doug Gwyn) - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c5a183de108e5685305734d5cf984b58bb0d614a
 (DIR) parent 151b86a03703255445a2165f714e914032f6c4a8
 (HTM) Author: Russ Cox <rsc@swtch.com>
       Date:   Mon, 29 Oct 2007 10:34:43 -0400
       
       grap: fclose, error context bug fixes (Doug Gwyn)
       
       Diffstat:
         M src/cmd/grap/input.c                |       2 +-
         M src/cmd/grap/print.c                |       5 +++--
       
       2 files changed, 4 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/src/cmd/grap/input.c b/src/cmd/grap/input.c
       t@@ -460,7 +460,7 @@ void eprint(void)        /* try to print context around error */
                        if (isprint((uchar)*p))
                                putc(*p, stderr);
                fprintf(stderr, " >>> ");
       -        for (; p < q; p++)
       +        for (; p < ep; p++)
                        if (isprint((uchar)*p))
                                putc(*p, stderr);
                fprintf(stderr, " <<< ");
 (DIR) diff --git a/src/cmd/grap/print.c b/src/cmd/grap/print.c
       t@@ -23,8 +23,9 @@ void print(void)        /* arrange final output */
                int c;
                double dx, dy, xfac, yfac;
        
       -        if (tfd != NULL) {
       -                fclose(tfd);        /* end the temp file */
       +        if (tfd != stdout) {
       +                if (tfd)
       +                        fclose(tfd);        /* end the temp file */
                        tfd = stdout;
                }