From 7998e1e77ef057bab28434edefb79d7be6a4de33 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Mon, 3 Jul 2023 11:21:20 +0300 Subject: [PATCH] melib/datetime: add missing LC libc constants for openbsd target_os Fixes #242 "Compilation failure on master on OpenBSD" #242 --- melib/src/utils/datetime.rs | 13 +++++++++++++ melib/src/utils/shellexpand.rs | 4 +--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/melib/src/utils/datetime.rs b/melib/src/utils/datetime.rs index 8ba414e3..23a2a37f 100644 --- a/melib/src/utils/datetime.rs +++ b/melib/src/utils/datetime.rs @@ -90,6 +90,7 @@ extern "C" { fn gettimeofday(tv: *mut libc::timeval, tz: *mut libc::timezone) -> i32; } +#[cfg(not(target_os = "openbsd"))] #[repr(i32)] #[derive(Copy, Clone)] #[allow(dead_code)] @@ -98,6 +99,18 @@ enum LocaleCategoryMask { All = libc::LC_ALL_MASK, } +#[cfg(target_os = "openbsd")] +const _LC_LAST: c_int = 7; + +#[cfg(target_os = "openbsd")] +#[repr(i32)] +#[derive(Copy, Clone)] +#[allow(dead_code)] +enum LocaleCategoryMask { + Time = 1 << libc::LC_TIME, + All = (1 << _LC_LAST) - 2, +} + #[repr(i32)] #[derive(Copy, Clone)] #[allow(dead_code)] diff --git a/melib/src/utils/shellexpand.rs b/melib/src/utils/shellexpand.rs index 09d9cf58..4697e541 100644 --- a/melib/src/utils/shellexpand.rs +++ b/melib/src/utils/shellexpand.rs @@ -21,8 +21,6 @@ //! A `ShellExpandTrait` to expand paths like a shell. -#[cfg(not(any(target_os = "netbsd", target_os = "macos")))] -use std::os::unix::io::AsRawFd; use std::{ ffi::OsStr, os::unix::ffi::OsStrExt, @@ -71,7 +69,7 @@ impl ShellExpandTrait for Path { #[cfg(target_os = "linux")] fn complete(&self, force: bool) -> SmallVec<[String; 128]> { - use std::convert::TryFrom; + use std::{convert::TryFrom, os::unix::io::AsRawFd}; use libc::dirent64; use nix::fcntl::OFlag;