projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
MSAVE tests
[pspp]
/
src
/
data
/
sys-file-reader.c
diff --git
a/src/data/sys-file-reader.c
b/src/data/sys-file-reader.c
index 1a17eb89a1ac38a248b3c269f5ee9259c54c2f0d..109b0dd16efd0d980a5a0e16225ae77a57e3650d 100644
(file)
--- a/
src/data/sys-file-reader.c
+++ b/
src/data/sys-file-reader.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-2000, 2006-2007, 2009-2016 Free Software Foundation, Inc.
+ Copyright (C) 1997-2000, 2006-2007, 2009-2016
, 2021
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-391,10
+391,9
@@
static struct any_reader *
sfm_open (struct file_handle *fh)
{
size_t allocated_mrsets = 0;
sfm_open (struct file_handle *fh)
{
size_t allocated_mrsets = 0;
- struct sfm_reader *r;
/* Create and initialize reader. */
/* Create and initialize reader. */
-
r = xzalloc (sizeof *
r);
+
struct sfm_reader *r = XZALLOC (struct sfm_reade
r);
r->any_reader.klass = &sys_file_reader_class;
r->pool = pool_create ();
pool_register (r->pool, free, r);
r->any_reader.klass = &sys_file_reader_class;
r->pool = pool_create ();
pool_register (r->pool, free, r);
@@
-640,6
+639,13
@@
add_id (struct get_strings_aux *aux, const char *id, const char *title, ...)
va_end (args);
}
va_end (args);
}
+static const char *
+skip_prefix (const char *s, const char *prefix)
+{
+ size_t prefix_len = strlen (prefix);
+ return !strncmp (s, prefix, prefix_len) ? s + prefix_len : s;
+}
+
/* Retrieves significant string data from R in its raw format, to allow the
caller to try to detect the encoding in use.
/* Retrieves significant string data from R in its raw format, to allow the
caller to try to detect the encoding in use.
@@
-689,7
+695,7
@@
sfm_get_strings (const struct any_reader *r_, struct pool *pool,
add_string (&aux, r->header.creation_date, _("Creation Date"));
add_string (&aux, r->header.creation_time, _("Creation Time"));
add_string (&aux, r->header.creation_date, _("Creation Date"));
add_string (&aux, r->header.creation_time, _("Creation Time"));
- add_string (&aux,
r->header.eye_catcher
, _("Product"));
+ add_string (&aux,
skip_prefix (r->header.eye_catcher, "@(#) ")
, _("Product"));
add_string (&aux, r->header.file_label, _("File Label"));
if (r->extensions[EXT_PRODUCT_INFO])
add_string (&aux, r->header.file_label, _("File Label"));
if (r->extensions[EXT_PRODUCT_INFO])
@@
-988,7
+994,7
@@
read_header (struct sfm_reader *r, struct any_read_info *info,
r->compression = ANY_COMP_NONE;
else if (compressed == 1)
r->compression = ANY_COMP_SIMPLE;
r->compression = ANY_COMP_NONE;
else if (compressed == 1)
r->compression = ANY_COMP_SIMPLE;
- else
if (compressed != 0)
+ else
{
sys_error (r, 0, "System file header has invalid compression "
"value %d.", compressed);
{
sys_error (r, 0, "System file header has invalid compression "
"value %d.", compressed);
@@
-1687,9
+1693,9
@@
parse_mrsets (struct sfm_reader *r, const struct sfm_extension_record *record,
text = open_text_record (r, record, false);
for (;;)
{
text = open_text_record (r, record, false);
for (;;)
{
- struct sfm_mrset *mrset;
- size_t allocated_vars;
- char delimiter;
+ struct sfm_mrset *mrset
= NULL
;
+ size_t allocated_vars
= 0
;
+ char delimiter
= '4'
;
/* Skip extra line feeds if present. */
while (text_match (text, '\n'))
/* Skip extra line feeds if present. */
while (text_match (text, '\n'))
@@
-1992,7
+1998,7
@@
rename_var_and_save_short_names (struct sfm_reader *r, off_t pos,
for (i = 0; i < n_short_names; i++)
{
const char *s = var_get_short_name (var, i);
for (i = 0; i < n_short_names; i++)
{
const char *s = var_get_short_name (var, i);
- short_names[i] =
s != NULL ? xstrdup (s) : NULL
;
+ short_names[i] =
xstrdup_if_nonnull (s)
;
}
/* Set long name. */
}
/* Set long name. */
@@
-3119,7
+3125,11
@@
text_get_token (struct text_record *text, struct substring delimiters,
char *end;
if (!ss_tokenize (text->buffer, delimiters, &text->pos, &token))
char *end;
if (!ss_tokenize (text->buffer, delimiters, &text->pos, &token))
- return NULL;
+ {
+ if (delimiter != NULL)
+ *delimiter = ss_data (text->buffer)[text->pos-1];
+ return NULL;
+ }
end = &ss_data (token)[ss_length (token)];
if (delimiter != NULL)
end = &ss_data (token)[ss_length (token)];
if (delimiter != NULL)
@@
-3233,12
+3243,13
@@
sys_msg (struct sfm_reader *r, off_t offset,
ds_put_format (&text, _("`%s': "), fh_get_file_name (r->fh));
ds_put_vformat (&text, format, args);
ds_put_format (&text, _("`%s': "), fh_get_file_name (r->fh));
ds_put_vformat (&text, format, args);
- struct msg m = {
+ struct msg *m = xmalloc (sizeof *m);
+ *m = (struct msg) {
.category = msg_class_to_category (class),
.severity = msg_class_to_severity (class),
.category = msg_class_to_category (class),
.severity = msg_class_to_severity (class),
- .text = ds_cstr (&text),
+ .text = ds_
steal_
cstr (&text),
};
};
- msg_emit (
&
m);
+ msg_emit (m);
}
/* Displays a warning for offset OFFSET in the file. */
}
/* Displays a warning for offset OFFSET in the file. */