From: John Darrington Date: Fri, 20 Apr 2007 11:04:55 +0000 (+0000) Subject: If sys files have no long_name table, implicitly add one, use the lower case X-Git-Tag: v0.6.0~485 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b8e2dc45abf0cf7a398cb8cef9d9faa24bee6f6c;p=pspp-builds.git If sys files have no long_name table, implicitly add one, use the lower case version of the variable names. --- diff --git a/src/data/ChangeLog b/src/data/ChangeLog index 1c616aeb..b5a299ad 100644 --- a/src/data/ChangeLog +++ b/src/data/ChangeLog @@ -1,3 +1,9 @@ +2007-04-19 John Darrington + + * sys-file-reader.c: When reading a system file which has no + long name table, automatically create one where the long names + are the lower case versions of the short names. + 2007-04-16 John Darrington * sys-file-reader.c: Some versions of Other Software seem to diff --git a/src/data/sys-file-reader.c b/src/data/sys-file-reader.c index 281edcbc..d04a757f 100644 --- a/src/data/sys-file-reader.c +++ b/src/data/sys-file-reader.c @@ -76,6 +76,7 @@ struct sfm_reader int value_cnt; /* Number of 8-byte units per case. */ struct sfm_var *vars; /* Variables. */ size_t var_cnt; /* Number of variables. */ + bool has_long_var_names; /* File has a long variable name map */ bool has_vls; /* File has one or more very long strings? */ /* Decompression. */ @@ -192,6 +193,7 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, r->error = false; r->value_cnt = 0; r->has_vls = false; + r->has_long_var_names = false; r->opcode_idx = sizeof r->opcodes; if (setjmp (r->bail_out)) @@ -250,6 +252,33 @@ sfm_open_reader (struct file_handle *fh, struct dictionary **dict, rec_type = read_int32 (r); } + + if ( ! r->has_long_var_names ) + { + int i; + for (i = 0; i < dict_get_var_cnt (*dict); i++) + { + struct variable *var = dict_get_var (*dict, i); + char short_name [SHORT_NAME_LEN + 1]; + char long_name [SHORT_NAME_LEN + 1]; + char *s = short_name; + char *d = long_name; + + strcpy (short_name, var_get_name (var)); + + strcpy (long_name, short_name); + str_lowercase (long_name); + + /* Set long name. Renaming a variable may clear the short + name, but we want to retain it, so re-set it + explicitly. */ + dict_rename_var (*dict, var, long_name); + var_set_short_name (var, short_name); + } + + r->has_long_var_names = true; + } + /* Read record 999 data, which is just filler. */ read_int32 (r); @@ -880,6 +909,7 @@ read_long_var_name_map (struct sfm_reader *r, size_t size, size_t count, var_set_short_name (var, short_name); } close_variable_to_value_map (r, map); + r->has_long_var_names = true; } /* Reads record type 7, subtype 14, which gives the real length diff --git a/tests/ChangeLog b/tests/ChangeLog index 1c8eff1f..4a549761 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2007-04-19 John Darrington + + * tests/command/no_case_size.sh tests/command/sysfiles-old.sh : + Changed tests to reflect new behaviour (case changing) when + reading system files with no long name table. + 2007-04-15 Ben Pfaff * automake.mk: Add recode.sh to tests. diff --git a/tests/command/no_case_size.sh b/tests/command/no_case_size.sh index d9016eb9..738ea140 100755 --- a/tests/command/no_case_size.sh +++ b/tests/command/no_case_size.sh @@ -78,19 +78,19 @@ diff -b -w pspp.list - <