From 3f2ed1c5fe6dc692ca00bb18a15e41617fa2d37d Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 17 Apr 2006 01:54:15 +0000 Subject: [PATCH] GNU standards require "file name" instead of "filename" in documentation. It's nice for our code to follow the convention too. --- src/ChangeLog | 10 ++ src/data/any-reader.c | 8 +- src/data/any-writer.c | 2 +- src/data/casefile.c | 34 +++---- src/data/file-handle-def.c | 28 +++--- src/data/file-handle-def.h | 6 +- src/data/file-name.c | 92 +++++++++--------- src/data/file-name.h | 2 +- src/data/make-file.c | 40 ++++---- src/data/make-file.h | 12 +-- src/data/por-file-reader.c | 16 +-- src/data/por-file-writer.c | 6 +- src/data/sys-file-reader.c | 124 ++++++++++++------------ src/data/sys-file-writer.c | 6 +- src/language/data-io/data-reader.c | 12 +-- src/language/data-io/data-writer.c | 4 +- src/language/data-io/file-handle.q | 10 +- src/language/dictionary/sys-file-info.c | 2 +- src/language/line-buffer.c | 8 +- src/language/stats/regression.q | 2 +- src/language/utilities/include.c | 4 +- src/language/utilities/permissions.c | 12 +-- src/libpspp/message.h | 2 +- src/libpspp/pool.c | 8 +- src/message.c | 6 +- src/output/chart.h | 2 +- src/output/html.c | 6 +- src/output/postscript.c | 2 +- src/ui/gui/menu-actions.c | 20 ++-- src/ui/gui/message-dialog.c | 2 +- 30 files changed, 249 insertions(+), 239 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 36ae08da..e31c7f24 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +Sun Apr 16 18:53:12 2006 Ben Pfaff + + GNU standards require "file name" instead of "filename" in + documentation. It's nice for our code to follow the convention + too. + + Basically did search and replace in the whole source tree. Major + changes in function names or struct member names have their own + change log entries. + Sun Apr 16 15:58:56 2006 Ben Pfaff Continue reforming error message support. In this phase, we get diff --git a/src/data/any-reader.c b/src/data/any-reader.c index 0156d0b5..0ab6dc23 100644 --- a/src/data/any-reader.c +++ b/src/data/any-reader.c @@ -68,17 +68,17 @@ try_detect (struct file_handle *handle, bool (*detect) (FILE *)) FILE *file; bool is_type; - file = fn_open (fh_get_filename (handle), "rb"); + file = fn_open (fh_get_file_name (handle), "rb"); if (file == NULL) { msg (ME, _("An error occurred while opening \"%s\": %s."), - fh_get_filename (handle), strerror (errno)); + fh_get_file_name (handle), strerror (errno)); return IO_ERROR; } is_type = detect (file); - fn_close (fh_get_filename (handle), file); + fn_close (fh_get_file_name (handle), file); return is_type ? YES : NO; } @@ -127,7 +127,7 @@ any_reader_open (struct file_handle *handle, struct dictionary **dict) pfm_open_reader (handle, dict, NULL)); msg (SE, _("\"%s\" is not a system or portable file."), - fh_get_filename (handle)); + fh_get_file_name (handle)); return NULL; } diff --git a/src/data/any-writer.c b/src/data/any-writer.c index 2aeaa3a5..5c3c0aee 100644 --- a/src/data/any-writer.c +++ b/src/data/any-writer.c @@ -62,7 +62,7 @@ any_writer_open (struct file_handle *handle, struct dictionary *dict) struct any_writer *writer; char *extension; - extension = fn_extension (fh_get_filename (handle)); + extension = fn_extension (fh_get_file_name (handle)); str_lowercase (extension); if (!strcmp (extension, ".por")) diff --git a/src/data/casefile.c b/src/data/casefile.c index 0bbd3773..1ae743bd 100644 --- a/src/data/casefile.c +++ b/src/data/casefile.c @@ -135,7 +135,7 @@ struct casefile /* Disk storage. */ int fd; /* File descriptor, -1 if none. */ - char *filename; /* Filename. */ + char *file_name; /* File name. */ union value *buffer; /* I/O buffer, NULL if none. */ size_t buffer_used; /* Number of values used in buffer. */ size_t buffer_size; /* Buffer size in values. */ @@ -179,7 +179,7 @@ static bool fill_buffer (struct casereader *reader); static void io_error (struct casefile *, const char *, ...) PRINTF_FORMAT (2, 3); -static int safe_open (const char *filename, int flags); +static int safe_open (const char *file_name, int flags); static int safe_close (int fd); /* Creates and returns a casefile to store cases of VALUE_CNT @@ -203,7 +203,7 @@ casefile_create (size_t value_cnt) cf->ok = true; cf->cases = NULL; cf->fd = -1; - cf->filename = NULL; + cf->file_name = NULL; cf->buffer = NULL; cf->buffer_size = ROUND_UP (cf->value_cnt, IO_BUF_SIZE); if (cf->value_cnt > 0 && cf->buffer_size % cf->value_cnt > 64) @@ -252,10 +252,10 @@ casefile_destroy (struct casefile *cf) if (cf->fd != -1) safe_close (cf->fd); - if (cf->filename != NULL && remove (cf->filename) == -1) + if (cf->file_name != NULL && remove (cf->file_name) == -1) io_error (cf, _("%s: Removing temporary file: %s."), - cf->filename, strerror (errno)); - free (cf->filename); + cf->file_name, strerror (errno)); + free (cf->file_name); free (cf->buffer); @@ -442,11 +442,11 @@ casefile_to_disk (const struct casefile *cf_) { size_t idx, block_cnt; - assert (cf->filename == NULL); + assert (cf->file_name == NULL); assert (cf->fd == -1); assert (cf->buffer_used == 0); - if (!make_temp_file (&cf->fd, &cf->filename)) + if (!make_temp_file (&cf->fd, &cf->file_name)) { cf->ok = false; return false; @@ -566,10 +566,10 @@ reader_open_file (struct casereader *reader) } else { - reader->fd = safe_open (cf->filename, O_RDONLY); + reader->fd = safe_open (cf->file_name, O_RDONLY); if (reader->fd < 0) io_error (cf, _("%s: Opening temporary file: %s."), - cf->filename, strerror (errno)); + cf->file_name, strerror (errno)); } if (cf->buffer != NULL) @@ -595,7 +595,7 @@ reader_open_file (struct casereader *reader) file_ofs = 0; if (lseek (reader->fd, file_ofs, SEEK_SET) != file_ofs) io_error (cf, _("%s: Seeking temporary file: %s."), - cf->filename, strerror (errno)); + cf->file_name, strerror (errno)); if (cf->case_cnt > 0 && cf->value_cnt > 0) fill_buffer (reader); @@ -613,10 +613,10 @@ fill_buffer (struct casereader *reader) reader->cf->buffer_size * sizeof *reader->buffer); if (bytes < 0) io_error (reader->cf, _("%s: Reading temporary file: %s."), - reader->cf->filename, strerror (errno)); + reader->cf->file_name, strerror (errno)); else if (bytes != reader->cf->buffer_size * sizeof *reader->buffer) io_error (reader->cf, _("%s: Temporary file ended unexpectedly."), - reader->cf->filename); + reader->cf->file_name); } return reader->cf->ok; } @@ -737,7 +737,7 @@ io_error (struct casefile *cf, const char *format, ...) va_list args; e.class = ME; - e.where.filename = NULL; + e.where.file_name = NULL; e.where.line_number = -1; e.title = NULL; @@ -748,16 +748,16 @@ io_error (struct casefile *cf, const char *format, ...) cf->ok = false; } -/* Calls open(), passing FILENAME and FLAGS, repeating as necessary +/* Calls open(), passing FILE_NAME and FLAGS, repeating as necessary to deal with interrupted calls. */ static int -safe_open (const char *filename, int flags) +safe_open (const char *file_name, int flags) { int fd; do { - fd = open (filename, flags); + fd = open (file_name, flags); } while (fd == -1 && errno == EINTR); diff --git a/src/data/file-handle-def.c b/src/data/file-handle-def.c index 152e5d4b..4b83c3e1 100644 --- a/src/data/file-handle-def.c +++ b/src/data/file-handle-def.c @@ -50,7 +50,7 @@ struct file_handle enum fh_referent referent; /* What the file handle refers to. */ /* FH_REF_FILE only. */ - char *filename; /* Filename as provided by user. */ + char *file_name; /* File name as provided by user. */ struct file_identity *identity; /* For checking file identity. */ enum fh_mode mode; /* File mode. */ @@ -100,7 +100,7 @@ free_handle (struct file_handle *handle) /* Free data. */ free (handle->name); - free (handle->filename); + free (handle->file_name); fn_free_identity (handle->identity); scratch_handle_destroy (handle->sh); free (handle); @@ -127,18 +127,18 @@ fh_from_name (const char *handle_name) return NULL; } -/* Returns the handle for the file named FILENAME, +/* Returns the handle for the file named FILE_NAME, or a null pointer if none exists. Different names for the same file (e.g. "x" and "./x") are considered equivalent. */ struct file_handle * -fh_from_filename (const char *filename) +fh_from_file_name (const char *file_name) { struct file_identity *identity; struct file_handle *iter; /* First check for a file with the same identity. */ - identity = fn_get_identity (filename); + identity = fn_get_identity (file_name); if (identity != NULL) { for (iter = file_handles; iter != NULL; iter = iter->next) @@ -156,7 +156,7 @@ fh_from_filename (const char *filename) /* Then check for a file with the same name. */ for (iter = file_handles; iter != NULL; iter = iter->next) if (!iter->deleted - && iter->referent == FH_REF_FILE && !strcmp (filename, iter->filename)) + && iter->referent == FH_REF_FILE && !strcmp (file_name, iter->file_name)) return iter; return NULL; @@ -194,16 +194,16 @@ fh_inline_file (void) /* Creates a new file handle named HANDLE_NAME, which must not be the name of an existing file handle. The new handle is - associated with file FILENAME and the given PROPERTIES. */ + associated with file FILE_NAME and the given PROPERTIES. */ struct file_handle * -fh_create_file (const char *handle_name, const char *filename, +fh_create_file (const char *handle_name, const char *file_name, const struct fh_properties *properties) { struct file_handle *handle; assert (fh_from_name (handle_name) == NULL); handle = create_handle (handle_name, FH_REF_FILE); - handle->filename = xstrdup (filename); - handle->identity = fn_get_identity (filename); + handle->file_name = xstrdup (file_name); + handle->identity = fn_get_identity (file_name); handle->mode = properties->mode; handle->record_width = properties->record_width; handle->tab_width = properties->tab_width; @@ -367,8 +367,8 @@ fh_is_open (const struct file_handle *handle) } /* 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 + by referring to a file name instead of a handle name, returns + the file name, enclosed in double quotes. Return value is owned by the file handle. Useful for printing error messages about use of file handles. */ @@ -387,10 +387,10 @@ fh_get_referent (const struct file_handle *handle) /* Returns the name of the file associated with HANDLE. */ const char * -fh_get_filename (const struct file_handle *handle) +fh_get_file_name (const struct file_handle *handle) { assert (handle->referent == FH_REF_FILE); - return handle->filename; + return handle->file_name; } /* Returns the mode of HANDLE. */ diff --git a/src/data/file-handle-def.h b/src/data/file-handle-def.h index c5c61ea8..9524bc03 100644 --- a/src/data/file-handle-def.h +++ b/src/data/file-handle-def.h @@ -53,7 +53,7 @@ void fh_done (void); /* Creating file handles. */ struct file_handle *fh_create_file (const char *handle_name, - const char *filename, + const char *file_name, const struct fh_properties *); struct file_handle *fh_create_scratch (const char *handle_name); const struct fh_properties *fh_default_properties (void); @@ -63,7 +63,7 @@ void fh_free (struct file_handle *); /* Finding file handles. */ struct file_handle *fh_from_name (const char *handle_name); -struct file_handle *fh_from_filename (const char *filename); +struct file_handle *fh_from_file_name (const char *file_name); struct file_handle *fh_inline_file (void); /* Generic properties of file handles. */ @@ -71,7 +71,7 @@ const char *fh_get_name (const struct file_handle *); enum fh_referent fh_get_referent (const struct file_handle *); /* Properties of FH_REF_FILE file handles. */ -const char *fh_get_filename (const struct file_handle *); +const char *fh_get_file_name (const struct file_handle *); enum fh_mode fh_get_mode (const struct file_handle *) ; /* Properties of FH_REF_FILE and FH_REF_INLINE file handles. */ diff --git a/src/data/file-name.c b/src/data/file-name.c index e0c6e7b4..dd512c03 100644 --- a/src/data/file-name.c +++ b/src/data/file-name.c @@ -65,7 +65,7 @@ fn_init (void) config_path = fn_getenv_default ("STAT_CONFIG_PATH", default_config_path); } -/* Functions for performing operations on filenames. */ +/* Functions for performing operations on file names. */ /* Substitutes $variables as defined by GETENV into TARGET. @@ -210,9 +210,9 @@ fn_tilde_expand (const char *input) malloc'd full name of the first file found, or NULL if none is found. - If PREFIX is non-NULL, then it is prefixed to each filename; - i.e., it looks like PREFIX/PATH_COMPONENT/NAME. This is not done - with absolute directories in the path. */ + If PREFIX is non-NULL, then it is prefixed to each file name; + i.e., it looks like PREFIX/PATH_COMPONENT/NAME. This is not + done with absolute directories in the path. */ char * fn_search_path (const char *base_name, const char *path_, const char *prefix) { @@ -271,22 +271,22 @@ fn_search_path (const char *base_name, const char *path_, const char *prefix) } /* fn_normalize(): This very OS-dependent routine canonicalizes - filename FN1. The filename should not need to be the name of an + file name FN1. The file name should not need to be the name of an existing file. Returns a malloc()'d copy of the canonical name. This function must always succeed; if it needs to bail out then it should return xstrdup(FN1). */ #ifdef unix char * -fn_normalize (const char *filename) +fn_normalize (const char *file_name) { const char *src; char *fn1, *fn2, *dest; int maxlen; - if (fn_is_special (filename)) - return xstrdup (filename); + if (fn_is_special (file_name)) + return xstrdup (file_name); - fn1 = fn_tilde_expand (filename); + fn1 = fn_tilde_expand (file_name); /* Follow symbolic links. */ for (;;) @@ -393,9 +393,9 @@ fn_normalize (const char *fn1) DWORD success; char *fn2; - /* Don't change special filenames. */ - if (is_special_filename (filename)) - return xstrdup (filename); + /* Don't change special file names. */ + if (is_special_file_name (file_name)) + return xstrdup (file_name); /* First find the required buffer length. */ len = GetFullPathName (fn1, 0, NULL, NULL); @@ -447,39 +447,39 @@ fn_normalize (const char *fn) } #endif /* not Lose32, Unix, or DJGPP */ -/* Returns the directory part of FILENAME, as a malloc()'d +/* Returns the directory part of FILE_NAME, as a malloc()'d string. */ char * -fn_dir_name (const char *filename) +fn_dir_name (const char *file_name) { const char *p; char *s; size_t len; - len = strlen (filename); - if (len == 1 && filename[0] == '/') - p = filename + 1; - else if (len && filename[len - 1] == '/') - p = buf_find_reverse (filename, len - 1, filename + len - 1, 1); + len = strlen (file_name); + if (len == 1 && file_name[0] == '/') + p = file_name + 1; + else if (len && file_name[len - 1] == '/') + p = buf_find_reverse (file_name, len - 1, file_name + len - 1, 1); else - p = strrchr (filename, '/'); + p = strrchr (file_name, '/'); if (p == NULL) - p = filename; + p = file_name; - s = xmalloc (p - filename + 1); - memcpy (s, filename, p - filename); - s[p - filename] = 0; + s = xmalloc (p - file_name + 1); + memcpy (s, file_name, p - file_name); + s[p - file_name] = 0; return s; } -/* Returns the extension part of FILENAME as a malloc()'d string. - If FILENAME does not have an extension, returns an empty +/* Returns the extension part of FILE_NAME as a malloc()'d string. + If FILE_NAME does not have an extension, returns an empty string. */ char * -fn_extension (const char *filename) +fn_extension (const char *file_name) { - const char *extension = strrchr (filename, '.'); + const char *extension = strrchr (file_name, '.'); if (extension == NULL) extension = ""; return xstrdup (extension); @@ -524,7 +524,7 @@ fn_get_cwd (void) /* Find out information about files. */ -/* Returns nonzero iff NAME specifies an absolute filename. */ +/* Returns nonzero iff NAME specifies an absolute file name. */ int fn_is_absolute (const char *name) { @@ -545,16 +545,16 @@ fn_is_absolute (const char *name) return 0; } -/* Returns 1 if the filename specified is a virtual file that doesn't - really exist on disk, 0 if it's a real filename. */ +/* Returns 1 if FILE_NAME is a virtual file that doesn't + really exist on disk, 0 if it's a real file name. */ int -fn_is_special (const char *filename) +fn_is_special (const char *file_name) { - if (!strcmp (filename, "-") || !strcmp (filename, "stdin") - || !strcmp (filename, "stdout") || !strcmp (filename, "stderr") + if (!strcmp (file_name, "-") || !strcmp (file_name, "stdin") + || !strcmp (file_name, "stdout") || !strcmp (file_name, "stderr") #ifdef unix - || filename[0] == '|' - || (*filename && filename[strlen (filename) - 1] == '|') + || file_name[0] == '|' + || (*file_name && file_name[strlen (file_name) - 1] == '|') #endif ) return 1; @@ -579,12 +579,12 @@ fn_exists (const char *name) #endif } -/* Returns the symbolic link value for FILENAME as a dynamically +/* Returns the symbolic link value for FILE_NAME as a dynamically allocated buffer, or a null pointer on failure. */ char * -fn_readlink (const char *filename) +fn_readlink (const char *file_name) { - return xreadlink (filename, 32); + return xreadlink (file_name, 32); } /* Environment variables. */ @@ -714,11 +714,11 @@ struct file_identity caller is responsible for freeing the structure with fn_free_identity() when finished. */ struct file_identity * -fn_get_identity (const char *filename) +fn_get_identity (const char *file_name) { struct stat s; - if (stat (filename, &s) == 0) + if (stat (file_name, &s) == 0) { struct file_identity *identity = xmalloc (sizeof *identity); identity->device = s.st_dev; @@ -752,7 +752,7 @@ fn_compare_file_identities (const struct file_identity *a, /* A file's identity. */ struct file_identity { - char *normalized_filename; /* File's normalized name. */ + char *normalized_file_name; /* File's normalized name. */ }; /* Returns a pointer to a dynamically allocated structure whose @@ -762,10 +762,10 @@ struct file_identity caller is responsible for freeing the structure with fn_free_identity() when finished. */ struct file_identity * -fn_get_identity (const char *filename) +fn_get_identity (const char *file_name) { struct file_identity *identity = xmalloc (sizeof *identity); - identity->normalized_filename = fn_normalize (filename); + identity->normalized_file_name = fn_normalize (file_name); return identity; } @@ -775,7 +775,7 @@ fn_free_identity (struct file_identity *identity) { if (identity != NULL) { - free (identity->normalized_filename); + free (identity->normalized_file_name); free (identity); } } @@ -785,6 +785,6 @@ int fn_compare_file_identities (const struct file_identity *a, const struct file_identity *b) { - return strcmp (a->normalized_filename, b->normalized_filename); + return strcmp (a->normalized_file_name, b->normalized_file_name); } #endif /* not unix */ diff --git a/src/data/file-name.h b/src/data/file-name.h index d4540ffe..427fa8dc 100644 --- a/src/data/file-name.h +++ b/src/data/file-name.h @@ -50,7 +50,7 @@ const char *fn_getenv_default (const char *variable, const char *def); FILE *fn_open (const char *fn, const char *mode); int fn_close (const char *fn, FILE *file); -struct file_identity *fn_get_identity (const char *filename); +struct file_identity *fn_get_identity (const char *file_name); void fn_free_identity (struct file_identity *); int fn_compare_file_identities (const struct file_identity *, const struct file_identity *); diff --git a/src/data/make-file.c b/src/data/make-file.c index f3cfdfbf..e6161448 100644 --- a/src/data/make-file.c +++ b/src/data/make-file.c @@ -36,15 +36,15 @@ #define P_tmpdir "/tmp" #endif -/* Creates a temporary file and stores its name in *FILENAME and +/* Creates a temporary file and stores its name in *FILE_NAME and a file descriptor for it in *FD. Returns success. Caller is - responsible for freeing *FILENAME. */ + responsible for freeing *FILE_NAME. */ int -make_temp_file (int *fd, char **filename) +make_temp_file (int *fd, char **file_name) { const char *parent_dir; - assert (filename != NULL); + assert (file_name != NULL); assert (fd != NULL); if (getenv ("TMPDIR") != NULL) @@ -52,26 +52,26 @@ make_temp_file (int *fd, char **filename) else parent_dir = P_tmpdir; - *filename = xmalloc (strlen (parent_dir) + 32); - sprintf (*filename, "%s/psppXXXXXX", parent_dir); - *fd = mkstemp (*filename); + *file_name = xmalloc (strlen (parent_dir) + 32); + sprintf (*file_name, "%s/psppXXXXXX", parent_dir); + *fd = mkstemp (*file_name); if (*fd < 0) { msg (ME, _("%s: Creating temporary file: %s."), - *filename, strerror (errno)); - free (*filename); - *filename = NULL; + *file_name, strerror (errno)); + free (*file_name); + *file_name = NULL; return 0; } return 1; } -/* Creates a temporary file and stores its name in *FILENAME and +/* Creates a temporary file and stores its name in *FILE_NAME and a file stream for it in *FP. Returns success. Caller is - responsible for freeing *FILENAME and for closing *FP */ + responsible for freeing *FILE_NAME and for closing *FP */ int -make_unique_file_stream (FILE **fp, char **filename) +make_unique_file_stream (FILE **fp, char **file_name) { static int serial = 0; const char *parent_dir; @@ -82,7 +82,7 @@ make_unique_file_stream (FILE **fp, char **filename) Need also to pass in the directory instead of using /tmp */ - assert (filename != NULL); + assert (file_name != NULL); assert (fp != NULL); if (getenv ("TMPDIR") != NULL) @@ -90,18 +90,18 @@ make_unique_file_stream (FILE **fp, char **filename) else parent_dir = P_tmpdir; - *filename = xmalloc (strlen (parent_dir) + 32); + *file_name = xmalloc (strlen (parent_dir) + 32); - sprintf (*filename, "%s/pspp%d.png", parent_dir, serial++); + sprintf (*file_name, "%s/pspp%d.png", parent_dir, serial++); - *fp = fopen(*filename, "w"); + *fp = fopen(*file_name, "w"); if (! *fp ) { - msg (ME, _("%s: Creating file: %s."), *filename, strerror (errno)); - free (*filename); - *filename = NULL; + msg (ME, _("%s: Creating file: %s."), *file_name, strerror (errno)); + free (*file_name); + *file_name = NULL; return 0; } diff --git a/src/data/make-file.h b/src/data/make-file.h index 88fa879b..68d6a2b9 100644 --- a/src/data/make-file.h +++ b/src/data/make-file.h @@ -21,15 +21,15 @@ #define MKFILE_H -/* Creates a temporary file and stores its name in *FILENAME and +/* Creates a temporary file and stores its name in *FILE_NAME and a file descriptor for it in *FD. Returns success. Caller is - responsible for freeing *FILENAME. */ -int make_temp_file (int *fd, char **filename); + responsible for freeing *FILE_NAME. */ +int make_temp_file (int *fd, char **file_name); -/* Creates a temporary file and stores its name in *FILENAME and +/* Creates a temporary file and stores its name in *FILE_NAME and a file stream for it in *FP. Returns success. Caller is - responsible for freeing *FILENAME. */ -int make_unique_file_stream (FILE **fp, char **filename) ; + responsible for freeing *FILE_NAME. */ +int make_unique_file_stream (FILE **fp, char **file_name) ; #endif /* make-file.h */ diff --git a/src/data/por-file-reader.c b/src/data/por-file-reader.c index 3f385223..0824bb31 100644 --- a/src/data/por-file-reader.c +++ b/src/data/por-file-reader.c @@ -86,17 +86,17 @@ static void error (struct pfm_reader *r, const char *msg, ...) { struct error e; - const char *filename; + const char *file_name; char *title; va_list args; e.class = ME; - e.where.filename = NULL; + e.where.file_name = NULL; e.where.line_number = 0; - filename = fh_get_filename (r->fh); - e.title = title = pool_alloc (r->pool, strlen (filename) + 80); + file_name = fh_get_file_name (r->fh); + e.title = title = pool_alloc (r->pool, strlen (file_name) + 80); sprintf (title, _("portable file %s corrupt at offset %ld: "), - filename, ftell (r->file)); + file_name, ftell (r->file)); va_start (args, msg); err_vmsg (&e, msg, args); @@ -172,7 +172,7 @@ pfm_open_reader (struct file_handle *fh, struct dictionary **dict, if (setjmp (r->bail_out)) goto error; r->fh = fh; - r->file = pool_fopen (r->pool, fh_get_filename (r->fh), "rb"); + r->file = pool_fopen (r->pool, fh_get_file_name (r->fh), "rb"); r->weight_index = -1; r->trans = NULL; r->var_cnt = 0; @@ -185,7 +185,7 @@ pfm_open_reader (struct file_handle *fh, struct dictionary **dict, { msg (ME, _("An error occurred while opening \"%s\" for reading " "as a portable file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); goto error; } @@ -403,7 +403,7 @@ read_header (struct pfm_reader *r) for (i = 0; i < 8; i++) if (!match (r, "SPSSPORT"[i])) { - msg (SE, _("%s: Not a portable file."), fh_get_filename (r->fh)); + msg (SE, _("%s: Not a portable file."), fh_get_file_name (r->fh)); longjmp (r->bail_out, 1); } } diff --git a/src/data/por-file-writer.c b/src/data/por-file-writer.c index 98b7b764..202d4c28 100644 --- a/src/data/por-file-writer.c +++ b/src/data/por-file-writer.c @@ -105,7 +105,7 @@ pfm_open_writer (struct file_handle *fh, struct dictionary *dict, mode = S_IRUSR | S_IRGRP | S_IROTH; if (opts.create_writeable) mode |= S_IWUSR | S_IWGRP | S_IWOTH; - fd = open (fh_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode); + fd = open (fh_get_file_name (fh), O_WRONLY | O_CREAT | O_TRUNC, mode); if (fd < 0) goto open_error; @@ -162,7 +162,7 @@ pfm_open_writer (struct file_handle *fh, struct dictionary *dict, open_error: msg (ME, _("An error occurred while opening \"%s\" for writing " "as a portable file: %s."), - fh_get_filename (fh), strerror (errno)); + fh_get_file_name (fh), strerror (errno)); goto error; } @@ -445,7 +445,7 @@ pfm_close_writer (struct pfm_writer *w) if (!ok) msg (ME, _("An I/O error occurred writing portable file \"%s\"."), - fh_get_filename (w->fh)); + fh_get_file_name (w->fh)); } fh_close (w->fh, "portable file", "we"); diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index d5fe5c7c..7ccf969b 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -127,7 +127,7 @@ corrupt_msg (int class, const char *format,...) va_list args; e.class = class; - e.where.filename = NULL; + e.where.file_name = NULL; e.where.line_number = 0; e.title = _("corrupt system file: "); @@ -145,9 +145,9 @@ sfm_close_reader (struct sfm_reader *r) if (r->file) { - if (fn_close (fh_get_filename (r->fh), r->file) == EOF) + if (fn_close (fh_get_file_name (r->fh), r->file) == EOF) msg (ME, _("%s: Closing system file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); r->file = NULL; } @@ -214,7 +214,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, /* Create and initialize reader. */ r = xmalloc (sizeof *r); r->fh = fh; - r->file = fn_open (fh_get_filename (fh), "rb"); + r->file = fn_open (fh_get_file_name (fh), "rb"); r->reverse_endian = 0; r->fix_specials = 0; @@ -239,7 +239,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, { msg (ME, _("An error occurred while opening \"%s\" for reading " "as a system file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); goto error; } @@ -256,7 +256,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, 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)."), - fh_get_filename (r->fh), r->weight_idx, r->value_cnt)); + fh_get_file_name (r->fh), r->weight_idx, r->value_cnt)); weight_var = var_by_idx[r->weight_idx]; @@ -264,10 +264,10 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, if (weight_var == NULL) lose ((ME, _("%s: Weighting variable may not be a continuation of " - "a long string variable."), fh_get_filename (fh))); + "a long string variable."), fh_get_file_name (fh))); else if (weight_var->type == ALPHA) lose ((ME, _("%s: Weighting variable may not be a string variable."), - fh_get_filename (fh))); + fh_get_file_name (fh))); dict_set_weight (*dict, weight_var); } @@ -294,7 +294,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, lose ((ME, _("%s: Orphaned variable index record (type 4). Type 4 " "records must always immediately follow type 3 " "records."), - fh_get_filename (r->fh))); + fh_get_file_name (r->fh))); case 6: if (!read_documents (r, *dict)) @@ -324,7 +324,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, bytes = data.size * data.count; if (bytes < data.size || bytes < data.count) lose ((ME, "%s: Record type %d subtype %d too large.", - fh_get_filename (r->fh), rec_type, data.subtype)); + fh_get_file_name (r->fh), rec_type, data.subtype)); switch (data.subtype) { @@ -351,7 +351,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, { msg (MW, _("%s: Invalid subrecord length. " "Record: 7; Subrecord: 11"), - fh_get_filename (r->fh)); + fh_get_file_name (r->fh)); skip = 1; } @@ -405,14 +405,14 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, { msg (MW, _("%s: Trailing garbage in long variable " "name map."), - fh_get_filename (r->fh)); + fh_get_file_name (r->fh)); break; } if (!var_is_valid_name (long_name, false)) { msg (MW, _("%s: Long variable mapping to invalid " "variable name `%s'."), - fh_get_filename (r->fh), long_name); + fh_get_file_name (r->fh), long_name); break; } @@ -422,7 +422,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, { msg (MW, _("%s: Long variable mapping for " "nonexistent variable %s."), - fh_get_filename (r->fh), short_name); + fh_get_file_name (r->fh), short_name); break; } @@ -431,7 +431,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, NULL != dict_lookup_var (*dict, long_name)) lose ((ME, _("%s: Duplicate long variable name `%s' " "within system file."), - fh_get_filename (r->fh), long_name)); + fh_get_file_name (r->fh), long_name)); /* Set long name. @@ -458,7 +458,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, default: msg (MW, _("%s: Unrecognized record type 7, subtype %d " "encountered in system file."), - fh_get_filename (r->fh), data.subtype); + fh_get_file_name (r->fh), data.subtype); skip = 1; } @@ -482,7 +482,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, default: corrupt_msg(MW, _("%s: Unrecognized record type %d."), - fh_get_filename (r->fh), rec_type); + fh_get_file_name (r->fh), rec_type); } } @@ -515,7 +515,7 @@ read_machine_int32_info (struct sfm_reader *r, int size, int count) if (size != sizeof (int32_t) || count != 8) lose ((ME, _("%s: Bad size (%d) or count (%d) field on record type 7, " "subtype 3. Expected size %d, count 8."), - fh_get_filename (r->fh), size, count, sizeof (int32_t))); + fh_get_file_name (r->fh), size, count, sizeof (int32_t))); assertive_buf_read (r, data, sizeof data, 0); if (r->reverse_endian) @@ -527,7 +527,7 @@ read_machine_int32_info (struct sfm_reader *r, int size, int count) lose ((ME, _("%s: Floating-point representation in system file is not " "IEEE-754. PSPP cannot convert between floating-point " "formats."), - fh_get_filename (r->fh))); + fh_get_file_name (r->fh))); #else #error Add support for your floating-point format. #endif @@ -542,7 +542,7 @@ read_machine_int32_info (struct sfm_reader *r, int size, int count) if (file_bigendian ^ (data[6] == 1)) lose ((ME, _("%s: File-indicated endianness (%s) does not match " "endianness intuited from file header (%s)."), - fh_get_filename (r->fh), + fh_get_file_name (r->fh), file_bigendian ? _("big-endian") : _("little-endian"), data[6] == 1 ? _("big-endian") : (data[6] == 2 ? _("little-endian") : _("unknown")))); @@ -551,7 +551,7 @@ read_machine_int32_info (struct sfm_reader *r, int size, int count) if (data[7] != 2 && data[7] != 3) lose ((ME, _("%s: File-indicated character representation code (%s) is " "not ASCII."), - fh_get_filename (r->fh), + fh_get_file_name (r->fh), (data[7] == 1 ? "EBCDIC" : (data[7] == 4 ? _("DEC Kanji") : _("Unknown"))))); @@ -571,7 +571,7 @@ read_machine_flt64_info (struct sfm_reader *r, int size, int count) 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."), - fh_get_filename (r->fh), size, count, sizeof (flt64))); + fh_get_file_name (r->fh), size, count, sizeof (flt64))); assertive_buf_read (r, data, sizeof data, 0); if (r->reverse_endian) @@ -588,7 +588,7 @@ read_machine_flt64_info (struct sfm_reader *r, int size, int count) "for at least one of the three system values. SYSMIS: " "indicated %g, expected %g; HIGHEST: %g, %g; LOWEST: " "%g, %g."), - fh_get_filename (r->fh), (double) data[0], (double) SYSMIS, + fh_get_file_name (r->fh), (double) data[0], (double) SYSMIS, (double) data[1], (double) FLT64_MAX, (double) data[2], (double) second_lowest_flt64); } @@ -613,7 +613,7 @@ read_header (struct sfm_reader *r, 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."), - fh_get_filename (r->fh))); + fh_get_file_name (r->fh))); /* Check eye-category.her string. */ memcpy (prod_name, hdr.prod_name, sizeof hdr.prod_name); @@ -655,7 +655,7 @@ read_header (struct sfm_reader *r, 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."), - fh_get_filename (r->fh), hdr.layout_code)); + fh_get_file_name (r->fh), hdr.layout_code)); r->reverse_endian = 1; bswap_int32 (&hdr.case_size); @@ -682,13 +682,13 @@ read_header (struct sfm_reader *r, 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."), - fh_get_filename (r->fh), (long) r->case_cnt, INT_MAX / 2)); + fh_get_file_name (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."), - fh_get_filename (r->fh), r->bias); + fh_get_file_name (r->fh), r->bias); /* Make a file label only on the condition that the given label is not all spaces or nulls. */ @@ -813,7 +813,7 @@ read_variables (struct sfm_reader *r, if (sv.type != -1) lose ((ME, _("%s: position %d: String variable does not have " "proper number of continuation records."), - fh_get_filename (r->fh), i)); + fh_get_file_name (r->fh), i)); r->vars[i].width = -1; @@ -824,25 +824,25 @@ read_variables (struct sfm_reader *r, else if (sv.type == -1) lose ((ME, _("%s: position %d: Superfluous long string continuation " "record."), - fh_get_filename (r->fh), i)); + fh_get_file_name (r->fh), i)); /* Check fields for validity. */ if (sv.type < 0 || sv.type > 255) lose ((ME, _("%s: position %d: Bad variable type code %d."), - fh_get_filename (r->fh), i, sv.type)); + fh_get_file_name (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."), fh_get_filename (r->fh), i)); + "0 or 1."), fh_get_file_name (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."), fh_get_filename (r->fh), i)); + "-3, -2, 0, 1, 2, or 3."), fh_get_file_name (r->fh), i)); /* Copy first character of variable name. */ if (sv.name[0] == '@' || sv.name[0] == '#') lose ((ME, _("%s: position %d: Variable name begins with invalid " "character."), - fh_get_filename (r->fh), i)); + fh_get_file_name (r->fh), i)); name[0] = sv.name[0]; @@ -860,13 +860,13 @@ read_variables (struct sfm_reader *r, if ( ! var_is_plausible_name(name, false) ) lose ((ME, _("%s: Invalid variable name `%s' within system file."), - fh_get_filename (r->fh), name)); + fh_get_file_name (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."), - fh_get_filename (r->fh), name)); + fh_get_file_name (r->fh), name)); var_set_short_name (vv, vv->name); @@ -890,7 +890,7 @@ read_variables (struct sfm_reader *r, if (len < 0 || len > 255) lose ((ME, _("%s: Variable %s indicates variable label of invalid " "length %d."), - fh_get_filename (r->fh), vv->name, len)); + fh_get_file_name (r->fh), vv->name, len)); if ( len != 0 ) { @@ -911,7 +911,7 @@ read_variables (struct sfm_reader *r, if (vv->width > MAX_SHORT_STRING) lose ((ME, _("%s: Long string variable %s may not have missing " "values."), - fh_get_filename (r->fh), vv->name)); + fh_get_file_name (r->fh), vv->name)); assertive_buf_read (r, mv, sizeof *mv * mv_cnt, 0); @@ -932,7 +932,7 @@ read_variables (struct sfm_reader *r, if (vv->type == ALPHA) lose ((ME, _("%s: String variable %s may not have missing " "values specified as a range."), - fh_get_filename (r->fh), vv->name)); + fh_get_file_name (r->fh), vv->name)); if (mv[0] == r->lowest) mv_add_num_range (&vv->miss, LOWEST, mv[1]); @@ -959,12 +959,12 @@ read_variables (struct sfm_reader *r, if (long_string_count != 0) lose ((ME, _("%s: Long string continuation records omitted at end of " "dictionary."), - fh_get_filename (r->fh))); + fh_get_file_name (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."), - fh_get_filename (r->fh), r->value_cnt, next_value); + fh_get_file_name (r->fh), r->value_cnt, next_value); return 1; @@ -982,13 +982,13 @@ parse_format_spec (struct sfm_reader *r, int32_t s, f->type = translate_fmt ((s >> 16) & 0xff); if (f->type == -1) lose ((ME, _("%s: Bad format specifier byte (%d)."), - fh_get_filename (r->fh), (s >> 16) & 0xff)); + fh_get_file_name (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."), - fh_get_filename (r->fh), + fh_get_file_name (r->fh), v->type == ALPHA ? _("String") : _("Numeric"), v->name, formats[f->type].cat & FCAT_STRING ? _("string") : _("numeric"), @@ -1041,7 +1041,7 @@ read_value_labels (struct sfm_reader *r, if ( n_labels >= ((int32_t) ~0) / sizeof *labels) { corrupt_msg(MW, _("%s: Invalid number of labels: %d. Ignoring labels."), - fh_get_filename (r->fh), n_labels); + fh_get_file_name (r->fh), n_labels); n_labels = 0; } @@ -1084,7 +1084,7 @@ read_value_labels (struct sfm_reader *r, if (rec_type != 4) lose ((ME, _("%s: Variable index record (type 4) does not immediately " "follow value label record (type 3) as it should."), - fh_get_filename (r->fh))); + fh_get_file_name (r->fh))); } /* Read number of variables associated with value label from type 4 @@ -1095,7 +1095,7 @@ read_value_labels (struct sfm_reader *r, 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)."), - fh_get_filename (r->fh), n_vars, dict_get_var_cnt (dict))); + fh_get_file_name (r->fh), n_vars, dict_get_var_cnt (dict))); /* Read the list of variables. */ var = xnmalloc (n_vars, sizeof *var); @@ -1111,7 +1111,7 @@ read_value_labels (struct sfm_reader *r, 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)."), - fh_get_filename (r->fh), var_idx, r->value_cnt)); + fh_get_file_name (r->fh), var_idx, r->value_cnt)); /* Make sure it's a real variable. */ v = var_by_idx[var_idx - 1]; @@ -1119,11 +1119,11 @@ read_value_labels (struct sfm_reader *r, lose ((ME, _("%s: Variable index associated with value label (%d) " "refers to a continuation of a string variable, not to " "an actual variable."), - fh_get_filename (r->fh), var_idx)); + fh_get_file_name (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)."), - fh_get_filename (r->fh), v->name)); + fh_get_file_name (r->fh), v->name)); /* Add it to the list of variables. */ var[i] = v; @@ -1135,7 +1135,7 @@ read_value_labels (struct sfm_reader *r, 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."), - fh_get_filename (r->fh), + fh_get_file_name (r->fh), var[0]->name, var[0]->type == ALPHA ? _("string") : _("numeric"), var[i]->name, var[i]->type == ALPHA ? _("string") : _("numeric"))); @@ -1175,11 +1175,11 @@ read_value_labels (struct sfm_reader *r, if (var[0]->type == NUMERIC) msg (MW, _("%s: File contains duplicate label for value %g for " "variable %s."), - fh_get_filename (r->fh), label->value.f, v->name); + fh_get_file_name (r->fh), label->value.f, v->name); else msg (MW, _("%s: File contains duplicate label for value `%.*s' " "for variable %s."), - fh_get_filename (r->fh), v->width, label->value.s, v->name); + fh_get_file_name (r->fh), v->width, label->value.s, v->name); } } @@ -1220,10 +1220,10 @@ buf_read (struct sfm_reader *r, void *buf, size_t byte_cnt, size_t min_alloc) { if (ferror (r->file)) msg (ME, _("%s: Reading system file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); else corrupt_msg (ME, _("%s: Unexpected end of file."), - fh_get_filename (r->fh)); + fh_get_file_name (r->fh)); r->ok = false; return NULL; } @@ -1239,7 +1239,7 @@ buf_unread(struct sfm_reader *r, size_t byte_cnt) if ( 0 != fseek(r->file, -byte_cnt, SEEK_CUR)) { msg (ME, _("%s: Seeking system file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); } } @@ -1255,13 +1255,13 @@ read_documents (struct sfm_reader *r, struct dictionary *dict) if (dict_get_documents (dict) != NULL) lose ((ME, _("%s: System file contains multiple " "type 6 (document) records."), - fh_get_filename (r->fh))); + fh_get_file_name (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."), - fh_get_filename (r->fh), (long) line_cnt)); + fh_get_file_name (r->fh), (long) line_cnt)); documents = buf_read (r, NULL, 80 * line_cnt, line_cnt * 80 + 1); /* FIXME? Run through asciify. */ @@ -1294,7 +1294,7 @@ buffer_input (struct sfm_reader *r) if (ferror (r->file)) { msg (ME, _("%s: Error reading file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); r->ok = false; return 0; } @@ -1334,14 +1334,14 @@ read_compressed_data (struct sfm_reader *r, flt64 *buf) return 0; lose ((ME, _("%s: Compressed data is corrupted. Data ends " "in partial case."), - fh_get_filename (r->fh))); + fh_get_file_name (r->fh))); case 253: /* Code 253 indicates that the value is stored explicitly following the instruction bytes. */ if (r->ptr == NULL || r->ptr >= r->end) if (!buffer_input (r)) lose ((ME, _("%s: Unexpected end of file."), - fh_get_filename (r->fh))); + fh_get_file_name (r->fh))); memcpy (buf++, r->ptr++, sizeof *buf); if (buf >= buf_end) goto success; @@ -1382,7 +1382,7 @@ read_compressed_data (struct sfm_reader *r, flt64 *buf) { if (buf_beg != buf) lose ((ME, _("%s: Unexpected end of file."), - fh_get_filename (r->fh))); + fh_get_file_name (r->fh))); else return 0; } @@ -1503,13 +1503,13 @@ fread_ok (struct sfm_reader *r, void *buffer, size_t byte_cnt) if (ferror (r->file)) { msg (ME, _("%s: Reading system file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); r->ok = false; } else if (read_bytes != 0) { msg (ME, _("%s: Partial record at end of system file."), - fh_get_filename (r->fh)); + fh_get_file_name (r->fh)); r->ok = false; } return 0; diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index 5ba525cb..690a4859 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -145,7 +145,7 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d, mode = S_IRUSR | S_IRGRP | S_IROTH; if (opts.create_writeable) mode |= S_IWUSR | S_IWGRP | S_IWOTH; - fd = open (fh_get_filename (fh), O_WRONLY | O_CREAT | O_TRUNC, mode); + fd = open (fh_get_file_name (fh), O_WRONLY | O_CREAT | O_TRUNC, mode); if (fd < 0) goto open_error; @@ -246,7 +246,7 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d, open_error: msg (ME, _("Error opening \"%s\" for writing as a system file: %s."), - fh_get_filename (fh), strerror (errno)); + fh_get_file_name (fh), strerror (errno)); goto error; } @@ -893,7 +893,7 @@ sfm_close_writer (struct sfm_writer *w) if (!ok) msg (ME, _("An I/O error occurred writing system file \"%s\"."), - fh_get_filename (w->fh)); + fh_get_file_name (w->fh)); } fh_close (w->fh, "system file", "we"); diff --git a/src/language/data-io/data-reader.c b/src/language/data-io/data-reader.c index 22e15f97..988735dd 100644 --- a/src/language/data-io/data-reader.c +++ b/src/language/data-io/data-reader.c @@ -71,7 +71,7 @@ dfm_close_reader (struct dfm_reader *r) return; is_inline = r->fh == fh_inline_file (); - file_name = is_inline ? NULL : xstrdup (fh_get_filename (r->fh)); + file_name = is_inline ? NULL : xstrdup (fh_get_file_name (r->fh)); still_open = fh_close (r->fh, "data file", "rs"); if (still_open) { @@ -123,13 +123,13 @@ dfm_open_reader (struct file_handle *fh) r->eof_cnt = 0; if (fh != fh_inline_file ()) { - r->where.filename = fh_get_filename (fh); + r->where.file_name = fh_get_file_name (fh); r->where.line_number = 0; - r->file = fn_open (fh_get_filename (fh), "rb"); + r->file = fn_open (fh_get_file_name (fh), "rb"); if (r->file == NULL) { msg (ME, _("Could not open \"%s\" for reading as a data file: %s."), - fh_get_filename (r->fh), strerror (errno)); + fh_get_file_name (r->fh), strerror (errno)); fh_close (fh,"data file", "rs"); free (r); return NULL; @@ -387,7 +387,7 @@ dfm_column_start (struct dfm_reader *r) return r->pos + 1; } -/* Pushes the filename and line number on the fn/ln stack. */ +/* Pushes the file name and line number on the fn/ln stack. */ void dfm_push (struct dfm_reader *r) { @@ -395,7 +395,7 @@ dfm_push (struct dfm_reader *r) err_push_file_locator (&r->where); } -/* Pops the filename and line number from the fn/ln stack. */ +/* Pops the file name and line number from the fn/ln stack. */ void dfm_pop (struct dfm_reader *r) { diff --git a/src/language/data-io/data-writer.c b/src/language/data-io/data-writer.c index 9aba2aaf..652d522f 100644 --- a/src/language/data-io/data-writer.c +++ b/src/language/data-io/data-writer.c @@ -54,14 +54,14 @@ dfm_open_writer (struct file_handle *fh) w = *aux = xmalloc (sizeof *w); w->fh = fh; - w->file = fn_open (fh_get_filename (w->fh), "wb"); + w->file = fn_open (fh_get_file_name (w->fh), "wb"); w->bounce = NULL; if (w->file == NULL) { msg (ME, _("An error occurred while opening \"%s\" for writing " "as a data file: %s."), - fh_get_filename (w->fh), strerror (errno)); + fh_get_file_name (w->fh), strerror (errno)); goto error; } diff --git a/src/language/data-io/file-handle.q b/src/language/data-io/file-handle.q index e44afbc7..94430627 100644 --- a/src/language/data-io/file-handle.q +++ b/src/language/data-io/file-handle.q @@ -158,7 +158,7 @@ referent_name (enum fh_referent referent) } } -/* Parses a file handle name, which may be a filename as a string +/* Parses a file handle name, which may be a file name as a string or a file handle name as an identifier. The allowed types of file handle are restricted to those in REFERENT_MASK. Returns the file handle when successful, a null pointer on failure. */ @@ -181,14 +181,14 @@ fh_parse (enum fh_referent referent_mask) if (token == T_ID) handle = fh_from_name (tokid); if (handle == NULL) - handle = fh_from_filename (ds_c_str (&tokstr)); + handle = fh_from_file_name (ds_c_str (&tokstr)); if (handle == NULL) { if (token != T_ID || tokid[0] != '#' || get_syntax () != ENHANCED) { - char *filename = ds_c_str (&tokstr); - char *handle_name = xasprintf ("\"%s\"", filename); - handle = fh_create_file (handle_name, filename, + char *file_name = ds_c_str (&tokstr); + char *handle_name = xasprintf ("\"%s\"", file_name); + handle = fh_create_file (handle_name, file_name, fh_default_properties ()); free (handle_name); } diff --git a/src/language/dictionary/sys-file-info.c b/src/language/dictionary/sys-file-info.c index 5421a3c1..d3414cb2 100644 --- a/src/language/dictionary/sys-file-info.c +++ b/src/language/dictionary/sys-file-info.c @@ -99,7 +99,7 @@ cmd_sysfile_info (void) t = tab_create (2, 9, 0); tab_vline (t, TAL_GAP, 1, 0, 8); tab_text (t, 0, 0, TAB_LEFT, _("File:")); - tab_text (t, 1, 0, TAB_LEFT, fh_get_filename (h)); + tab_text (t, 1, 0, TAB_LEFT, fh_get_file_name (h)); tab_text (t, 0, 1, TAB_LEFT, _("Label:")); { const char *label = dict_get_label (d); diff --git a/src/language/line-buffer.c b/src/language/line-buffer.c index aeb99e0a..24b09b8c 100644 --- a/src/language/line-buffer.c +++ b/src/language/line-buffer.c @@ -45,7 +45,7 @@ struct getl_source struct getl_source *next; /* Next file in list. */ /* Current location. */ - char *fn; /* Filename. */ + char *fn; /* File name. */ int ln; /* Line number. */ enum getl_source_type @@ -228,8 +228,8 @@ getl_append_syntax_file (const char *fn) append_source (create_syntax_file_source (fn)); } -/* Inserts the given file with filename FN into the current file after - the current line. */ +/* Inserts the given file with name FN into the current file + after the current line. */ void getl_include_syntax_file (const char *fn) { @@ -427,7 +427,7 @@ err_location (struct file_locator *f) if (nfile_loc) *f = *file_loc[nfile_loc - 1]; else - getl_location (&f->filename, &f->line_number); + getl_location (&f->file_name, &f->line_number); } /* Reads a line from syntax file source S into LINE. diff --git a/src/language/stats/regression.q b/src/language/stats/regression.q index d5536e80..737a25fd 100644 --- a/src/language/stats/regression.q +++ b/src/language/stats/regression.q @@ -671,7 +671,7 @@ subcommand_export (int export, pspp_linreg_cache * c) { assert (c != NULL); assert (model_file != NULL); - fp = fopen (fh_get_filename (model_file), "w"); + fp = fopen (fh_get_file_name (model_file), "w"); assert (fp != NULL); fprintf (fp, "%s", reg_preamble); reg_print_getvar (fp, c); diff --git a/src/language/utilities/include.c b/src/language/utilities/include.c index a148d6fa..42614f1b 100644 --- a/src/language/utilities/include.c +++ b/src/language/utilities/include.c @@ -37,10 +37,10 @@ cmd_include (void) if (lex_match_id ("FILE")) lex_match ('='); - /* Filename can be identifier or string. */ + /* File name can be identifier or string. */ if (token != T_ID && token != T_STRING) { - lex_error (_("expecting filename")); + lex_error (_("expecting file name")); return CMD_CASCADING_FAILURE; } getl_include_syntax_file (ds_c_str (&tokstr)); diff --git a/src/language/utilities/permissions.c b/src/language/utilities/permissions.c index 940b2d2b..b0a8e27c 100644 --- a/src/language/utilities/permissions.c +++ b/src/language/utilities/permissions.c @@ -37,7 +37,7 @@ enum PER {PER_RO, PER_RW}; -int change_permissions(const char *filename, enum PER per); +int change_permissions(const char *file_name, enum PER per); /* Parses the PERMISSIONS command. */ @@ -92,7 +92,7 @@ cmd_permissions (void) int -change_permissions(const char *filename, enum PER per) +change_permissions(const char *file_name, enum PER per) { struct stat buf; mode_t mode; @@ -104,10 +104,10 @@ change_permissions(const char *filename, enum PER per) } - if ( -1 == stat(filename, &buf) ) + if ( -1 == stat(file_name, &buf) ) { const int errnum = errno; - msg(ME,_("Cannot stat %s: %s"), filename, strerror(errnum)); + msg(ME,_("Cannot stat %s: %s"), file_name, strerror(errnum)); return 0; } @@ -116,11 +116,11 @@ change_permissions(const char *filename, enum PER per) else mode = buf.st_mode & ~( S_IWOTH | S_IWUSR | S_IWGRP ); - if ( -1 == chmod(filename, mode)) + if ( -1 == chmod(file_name, mode)) { const int errnum = errno; - msg(ME,_("Cannot change mode of %s: %s"), filename, strerror(errnum)); + msg(ME,_("Cannot change mode of %s: %s"), file_name, strerror(errnum)); return 0; } diff --git a/src/libpspp/message.h b/src/libpspp/message.h index 4c73b3e1..3422a6ed 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -36,7 +36,7 @@ enum /* A file location. */ struct file_locator { - const char *filename; /* Filename. */ + const char *file_name; /* File name. */ int line_number; /* Line number. */ }; diff --git a/src/libpspp/pool.c b/src/libpspp/pool.c index 105937b9..a0dc99e3 100644 --- a/src/libpspp/pool.c +++ b/src/libpspp/pool.c @@ -621,18 +621,18 @@ pool_add_subpool (struct pool *pool, struct pool *subpool) subpool->parent = pool; } -/* Opens file FILENAME with mode MODE and returns a handle to it +/* Opens file FILE_NAME with mode MODE and returns a handle to it if successful or a null pointer if not. The file will be closed automatically when POOL is destroyed, or it may be closed explicitly in advance using pool_fclose(), or detached from the pool with pool_detach_file(). */ FILE * -pool_fopen (struct pool *pool, const char *filename, const char *mode) +pool_fopen (struct pool *pool, const char *file_name, const char *mode) { FILE *f; - assert (pool && filename && mode); - f = fopen (filename, mode); + assert (pool && file_name && mode); + f = fopen (file_name, mode); if (f == NULL) return NULL; diff --git a/src/message.c b/src/message.c index dbd3c638..e6a8f76b 100644 --- a/src/message.c +++ b/src/message.c @@ -145,7 +145,7 @@ err_vmsg (const struct error *e, const char *format, va_list args) enum { ERR_IN_PROCEDURE = 01, /* 1=Display name of current procedure. */ - ERR_WITH_FILE = 02, /* 1=Display filename and line number. */ + ERR_WITH_FILE = 02, /* 1=Display file name and line number. */ }; /* Describes one class of error. */ @@ -176,9 +176,9 @@ err_vmsg (const struct error *e, const char *format, va_list args) assert (format != NULL); ds_init (&msg, 64); - if (e->where.filename && (error_classes[e->class].flags & ERR_WITH_FILE)) + if (e->where.file_name && (error_classes[e->class].flags & ERR_WITH_FILE)) { - ds_printf (&msg, "%s:", e->where.filename); + ds_printf (&msg, "%s:", e->where.file_name); if (e->where.line_number != -1) ds_printf (&msg, "%d:", e->where.line_number); ds_putc (&msg, ' '); diff --git a/src/output/chart.h b/src/output/chart.h index 98052f28..05f14af6 100644 --- a/src/output/chart.h +++ b/src/output/chart.h @@ -47,7 +47,7 @@ struct chart { #else void *lp; #endif - char *filename; + char *file_name; FILE *file; /* The geometry of the chart diff --git a/src/output/html.c b/src/output/html.c index fd25285a..d5b4f5d4 100644 --- a/src/output/html.c +++ b/src/output/html.c @@ -190,7 +190,7 @@ html_submit (struct outp_driver *this, struct som_entity *s) output_tab_table ( this, (struct tab_table *) s->ext); break; case SOM_CHART: - link_image (x->file, ((struct chart *)s->ext)->filename); + link_image (x->file, ((struct chart *)s->ext)->file_name); break; default: abort (); @@ -345,7 +345,7 @@ html_initialise_chart(struct outp_driver *d UNUSED, struct chart *ch) FILE *fp; - make_unique_file_stream(&fp, &ch->filename); + make_unique_file_stream(&fp, &ch->file_name); #ifdef NO_CHARTS ch->lp = 0; @@ -359,7 +359,7 @@ html_initialise_chart(struct outp_driver *d UNUSED, struct chart *ch) static void html_finalise_chart(struct outp_driver *d UNUSED, struct chart *ch) { - free(ch->filename); + free(ch->file_name); } diff --git a/src/output/postscript.c b/src/output/postscript.c index 6c9cc860..3b655e29 100644 --- a/src/output/postscript.c +++ b/src/output/postscript.c @@ -424,7 +424,7 @@ handle_option (struct outp_driver *this, const char *key, } /* Looks for a PostScript font file or config file in all the - appropriate places. Returns the filename on success, NULL on + appropriate places. Returns the file name on success, NULL on failure. */ static char * find_ps_file (const char *name) diff --git a/src/ui/gui/menu-actions.c b/src/ui/gui/menu-actions.c index 02718370..31800452 100644 --- a/src/ui/gui/menu-actions.c +++ b/src/ui/gui/menu-actions.c @@ -142,24 +142,24 @@ on_open1_activate (GtkMenuItem *menuitem, GtkWidget *data_sheet = get_widget_assert(xml, "data_sheet"); GtkWidget *var_sheet = get_widget_assert(xml, "variable_sheet"); - gchar *filename; + gchar *file_name; g_assert(data_sheet); g_assert(var_sheet); - filename = gtk_file_chooser_get_filename + file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); if ( psppire_handle ) fh_free(psppire_handle); psppire_handle = - fh_create_file (handle_name, filename, fh_default_properties()); + fh_create_file (handle_name, file_name, fh_default_properties()); if ( !psppire_handle ) { g_warning("Cannot read handle for reading system file \"%s\"\n", - filename); + file_name); continue; } @@ -187,9 +187,9 @@ on_open1_activate (GtkMenuItem *menuitem, psppire_case_array_clear(data_store->cases); - psppire_set_window_title(basename(filename)); + psppire_set_window_title(basename(file_name)); - g_free (filename); + g_free (file_name); { const int ni = dict_get_next_value_idx(the_dictionary->dict); @@ -238,18 +238,18 @@ recreate_save_handle(struct file_handle **handle) if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { - char *filename = gtk_file_chooser_get_filename + char *file_name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); #if 0 if ( *handle ) destroy_file_handle(*handle, 0); #endif - *handle = fh_create_file (handle_name, filename, fh_default_properties()); + *handle = fh_create_file (handle_name, file_name, fh_default_properties()); - psppire_set_window_title(basename(filename)); + psppire_set_window_title(basename(file_name)); - g_free (filename); + g_free (file_name); } gtk_widget_destroy (dialog); diff --git a/src/ui/gui/message-dialog.c b/src/ui/gui/message-dialog.c index 73e147d6..693db49f 100644 --- a/src/ui/gui/message-dialog.c +++ b/src/ui/gui/message-dialog.c @@ -149,7 +149,7 @@ verbose_msg (int level, const char *format, ...) void err_location (struct file_locator *f) { - f->filename = 0; + f->file_name = 0; f->line_number = -1; } -- 2.30.2