work
[pspp] / utilities / pspp-dump-sav.c
index d08999e01b673984a4af349c5d862783fea17bf3..3268575459db61d4db79bfebb9cfee60c70ce703 100644 (file)
@@ -65,6 +65,9 @@ struct sfm_reader
     double bias;
   };
 
+  static int character_code;
+static char *encoding;
+
 static void read_header (struct sfm_reader *);
 static void read_variable_record (struct sfm_reader *);
 static void read_value_label_record (struct sfm_reader *);
@@ -229,6 +232,7 @@ main (int argc, char *argv[])
               (long long int) ftello (r.file),
               (long long int) ftello (r.file) + 4);
 
+      printf ("Character Encoding: %s (%d)\n", encoding ? encoding : "none", character_code);
       if (r.compression == COMP_SIMPLE)
         {
           if (max_cases > 0)
@@ -695,7 +699,7 @@ read_machine_integer_info (struct sfm_reader *r, size_t size, size_t count)
   int float_representation = read_int (r);
   int compression_code = read_int (r);
   int integer_representation = read_int (r);
-  int character_code = read_int (r);
+  character_code = read_int (r);
 
   printf ("%08llx: machine integer info\n", offset);
   if (size != 4 || count != 8)
@@ -1065,13 +1069,9 @@ read_datafile_attributes (struct sfm_reader *r, size_t size, size_t count)
 static void
 read_character_encoding (struct sfm_reader *r, size_t size, size_t count)
 {
-  long long int posn =  ftello (r->file);
-  char *encoding = xcalloc (size, count + 1);
+  encoding = xcalloc (size, count + 1);
   read_string (r, encoding, count + 1);
 
-  printf ("%08llx: Character Encoding: %s\n", posn, encoding);
-
-  free (encoding);
 }
 
 static void