[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src/output ascii.c chart.c html.c postscri...
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp/src/output ascii.c chart.c html.c postscri... |
Date: |
Fri, 21 Sep 2007 14:12:57 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Ben Pfaff <blp> 07/09/21 14:12:57
Modified files:
src/output : ascii.c chart.c html.c postscript.c
Log message:
* ascii.c (struct ascii_driver_ext): New member reported_error.
(ascii_open_driver): Initialize reported_error.
(ascii_open_page): Initialize the rest of the ascii driver data
even if we fail to open the output file. Fixes bug #21117.
* chart.c (chart_create): Initialize lp member. Fixes crash if
chart initialization fails.
* html.c (html_open_driver): Don't free chart_file_name in error
case, since html_close_driver will do that. Fixes crash if file
open fails.
* postscript.c (ps_close_driver): Don't try to write to file if
it's null. Fixes crash if file open fails.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/ascii.c?cvsroot=pspp&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/chart.c?cvsroot=pspp&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/html.c?cvsroot=pspp&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/pspp/src/output/postscript.c?cvsroot=pspp&r1=1.29&r2=1.30
Patches:
Index: ascii.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/ascii.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- ascii.c 16 Aug 2007 06:30:23 -0000 1.18
+++ ascii.c 21 Sep 2007 14:12:57 -0000 1.19
@@ -120,6 +120,7 @@
/* Internal state. */
char *file_name; /* Output file name. */
FILE *file; /* Output file. */
+ bool reported_error; /* Reported file open error? */
int page_number; /* Current page number. */
struct line *lines; /* Page content. */
int line_cap; /* Number of lines allocated. */
@@ -161,6 +162,7 @@
x->init = NULL;
x->file_name = pool_strdup (x->pool, "pspp.list");
x->file = NULL;
+ x->reported_error = false;
x->page_number = 0;
x->lines = NULL;
x->line_cap = 0;
@@ -449,17 +451,26 @@
if (x->file == NULL)
{
x->file = fn_open (x->file_name, x->append ? "a" : "w");
- if (x->file == NULL)
+ if (x->file != NULL)
{
- error (0, errno, _("ascii: opening output file \"%s\""),
- x->file_name);
- return;
- }
pool_attach_file (x->pool, x->file);
-
if (x->init != NULL)
fputs (x->init, x->file);
}
+ else
+ {
+ /* Report the error to the user and complete
+ initialization. If we do not finish initialization,
+ then calls to other driver functions will segfault
+ later. It would be better to simply drop the driver
+ entirely, but we do not have a convenient mechanism
+ for this (yet). */
+ if (!x->reported_error)
+ error (0, errno, _("ascii: opening output file \"%s\""),
+ x->file_name);
+ x->reported_error = true;
+ }
+ }
x->page_number++;
Index: chart.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/chart.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- chart.c 13 Aug 2007 00:26:32 -0000 1.6
+++ chart.c 21 Sep 2007 14:12:57 -0000 1.7
@@ -52,6 +52,7 @@
return NULL;
chart = xmalloc (sizeof *chart);
+ chart->lp = NULL;
d->class->initialise_chart(d, chart);
if (!chart->lp)
{
Index: html.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/html.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- html.c 8 Sep 2007 01:00:40 -0000 1.24
+++ html.c 21 Sep 2007 14:12:57 -0000 1.25
@@ -91,7 +91,6 @@
return true;
error:
- free (x->chart_file_name);
this->class->close_driver (this);
return false;
}
Index: postscript.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/output/postscript.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- postscript.c 8 Sep 2007 01:00:40 -0000 1.29
+++ postscript.c 21 Sep 2007 14:12:57 -0000 1.30
@@ -230,9 +230,11 @@
ps_close_driver (struct outp_driver *this)
{
struct ps_driver_ext *x = this->ext;
- bool ok;
+ bool ok = true;
size_t i;
+ if (x->file != NULL)
+ {
fprintf (x->file,
"%%%%Trailer\n"
"%%%%Pages: %d\n"
@@ -241,7 +243,10 @@
ok = fn_close (x->file_name, x->file) == 0;
if (!ok)
- error (0, errno, _("closing PostScript output file \"%s\""), x->file_name);
+ error (0, errno, _("closing PostScript output file \"%s\""),
+ x->file_name);
+ }
+
free (x->file_name);
for (i = 0; i < OUTP_FONT_CNT; i++)
free_font (x->fonts[i]);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/src/output ascii.c chart.c html.c postscri...,
Ben Pfaff <=