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)
{
- msg (ME, _("Error opening \"%s\" for writing as a system file: %s."),
+ msg (ME, _("Error opening `%s' for writing as a system file: %s."),
fh_get_file_name (fh), strerror (errno));
goto error;
}
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);
size_t j;
ds_put_cstr (string, attribute_get_name (attr));
- ds_put_char (string, '(');
+ ds_put_byte (string, '(');
for (j = 0; j < n_values; j++)
ds_put_format (string, "'%s'\n", attribute_get_value (attr, j));
- ds_put_char (string, ')');
+ ds_put_byte (string, ')');
}
}
if (attrset_count (attrs))
{
if (n_attrsets++)
- ds_put_char (&s, '/');
+ ds_put_byte (&s, '/');
ds_put_format (&s, "%s:", var_get_short_name (v, 0));
put_attrset (&s, attrs);
}
if (mrset->cat_source == MRSET_COUNTEDVALUES)
ds_put_format (&s, "E %d ", mrset->label_from_var_label ? 11 : 1);
else
- ds_put_char (&s, 'D');
+ ds_put_byte (&s, 'D');
if (mrset->width == 0)
counted = xasprintf ("%.0f", mrset->counted.f);
free (counted);
}
else
- ds_put_char (&s, 'C');
- ds_put_char (&s, ' ');
+ ds_put_byte (&s, 'C');
+ ds_put_byte (&s, ' ');
label = mrset->label && !mrset->label_from_var_label ? mrset->label : "";
ds_put_format (&s, "%zu %s", strlen (label), label);
for (j = 0; j < mrset->n_vars; j++)
ds_put_format (&s, " %s", var_get_short_name (mrset->vars[j], 0));
- ds_put_char (&s, '\n');
+ ds_put_byte (&s, '\n');
}
write_attribute_record (w, &s, 7);
ds_destroy (&s);
char *longname = recode_string (dict_get_encoding (dict), UTF8, var_get_name (v), -1);
if (i)
- ds_put_char (&map, '\t');
+ ds_put_byte (&map, '\t');
ds_put_format (&map, "%s=%s",
var_get_short_name (v, 0), longname);
free (longname);
}
/* 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;
ok = false;
if (!ok)
- msg (ME, _("An I/O error occurred writing system file \"%s\"."),
+ msg (ME, _("An I/O error occurred writing system file `%s'."),
fh_get_file_name (w->fh));
if (ok ? !replace_file_commit (w->rf) : !replace_file_abort (w->rf))