[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp doc/language.texi src/data/ChangeLog src/d...
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp doc/language.texi src/data/ChangeLog src/d... |
Date: |
Mon, 30 Jul 2007 17:07:50 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Changes by: Ben Pfaff <blp> 07/07/30 17:07:50
Modified files:
doc : language.texi
src/data : ChangeLog file-name.c por-file-reader.c
Log message:
Provisional fix for bug #18692 and bug #20161. Reviewed by John
Darrington.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/doc/language.texi?cvsroot=pspp&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/ChangeLog?cvsroot=pspp&r1=1.146&r2=1.147
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/file-name.c?cvsroot=pspp&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/pspp/src/data/por-file-reader.c?cvsroot=pspp&r1=1.21&r2=1.22
Patches:
Index: doc/language.texi
===================================================================
RCS file: /cvsroot/pspp/pspp/doc/language.texi,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- doc/language.texi 6 Jun 2007 05:17:48 -0000 1.11
+++ doc/language.texi 30 Jul 2007 17:07:50 -0000 1.12
@@ -1331,6 +1331,14 @@
name of a file as a string, that is, enclosed within @samp{'} or
@samp{"}.
+A file name string that begins or ends with @samp{|} is treated as the
+name of a command to pipe data to or from. You can use this feature
+to read data over the network using a program such as @samp{curl}
+(e.g.@: @code{GET '|curl -s -S http://example.com/mydata.sav'}), to
+read compressed data from a file using a program such as @samp{zcat}
+(e.g.@: @code{GET '|zcat mydata.sav.gz'}), and for many other
+purposes.
+
PSPP also supports declaring named file handles with the @cmd{FILE
HANDLE} command. This command associates an identifier of your choice
(the file handle's name) with a file. Later, the file handle name can
Index: src/data/ChangeLog
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/ChangeLog,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -b -r1.146 -r1.147
--- src/data/ChangeLog 29 Jul 2007 05:40:51 -0000 1.146
+++ src/data/ChangeLog 30 Jul 2007 17:07:50 -0000 1.147
@@ -1,3 +1,19 @@
+2007-07-29 Ben Pfaff <address@hidden>
+
+ Provisional fix for bug #18692 and bug #20161. Reviewed by John
+ Darrington.
+
+ * file-name.c (fn_open): Only pass "r" or "w" to popen as mode
+ argument (never "rb" or "wb") because SUSv3 says that only those
+ modes are defined, and glibc in fact rejects other modes.
+
+ Open portable files with fn_open so that they can be read from
+ pipes. Fix missing fh_close call to go along with fh_open.
+ Report an error if the file close reports an error.
+ * por-file-reader.c (close_reader): New function.
+ (por_file_casereader_destroy): Use close_reader.
+ (pfm_open_reader): Open file with fn_open.
+
2007-07-28 Ben Pfaff <address@hidden>
Make PSPP able to read all the portable files I could find on the
Index: src/data/file-name.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/file-name.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- src/data/file-name.c 27 Jul 2007 22:58:02 -0000 1.15
+++ src/data/file-name.c 30 Jul 2007 17:07:50 -0000 1.16
@@ -267,7 +267,7 @@
if (get_safer_mode ())
return safety_violation (fn);
- return popen (&fn[1], mode);
+ return popen (&fn[1], mode[0] == 'r' ? "r" : "w");
}
else if (*fn && fn[strlen (fn) - 1] == '|')
{
@@ -281,7 +281,7 @@
memcpy (s, fn, strlen (fn) - 1);
s[strlen (fn) - 1] = 0;
- f = popen (s, mode);
+ f = popen (s, mode[0] == 'r' ? "r" : "w");
local_free (s);
Index: src/data/por-file-reader.c
===================================================================
RCS file: /cvsroot/pspp/pspp/src/data/por-file-reader.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- src/data/por-file-reader.c 29 Jul 2007 05:40:51 -0000 1.21
+++ src/data/por-file-reader.c 30 Jul 2007 17:07:50 -0000 1.22
@@ -30,6 +30,7 @@
#include <data/casereader.h>
#include <data/dictionary.h>
#include <data/file-handle-def.h>
+#include <data/file-name.h>
#include <data/format.h>
#include <data/missing-values.h>
#include <data/value-labels.h>
@@ -136,12 +137,42 @@
msg_emit (&m);
}
+/* Close and destroy R.
+ Returns false if an error was detected on R, true otherwise. */
+static bool
+close_reader (struct pfm_reader *r)
+{
+ bool ok;
+ if (r == NULL)
+ return true;
+
+ if (r->file)
+ {
+ if (fn_close (fh_get_file_name (r->fh), r->file) == EOF)
+ {
+ msg (ME, _("Error closing portable file \"%s\": %s."),
+ fh_get_file_name (r->fh), strerror (errno));
+ r->ok = false;
+ }
+ r->file = NULL;
+ }
+
+ if (r->fh != NULL)
+ fh_close (r->fh, "portable file", "rs");
+
+ ok = r->ok;
+ pool_destroy (r->pool);
+
+ return ok;
+}
+
/* Closes portable file reader R, after we're done with it. */
static void
-por_file_casereader_destroy (struct casereader *reader UNUSED, void *r_)
+por_file_casereader_destroy (struct casereader *reader, void *r_)
{
struct pfm_reader *r = r_;
- pool_destroy (r->pool);
+ if (!close_reader (r))
+ casereader_force_error (reader);
}
/* Read a single character into cur_char. */
@@ -217,10 +248,8 @@
pool = pool_create ();
r = pool_alloc (pool, sizeof *r);
r->pool = pool;
- if (setjmp (r->bail_out))
- goto error;
r->fh = fh;
- r->file = pool_fopen (r->pool, fh_get_file_name (r->fh), "rb");
+ r->file = fn_open (fh_get_file_name (r->fh), "rb");
r->line_length = 0;
r->weight_index = -1;
r->trans = NULL;
@@ -229,7 +258,10 @@
r->value_cnt = 0;
r->ok = true;
- /* Check that file open succeeded, prime reading. */
+ if (setjmp (r->bail_out))
+ goto error;
+
+ /* Check that file open succeeded. */
if (r->file == NULL)
{
msg (ME, _("An error occurred while opening \"%s\" for reading "
@@ -260,7 +292,7 @@
&por_file_casereader_class, r);
error:
- pool_destroy (r->pool);
+ close_reader (r);
dict_destroy (*dict);
*dict = NULL;
return NULL;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp doc/language.texi src/data/ChangeLog src/d...,
Ben Pfaff <=