[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src ChangeLog data-list.c dfm-read.c dfm-w...
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp/src ChangeLog data-list.c dfm-read.c dfm-w... |
Date: |
Thu, 12 Jan 2006 03:39:02 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Branch:
Changes by: Ben Pfaff <address@hidden> 06/01/12 03:39:02
Modified files:
src : ChangeLog data-list.c dfm-read.c dfm-write.c
file-handle-def.c file-handle-def.h
file-handle.h file-handle.q get.c main.c
pfm-read.c pfm-write.c print.c regression.q
sfm-read.c sfm-write.c sysfile-info.c
Log message:
Clean up file handle code in preparation to add temporary file
handles.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/ChangeLog.diff?tr1=1.258&tr2=1.259&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data-list.c.diff?tr1=1.43&tr2=1.44&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/dfm-read.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/dfm-write.c.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/file-handle-def.c.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/file-handle-def.h.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/file-handle.h.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/file-handle.q.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/get.c.diff?tr1=1.41&tr2=1.42&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/main.c.diff?tr1=1.21&tr2=1.22&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/pfm-read.c.diff?tr1=1.29&tr2=1.30&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/pfm-write.c.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/print.c.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/regression.q.diff?tr1=1.35&tr2=1.36&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/sfm-read.c.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/sfm-write.c.diff?tr1=1.22&tr2=1.23&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/sysfile-info.c.diff?tr1=1.19&tr2=1.20&r1=text&r2=text
Patches:
Index: pspp/src/ChangeLog
diff -u pspp/src/ChangeLog:1.258 pspp/src/ChangeLog:1.259
--- pspp/src/ChangeLog:1.258 Mon Jan 9 01:13:26 2006
+++ pspp/src/ChangeLog Thu Jan 12 03:39:01 2006
@@ -1,3 +1,42 @@
+Wed Jan 11 19:28:39 2006 Ben Pfaff <address@hidden>
+
+ Clean up file handle code in preparation to add temporary file
+ handles.
+
+ * file-handle-def.c: Lots of formatting cleanup. Added function
+ comments.
+ (struct file_handle) Renamed `length' member
+ to `record_width'. All references updated.
+ (fh_init) New function. Moved here from file-handle.q.
+ (fh_done) New function. Moved here from file-handle.q and
+ rewrote.
+ (get_handle_with_name) Renamed fh_from_name().
+ (get_handle_for_filename) Renamed fh_from_filename().
+ (create_file_handle) Renamed fh_create(). Changed to take a
+ `struct fh_properties' instead of discrete values. Updated all
+ references.
+ (create_file_handle_with_defaults) Removed. Updated all
+ references to use fh_create() with fh_default_properties().
+ (fh_default_properties) New function.
+ (destroy_file_handle) Removed. The code is now in fh_done().
+ (handle_get_name) Renamed fh_get_name().
+ (handle_get_filename) Renamed fh_get_filename().
+ (handle_get_record_width) Renamed fh_get_record_width().
+ (handle_get_tab_width) Renamed fh_get_tab_width().
+
+ * file-handle-def.h: Formatting, comment fixes.
+ (enum file_handle_mode) Renamed struct fh_mode.
+ (struct fh_properties) New structure.
+ (fh_init) Move prototype here from file-handle.h.
+ (fh_done) Ditto.
+ (fh_close) Ditto.
+
+ * file-handle.q: (static var handle_list) Removed.
+ (fh_parse) Don't add handle to handle_list, because
+ file-handle-def.c has its own list.
+ (fh_init) Moved to file-handle-def.c.
+ (fh_done) Ditto.
+
Sun Jan 9 01:09 Jason Stover <address@hidden>
* regression.q: (run_regression) Moved coefficient initialization
Index: pspp/src/data-list.c
diff -u pspp/src/data-list.c:1.43 pspp/src/data-list.c:1.44
--- pspp/src/data-list.c:1.43 Sun Dec 11 02:48:45 2005
+++ pspp/src/data-list.c Thu Jan 12 03:39:01 2006
@@ -798,7 +798,7 @@
if (fh != NULL)
tab_title (t, 1, ngettext ("Reading %d record from file %s.",
"Reading %d records from file %s.", rec_cnt),
- rec_cnt, handle_get_filename (fh));
+ rec_cnt, fh_get_filename (fh));
else
tab_title (t, 1, ngettext ("Reading %d record from the command file.",
"Reading %d records from the command file.",
@@ -919,7 +919,7 @@
if (fh != NULL)
tab_title (t, 1, _("Reading free-form data from file %s."),
- handle_get_filename (fh));
+ fh_get_filename (fh));
else
tab_title (t, 1, _("Reading free-form data from the command file."));
@@ -1585,7 +1585,7 @@
/* Calculate and check starts_end, cont_end if necessary. */
if (rpd->starts_end.num == 0 && rpd->starts_end.var == NULL)
{
- rpd->starts_end.num = fh != NULL ? handle_get_record_width (fh) : 80;
+ rpd->starts_end.num = fh != NULL ? fh_get_record_width (fh) : 80;
if (rpd->starts_beg.num != 0
&& rpd->starts_beg.num > rpd->starts_end.num)
{
@@ -1598,7 +1598,7 @@
}
if (rpd->cont_end.num == 0 && rpd->cont_end.var == NULL)
{
- rpd->cont_end.num = fh != NULL ? handle_get_record_width (fh) : 80;
+ rpd->cont_end.num = fh != NULL ? fh_get_record_width (fh) : 80;
if (rpd->cont_beg.num != 0
&& rpd->cont_beg.num > rpd->cont_end.num)
{
Index: pspp/src/dfm-read.c
diff -u pspp/src/dfm-read.c:1.8 pspp/src/dfm-read.c:1.9
--- pspp/src/dfm-read.c:1.8 Thu Nov 3 06:21:46 2005
+++ pspp/src/dfm-read.c Thu Jan 12 03:39:01 2006
@@ -136,7 +136,7 @@
r->fh = fh;
if (fh != NULL)
{
- r->where.filename = handle_get_filename (fh);
+ r->where.filename = fh_get_filename (fh);
r->where.line_number = 0;
}
r->file.file = NULL;
@@ -146,7 +146,7 @@
if (fh != NULL)
{
- r->file.filename = xstrdup (handle_get_filename (r->fh));
+ r->file.filename = xstrdup (fh_get_filename (r->fh));
r->file.mode = "rb";
r->file.file = NULL;
r->file.sequence_no = NULL;
@@ -157,7 +157,7 @@
{
msg (ME, _("Could not open \"%s\" for reading "
"as a data file: %s."),
- handle_get_filename (r->fh), strerror (errno));
+ fh_get_filename (r->fh), strerror (errno));
err_cond_fail ();
fh_close (fh,"data file", "rs");
free (r);
@@ -241,7 +241,7 @@
read_file_record (struct dfm_reader *r)
{
assert (r->fh != NULL);
- if (handle_get_mode (r->fh) == MODE_TEXT)
+ if (fh_get_mode (r->fh) == MODE_TEXT)
{
ds_clear (&r->line);
if (!ds_gets (&r->line, r->file.file))
@@ -249,15 +249,15 @@
if (ferror (r->file.file))
{
msg (ME, _("Error reading file %s: %s."),
- handle_get_name (r->fh), strerror (errno));
+ fh_get_name (r->fh), strerror (errno));
err_cond_fail ();
}
return 0;
}
}
- else if (handle_get_mode (r->fh) == MODE_BINARY)
+ else if (fh_get_mode (r->fh) == MODE_BINARY)
{
- size_t record_width = handle_get_record_width (r->fh);
+ size_t record_width = fh_get_record_width (r->fh);
size_t amt;
if (ds_length (&r->line) < record_width)
@@ -269,10 +269,10 @@
{
if (ferror (r->file.file))
msg (ME, _("Error reading file %s: %s."),
- handle_get_name (r->fh), strerror (errno));
+ fh_get_name (r->fh), strerror (errno));
else if (amt != 0)
msg (ME, _("%s: Partial record at end of file."),
- handle_get_name (r->fh));
+ fh_get_name (r->fh));
else
return 0;
@@ -315,7 +315,7 @@
{
if (r->fh != NULL)
msg (SE, _("Attempt to read beyond end-of-file on file %s."),
- handle_get_name (r->fh));
+ fh_get_name (r->fh));
else
msg (SE, _("Attempt to read beyond END DATA."));
err_cond_fail ();
@@ -360,14 +360,14 @@
r->flags |= DFM_TABS_EXPANDED;
if (r->fh != NULL
- && (handle_get_mode (r->fh) == MODE_BINARY
- || handle_get_tab_width (r->fh) == 0
+ && (fh_get_mode (r->fh) == MODE_BINARY
+ || fh_get_tab_width (r->fh) == 0
|| memchr (ds_c_str (&r->line), '\t', ds_length (&r->line)) == NULL))
return;
/* Expand tabs from r->line into r->scratch, and figure out
new value for r->pos. */
- tab_width = r->fh != NULL ? handle_get_tab_width (r->fh) : 8;
+ tab_width = r->fh != NULL ? fh_get_tab_width (r->fh) : 8;
ds_clear (&r->scratch);
new_pos = 0;
for (ofs = 0; ofs < ds_length (&r->line); ofs++)
Index: pspp/src/dfm-write.c
diff -u pspp/src/dfm-write.c:1.3 pspp/src/dfm-write.c:1.4
--- pspp/src/dfm-write.c:1.3 Sun Jul 31 21:42:46 2005
+++ pspp/src/dfm-write.c Thu Jan 12 03:39:01 2006
@@ -57,7 +57,7 @@
w->file.file = NULL;
w->bounce = NULL;
- w->file.filename = xstrdup (handle_get_filename (w->fh));
+ w->file.filename = xstrdup (fh_get_filename (w->fh));
w->file.mode = "wb";
w->file.file = NULL;
w->file.sequence_no = NULL;
@@ -69,7 +69,7 @@
{
msg (ME, _("An error occurred while opening \"%s\" for writing "
"as a data file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (w->fh), strerror (errno));
goto error;
}
@@ -89,10 +89,10 @@
{
assert (w != NULL);
- if (handle_get_mode (w->fh) == MODE_BINARY
- && len < handle_get_record_width (w->fh))
+ if (fh_get_mode (w->fh) == MODE_BINARY
+ && len < fh_get_record_width (w->fh))
{
- size_t rec_width = handle_get_record_width (w->fh);
+ size_t rec_width = fh_get_record_width (w->fh);
if (w->bounce == NULL)
w->bounce = xmalloc (rec_width);
memcpy (w->bounce, rec, len);
@@ -104,7 +104,7 @@
if (fwrite (rec, len, 1, w->file.file) != 1)
{
msg (ME, _("Error writing file %s: %s."),
- handle_get_name (w->fh), strerror (errno));
+ fh_get_name (w->fh), strerror (errno));
err_cond_fail ();
return 0;
}
Index: pspp/src/file-handle-def.c
diff -u pspp/src/file-handle-def.c:1.2 pspp/src/file-handle-def.c:1.3
--- pspp/src/file-handle-def.c:1.2 Thu Nov 3 06:21:46 2005
+++ pspp/src/file-handle-def.c Thu Jan 12 03:39:01 2006
@@ -47,8 +47,8 @@
char *filename; /* Filename as provided by user. */
struct file_identity *identity; /* For checking file identity. */
struct file_locator where; /* Used for reporting error messages. */
- enum file_handle_mode mode; /* File mode. */
- size_t length; /* Length of fixed-format records. */
+ enum fh_mode mode; /* File mode. */
+ size_t record_width; /* Length of fixed-format records. */
size_t tab_width; /* Tab width, 0=do not expand tabs. */
int open_cnt; /* 0=not open, otherwise # of openers. */
@@ -57,12 +57,36 @@
void *aux; /* Aux data pointer for owner if any. */
};
-
static struct file_handle *file_handles;
+/* File handle initialization routine. */
+void
+fh_init (void)
+{
+ /* Currently nothing to do. */
+}
+
+/* Frees all the file handles. */
+void
+fh_done (void)
+{
+ struct file_handle *fh, *next;
+
+ for (fh = file_handles; fh != NULL; fh = next)
+ {
+ next = fh->next;
+ free (fh->name);
+ free (fh->filename);
+ fn_free_identity (fh->identity);
+ free (fh);
+ }
+ file_handles = NULL;
+}
+/* Returns the handle named HANDLE_NAME, or a null pointer if
+ there is none. */
struct file_handle *
-get_handle_with_name (const char *handle_name)
+fh_from_name (const char *handle_name)
{
struct file_handle *iter;
@@ -72,8 +96,12 @@
return NULL;
}
+/* Returns the handle for the file named FILENAME,
+ or a null pointer if none exists.
+ Different names for the same file (e.g. "x" and "./x") are
+ considered equivalent. */
struct file_handle *
-get_handle_for_filename (const char *filename)
+fh_from_filename (const char *filename)
{
struct file_identity *identity;
struct file_handle *iter;
@@ -100,27 +128,12 @@
return NULL;
}
-
-/* File handle functions. */
-
-struct file_handle *
-create_file_handle_with_defaults (const char *handle_name,
- const char *filename)
-{
- return create_file_handle (handle_name, filename,
- MODE_TEXT,1024, 4);
-}
-
-
/* Creates and returns a new file handle with the given values
and defaults for other values. Adds the created file handle
to the global list. */
struct file_handle *
-create_file_handle (const char *handle_name, const char *filename,
- enum file_handle_mode mode,
- size_t length,
- size_t tab_width
- )
+fh_create (const char *handle_name, const char *filename,
+ const struct fh_properties *properties)
{
struct file_handle *handle;
@@ -132,9 +145,9 @@
handle->identity = fn_get_identity (filename);
handle->where.filename = handle->filename;
handle->where.line_number = 0;
- handle->mode = mode;
- handle->length = length;
- handle->tab_width = tab_width;
+ handle->mode = properties->mode;
+ handle->record_width = properties->record_width;
+ handle->tab_width = properties->tab_width;
handle->open_cnt = 0;
handle->type = NULL;
handle->aux = NULL;
@@ -143,16 +156,16 @@
return handle;
}
-void
-destroy_file_handle(void *fh_, void *aux UNUSED)
+/* Returns a set of default properties for a file handle. */
+const struct fh_properties *
+fh_default_properties (void)
{
- struct file_handle *fh = fh_;
- free (fh->name);
- free (fh->filename);
- fn_free_identity (fh->identity);
- free (fh);
+ static const struct fh_properties default_properties = {MODE_TEXT, 1024, 4};
+ return &default_properties;
}
+/* Returns an English description of MODE,
+ which is in the format of the MODE argument to fh_open(). */
static const char *
mode_name (const char *mode)
{
@@ -162,7 +175,6 @@
return mode[0] == 'r' ? "reading" : "writing";
}
-
/* Tries to open handle H with the given TYPE and MODE.
TYPE is the sort of file, e.g. "system file". Only one given
@@ -198,21 +210,21 @@
{
msg (SE, _("Can't open %s as a %s because it is "
"already open as a %s"),
- handle_get_name (h), type, h->type);
+ fh_get_name (h), type, h->type);
return NULL;
}
else if (strcmp (h->open_mode, mode))
{
msg (SE, _("Can't open %s as a %s for %s because it is "
"already open for %s"),
- handle_get_name (h), type,
- mode_name (mode), mode_name (h->open_mode));
+ fh_get_name (h), type, mode_name (mode),
+ mode_name (h->open_mode));
return NULL;
}
else if (h->open_mode[1] == 'e')
{
msg (SE, _("Can't re-open %s as a %s for %s"),
- handle_get_name (h), type, mode_name (mode));
+ fh_get_name (h), type, mode_name (mode));
return NULL;
}
}
@@ -250,9 +262,6 @@
return h->open_cnt;
}
-
-
-
/* Returns the identifier of file HANDLE. If HANDLE was created
by referring to a filename instead of a handle name, returns
the filename, enclosed in double quotes. Return value is
@@ -260,7 +269,7 @@
Useful for printing error messages about use of file handles. */
const char *
-handle_get_name (const struct file_handle *handle)
+fh_get_name (const struct file_handle *handle)
{
assert (handle != NULL);
return handle->name;
@@ -268,15 +277,15 @@
/* Returns the name of the file associated with HANDLE. */
const char *
-handle_get_filename (const struct file_handle *handle)
+fh_get_filename (const struct file_handle *handle)
{
assert (handle != NULL);
return handle->filename;
}
/* Returns the mode of HANDLE. */
-enum file_handle_mode
-handle_get_mode (const struct file_handle *handle)
+enum fh_mode
+fh_get_mode (const struct file_handle *handle)
{
assert (handle != NULL);
return handle->mode;
@@ -284,19 +293,18 @@
/* Returns the width of a logical record on HANDLE. */
size_t
-handle_get_record_width (const struct file_handle *handle)
+fh_get_record_width (const struct file_handle *handle)
{
assert (handle != NULL);
- return handle->length;
+ return handle->record_width;
}
/* Returns the number of characters per tab stop for HANDLE, or
zero if tabs are not to be expanded. Applicable only to
MODE_TEXT files. */
size_t
-handle_get_tab_width (const struct file_handle *handle)
+fh_get_tab_width (const struct file_handle *handle)
{
assert (handle != NULL);
return handle->tab_width;
}
-
Index: pspp/src/file-handle-def.h
diff -u pspp/src/file-handle-def.h:1.1 pspp/src/file-handle-def.h:1.2
--- pspp/src/file-handle-def.h:1.1 Thu Oct 27 03:19:07 2005
+++ pspp/src/file-handle-def.h Thu Jan 12 03:39:01 2006
@@ -23,75 +23,42 @@
#include <config.h>
/* File modes. */
-enum file_handle_mode
+enum fh_mode
{
MODE_TEXT, /* New-line delimited lines. */
MODE_BINARY /* Fixed-length records. */
};
-struct file_handle *create_file_handle_with_defaults (const char *handle_name,
- const char *filename);
-
-struct file_handle *create_file_handle (const char *handle_name,
- const char *filename,
- enum file_handle_mode mode,
- size_t length,
- size_t tab_width
- );
-
-
-
-struct file_handle *
-get_handle_with_name (const char *handle_name) ;
-
-struct file_handle *
-get_handle_for_filename (const char *filename);
-
-const char *handle_get_name (const struct file_handle *handle);
-
-/* Returns the name of the file associated with HANDLE. */
-const char *handle_get_filename (const struct file_handle *handle) ;
-
-
-
-/* Returns the mode of HANDLE. */
-enum file_handle_mode handle_get_mode (const struct file_handle *handle) ;
-
-/* Returns the width of a logical record on HANDLE. */
-size_t handle_get_record_width (const struct file_handle *handle);
-
-
-/* Returns the number of characters per tab stop for HANDLE, or
- zero if tabs are not to be expanded. Applicable only to
- MODE_TEXT files. */
-size_t handle_get_tab_width (const struct file_handle *handle);
-
-
-
-void destroy_file_handle(void *fh_, void *aux UNUSED);
-
-
-/* Tries to open handle H with the given TYPE and MODE.
-
- TYPE is the sort of file, e.g. "system file". Only one given
- type of access is allowed on a given file handle at once.
-
- MODE combines the read or write mode with the sharing mode.
- The first character is 'r' for read, 'w' for write. The
- second character is 's' to permit sharing, 'e' to require
- exclusive access.
-
- Returns the address of a void * that the caller can use for
- data specific to the file handle if successful, or a null
- pointer on failure. For exclusive access modes the void *
- will always be a null pointer at return. In shared access
- modes the void * will necessarily be null only if no other
- sharers are active.
-
- If successful, a reference to type is retained, so it should
- probably be a string literal. */
+/* Properties of a file handle. */
+struct fh_properties
+ {
+ enum fh_mode mode; /* File mode. */
+ size_t record_width; /* Length of fixed-format records. */
+ size_t tab_width; /* Tab width, 0=do not expand tabs. */
+ };
-void ** fh_open (struct file_handle *h, const char *type, const char *mode) ;
+void fh_init (void);
+void fh_done (void);
+/* Creating file handles. */
+struct file_handle *fh_create (const char *handle_name,
+ const char *filename,
+ const struct fh_properties *);
+const struct fh_properties *fh_default_properties (void);
+
+/* Finding file handles, based on handle name or filename. */
+struct file_handle *fh_from_name (const char *handle_name);
+struct file_handle *fh_from_filename (const char *filename);
+
+/* Querying properties of file handles. */
+const char *fh_get_name (const struct file_handle *);
+const char *fh_get_filename (const struct file_handle *);
+enum fh_mode fh_get_mode (const struct file_handle *) ;
+size_t fh_get_record_width (const struct file_handle *);
+size_t fh_get_tab_width (const struct file_handle *);
+
+/* Opening and closing file handles. */
+void **fh_open (struct file_handle *, const char *type, const char *mode);
+int fh_close (struct file_handle *, const char *type, const char *mode);
#endif
Index: pspp/src/file-handle.h
diff -u pspp/src/file-handle.h:1.10 pspp/src/file-handle.h:1.11
--- pspp/src/file-handle.h:1.10 Thu Oct 27 03:19:07 2005
+++ pspp/src/file-handle.h Thu Jan 12 03:39:01 2006
@@ -25,19 +25,6 @@
#include <stddef.h>
#include "file-handle-def.h"
-
-
-void fh_init(void);
-void fh_done(void);
-
-
-/* Parsing handles. */
struct file_handle *fh_parse (void);
-
-/* Opening and closing handles. */
-void **fh_open (struct file_handle *, const char *type, const char *mode);
-int fh_close (struct file_handle *, const char *type, const char *mode);
-
-
#endif /* !file_handle.h */
Index: pspp/src/file-handle.q
diff -u pspp/src/file-handle.q:1.24 pspp/src/file-handle.q:1.25
--- pspp/src/file-handle.q:1.24 Thu Nov 3 06:21:46 2005
+++ pspp/src/file-handle.q Thu Jan 12 03:39:01 2006
@@ -49,14 +49,11 @@
/* (declarations) */
/* (functions) */
-
int
cmd_file_handle (void)
{
char handle_name[LONG_NAME_LEN + 1];
- enum file_handle_mode mode = MODE_TEXT;
- size_t length = 1024;
- size_t tab_width = 4;
+ struct fh_properties properties = *fh_default_properties ();
struct cmd_file_handle cmd;
struct file_handle *handle;
@@ -65,12 +62,12 @@
return CMD_FAILURE;
str_copy_trunc (handle_name, sizeof handle_name, tokid);
- handle = get_handle_with_name (handle_name);
+ handle = fh_from_name (handle_name);
if (handle != NULL)
{
msg (SE, _("File handle %s already refers to file %s. "
"File handles cannot be redefined within a session."),
- handle_name, handle_get_filename(handle));
+ handle_name, fh_get_filename(handle));
return CMD_FAILURE;
}
@@ -97,36 +94,29 @@
switch (cmd.mode)
{
case FH_CHARACTER:
- mode = MODE_TEXT;
+ properties.mode = MODE_TEXT;
if (cmd.sbc_tabwidth)
- tab_width = cmd.n_tabwidth[0];
- else
- tab_width = 4;
+ properties.tab_width = cmd.n_tabwidth[0];
break;
case FH_IMAGE:
- mode = MODE_BINARY;
+ properties.mode = MODE_BINARY;
if (cmd.n_lrecl[0] == NOT_LONG)
- {
- msg (SE, _("Fixed-length records were specified on /RECFORM, but "
- "record length was not specified on /LRECL. "
- "Assuming 1024-character records."));
- length = 1024;
- }
+ msg (SE, _("Fixed-length records were specified on /RECFORM, but "
+ "record length was not specified on /LRECL. "
+ "Assuming %d-character records."),
+ properties.record_width);
else if (cmd.n_lrecl[0] < 1)
- {
- msg (SE, _("Record length (%ld) must be at least one byte. "
- "1-character records will be assumed."), cmd.n_lrecl[0]);
- length = 1;
- }
+ msg (SE, _("Record length (%ld) must be at least one byte. "
+ "Assuming %d-character records."),
+ cmd.n_lrecl[0], properties.record_width);
else
- length = cmd.n_lrecl[0];
+ properties.record_width = cmd.n_lrecl[0];
break;
default:
assert (0);
}
- handle = create_file_handle (handle_name, cmd.s_name,
- mode, length, tab_width);
+ handle = fh_create (handle_name, cmd.s_name, &properties);
free_file_handle (&cmd);
return CMD_SUCCESS;
@@ -136,11 +126,6 @@
return CMD_FAILURE;
}
-
-
-static struct linked_list *handle_list;
-
-
/* Parses a file handle name, which may be a filename as a string or
a file handle name as an identifier. Returns the file handle or
NULL on failure. */
@@ -158,44 +143,23 @@
/* Check for named handles first, then go by filename. */
handle = NULL;
if (token == T_ID)
- handle = get_handle_with_name (tokid);
+ handle = fh_from_name (tokid);
if (handle == NULL)
- handle = get_handle_for_filename (ds_c_str (&tokstr));
+ handle = fh_from_filename (ds_c_str (&tokstr));
if (handle == NULL)
{
char *filename = ds_c_str (&tokstr);
char *handle_name = xmalloc (strlen (filename) + 3);
sprintf (handle_name, "\"%s\"", filename);
- handle = create_file_handle_with_defaults (handle_name, filename);
- ll_push_front(handle_list, handle);
+ handle = fh_create (handle_name, filename, fh_default_properties ());
free (handle_name);
}
lex_get ();
-
return handle;
}
-
-
-void
-fh_init(void)
-{
- handle_list = ll_create(destroy_file_handle,0);
-}
-
-void
-fh_done(void)
-{
- if ( handle_list )
- {
- ll_destroy(handle_list);
- handle_list = 0;
- }
-}
-
-
/*
Local variables:
mode: c
Index: pspp/src/get.c
diff -u pspp/src/get.c:1.41 pspp/src/get.c:1.42
--- pspp/src/get.c:1.41 Thu Nov 3 06:21:46 2005
+++ pspp/src/get.c Thu Jan 12 03:39:01 2006
@@ -928,7 +928,7 @@
if (iter->by[i] == NULL)
{
msg (SE, _("File %s lacks BY variable %s."),
- iter->handle ? handle_get_name (iter->handle) : "*",
+ iter->handle ? fh_get_name (iter->handle) : "*",
by[i]->name);
free (by);
goto error;
@@ -1461,7 +1461,7 @@
msg (SE, _("Variable %s in file %s (%s) has different "
"type or width from the same variable in "
"earlier file (%s)."),
- dv->name, handle_get_name (f->handle),
+ dv->name, fh_get_name (f->handle),
var_type_description (dv), var_type_description (mv));
return 0;
}
Index: pspp/src/main.c
diff -u pspp/src/main.c:1.21 pspp/src/main.c:1.22
--- pspp/src/main.c:1.21 Sat Jan 7 07:29:38 2006
+++ pspp/src/main.c Thu Jan 12 03:39:01 2006
@@ -26,7 +26,7 @@
#include "command.h"
#include "dictionary.h"
#include "error.h"
-#include "file-handle.h"
+#include "file-handle-def.h"
#include "filename.h"
#include "getl.h"
#include "glob.h"
Index: pspp/src/pfm-read.c
diff -u pspp/src/pfm-read.c:1.29 pspp/src/pfm-read.c:1.30
--- pspp/src/pfm-read.c:1.29 Sat Oct 29 05:50:06 2005
+++ pspp/src/pfm-read.c Thu Jan 12 03:39:01 2006
@@ -82,7 +82,7 @@
e.class = ME;
getl_location (&e.where.filename, &e.where.line_number);
- filename = handle_get_filename (r->fh);
+ filename = fh_get_filename (r->fh);
e.title = title = pool_alloc (r->pool, strlen (filename) + 80);
sprintf (title, _("portable file %s corrupt at offset %ld: "),
filename, ftell (r->file));
@@ -159,7 +159,7 @@
if (setjmp (r->bail_out))
goto error;
r->fh = fh;
- r->file = pool_fopen (r->pool, handle_get_filename (r->fh), "rb");
+ r->file = pool_fopen (r->pool, fh_get_filename (r->fh), "rb");
r->weight_index = -1;
r->trans = NULL;
r->var_cnt = 0;
@@ -171,7 +171,7 @@
{
msg (ME, _("An error occurred while opening \"%s\" for reading "
"as a portable file: %s."),
- handle_get_filename (r->fh), strerror (errno));
+ fh_get_filename (r->fh), strerror (errno));
err_cond_fail ();
goto error;
}
@@ -400,7 +400,7 @@
for (i = 0; i < 8; i++)
if (!match (r, "SPSSPORT"[i]))
{
- msg (SE, _("%s: Not a portable file."), handle_get_filename (r->fh));
+ msg (SE, _("%s: Not a portable file."), fh_get_filename (r->fh));
longjmp (r->bail_out, 1);
}
}
Index: pspp/src/pfm-write.c
diff -u pspp/src/pfm-write.c:1.19 pspp/src/pfm-write.c:1.20
--- pspp/src/pfm-write.c:1.19 Wed Oct 26 05:06:14 2005
+++ pspp/src/pfm-write.c Thu Jan 12 03:39:01 2006
@@ -106,7 +106,7 @@
mode = S_IRUSR | S_IRGRP | S_IROTH;
if (opts.create_writeable)
mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- fd = open (handle_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode);
+ fd = open (fh_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode);
if (fd < 0)
goto open_error;
@@ -163,7 +163,7 @@
open_error:
msg (ME, _("An error occurred while opening \"%s\" for writing "
"as a portable file: %s."),
- handle_get_filename (fh), strerror (errno));
+ fh_get_filename (fh), strerror (errno));
err_cond_fail ();
goto error;
}
@@ -199,7 +199,7 @@
error:
msg (ME, _("%s: Writing portable file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (w->fh), strerror (errno));
return 0;
}
@@ -466,7 +466,7 @@
if (fclose (w->file) == EOF)
msg (ME, _("%s: Closing portable file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (w->fh), strerror (errno));
}
free (w->vars);
Index: pspp/src/print.c
diff -u pspp/src/print.c:1.23 pspp/src/print.c:1.24
--- pspp/src/print.c:1.23 Thu Nov 3 06:21:46 2005
+++ pspp/src/print.c Thu Jan 12 03:39:01 2006
@@ -191,7 +191,7 @@
if (prt.writer == NULL)
goto error;
- if (handle_get_mode (fh) == MODE_BINARY)
+ if (fh_get_mode (fh) == MODE_BINARY)
prt.options |= PRT_BINARY;
}
@@ -837,7 +837,7 @@
if (fh != NULL)
tab_title (t, 1, _("Writing %d record(s) to file %s."),
- recno, handle_get_filename (fh));
+ recno, fh_get_filename (fh));
else
tab_title (t, 1, _("Writing %d record(s) to the listing file."), recno);
tab_submit (t);
Index: pspp/src/regression.q
diff -u pspp/src/regression.q:1.35 pspp/src/regression.q:1.36
--- pspp/src/regression.q:1.35 Mon Jan 9 00:51:18 2006
+++ pspp/src/regression.q Thu Jan 12 03:39:01 2006
@@ -611,7 +611,7 @@
assert (c != NULL);
assert (model_file != NULL);
assert (fp != NULL);
- fp = fopen (handle_get_filename (model_file), "w");
+ fp = fopen (fh_get_filename (model_file), "w");
fprintf (fp, "%s", reg_preamble);
reg_print_getvar (fp, c);
reg_print_categorical_encoding (fp, c);
Index: pspp/src/sfm-read.c
diff -u pspp/src/sfm-read.c:1.27 pspp/src/sfm-read.c:1.28
--- pspp/src/sfm-read.c:1.27 Wed Oct 26 05:06:14 2005
+++ pspp/src/sfm-read.c Thu Jan 12 03:39:01 2006
@@ -147,9 +147,9 @@
fh_close (r->fh, "system file", "rs");
if ( r->file ) {
- if (fn_close (handle_get_filename (r->fh), r->file) == EOF)
+ if (fn_close (fh_get_filename (r->fh), r->file) == EOF)
msg (ME, _("%s: Closing system file: %s."),
- handle_get_filename (r->fh), strerror (errno));
+ fh_get_filename (r->fh), strerror (errno));
r->file = NULL;
}
free (r->vars);
@@ -212,7 +212,7 @@
/* Create and initialize reader. */
r = xmalloc (sizeof *r);
r->fh = fh;
- r->file = fn_open (handle_get_filename (fh), "rb");
+ r->file = fn_open (fh_get_filename (fh), "rb");
r->reverse_endian = 0;
r->fix_specials = 0;
@@ -236,7 +236,7 @@
{
msg (ME, _("An error occurred while opening \"%s\" for reading "
"as a system file: %s."),
- handle_get_filename (r->fh), strerror (errno));
+ fh_get_filename (r->fh), strerror (errno));
err_cond_fail ();
goto error;
}
@@ -254,7 +254,7 @@
if (r->weight_idx < 0 || r->weight_idx >= r->value_cnt)
lose ((ME, _("%s: Index of weighting variable (%d) is not between 0 "
"and number of elements per case (%d)."),
- handle_get_filename (r->fh), r->weight_idx, r->value_cnt));
+ fh_get_filename (r->fh), r->weight_idx, r->value_cnt));
weight_var = var_by_idx[r->weight_idx];
@@ -262,10 +262,10 @@
if (weight_var == NULL)
lose ((ME,
_("%s: Weighting variable may not be a continuation of "
- "a long string variable."), handle_get_filename (fh)));
+ "a long string variable."), fh_get_filename (fh)));
else if (weight_var->type == ALPHA)
lose ((ME, _("%s: Weighting variable may not be a string variable."),
- handle_get_filename (fh)));
+ fh_get_filename (fh)));
dict_set_weight (*dict, weight_var);
}
@@ -292,7 +292,7 @@
lose ((ME, _("%s: Orphaned variable index record (type 4). Type 4 "
"records must always immediately follow type 3 "
"records."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
case 6:
if (!read_documents (r, *dict))
@@ -322,7 +322,7 @@
bytes = data.size * data.count;
if (bytes < data.size || bytes < data.count)
lose ((ME, "%s: Record type %d subtype %d too large.",
- handle_get_filename (r->fh), rec_type, data.subtype));
+ fh_get_filename (r->fh), rec_type, data.subtype));
switch (data.subtype)
{
@@ -349,7 +349,7 @@
{
msg (MW, _("%s: Invalid subrecord length. "
"Record: 7; Subrecord: 11"),
- handle_get_filename (r->fh));
+ fh_get_filename (r->fh));
skip = 1;
}
@@ -403,14 +403,14 @@
{
msg (MW, _("%s: Trailing garbage in long variable "
"name map."),
- handle_get_filename (r->fh));
+ fh_get_filename (r->fh));
break;
}
if (!var_is_valid_name (long_name, false))
{
msg (MW, _("%s: Long variable mapping to invalid "
"variable name `%s'."),
- handle_get_filename (r->fh), long_name);
+ fh_get_filename (r->fh), long_name);
break;
}
@@ -420,7 +420,7 @@
{
msg (MW, _("%s: Long variable mapping for "
"nonexistent variable %s."),
- handle_get_filename (r->fh), short_name);
+ fh_get_filename (r->fh), short_name);
break;
}
@@ -430,7 +430,7 @@
{
lose ((ME, _("%s: Duplicate long variable name `%s' "
"within system file."),
- handle_get_filename (r->fh), long_name));
+ fh_get_filename (r->fh), long_name));
break;
}
@@ -458,7 +458,7 @@
default:
msg (MW, _("%s: Unrecognized record type 7, subtype %d "
"encountered in system file."),
- handle_get_filename (r->fh), data.subtype);
+ fh_get_filename (r->fh), data.subtype);
skip = 1;
}
@@ -482,7 +482,7 @@
default:
corrupt_msg(MW, _("%s: Unrecognized record type %d."),
- handle_get_filename (r->fh), rec_type);
+ fh_get_filename (r->fh), rec_type);
}
}
@@ -515,7 +515,7 @@
if (size != sizeof (int32) || count != 8)
lose ((ME, _("%s: Bad size (%d) or count (%d) field on record type 7, "
"subtype 3. Expected size %d, count 8."),
- handle_get_filename (r->fh), size, count, sizeof (int32)));
+ fh_get_filename (r->fh), size, count, sizeof (int32)));
assertive_buf_read (r, data, sizeof data, 0);
if (r->reverse_endian)
@@ -527,7 +527,7 @@
lose ((ME, _("%s: Floating-point representation in system file is not "
"IEEE-754. PSPP cannot convert between floating-point "
"formats."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
#else
#error Add support for your floating-point format.
#endif
@@ -542,7 +542,7 @@
if (file_bigendian ^ (data[6] == 1))
lose ((ME, _("%s: File-indicated endianness (%s) does not match "
"endianness intuited from file header (%s)."),
- handle_get_filename (r->fh),
+ fh_get_filename (r->fh),
file_bigendian ? _("big-endian") : _("little-endian"),
data[6] == 1 ? _("big-endian") : (data[6] == 2 ? _("little-endian")
: _("unknown"))));
@@ -551,7 +551,7 @@
if (data[7] != 2 && data[7] != 3)
lose ((ME, _("%s: File-indicated character representation code (%s) is "
"not ASCII."),
- handle_get_filename (r->fh),
+ fh_get_filename (r->fh),
(data[7] == 1 ? "EBCDIC"
: (data[7] == 4 ? _("DEC Kanji") : _("Unknown")))));
@@ -571,7 +571,7 @@
if (size != sizeof (flt64) || count != 3)
lose ((ME, _("%s: Bad size (%d) or count (%d) field on record type 7, "
"subtype 4. Expected size %d, count 8."),
- handle_get_filename (r->fh), size, count, sizeof (flt64)));
+ fh_get_filename (r->fh), size, count, sizeof (flt64)));
assertive_buf_read (r, data, sizeof data, 0);
if (r->reverse_endian)
@@ -588,7 +588,7 @@
"for at least one of the three system values. SYSMIS: "
"indicated %g, expected %g; HIGHEST: %g, %g; LOWEST: "
"%g, %g."),
- handle_get_filename (r->fh), (double) data[0], (double) SYSMIS,
+ fh_get_filename (r->fh), (double) data[0], (double) SYSMIS,
(double) data[1], (double) FLT64_MAX,
(double) data[2], (double) second_lowest_flt64);
}
@@ -613,7 +613,7 @@
if (strncmp ("$FL2", hdr.rec_type, 4) != 0)
lose ((ME, _("%s: Bad magic. Proper system files begin with "
"the four characters `$FL2'. This file will not be read."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
/* Check eye-catcher string. */
memcpy (prod_name, hdr.prod_name, sizeof hdr.prod_name);
@@ -655,7 +655,7 @@
if (hdr.layout_code != 2)
lose ((ME, _("%s: File layout code has unexpected value %d. Value "
"should be 2, in big-endian or little-endian format."),
- handle_get_filename (r->fh), hdr.layout_code));
+ fh_get_filename (r->fh), hdr.layout_code));
r->reverse_endian = 1;
bswap_int32 (&hdr.case_size);
@@ -682,13 +682,13 @@
if (r->case_cnt < -1 || r->case_cnt > INT_MAX / 2)
lose ((ME,
_("%s: Number of cases in file (%ld) is not between -1 and %d."),
- handle_get_filename (r->fh), (long) r->case_cnt, INT_MAX / 2));
+ fh_get_filename (r->fh), (long) r->case_cnt, INT_MAX / 2));
r->bias = hdr.bias;
if (r->bias != 100.0)
corrupt_msg (MW, _("%s: Compression bias (%g) is not the usual "
"value of 100."),
- handle_get_filename (r->fh), r->bias);
+ fh_get_filename (r->fh), r->bias);
/* Make a file label only on the condition that the given label is
not all spaces or nulls. */
@@ -811,7 +811,7 @@
if (sv.type != -1)
lose ((ME, _("%s: position %d: String variable does not have "
"proper number of continuation records."),
- handle_get_filename (r->fh), i));
+ fh_get_filename (r->fh), i));
r->vars[i].width = -1;
@@ -822,35 +822,35 @@
else if (sv.type == -1)
lose ((ME, _("%s: position %d: Superfluous long string continuation "
"record."),
- handle_get_filename (r->fh), i));
+ fh_get_filename (r->fh), i));
/* Check fields for validity. */
if (sv.type < 0 || sv.type > 255)
lose ((ME, _("%s: position %d: Bad variable type code %d."),
- handle_get_filename (r->fh), i, sv.type));
+ fh_get_filename (r->fh), i, sv.type));
if (sv.has_var_label != 0 && sv.has_var_label != 1)
lose ((ME, _("%s: position %d: Variable label indicator field is not "
- "0 or 1."), handle_get_filename (r->fh), i));
+ "0 or 1."), fh_get_filename (r->fh), i));
if (sv.n_missing_values < -3 || sv.n_missing_values > 3
|| sv.n_missing_values == -1)
lose ((ME, _("%s: position %d: Missing value indicator field is not "
- "-3, -2, 0, 1, 2, or 3."), handle_get_filename (r->fh),
i));
+ "-3, -2, 0, 1, 2, or 3."), fh_get_filename (r->fh), i));
/* Copy first character of variable name. */
if (!isalpha ((unsigned char) sv.name[0])
&& sv.name[0] != '@' && sv.name[0] != '#')
lose ((ME, _("%s: position %d: Variable name begins with invalid "
"character."),
- handle_get_filename (r->fh), i));
+ fh_get_filename (r->fh), i));
if (islower ((unsigned char) sv.name[0]))
msg (MW, _("%s: position %d: Variable name begins with lowercase letter
"
"%c."),
- handle_get_filename (r->fh), i, sv.name[0]);
+ fh_get_filename (r->fh), i, sv.name[0]);
if (sv.name[0] == '#')
msg (MW, _("%s: position %d: Variable name begins with octothorpe "
"(`#'). Scratch variables should not appear in system "
"files."),
- handle_get_filename (r->fh), i);
+ fh_get_filename (r->fh), i);
name[0] = toupper ((unsigned char) (sv.name[0]));
/* Copy remaining characters of variable name. */
@@ -864,7 +864,7 @@
{
msg (MW, _("%s: position %d: Variable name character %d is "
"lowercase letter %c."),
- handle_get_filename (r->fh), i, j + 1, sv.name[j]);
+ fh_get_filename (r->fh), i, j + 1, sv.name[j]);
name[j] = toupper ((unsigned char) (c));
}
else if (isalnum (c) || c == '.' || c == '@'
@@ -873,20 +873,20 @@
else
lose ((ME, _("%s: position %d: character `\\%03o' (%c) is not valid
in a "
"variable name."),
- handle_get_filename (r->fh), i, c, c));
+ fh_get_filename (r->fh), i, c, c));
}
name[j] = 0;
if ( ! var_is_valid_name(name, false) )
lose ((ME, _("%s: Invalid variable name `%s' within system file."),
- handle_get_filename (r->fh), name));
+ fh_get_filename (r->fh), name));
/* Create variable. */
vv = (*var_by_idx)[i] = dict_create_var (dict, name, sv.type);
if (vv == NULL)
lose ((ME, _("%s: Duplicate variable name `%s' within system file."),
- handle_get_filename (r->fh), name));
+ fh_get_filename (r->fh), name));
var_set_short_name (vv, vv->name);
@@ -910,7 +910,7 @@
if (len < 0 || len > 255)
lose ((ME, _("%s: Variable %s indicates variable label of invalid "
"length %d."),
- handle_get_filename (r->fh), vv->name, len));
+ fh_get_filename (r->fh), vv->name, len));
if ( len != 0 )
{
@@ -931,7 +931,7 @@
if (vv->width > MAX_SHORT_STRING)
lose ((ME, _("%s: Long string variable %s may not have missing "
"values."),
- handle_get_filename (r->fh), vv->name));
+ fh_get_filename (r->fh), vv->name));
assertive_buf_read (r, mv, sizeof *mv * mv_cnt, 0);
@@ -952,7 +952,7 @@
if (vv->type == ALPHA)
lose ((ME, _("%s: String variable %s may not have missing "
"values specified as a range."),
- handle_get_filename (r->fh), vv->name));
+ fh_get_filename (r->fh), vv->name));
if (mv[0] == r->lowest)
mv_add_num_range (&vv->miss, LOWEST, mv[1]);
@@ -979,12 +979,12 @@
if (long_string_count != 0)
lose ((ME, _("%s: Long string continuation records omitted at end of "
"dictionary."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
if (next_value != r->value_cnt)
corrupt_msg(MW, _("%s: System file header indicates %d variable positions
but "
"%d were read from file."),
- handle_get_filename (r->fh), r->value_cnt, next_value);
+ fh_get_filename (r->fh), r->value_cnt, next_value);
return 1;
@@ -1002,13 +1002,13 @@
f->type = translate_fmt ((s >> 16) & 0xff);
if (f->type == -1)
lose ((ME, _("%s: Bad format specifier byte (%d)."),
- handle_get_filename (r->fh), (s >> 16) & 0xff));
+ fh_get_filename (r->fh), (s >> 16) & 0xff));
f->w = (s >> 8) & 0xff;
f->d = s & 0xff;
if ((v->type == ALPHA) ^ ((formats[f->type].cat & FCAT_STRING) != 0))
lose ((ME, _("%s: %s variable %s has %s format specifier %s."),
- handle_get_filename (r->fh),
+ fh_get_filename (r->fh),
v->type == ALPHA ? _("String") : _("Numeric"),
v->name,
formats[f->type].cat & FCAT_STRING ? _("string") : _("numeric"),
@@ -1061,7 +1061,7 @@
if ( n_labels >= ((int32) ~0) / sizeof *labels)
{
corrupt_msg(MW, _("%s: Invalid number of labels: %d. Ignoring labels."),
- handle_get_filename (r->fh), n_labels);
+ fh_get_filename (r->fh), n_labels);
n_labels = 0;
}
@@ -1104,7 +1104,7 @@
if (rec_type != 4)
lose ((ME, _("%s: Variable index record (type 4) does not immediately "
"follow value label record (type 3) as it should."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
}
/* Read number of variables associated with value label from type 4
@@ -1115,7 +1115,7 @@
if (n_vars < 1 || n_vars > dict_get_var_cnt (dict))
lose ((ME, _("%s: Number of variables associated with a value label (%d) "
"is not between 1 and the number of variables (%d)."),
- handle_get_filename (r->fh), n_vars, dict_get_var_cnt (dict)));
+ fh_get_filename (r->fh), n_vars, dict_get_var_cnt (dict)));
/* Read the list of variables. */
var = xnmalloc (n_vars, sizeof *var);
@@ -1131,7 +1131,7 @@
if (var_idx < 1 || var_idx > r->value_cnt)
lose ((ME, _("%s: Variable index associated with value label (%d) is "
"not between 1 and the number of values (%d)."),
- handle_get_filename (r->fh), var_idx, r->value_cnt));
+ fh_get_filename (r->fh), var_idx, r->value_cnt));
/* Make sure it's a real variable. */
v = var_by_idx[var_idx - 1];
@@ -1139,11 +1139,11 @@
lose ((ME, _("%s: Variable index associated with value label (%d) "
"refers to a continuation of a string variable, not to "
"an actual variable."),
- handle_get_filename (r->fh), var_idx));
+ fh_get_filename (r->fh), var_idx));
if (v->type == ALPHA && v->width > MAX_SHORT_STRING)
lose ((ME, _("%s: Value labels are not allowed on long string "
"variables (%s)."),
- handle_get_filename (r->fh), v->name));
+ fh_get_filename (r->fh), v->name));
/* Add it to the list of variables. */
var[i] = v;
@@ -1155,7 +1155,7 @@
lose ((ME, _("%s: Variables associated with value label are not all of "
"identical type. Variable %s has %s type, but variable "
"%s has %s type."),
- handle_get_filename (r->fh),
+ fh_get_filename (r->fh),
var[0]->name, var[0]->type == ALPHA ? _("string") : _("numeric"),
var[i]->name, var[i]->type == ALPHA ? _("string") : _("numeric")));
@@ -1195,11 +1195,11 @@
if (var[0]->type == NUMERIC)
msg (MW, _("%s: File contains duplicate label for value %g for "
"variable %s."),
- handle_get_filename (r->fh), label->value.f, v->name);
+ fh_get_filename (r->fh), label->value.f, v->name);
else
msg (MW, _("%s: File contains duplicate label for value `%.*s' "
"for variable %s."),
- handle_get_filename (r->fh), v->width, label->value.s,
v->name);
+ fh_get_filename (r->fh), v->width, label->value.s, v->name);
}
}
@@ -1240,10 +1240,10 @@
{
if (ferror (r->file))
msg (ME, _("%s: Reading system file: %s."),
- handle_get_filename (r->fh), strerror (errno));
+ fh_get_filename (r->fh), strerror (errno));
else
corrupt_msg (ME, _("%s: Unexpected end of file."),
- handle_get_filename (r->fh));
+ fh_get_filename (r->fh));
return NULL;
}
return buf;
@@ -1258,7 +1258,7 @@
if ( 0 != fseek(r->file, -byte_cnt, SEEK_CUR))
{
msg (ME, _("%s: Seeking system file: %s."),
- handle_get_filename (r->fh), strerror (errno));
+ fh_get_filename (r->fh), strerror (errno));
}
}
@@ -1274,13 +1274,13 @@
if (dict_get_documents (dict) != NULL)
lose ((ME, _("%s: System file contains multiple "
"type 6 (document) records."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
assertive_buf_read (r, &line_cnt, sizeof line_cnt, 0);
if (line_cnt <= 0)
lose ((ME, _("%s: Number of document lines (%ld) "
"must be greater than 0."),
- handle_get_filename (r->fh), (long) line_cnt));
+ fh_get_filename (r->fh), (long) line_cnt));
documents = buf_read (r, NULL, 80 * line_cnt, line_cnt * 80 + 1);
/* FIXME? Run through asciify. */
@@ -1311,7 +1311,7 @@
if (ferror (r->file))
{
msg (ME, _("%s: Error reading file: %s."),
- handle_get_filename (r->fh), strerror (errno));
+ fh_get_filename (r->fh), strerror (errno));
return 0;
}
r->ptr = r->buf;
@@ -1349,7 +1349,7 @@
if (buf_beg != buf)
lose ((ME, _("%s: Compressed data is corrupted. Data ends "
"in partial case."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
goto error;
case 253:
/* Code 253 indicates that the value is stored explicitly
@@ -1358,7 +1358,7 @@
if (!buffer_input (r))
{
lose ((ME, _("%s: Unexpected end of file."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
goto error;
}
memcpy (buf++, r->ptr++, sizeof *buf);
@@ -1400,7 +1400,7 @@
{
if (buf_beg != buf)
lose ((ME, _("%s: Unexpected end of file."),
- handle_get_filename (r->fh)));
+ fh_get_filename (r->fh)));
goto error;
}
memcpy (r->x, r->ptr++, sizeof *buf);
@@ -1517,10 +1517,10 @@
{
if (ferror (r->file))
msg (ME, _("%s: Reading system file: %s."),
- handle_get_filename (r->fh), strerror (errno));
+ fh_get_filename (r->fh), strerror (errno));
else if (read_bytes != 0)
msg (ME, _("%s: Partial record at end of system file."),
- handle_get_filename (r->fh));
+ fh_get_filename (r->fh));
return 0;
}
}
Index: pspp/src/sfm-write.c
diff -u pspp/src/sfm-write.c:1.22 pspp/src/sfm-write.c:1.23
--- pspp/src/sfm-write.c:1.22 Wed Oct 26 05:06:14 2005
+++ pspp/src/sfm-write.c Thu Jan 12 03:39:01 2006
@@ -151,7 +151,7 @@
mode = S_IRUSR | S_IRGRP | S_IROTH;
if (opts.create_writeable)
mode |= S_IWUSR | S_IWGRP | S_IWOTH;
- fd = open (handle_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode);
+ fd = open (fh_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode);
if (fd < 0)
goto open_error;
@@ -257,7 +257,7 @@
open_error:
msg (ME, _("Error opening \"%s\" for writing as a system file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (w->fh), strerror (errno));
err_cond_fail ();
goto error;
}
@@ -749,7 +749,7 @@
if (fwrite (buf, nbytes, 1, w->file) != 1)
{
msg (ME, _("%s: Writing system file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (w->fh), strerror (errno));
return 0;
}
return 1;
@@ -929,7 +929,7 @@
if (fclose (w->file) == EOF)
msg (ME, _("%s: Closing system file: %s."),
- handle_get_filename (w->fh), strerror (errno));
+ fh_get_filename (w->fh), strerror (errno));
}
free (w->buf);
Index: pspp/src/sysfile-info.c
diff -u pspp/src/sysfile-info.c:1.19 pspp/src/sysfile-info.c:1.20
--- pspp/src/sysfile-info.c:1.19 Wed Oct 26 05:06:14 2005
+++ pspp/src/sysfile-info.c Thu Jan 12 03:39:01 2006
@@ -98,7 +98,7 @@
t = tab_create (2, 9, 0);
tab_vline (t, TAL_1 | TAL_SPACING, 1, 0, 8);
tab_text (t, 0, 0, TAB_LEFT, _("File:"));
- tab_text (t, 1, 0, TAB_LEFT, handle_get_filename (h));
+ tab_text (t, 1, 0, TAB_LEFT, fh_get_filename (h));
tab_text (t, 0, 1, TAB_LEFT, _("Label:"));
{
const char *label = dict_get_label (d);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/src ChangeLog data-list.c dfm-read.c dfm-w...,
Ben Pfaff <=