From 325735888b8c62eb5a0909bc4b22dd54997462b9 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 12 Jul 2025 10:17:44 -0700 Subject: [PATCH] rust: Remove `sack` standalone program. It wasn't really useful and it didn't make sense to run it as a test. --- rust/Cargo.lock | 8 +-- rust/pspp/Cargo.toml | 6 --- rust/pspp/src/sys/sack.rs | 41 ++++++++++++++ rust/pspp/tests/sack.rs | 109 -------------------------------------- 4 files changed, 45 insertions(+), 119 deletions(-) delete mode 100644 rust/pspp/tests/sack.rs diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 1e7795ae4c..52e8544160 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -2749,18 +2749,18 @@ dependencies = [ [[package]] name = "zerocopy" -version = "0.8.25" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1702d9583232ddb9174e01bb7c15a2ab8fb1bc6f227aa1233858c351a3ba0cb" +checksum = "1039dd0d3c310cf05de012d8a39ff557cb0d23087fd44cad61df08fc31907a2f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.25" +version = "0.8.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28a6e20d751156648aa063f3800b706ee209a32c0b4d9f24be3d980b01be55ef" +checksum = "9ecf5b4cc5364572d7f4c329661bcc82724222973f2cab6f050a4e5c22f75181" dependencies = [ "proc-macro2", "quote", diff --git a/rust/pspp/Cargo.toml b/rust/pspp/Cargo.toml index 043fbae2a4..73a2188660 100644 --- a/rust/pspp/Cargo.toml +++ b/rust/pspp/Cargo.toml @@ -55,7 +55,6 @@ windows-sys = { version = "0.48.0", features = ["Win32_Globalization"] } [build-dependencies] anyhow = "1.0.69" -flate2 = "1.0.26" [[bin]] name = "pspp" @@ -64,11 +63,6 @@ path = "src/main.rs" [lib] path = "src/lib.rs" -[[test]] -name = "sack" -path = "tests/sack.rs" -harness = false - [dev-dependencies] diff = "0.1.13" rand = "0.9.0" diff --git a/rust/pspp/src/sys/sack.rs b/rust/pspp/src/sys/sack.rs index 99484e3735..c6695bd1be 100644 --- a/rust/pspp/src/sys/sack.rs +++ b/rust/pspp/src/sys/sack.rs @@ -71,6 +71,47 @@ impl Display for Error { } } +/// SAv Construction Kit +/// +/// The input is a sequence of data items, each followed by a semicolon. Each +/// data item is converted to the output format and written on stdout. A data +/// item is one of the following: +/// +/// - An integer in decimal, in hexadecimal prefixed by `0x`, or in octal +/// prefixed by `0`. Output as a 32-bit binary integer. +/// +/// - A floating-point number. Output in 64-bit IEEE 754 format. +/// +/// - A string enclosed in double quotes. Output literally. There is no +/// syntax for "escapes". Strings may not contain new-lines. +/// +/// - A literal of the form `s` followed by a quoted string as above. +/// Output as the string's contents followed by enough spaces to fill up +/// `` bytes. For example, `s8 "foo"` is output as `foo` followed +/// by 5 spaces. +/// +/// - The literal `i8`, `i16`, or `i64` followed by an integer. Output +/// as a binary integer with the specified number of bits. +/// +/// - One of the literals `SYSMIS`, `LOWEST`, or `HIGHEST`. Output as a +/// 64-bit IEEE 754 float of the appropriate PSPP value. +/// +/// - `PCSYSMIS`. Output as SPSS/PC+ system-missing value. +/// +/// - The literal `ENDIAN`. Output as a 32-bit binary integer, either with +/// value 1 if `--be` is in effect or 2 if `--le` is in effect. +/// +/// - A pair of parentheses enclosing a sequence of data items, each followed +/// by a semicolon (the last semicolon is optional). Output as the enclosed +/// data items in sequence. +/// +/// - The literal `COUNT` or `COUNT8` followed by a sequence of parenthesized +/// data items, as above. Output as a 32-bit or 8-bit binary integer whose +/// value is the number of bytes enclosed within the parentheses, followed +/// by the enclosed data items themselves. +/// +/// optionally followed by an asterisk and a positive integer, which specifies a +/// repeat count for the data item. pub fn sack(input: &str, input_file_name: Option<&Path>, endian: Endian) -> Result> { let mut symbol_table = HashMap::new(); let output = _sack(input, input_file_name, endian, &mut symbol_table)?; diff --git a/rust/pspp/tests/sack.rs b/rust/pspp/tests/sack.rs deleted file mode 100644 index 3e47847178..0000000000 --- a/rust/pspp/tests/sack.rs +++ /dev/null @@ -1,109 +0,0 @@ -// PSPP - a program for statistical analysis. -// Copyright (C) 2025 Free Software Foundation, Inc. -// -// This program is free software: you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free Software -// Foundation, either version 3 of the License, or (at your option) any later -// version. -// -// This program is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// this program. If not, see . - -use std::fs::read_to_string; -use std::path::PathBuf; - -use anyhow::{anyhow, Result}; -use clap::Parser; -use pspp::endian::Endian; -use pspp::sys::sack::sack; - -/// SAv Construction Kit -/// -/// The input is a sequence of data items, each followed by a semicolon. Each -/// data item is converted to the output format and written on stdout. A data -/// item is one of the following: -/// -/// - An integer in decimal, in hexadecimal prefixed by `0x`, or in octal -/// prefixed by `0`. Output as a 32-bit binary integer. -/// -/// - A floating-point number. Output in 64-bit IEEE 754 format. -/// -/// - A string enclosed in double quotes. Output literally. There is no -/// syntax for "escapes". Strings may not contain new-lines. -/// -/// - A literal of the form `s` followed by a quoted string as above. -/// Output as the string's contents followed by enough spaces to fill up -/// `` bytes. For example, `s8 "foo"` is output as `foo` followed -/// by 5 spaces. -/// -/// - The literal `i8`, `i16`, or `i64` followed by an integer. Output -/// as a binary integer with the specified number of bits. -/// -/// - One of the literals `SYSMIS`, `LOWEST`, or `HIGHEST`. Output as a -/// 64-bit IEEE 754 float of the appropriate PSPP value. -/// -/// - `PCSYSMIS`. Output as SPSS/PC+ system-missing value. -/// -/// - The literal `ENDIAN`. Output as a 32-bit binary integer, either with -/// value 1 if `--be` is in effect or 2 if `--le` is in effect. -/// -/// - A pair of parentheses enclosing a sequence of data items, each followed -/// by a semicolon (the last semicolon is optional). Output as the enclosed -/// data items in sequence. -/// -/// - The literal `COUNT` or `COUNT8` followed by a sequence of parenthesized -/// data items, as above. Output as a 32-bit or 8-bit binary integer whose -/// value is the number of bytes enclosed within the parentheses, followed -/// by the enclosed data items themselves. -/// -/// optionally followed by an asterisk and a positive integer, which specifies a -/// repeat count for the data item. -#[derive(Parser, Debug)] -struct Args { - /// Big-endian output format (default) - #[arg(long = "be")] - be: bool, - - /// Little-endian output format - #[arg(long = "le")] - le: bool, - - /// Input file. - #[arg(required = true, name = "input")] - input_file_name: PathBuf, - - /// Output file. - #[arg(required = true, name = "output")] - output_file_name: PathBuf, -} - -fn main() -> Result<()> { - let Args { - be, - le, - input_file_name, - output_file_name, - } = Args::parse(); - let endian = match (be, le) { - (false, false) | (true, false) => Endian::Big, - (false, true) => Endian::Little, - (true, true) => return Err(anyhow!("can't use both `--be` and `--le`")), - }; - - let input_file_str = input_file_name.to_string_lossy(); - let input = read_to_string(&input_file_name) - .map_err(|err| anyhow!("{input_file_str}: read failed ({err})"))?; - - let output = sack(&input, Some(&input_file_name), endian)?; - - let output_file_str = output_file_name.to_string_lossy(); - std::fs::write(&output_file_name, output) - .map_err(|err| anyhow!("{output_file_str}: write failed ({err})"))?; - - Ok(()) -} -- 2.30.2