#[error("Invalid multiple response type")]
InvalidMultipleResponseType,
- #[error("Syntax error in multiple response record")]
- MultipleResponseSyntaxError,
+ #[error("Syntax error in multiple response record ({0})")]
+ MultipleResponseSyntaxError(&'static str),
#[error("Syntax error parsing counted string (missing trailing space)")]
CountedStringMissingSpace,
impl MultipleResponseSet<RawString, RawString> {
fn parse(input: &[u8]) -> Result<(Self, &[u8]), Warning> {
let Some(equals) = input.iter().position(|&b| b == b'=') else {
- return Err(Warning::MultipleResponseSyntaxError);
+ return Err(Warning::MultipleResponseSyntaxError("missing `=`"));
};
let (name, input) = input.split_at(equals);
let input = input.strip_prefix(b"=").unwrap();
let (mr_type, input) = MultipleResponseType::parse(input)?;
let Some(input) = input.strip_prefix(b" ") else {
- return Err(Warning::MultipleResponseSyntaxError);
+ return Err(Warning::MultipleResponseSyntaxError(
+ "missing space after multiple response type",
+ ));
};
let (label, mut input) = parse_counted_string(input)?;
let mut vars = Vec::new();
match input.split_first() {
Some((b' ', rest)) => {
let Some(length) = rest.iter().position(|b| b" \n".contains(b)) else {
- return Err(Warning::MultipleResponseSyntaxError);
+ return Err(Warning::MultipleResponseSyntaxError(
+ "missing variable name delimiter",
+ ));
};
let (var, rest) = rest.split_at(length);
if !var.is_empty() {
}
input = rest;
}
- _ => return Err(Warning::MultipleResponseSyntaxError),
+ _ => {
+ return Err(Warning::MultipleResponseSyntaxError(
+ "missing space preceding variable name",
+ ))
+ }
}
}
while input.first() == Some(&b'\n') {
--- /dev/null
+Syntax error in multiple response record (missing space after multiple response type)
+
+╭──────────────────────┬────────────────────────╮
+│ Created │ 01-JAN-2011 20:53:52│
+├──────────────────────┼────────────────────────┤
+│Writer Product │PSPP synthetic test file│
+├──────────────────────┼────────────────────────┤
+│ Compression │SAV │
+│ Number of Cases│Unknown │
+╰──────────────────────┴────────────────────────╯
+
+╭─────────┬─╮
+│Variables│1│
+╰─────────┴─╯
+
+╭────┬────────┬─────┬─────────────────┬─────┬─────┬─────────┬────────────┬────────────┬──────────────╮
+│ │Position│Label│Measurement Level│ Role│Width│Alignment│Print Format│Write Format│Missing Values│
+├────┼────────┼─────┼─────────────────┼─────┼─────┼─────────┼────────────┼────────────┼──────────────┤
+│num1│ 1│ │ │Input│ 8│Right │F8.0 │F8.0 │ │
+╰────┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯
--- /dev/null
+# File header.
+"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
+2; 1; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
+
+# Numeric variable, no label or missing values.
+2; 0; 0; 0; 0x050800 *2; s8 "NUM1";
+
+# Multiple response sets.
+7; 7; 1; COUNT("$a=Cx");
+
+# Character encoding record.
+7; 20; 1; 12; "windows-1252";
+
+999; 0;