{
const char *dict_encoding = dict_get_encoding (d);
char prod_name[61];
- char creation_date[10];
- char creation_time[9];
const char *file_label;
struct variable *weight;
write_float (w, COMPRESSION_BIAS);
/* Creation date and time. */
+ char *creation_date, *creation_time;
if (time (&t) == (time_t) -1)
{
- strcpy (creation_date, "01 Jan 70");
- strcpy (creation_time, "00:00:00");
+ creation_date = xstrdup ("01 Jan 70");
+ creation_time = xstrdup ( "00:00:00");
}
else
{
int min = rerange (tmp->tm_min + 1);
int sec = rerange (tmp->tm_sec + 1);
- snprintf (creation_date, sizeof creation_date,
- "%02d %s %02d", day, month_name[mon - 1], year);
- snprintf (creation_time, sizeof creation_time,
- "%02d:%02d:%02d", hour - 1, min - 1, sec - 1);
+ creation_date = xasprintf ("%02d %s %02d",
+ day, month_name[mon - 1], year);
+ creation_time = xasprintf ("%02d:%02d:%02d", hour - 1, min - 1, sec - 1);
}
write_utf8_string (w, dict_encoding, creation_date, 9);
write_utf8_string (w, dict_encoding, creation_time, 8);
+ free (creation_time);
+ free (creation_date);
/* File label. */
file_label = dict_get_label (d);
Missing values for long string variables are written in a separate
record. */
+ enum { MAX_SHORT_STRING = 8 };
if (width <= MAX_SHORT_STRING)
{
const struct missing_values *mv = var_get_missing_values (v);
const char *encoding = dict_get_encoding (dict);
size_t n_vars = dict_get_var_cnt (dict);
size_t size, i;
- off_t start UNUSED;
/* Figure out the size in advance. */
size = 0;
write_int (w, 1); /* Data item (byte) size. */
write_int (w, size); /* Number of data items. */
- start = ftello (w->file);
for (i = 0; i < n_vars; i++)
{
struct variable *var = dict_get_var (dict, i);
free (label);
}
}
- assert (ftello (w->file) == start + size);
}
static void
const char *encoding = dict_get_encoding (dict);
size_t n_vars = dict_get_var_cnt (dict);
size_t size, i;
- off_t start UNUSED;
/* Figure out the size in advance. */
size = 0;
write_int (w, 1); /* Data item (byte) size. */
write_int (w, size); /* Number of data items. */
- start = ftello (w->file);
for (i = 0; i < n_vars; i++)
{
struct variable *var = dict_get_var (dict, i);
write_bytes (w, value_str (value, width), 8);
}
}
- assert (ftello (w->file) == start + size);
}
static void