From 997d6cd9819b35b99c8da22351d4d57427dfe398 Mon Sep 17 00:00:00 2001 From: CGMossa Date: Fri, 6 Oct 2023 09:20:58 +0200 Subject: [PATCH 1/2] [internal] Clippy suggestions (#184) * Clippy suggestions * Update bindings [skip ci] --------- Co-authored-by: CGMossa --- bindings/bindings-linux-aarch64-R4.4-devel.rs | 6 ++-- bindings/bindings-linux-x86_64-R4.4-devel.rs | 6 ++-- bindings/bindings-macos-x86_64-R4.4-devel.rs | 6 ++-- .../bindings-windows-x86_64-R4.4-devel.rs | 6 ++-- build.rs | 32 +++++++++---------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/bindings/bindings-linux-aarch64-R4.4-devel.rs b/bindings/bindings-linux-aarch64-R4.4-devel.rs index d9a3ece3..0305d666 100644 --- a/bindings/bindings-linux-aarch64-R4.4-devel.rs +++ b/bindings/bindings-linux-aarch64-R4.4-devel.rs @@ -164,9 +164,9 @@ pub const R_MAJOR: &[u8; 2] = b"4\0"; pub const R_MINOR: &[u8; 4] = b"4.0\0"; pub const R_STATUS: &[u8; 29] = b"Under development (unstable)\0"; pub const R_YEAR: &[u8; 5] = b"2023\0"; -pub const R_MONTH: &[u8; 3] = b"09\0"; -pub const R_DAY: &[u8; 3] = b"29\0"; -pub const R_SVN_REVISION: u32 = 85235; +pub const R_MONTH: &[u8; 3] = b"10\0"; +pub const R_DAY: &[u8; 3] = b"04\0"; +pub const R_SVN_REVISION: u32 = 85267; pub const R_GE_definitions: u32 = 13; pub const R_GE_deviceClip: u32 = 14; pub const R_GE_group: u32 = 15; diff --git a/bindings/bindings-linux-x86_64-R4.4-devel.rs b/bindings/bindings-linux-x86_64-R4.4-devel.rs index 33c677e2..0aa46117 100644 --- a/bindings/bindings-linux-x86_64-R4.4-devel.rs +++ b/bindings/bindings-linux-x86_64-R4.4-devel.rs @@ -164,9 +164,9 @@ pub const R_MAJOR: &[u8; 2] = b"4\0"; pub const R_MINOR: &[u8; 4] = b"4.0\0"; pub const R_STATUS: &[u8; 29] = b"Under development (unstable)\0"; pub const R_YEAR: &[u8; 5] = b"2023\0"; -pub const R_MONTH: &[u8; 3] = b"09\0"; -pub const R_DAY: &[u8; 3] = b"30\0"; -pub const R_SVN_REVISION: u32 = 85239; +pub const R_MONTH: &[u8; 3] = b"10\0"; +pub const R_DAY: &[u8; 3] = b"04\0"; +pub const R_SVN_REVISION: u32 = 85267; pub const R_GE_definitions: u32 = 13; pub const R_GE_deviceClip: u32 = 14; pub const R_GE_group: u32 = 15; diff --git a/bindings/bindings-macos-x86_64-R4.4-devel.rs b/bindings/bindings-macos-x86_64-R4.4-devel.rs index eb5712ca..e1771660 100644 --- a/bindings/bindings-macos-x86_64-R4.4-devel.rs +++ b/bindings/bindings-macos-x86_64-R4.4-devel.rs @@ -166,9 +166,9 @@ pub const R_MAJOR: &[u8; 2] = b"4\0"; pub const R_MINOR: &[u8; 4] = b"4.0\0"; pub const R_STATUS: &[u8; 29] = b"Under development (unstable)\0"; pub const R_YEAR: &[u8; 5] = b"2023\0"; -pub const R_MONTH: &[u8; 3] = b"09\0"; -pub const R_DAY: &[u8; 3] = b"29\0"; -pub const R_SVN_REVISION: u32 = 85235; +pub const R_MONTH: &[u8; 3] = b"10\0"; +pub const R_DAY: &[u8; 3] = b"05\0"; +pub const R_SVN_REVISION: u32 = 85268; pub const R_GE_definitions: u32 = 13; pub const R_GE_deviceClip: u32 = 14; pub const R_GE_group: u32 = 15; diff --git a/bindings/bindings-windows-x86_64-R4.4-devel.rs b/bindings/bindings-windows-x86_64-R4.4-devel.rs index 1b41f8c0..0d953359 100644 --- a/bindings/bindings-windows-x86_64-R4.4-devel.rs +++ b/bindings/bindings-windows-x86_64-R4.4-devel.rs @@ -83,9 +83,9 @@ pub const R_MAJOR: &[u8; 2] = b"4\0"; pub const R_MINOR: &[u8; 4] = b"4.0\0"; pub const R_STATUS: &[u8; 29] = b"Under development (unstable)\0"; pub const R_YEAR: &[u8; 5] = b"2023\0"; -pub const R_MONTH: &[u8; 3] = b"09\0"; -pub const R_DAY: &[u8; 3] = b"30\0"; -pub const R_SVN_REVISION: u32 = 85239; +pub const R_MONTH: &[u8; 3] = b"10\0"; +pub const R_DAY: &[u8; 3] = b"04\0"; +pub const R_SVN_REVISION: u32 = 85267; pub const R_GE_definitions: u32 = 13; pub const R_GE_deviceClip: u32 = 14; pub const R_GE_group: u32 = 15; diff --git a/build.rs b/build.rs index 6c45778f..167db9ec 100644 --- a/build.rs +++ b/build.rs @@ -156,9 +156,7 @@ fn byte_array_to_os_string(bytes: &[u8]) -> OsString { // Execute an R script and return the captured output fn r_command>(r_binary: S, script: &str) -> io::Result { - let out = Command::new(r_binary) - .args(&["-s", "-e", script]) - .output()?; + let out = Command::new(r_binary).args(["-s", "-e", script]).output()?; // if there are any errors we print them out, helps with debugging if !out.stderr.is_empty() { @@ -220,7 +218,7 @@ fn get_r_include(r_home: &Path, library: &Path) -> io::Result { } .get_r_binary(); - let rout = r_command(&r_binary, r#"cat(normalizePath(R.home('include')))"#)?; + let rout = r_command(r_binary, r#"cat(normalizePath(R.home('include')))"#)?; if !rout.is_empty() { Ok(PathBuf::from(rout)) } else { @@ -266,7 +264,7 @@ fn parse_r_version(r_version: String) -> Result { // Bad: // - "4.1.foo" (some part contains any non-digit characters) // - "4.1." (some part is missing) - if !s.is_empty() && s.chars().all(|c| c.is_digit(10)) { + if !s.is_empty() && s.chars().all(|c| c.is_ascii_digit()) { Some(s) } else { None @@ -330,8 +328,8 @@ fn get_r_version_from_r(r_paths: &InstallationPaths) -> Result Date: Sun, 8 Oct 2023 00:03:11 +0200 Subject: [PATCH 2/2] Use `R_ParseEvalString` in test (#188) * Remove unnecessary `tasks.json` file! * Since all supported versions have `R_ParseEvalString`, then we should use it! --- .vscode/tasks.json | 18 ------------------ src/lib.rs | 12 ++---------- 2 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 .vscode/tasks.json diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 62016596..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ - { - "type": "cargo", - "subcommand": "test", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index eea9dff9..cd882a0a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -137,19 +137,11 @@ mod tests { fn test_eval() { start_R(); unsafe { - // In an ideal world, we would do the following. - // let res = R_ParseEvalString(cstr!("1"), R_NilValue); - // But R_ParseEvalString is only in recent packages. - - let s = Rf_protect(Rf_mkString(cstr!("1"))); - let mut status: ParseStatus = 0; - let status_ptr = &mut status as *mut ParseStatus; - let ps = Rf_protect(R_ParseVector(s, -1, status_ptr, R_NilValue)); - let val = Rf_eval(VECTOR_ELT(ps, 0), R_GlobalEnv); + let val = Rf_protect(R_ParseEvalString(cstr!("1"), R_NilValue)); Rf_PrintValue(val); assert_eq!(TYPEOF(val) as u32, REALSXP); assert_eq!(*REAL(val), 1.); - Rf_unprotect(2); + Rf_unprotect(1); } } }