|
From: Ethan M. <merritt@u.washington.edu> - 2006-03-04 00:04:30
|
On Friday 03 March 2006 10:29 am, Ethan Merritt wrote:
> On Friday 03 March 2006 10:05 am, Petr Mikulik wrote:
> >
> > gnuplot> plot 'a.dat', 'bla'
> > ^
> > can't read data file "bla"
> > util.c: No such file or directory
Here's a simple patch to fix this.
It is directly parallel to the recently added test that skips
files containing no data points.
Please try it and comment.
I already know that it emits an extraneous error message
for a couple of special cases (e.g. after 'set xdata time'),
and that it doesn't handle missing files passed to "fit".
I think the 2D case is probably solid. I have not tested all
possible 3D plot modes, so it is possible that some additional
checks need to be added there.
Ethan
--- gnuplot/src/datafile.c 2006-01-27 08:36:48.000000000 -0800
+++ gnuplot-cvs/src/datafile.c 2006-03-03 15:19:13.000000000 -0800
@@ -1275,7 +1275,9 @@
if ((data_fp = loadpath_fopen(df_filename, df_binary ? "rb" : "r")) ==
#endif
(FILE *) NULL) {
- os_error(name_token, "can't read data file \"%s\"", df_filename);
+ /* os_error(name_token, "can't read data file \"%s\"", df_filename); */
+ int_warn(name_token, "Skipping unreadable file \"%s\"", df_filename);
+ return -1;
}
}
/*}}} */
--- gnuplot/src/plot2d.c 2005-11-28 11:02:56.000000000 -0800
+++ gnuplot-cvs/src/plot2d.c 2006-03-03 15:33:24.000000000 -0800
@@ -1787,6 +1787,11 @@
++line_num;
}
if (this_plot->plot_type == DATA) {
+ if (specs < 0) {
+ /* Error check to handle missing or unreadable file */
+ this_plot->plot_type = NODATA;
+ goto SKIPPED_EMPTY_FILE;
+ }
/* actually get the data now */
if (get_data(this_plot) == 0) {
/* EAM 2005 - warn, but keep going */
--- gnuplot/src/plot3d.c 2006-01-12 11:55:14.000000000 -0800
+++ gnuplot-cvs/src/plot3d.c 2006-03-03 15:32:54.000000000 -0800
@@ -1560,6 +1560,9 @@
struct surface_points *first_dataset = this_plot;
/* pointer to the plot of the first dataset (surface) in the file */
int this_token = this_plot->token;
+ /* Error check to handle unreadable or missing data file */
+ if (specs < 0)
+ df_eof = 1;
while (!df_eof) {
this_plot = *tp_3d_ptr;
assert(this_plot != NULL);
--
Ethan A Merritt
Biomolecular Structure Center
University of Washington, Seattle WA
|