From: Ben Pfaff Date: Wed, 5 Jun 2024 00:59:52 +0000 (-0700) Subject: incomplete work X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4be19fbd685bcc1c248cf77cd7dbe54a4c675dfd;p=pspp incomplete work --- diff --git a/rust/src/cooked.rs b/rust/src/cooked.rs index 71d65adddd..3e97e404df 100644 --- a/rust/src/cooked.rs +++ b/rust/src/cooked.rs @@ -10,9 +10,9 @@ use crate::{ self, Cases, DecodedRecord, DocumentRecord, EncodingRecord, Extension, FileAttributeRecord, FloatInfoRecord, HeaderRecord, IntegerInfoRecord, LongNamesRecord, LongStringMissingValueRecord, LongStringValueLabelRecord, MultipleResponseRecord, - NumberOfCasesRecord, ProductInfoRecord, RawStr, ValueLabelRecord, VarDisplayRecord, - VariableAttributeRecord, VariableRecord, VariableSetRecord, VeryLongStringsRecord, ZHeader, - ZTrailer, + NumberOfCasesRecord, ProductInfoRecord, RawStr, ValueLabel, ValueLabelRecord, + VarDisplayRecord, VariableAttributeRecord, VariableRecord, VariableSetRecord, + VeryLongStringsRecord, ZHeader, ZTrailer, }, }; use chrono::{NaiveDate, NaiveDateTime, NaiveTime}; @@ -546,6 +546,13 @@ pub fn decode( variables: long_string_variables, }); } + + for dict_index in dict_indexes { + let mut variable = &dictionary.variables[dict_index]; + for ValueLabel { value, label } in record.labels.iter().cloned() { + + } + } } let metadata = Metadata::decode(&headers, warn); @@ -561,8 +568,7 @@ fn trim_end_spaces(mut s: String) -> String { /// replaced by LF. /// /// (A product that identifies itself as VOXCO INTERVIEWER 4.3 produces system -/// files that use CR-only line ends in the file label and extra product -/// info.) */ +/// files that use CR-only line ends in the file label and extra product info.) fn fix_line_ends(s: &str) -> String { let mut out = String::with_capacity(s.len()); let mut s = s.chars().peekable(); diff --git a/rust/src/raw.rs b/rust/src/raw.rs index f492710378..14231b18a6 100644 --- a/rust/src/raw.rs +++ b/rust/src/raw.rs @@ -826,7 +826,7 @@ impl RawValue { Ok(Some(values)) } - fn decode(self, decoder: &Decoder) -> Value { + pub fn decode(self, decoder: &Decoder) -> Value { match self { Self::Number(x) => Value::Number(x), Self::String(s) => Value::String(decoder.decode_exact_length(&s.0).into()), @@ -1302,7 +1302,10 @@ impl VariableRecord> { let start_offset = r.stream_position()?; let width: i32 = endian.parse(read_bytes(r)?); if !(-1..=255).contains(&width) { - return Err(Error::BadVariableWidth { start_offset, width }); + return Err(Error::BadVariableWidth { + start_offset, + width, + }); } let code_offset = r.stream_position()?; let has_variable_label: u32 = endian.parse(read_bytes(r)?); @@ -1540,8 +1543,13 @@ impl ValueLabelRecord, RawString> { n, max: Self::MAX_INDEXES, }); + } else if n == 0 { + warn(Warning::NoVarIndexes { + offset: index_offset, + }); + return Ok(None); } - + let index_offset = r.stream_position()?; let mut dict_indexes = Vec::with_capacity(n as usize); let mut invalid_indexes = Vec::new(); @@ -1562,9 +1570,6 @@ impl ValueLabelRecord, RawString> { } let Some(&first_index) = dict_indexes.first() else { - warn(Warning::NoVarIndexes { - offset: index_offset, - }); return Ok(None); }; let var_type = var_types[first_index as usize - 1];