From 838ff86ae7474b78c07a5f9d8136cfd4bea251db Mon Sep 17 00:00:00 2001 From: ridiculousfish Date: Sun, 9 Jun 2024 12:29:09 -0700 Subject: [PATCH] Rename printf crate to fish-printf Preparing to publish to crates.io --- Cargo.lock | 18 +++++++++--------- Cargo.toml | 2 +- printf/Cargo.toml | 2 +- src/builtins/jobs.rs | 2 +- src/builtins/printf.rs | 2 +- src/builtins/string/match.rs | 2 +- src/complete.rs | 2 +- src/job_group.rs | 4 ++-- src/key.rs | 6 +++--- src/locale.rs | 2 +- src/parse_constants.rs | 6 +++--- src/parser.rs | 2 +- src/proc.rs | 2 +- src/tokenizer.rs | 6 +++--- src/wutil/mod.rs | 4 ++-- src/wutil/printf.rs | 2 +- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b20c11187..9af4f325f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -91,6 +91,7 @@ dependencies = [ "cc", "errno", "fast-float", + "fish-printf", "lazy_static", "libc", "lru", @@ -98,7 +99,6 @@ dependencies = [ "num-traits", "once_cell", "pcre2", - "printf", "rand", "rand_pcg", "rsconf", @@ -107,6 +107,14 @@ dependencies = [ "widestring", ] +[[package]] +name = "fish-printf" +version = "0.1.0" +dependencies = [ + "libc", + "widestring", +] + [[package]] name = "fnv" version = "1.0.7" @@ -323,14 +331,6 @@ version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" -[[package]] -name = "printf" -version = "0.1.0" -dependencies = [ - "libc", - "widestring", -] - [[package]] name = "proc-macro2" version = "1.0.85" diff --git a/Cargo.toml b/Cargo.toml index 73ea2c102..c781416ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ lru = "0.12.3" nix = { version = "0.29.0", default-features = false, features = ["inotify", "resource", "fs"] } num-traits = "0.2.19" once_cell = "1.19.0" -printf = { path = "./printf" } +fish-printf = { path = "./printf" } rand = { version = "0.8.5", features = ["small_rng"] } widestring = "1.1.0" terminfo = "0.9.0" diff --git a/printf/Cargo.toml b/printf/Cargo.toml index 825beb46a..e2476dfbe 100644 --- a/printf/Cargo.toml +++ b/printf/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "printf" +name = "fish-printf" edition = "2021" version = "0.1.0" description = "printf implementation, based on musl" diff --git a/src/builtins/jobs.rs b/src/builtins/jobs.rs index 7660091af..5a817b82b 100644 --- a/src/builtins/jobs.rs +++ b/src/builtins/jobs.rs @@ -17,8 +17,8 @@ use crate::{ wchar::{wstr, WString, L}, wutil::{fish_wcstoi, wgettext_fmt}, }; +use fish_printf::sprintf; use libc::c_int; -use printf::sprintf; use std::num::NonZeroU32; use std::sync::atomic::Ordering; diff --git a/src/builtins/printf.rs b/src/builtins/printf.rs index 4c896c7f3..a67e418fd 100644 --- a/src/builtins/printf.rs +++ b/src/builtins/printf.rs @@ -57,7 +57,7 @@ use crate::wutil::{ wcstoi::{wcstoi_partial, Options as WcstoiOpts}, wstr_offset_in, }; -use printf::{sprintf_locale, ToArg}; +use fish_printf::{sprintf_locale, ToArg}; /// Return true if `c` is an octal digit. fn is_octal_digit(c: char) -> bool { diff --git a/src/builtins/string/match.rs b/src/builtins/string/match.rs index af0ff4da8..d67ec6fef 100644 --- a/src/builtins/string/match.rs +++ b/src/builtins/string/match.rs @@ -1,5 +1,5 @@ +use fish_printf::sprintf; use pcre2::utf32::{Captures, Regex, RegexBuilder}; -use printf::sprintf; use std::collections::HashMap; use super::*; diff --git a/src/complete.rs b/src/complete.rs index ade72348d..6a69e57ba 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -15,8 +15,8 @@ use crate::{ util::wcsfilecmp, }; use bitflags::bitflags; +use fish_printf::sprintf; use once_cell::sync::Lazy; -use printf::sprintf; use crate::{ abbrs::with_abbrs, diff --git a/src/job_group.rs b/src/job_group.rs index a9ad2a798..944642e80 100644 --- a/src/job_group.rs +++ b/src/job_group.rs @@ -41,8 +41,8 @@ impl ToWString for MaybeJobId { } } -impl<'a> printf::ToArg<'a> for MaybeJobId { - fn to_arg(self) -> printf::Arg<'a> { +impl<'a> fish_printf::ToArg<'a> for MaybeJobId { + fn to_arg(self) -> fish_printf::Arg<'a> { self.as_num().to_arg() } } diff --git a/src/key.rs b/src/key.rs index fb5c499a9..b5f476528 100644 --- a/src/key.rs +++ b/src/key.rs @@ -375,9 +375,9 @@ impl std::fmt::Display for Key { } } -impl printf::ToArg<'static> for Key { - fn to_arg(self) -> printf::Arg<'static> { - printf::Arg::WString(self.into()) +impl fish_printf::ToArg<'static> for Key { + fn to_arg(self) -> fish_printf::Arg<'static> { + fish_printf::Arg::WString(self.into()) } } diff --git a/src/locale.rs b/src/locale.rs index 99e0d94f0..1e95add5a 100644 --- a/src/locale.rs +++ b/src/locale.rs @@ -1,5 +1,5 @@ /// Support for the "current locale." -pub use printf::locale::{Locale, C_LOCALE}; +pub use fish_printf::locale::{Locale, C_LOCALE}; use std::sync::Mutex; /// Lock guarding libc `setlocale()` or `localeconv()` calls to avoid races. diff --git a/src/parse_constants.rs b/src/parse_constants.rs index 3b8d0eb73..d9f19e809 100644 --- a/src/parse_constants.rs +++ b/src/parse_constants.rs @@ -235,9 +235,9 @@ impl ParseKeyword { } } -impl printf::ToArg<'static> for ParseKeyword { - fn to_arg(self) -> printf::Arg<'static> { - printf::Arg::WStr(self.to_wstr()) +impl fish_printf::ToArg<'static> for ParseKeyword { + fn to_arg(self) -> fish_printf::Arg<'static> { + fish_printf::Arg::WStr(self.to_wstr()) } } diff --git a/src/parser.rs b/src/parser.rs index ee4818071..e1502ccf6 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -31,8 +31,8 @@ use crate::wait_handle::WaitHandleStore; use crate::wchar::{wstr, WString, L}; use crate::wutil::{perror, wgettext, wgettext_fmt}; use crate::{function, FLOG}; +use fish_printf::sprintf; use libc::c_int; -use printf::sprintf; use std::cell::{Ref, RefCell, RefMut}; use std::ffi::{CStr, OsStr}; use std::os::fd::{AsRawFd, OwnedFd, RawFd}; diff --git a/src/proc.rs b/src/proc.rs index 7b97bc56b..2dc5c19a8 100644 --- a/src/proc.rs +++ b/src/proc.rs @@ -25,6 +25,7 @@ use crate::wait_handle::{InternalJobId, WaitHandle, WaitHandleRef, WaitHandleSto use crate::wchar::{wstr, WString, L}; use crate::wchar_ext::ToWString; use crate::wutil::{perror, wbasename, wgettext, wperror}; +use fish_printf::sprintf; use libc::{ EBADF, EINVAL, ENOTTY, EPERM, EXIT_SUCCESS, SIGABRT, SIGBUS, SIGCONT, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGKILL, SIGPIPE, SIGQUIT, SIGSEGV, SIGSYS, SIGTTOU, SIG_DFL, SIG_IGN, STDIN_FILENO, @@ -32,7 +33,6 @@ use libc::{ WUNTRACED, _SC_CLK_TCK, }; use once_cell::sync::Lazy; -use printf::sprintf; use std::cell::{Cell, Ref, RefCell, RefMut}; use std::fs; use std::io::{Read, Write}; diff --git a/src/tokenizer.rs b/src/tokenizer.rs index a23bc6d9a..f13f80b4d 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -191,10 +191,10 @@ impl From for &'static wstr { } } -impl printf::ToArg<'static> for TokenizerError { - fn to_arg(self) -> printf::Arg<'static> { +impl fish_printf::ToArg<'static> for TokenizerError { + fn to_arg(self) -> fish_printf::Arg<'static> { let msg: &'static wstr = self.into(); - printf::Arg::WStr(msg) + fish_printf::Arg::WStr(msg) } } diff --git a/src/wutil/mod.rs b/src/wutil/mod.rs index 4778abeae..4a66271ef 100644 --- a/src/wutil/mod.rs +++ b/src/wutil/mod.rs @@ -26,8 +26,8 @@ use std::fs::{self, canonicalize}; use std::io::{self, Write}; use std::os::unix::prelude::*; -extern crate printf as extern_printf; -pub use extern_printf::sprintf; +extern crate fish_printf; +pub use fish_printf::sprintf; pub use wcstoi::*; diff --git a/src/wutil/printf.rs b/src/wutil/printf.rs index 859aac619..066e28b91 100644 --- a/src/wutil/printf.rs +++ b/src/wutil/printf.rs @@ -1,5 +1,5 @@ // Re-export sprintf macro. -pub use printf::sprintf; +pub use fish_printf::sprintf; #[cfg(test)] mod tests {