static void put_cmp_number (struct sfm_writer *, double);
static void put_cmp_string (struct sfm_writer *, const void *, size_t);
-bool write_error (const struct sfm_writer *);
-bool close_writer (struct sfm_writer *);
+static bool write_error (const struct sfm_writer *);
+static bool close_writer (struct sfm_writer *);
/* Returns default options for writing a system file. */
struct sfm_write_options
}
/* Opens the system file designated by file handle FH for writing
- cases from dictionary D according to the given OPTS. If
- COMPRESS is nonzero, the system file will be compressed.
+ cases from dictionary D according to the given OPTS.
No reference to D is retained, so it may be modified or
destroyed at will after this function returns. D is not
goto error;
/* Create the file on disk. */
- mode = S_IRUSR | S_IRGRP | S_IROTH;
+ mode = 0444;
if (opts.create_writeable)
- mode |= S_IWUSR | S_IWGRP | S_IWOTH;
+ mode |= 0222;
w->rf = replace_file_start (fh_get_file_name (fh), "wb", mode,
&w->file, NULL);
if (w->rf == NULL)
write_int (w, 0);
if (write_error (w))
- {
- close_writer (w);
- return NULL;
- }
+ goto error;
return casewriter_create (dict_get_proto (d), &sys_file_casewriter_class, w);
}
/* Returns true if an I/O error has occurred on WRITER, false otherwise. */
-bool
+static bool
write_error (const struct sfm_writer *writer)
{
return ferror (writer->file);
/* Closes a system file after we're done with it.
Returns true if successful, false if an I/O error occurred. */
-bool
+static bool
close_writer (struct sfm_writer *w)
{
bool ok;
/* Seek back to the beginning and update the number of cases.
This is just a courtesy to later readers, so there's no need
to check return values or report errors. */
- if (ok && w->case_cnt <= INT32_MAX && !fseek (w->file, 80, SEEK_SET))
+ if (ok && w->case_cnt <= INT32_MAX && !fseeko (w->file, 80, SEEK_SET))
{
write_int (w, w->case_cnt);
clearerr (w->file);