X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fsys-file-reader.c;h=8f39f47826c8f6e6a26b2ff08ae7644c33683308;hb=6c091c8123879cb0cf385e167e468eb82ac69d2c;hp=36a2cb7a986f24208de96bfb0dc257cda64f21fc;hpb=7d34380bb2fddca820a6f414564738cc2f70afc9;p=pspp-builds.git diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 36a2cb7a..8f39f478 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2007, 2009, 2010, 2011 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 @@ -513,7 +513,6 @@ read_header (struct sfm_reader *r, struct dictionary *dict, if ( r->case_cnt > INT_MAX / 2) r->case_cnt = -1; - /* Identify floating-point format and obtain compression bias. */ read_bytes (r, raw_bias, sizeof raw_bias); if (float_identify (100.0, raw_bias, sizeof raw_bias, &r->float_format) == 0) @@ -595,7 +594,7 @@ read_variable_record (struct sfm_reader *r, struct dictionary *dict, /* Check variable name. */ if (name[0] == '$' || name[0] == '#') - sys_error (r, "Variable name begins with invalid character `%c'.", + sys_error (r, _("Variable name begins with invalid character `%c'."), name[0]); if (!var_is_plausible_name (name, false)) sys_error (r, _("Invalid variable name `%s'."), name); @@ -605,9 +604,7 @@ read_variable_record (struct sfm_reader *r, struct dictionary *dict, sys_error (r, _("Bad width %d for variable %s."), width, name); var = dict_create_var (dict, name, width); if (var == NULL) - sys_error (r, - _("Duplicate variable name `%s' within system file."), - name); + sys_error (r, _("Duplicate variable name `%s'."), name); /* Set the short name the same as the long name. */ var_set_short_name (var, 0, var_get_name (var)); @@ -744,7 +741,7 @@ parse_format_spec (struct sfm_reader *r, unsigned int s, else var_set_write_format (v, &f); } - else if (*++format_warning_cnt <= max_format_warnings) + else if (++*format_warning_cnt <= max_format_warnings) { char fmt_string[FMT_STRING_LEN_MAX + 1]; sys_warn (r, _("%s variable %s has invalid %s format %s."), @@ -772,7 +769,9 @@ setup_weight (struct sfm_reader *r, int weight_idx, if (var_is_numeric (weight_var)) dict_set_weight (dict, weight_var); else - sys_error (r, _("Weighting variable must be numeric.")); + sys_error (r, _("Weighting variable must be numeric " + "(not string variable `%s')."), + var_get_name (weight_var)); } } @@ -889,7 +888,9 @@ read_extension_record (struct sfm_reader *r, struct dictionary *dict, return; default: - sys_warn (r, _("Unrecognized record type 7, subtype %d. Please send a copy of this file, and the syntax which created it to %s"), + sys_warn (r, _("Unrecognized record type 7, subtype %d. Please send " + "a copy of this file, and the syntax which created it " + "to %s."), subtype, PACKAGE_BUGREPORT); break; } @@ -938,7 +939,7 @@ read_machine_integer_info (struct sfm_reader *r, size_t size, size_t count, if (float_representation != expected_float_format) sys_error (r, _("Floating-point representation indicated by " "system file (%d) differs from expected (%d)."), - r->float_format, expected_float_format); + float_representation, expected_float_format); /* Check integer format. */ if (r->integer_format == INTEGER_MSB_FIRST) @@ -948,14 +949,9 @@ read_machine_integer_info (struct sfm_reader *r, size_t size, size_t count, else NOT_REACHED (); if (integer_representation != expected_integer_format) - { - static const char *const endian[] = {N_("Little Endian"), N_("Big Endian")}; - sys_warn (r, _("Integer format indicated by system file (%s) " - "differs from expected (%s)."), - gettext (endian[integer_representation == 1]), - gettext (endian[expected_integer_format == 1])); - } - + sys_warn (r, _("Integer format indicated by system file (%d) " + "differs from expected (%d)."), + integer_representation, expected_integer_format); /* Record 7 (20) provides a much more reliable way of @@ -1047,13 +1043,20 @@ read_mrsets (struct sfm_reader *r, size_t size, size_t count, break; mrset->name = xstrdup (name); + if (mrset->name[0] != '$') + { + sys_warn (r, _("`%s' does not begin with `$' at offset %zu " + "in MRSETS record."), mrset->name, text_pos (text)); + break; + } + if (text_match (text, 'C')) { mrset->type = MRSET_MC; if (!text_match (text, ' ')) { sys_warn (r, _("Missing space following `%c' at offset %zu " - "in MRSETS record"), 'C', text_pos (text)); + "in MRSETS record."), 'C', text_pos (text)); break; } } @@ -1071,7 +1074,7 @@ read_mrsets (struct sfm_reader *r, size_t size, size_t count, if (!text_match (text, ' ')) { sys_warn (r, _("Missing space following `%c' at offset %zu " - "in MRSETS record"), 'E', text_pos (text)); + "in MRSETS record."), 'E', text_pos (text)); break; } @@ -1080,7 +1083,7 @@ read_mrsets (struct sfm_reader *r, size_t size, size_t count, mrset->label_from_var_label = true; else if (strcmp (number, "1")) sys_warn (r, _("Unexpected label source value `%s' " - "following `E' at offset %zu in MRSETS record"), + "following `E' at offset %zu in MRSETS record."), number, text_pos (text)); } else @@ -1278,8 +1281,7 @@ read_long_var_name_map (struct sfm_reader *r, size_t size, size_t count, if (strcasecmp (var_get_short_name (var, 0), long_name) && dict_lookup_var (dict, long_name) != NULL) { - sys_warn (r, _("Duplicate long variable name `%s' " - "within system file."), long_name); + sys_warn (r, _("Duplicate long variable name `%s'."), long_name); continue; } @@ -1332,7 +1334,7 @@ read_long_string_map (struct sfm_reader *r, size_t size, size_t count, if (length < 1 || length > MAX_STRING) { sys_warn (r, _("%s listed as string of invalid length %s " - "in very length string record."), + "in very long string record."), var_get_name (var), length_s); continue; } @@ -1362,7 +1364,7 @@ read_long_string_map (struct sfm_reader *r, size_t size, size_t count, var_set_short_name (var, i, var_get_short_name (seg, 0)); if (ROUND_UP (width, 8) != ROUND_UP (alloc_width, 8)) sys_error (r, _("Very long string with width %ld has segment %d " - "of width %d (expected %d)"), + "of width %d (expected %d)."), length, i, width, alloc_width); } dict_delete_consecutive_vars (dict, idx + 1, segment_cnt - 1); @@ -1406,11 +1408,7 @@ read_value_labels (struct sfm_reader *r, label_cnt = read_int (r); if (size_overflow_p (xtimes (label_cnt, sizeof *labels))) - { - sys_warn (r, _("Invalid number of labels: %d. Ignoring labels."), - label_cnt); - label_cnt = 0; - } + sys_error (r, _("Invalid number of labels %d."), label_cnt); /* Read each value/label tuple into labels[]. */ labels = pool_nalloc (subpool, label_cnt, sizeof *labels); @@ -1540,7 +1538,7 @@ read_attributes (struct sfm_reader *r, struct text_record *text, value = text_get_token (text, ss_cstr ("\n"), NULL); if (value == NULL) { - text_warn (r, text, _("Error parsing attribute value %s[%d]"), + text_warn (r, text, _("Error parsing attribute value %s[%d]."), key, index); break; } @@ -1554,7 +1552,7 @@ read_attributes (struct sfm_reader *r, struct text_record *text, else { text_warn (r, text, - _("Attribute value %s[%d] is not quoted: %s"), + _("Attribute value %s[%d] is not quoted: %s."), key, index, value); attribute_add_value (attr, value); } @@ -1643,7 +1641,7 @@ read_long_string_value_labels (struct sfm_reader *r, { sys_warn (r, _("Ignoring long string value record for variable %s " "because the record's width (%d) does not match the " - "variable's width (%d)"), + "variable's width (%d)."), var_name, width, var_get_width (v)); skip_long_string_value_labels (r, n_labels); continue; @@ -1766,11 +1764,11 @@ sys_file_casereader_read (struct casereader *reader, void *r_) return c; eof: - case_unref (c); if (i != 0) partial_record (r); if (r->case_cnt != -1) read_error (reader, r); + case_unref (c); return NULL; } @@ -1941,7 +1939,7 @@ read_compressed_string (struct sfm_reader *r, uint8_t *dst) { r->corruption_warning = true; sys_warn (r, _("Possible compressed data corruption: " - "string contains compressed integer (opcode %d)"), + "string contains compressed integer (opcode %d)."), opcode); } }