.filter(|(_index, record)| record.width != RawWidth::Continuation)
{
let name = trim_end_spaces(input.name.to_string());
- let name = match Identifier::from_encoding(name, encoding) {
+ let name = match Identifier::from_encoding(name, encoding)
+ .and_then(Identifier::must_be_ordinary)
+ {
Ok(name) => {
if !dictionary.variables.contains(&name.0) {
name
test_sysfile("wrong_variable_positions");
}
+#[test]
+fn invalid_variable_name() {
+ test_sysfile("invalid_variable_name");
+}
+
fn test_sysfile(name: &str) {
let input_filename = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("src/sys/testdata")
--- /dev/null
+"$UM1" may not be used as an identifier because it begins with disallowed character "$". Renaming variable to VAR001.
+
+"#UM1" may not be used as an identifier because it begins with disallowed character "#". Renaming variable to VAR002.
+
+"!UM1" may not be used as an identifier because it begins with disallowed character "!". Renaming variable to VAR003.
+
+"GE" may not be used as an identifier because it is a reserved word. Renaming variable to VAR004.
+
+╭──────────────────────┬────────────────────────╮
+│ Created │ 01-JAN-2011 20:53:52│
+├──────────────────────┼────────────────────────┤
+│Writer Product │PSPP synthetic test file│
+├──────────────────────┼────────────────────────┤
+│ Compression │SAV │
+│ Number of Cases│Unknown │
+╰──────────────────────┴────────────────────────╯
+
+╭─────────┬─╮
+│Variables│4│
+╰─────────┴─╯
+
+╭──────┬────────┬─────┬─────────────────┬─────┬─────┬─────────┬────────────┬────────────┬──────────────╮
+│ │Position│Label│Measurement Level│ Role│Width│Alignment│Print Format│Write Format│Missing Values│
+├──────┼────────┼─────┼─────────────────┼─────┼─────┼─────────┼────────────┼────────────┼──────────────┤
+│var001│ 1│ │ │Input│ 8│Right │F8.0 │F8.0 │ │
+│var002│ 2│ │ │Input│ 8│Right │F8.0 │F8.0 │ │
+│var003│ 3│ │ │Input│ 8│Right │F8.0 │F8.0 │ │
+│var004│ 4│ │ │Input│ 8│Right │F8.0 │F8.0 │ │
+╰──────┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯
--- /dev/null
+# File header.
+"$FL2"; s60 "$(#) SPSS DATA FILE PSPP synthetic test file";
+2; 4; 1; 0; -1; 100.0; "01 Jan 11"; "20:53:52"; s64 ""; i8 0 *3;
+
+# Numeric variable.
+2; 0; 0; 0; 0x050800 *2; s8 >>"$UM1"<<;
+2; 0; 0; 0; 0x050800 *2; s8 >>"#UM1"<<;
+2; 0; 0; 0; 0x050800 *2; s8 >>"!UM1"<<;
+2; 0; 0; 0; 0x050800 *2; s8 >>"GE"<<;
+
+# Character encoding record.
+7; 20; 1; 12; "windows-1252";
+
+# End of dictionary.
+999; 0;