Added CONFIGUREFLAGS option to Smake.
[pspp-builds.git] / src / casefile.c
index 242fc385c0ca7890e3017d3c239fdf72ebad6f08..f43ec8faa4fb22d7e6a25f2ae536c9521b0a41fa 100644 (file)
@@ -14,8 +14,8 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-   02111-1307, USA. */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+   02110-1301, USA. */
 
 #include <config.h>
 #include "casefile.h"
 #include "case.h"
 #include "error.h"
 #include "misc.h"
+#include "mkfile.h"
 #include "settings.h"
 #include "var.h"
-#include "signal.h"
-
-#ifdef HAVE_VALGRIND_VALGRIND_H
-#include <valgrind/valgrind.h>
-#endif
 
 #define IO_BUF_SIZE (8192 / sizeof (union value))
 
@@ -340,35 +336,6 @@ flush_buffer (struct casefile *cf)
     } 
 }
 
-/* Creates a temporary file and stores its name in *FILENAME and
-   a file descriptor for it in *FD.  Returns success.  Caller is
-   responsible for freeing *FILENAME. */
-static int
-make_temp_file (int *fd, char **filename)
-{
-  const char *parent_dir;
-
-  assert (filename != NULL);
-  assert (fd != NULL);
-
-  if (getenv ("TMPDIR") != NULL)
-    parent_dir = getenv ("TMPDIR");
-  else
-    parent_dir = P_tmpdir;
-
-  *filename = xmalloc (strlen (parent_dir) + 32);
-  sprintf (*filename, "%s%cpsppXXXXXX", parent_dir, DIR_SEPARATOR);
-  *fd = mkstemp (*filename);
-  if (*fd < 0)
-    {
-      msg (FE, _("%s: Creating temporary file: %s."),
-           *filename, strerror (errno));
-      free (*filename);
-      *filename = NULL;
-      return 0;
-    }
-  return 1;
-}
 
 /* If CF is currently stored in memory, writes it to disk.  Readers, if any,
    retain their current positions. */
@@ -564,7 +531,8 @@ casereader_get_casefile (const struct casereader *reader)
 }
 
 /* Reads a copy of the next case from READER into C.
-   Caller is responsible for destroying C. */
+   Caller is responsible for destroying C.
+   Returns true if successful, false at end of file. */
 int
 casereader_read (struct casereader *reader, struct ccase *c) 
 {
@@ -601,7 +569,8 @@ casereader_read (struct casereader *reader, struct ccase *c)
 }
 
 /* Reads the next case from READER into C and transfers ownership
-   to the caller.  Caller is responsible for destroying C. */
+   to the caller.  Caller is responsible for destroying C.
+   Returns true if successful, false at end of file. */
 int
 casereader_read_xfer (struct casereader *reader, struct ccase *c)
 {
@@ -623,6 +592,16 @@ casereader_read_xfer (struct casereader *reader, struct ccase *c)
     }
 }
 
+/* Reads the next case from READER into C and transfers ownership
+   to the caller.  Caller is responsible for destroying C.
+   Assert-fails at end of file. */
+void
+casereader_read_xfer_assert (struct casereader *reader, struct ccase *c) 
+{
+  bool success = casereader_read_xfer (reader, c);
+  assert (success);
+}
+
 /* Destroys READER. */
 void
 casereader_destroy (struct casereader *reader)
@@ -727,6 +706,7 @@ full_write (int fd, const void *buffer_, size_t size)
   return bytes_written;
 }
 
+
 /* Registers our exit handler with atexit() if it has not already
    been registered. */
 static void
@@ -736,12 +716,12 @@ register_atexit (void)
   if (!registered) 
     {
       registered = 1;
-      signal (SIGQUIT, (sighandler_t) exit_handler);
-      signal (SIGINT,  (sighandler_t) exit_handler);
       atexit (exit_handler);
     }
 }
 
+
+
 /* atexit() handler that closes and deletes our temporary
    files. */
 static void