work
[pspp] / rust / src / cooked.rs
index f1753846c21f1c135750a533a845df87d7583e69..be1b4c4b71fd77fa9cb344dec127ef9491cb2b87 100644 (file)
@@ -210,54 +210,6 @@ pub struct Decoder {
     n_generated_names: usize,
 }
 
-fn decode_sort_order(record: &raw::Record) -> i32 {
-    match record {
-        // File header record.
-        raw::Record::Header(_) => 0,
-
-        // Then the records used to decide character encoding.
-        raw::Record::Encoding(_) => 1,
-        raw::Record::IntegerInfo(_) => 2,
-
-        // Then the other records that don't use variables at all.
-        raw::Record::Document(_) => 3,
-        raw::Record::FloatInfo(_) => 4,
-        raw::Record::ProductInfo(_) => 5,
-        raw::Record::FileAttributes(_) => 6,
-
-        // Variable records.
-        raw::Record::Variable(_) => 7,
-
-        // These records use variable indexes that would be invalidated by very
-        // long string variables.
-        raw::Record::ValueLabel(_) => 8,
-        raw::Record::VarDisplay(_) => 9,
-
-        // These records use short names.
-        raw::Record::MultipleResponse(_) => 10,
-        raw::Record::VeryLongStrings(_) => 11,
-
-        // Rename short names to long names.
-        raw::Record::LongNames(_) => 12,
-
-        // These records use long names.
-        raw::Record::VariableAttributes(_) => 13,
-        raw::Record::LongStringValueLabels(_) => 14,
-        raw::Record::LongStringMissingValues(_) => 15,
-        raw::Record::VariableSets(_) => 16,
-
-        // Cases come last.
-        raw::Record::Cases(_) => 17,
-
-        // We don't use these records at all.
-        raw::Record::NumberOfCases(_) => i32::MAX,
-        raw::Record::OtherExtension(_) => i32::MAX,
-        raw::Record::EndOfHeaders(_) => i32::MAX,
-        raw::Record::ZHeader(_) => i32::MAX,
-        raw::Record::ZTrailer(_) => i32::MAX,
-    }
-}
-
 #[derive(Default)]
 struct Headers<'a> {
     header: Option<&'a raw::HeaderRecord>,
@@ -274,7 +226,7 @@ struct Headers<'a> {
     encoding: Option<&'a raw::EncodingRecord>,
     number_of_cases: Option<&'a raw::NumberOfCasesRecord>,
     product_info: Option<&'a raw::TextRecord>,
-    long_names: Vec<&'a raw::TextRecord>,
+    long_names: Option<&'a raw::TextRecord>,
     very_long_strings: Vec<&'a raw::TextRecord>,
     file_attributes: Vec<&'a raw::TextRecord>,
     variable_attributes: Vec<&'a raw::TextRecord>,
@@ -315,14 +267,14 @@ impl<'a> Headers<'a> {
                     set_or_warn(&mut h.number_of_cases, record, warn)
                 }
                 raw::Record::ProductInfo(record) => set_or_warn(&mut h.product_info, record, warn),
-                raw::Record::LongNames(record) => h.long_names.push(record),
+                raw::Record::LongNames(record) => set_or_warn(&mut h.long_names, record, warn),
                 raw::Record::VeryLongStrings(record) => h.very_long_strings.push(record),
                 raw::Record::FileAttributes(record) => h.file_attributes.push(record),
                 raw::Record::VariableAttributes(record) => h.variable_attributes.push(record),
                 raw::Record::OtherExtension(record) => h.other_extensions.push(record),
-                raw::Record::EndOfHeaders(_) => todo!(),
-                raw::Record::ZHeader(_) => todo!(),
-                raw::Record::ZTrailer(_) => todo!(),
+                raw::Record::EndOfHeaders(_) => (),
+                raw::Record::ZHeader(_) => (),
+                raw::Record::ZTrailer(_) => (),
                 raw::Record::Cases(record) => set_or_warn(&mut h.cases, record, warn),
             }
         }