Made BSD diff compatible
[pspp] / src / casefile.c
index f7d171f766be4402fdd9a104b8ca827ae7b59023..9c3da66023384390cf3018d61a202abee95d851c 100644 (file)
 #include "alloc.h"
 #include "case.h"
 #include "error.h"
+#include "full-read.h"
+#include "full-write.h"
 #include "misc.h"
 #include "mkfile.h"
 #include "settings.h"
 #include "var.h"
 
+#include "gettext.h"
+#define _(msgid) gettext (msgid)
+
 #define IO_BUF_SIZE (8192 / sizeof (union value))
 
 /* A casefile represents a sequentially accessible stream of
           independent position in the casefile.
 
           Casereaders may only move forward.  They cannot move
-          backward to arbitrary records or seek randomly.  (In the
-          future, the concept of a "casemark" will be introduced
-          to allow a limited form of backward seek, but this has
-          not yet been implemented.)
-
-          Cloning casereaders is possible, but no one has had a
-          need for it yet, so it is not implemented.
+          backward to arbitrary records or seek randomly.
+          Cloning casereaders is possible, but it is not yet
+          implemented.
 
           Use casefile_get_reader() to create a casereader for
-          use in phase 2.  This also transitions from phase 2 to
-          phase 3.  Calling casefile_mode_reader() makes the same
+          use in phase 2.  This also transitions from phase 1 to
+          phase 2.  Calling casefile_mode_reader() makes the same
           transition, without creating a casereader.
 
           Use casereader_read(), casereader_read_xfer(), or
@@ -83,9 +84,8 @@
           also read with casereaders in this phase, but the
           ability to create new casereaders is curtailed.
 
-          In this phase, casereaders could still be cloned, and
-          casemarks could still be used to seek backward (given
-          that we eventually implement these functionalities).
+          In this phase, casereaders could still be cloned (once
+          we eventually implement cloning).
 
           To transition from phase 1 or 2 to phase 3 and create a
           casereader, call casefile_get_destructive_reader().
@@ -96,8 +96,8 @@
           more casereaders may be created with
           casefile_get_reader() or
           casefile_get_destructive_reader().  (If cloning of
-          casereaders or casemarks were implemented, they would
-          still be possible.)
+          casereaders were implemented, it would still be
+          possible.)
 
           The purpose of the limitations applied to casereaders
           in phase 3 is to allow in-memory casefiles to fully
@@ -178,8 +178,6 @@ static void fill_buffer (struct casereader *reader);
 
 static int safe_open (const char *filename, int flags);
 static int safe_close (int fd);
-static int full_read (int fd, void *buffer, size_t size);
-static int full_write (int fd, const void *buffer, size_t size);
 
 /* Creates and returns a casefile to store cases of VALUE_CNT
    `union value's each. */
@@ -732,49 +730,6 @@ static int safe_close (int fd)
   return retval;
 }
 
-/* Calls read(), passing FD, BUFFER, and SIZE, repeating as
-   necessary to deal with interrupted calls. */
-static int
-full_read (int fd, void *buffer_, size_t size) 
-{
-  char *buffer = buffer_;
-  size_t bytes_read = 0;
-  
-  while (bytes_read < size)
-    {
-      int retval = read (fd, buffer + bytes_read, size - bytes_read);
-      if (retval > 0) 
-        bytes_read += retval; 
-      else if (retval == 0) 
-        return bytes_read;
-      else if (errno != EINTR)
-        return -1;
-    }
-
-  return bytes_read;
-}
-
-/* Calls write(), passing FD, BUFFER, and SIZE, repeating as
-   necessary to deal with interrupted calls. */
-static int
-full_write (int fd, const void *buffer_, size_t size) 
-{
-  const char *buffer = buffer_;
-  size_t bytes_written = 0;
-  
-  while (bytes_written < size)
-    {
-      int retval = write (fd, buffer + bytes_written, size - bytes_written);
-      if (retval >= 0) 
-        bytes_written += retval; 
-      else if (errno != EINTR)
-        return -1;
-    }
-
-  return bytes_written;
-}
-
-
 /* Registers our exit handler with atexit() if it has not already
    been registered. */
 static void