From a3fb4bf7e0a3224a7c0fe4a90058d50922401350 Mon Sep 17 00:00:00 2001 From: fox0 <15684995+fox0@users.noreply.github.com> Date: Sat, 28 Sep 2024 19:19:59 +0700 Subject: [PATCH] Move plib to [dev-dependencies] --- .cargo/config.toml | 2 ++ awk/Cargo.toml | 4 +++- awk/src/main.rs | 5 ++--- calc/Cargo.toml | 4 +++- calc/bc.rs | 5 ++--- calc/expr.rs | 5 ++--- datetime/Cargo.toml | 4 +++- datetime/cal.rs | 5 ++--- datetime/date.rs | 5 ++--- datetime/sleep.rs | 5 ++--- datetime/time.rs | 5 ++--- dev/Cargo.toml | 4 +++- dev/nm.rs | 5 ++--- dev/strings.rs | 5 ++--- dev/strip.rs | 5 ++--- display/Cargo.toml | 4 +++- display/echo.rs | 5 ++--- display/printf.rs | 5 ++--- file/cat.rs | 5 ++--- file/cmp.rs | 5 ++--- file/dd.rs | 5 ++--- file/file.rs | 5 ++--- file/find.rs | 5 ++--- file/od.rs | 5 ++--- file/split.rs | 5 ++--- file/tee.rs | 5 ++--- fs/Cargo.toml | 4 +++- fs/df.rs | 5 ++--- i18n/gencat.rs | 5 ++--- misc/Cargo.toml | 4 +++- misc/test.rs | 5 ++--- pathnames/Cargo.toml | 4 +++- pathnames/basename.rs | 5 ++--- pathnames/dirname.rs | 5 ++--- pathnames/pathchk.rs | 5 ++--- pathnames/realpath.rs | 5 ++--- plib/src/lib.rs | 2 -- process/env.rs | 5 ++--- process/fuser.rs | 5 ++--- process/kill.rs | 5 ++--- process/nice.rs | 5 ++--- process/nohup.rs | 5 ++--- process/renice.rs | 5 ++--- process/timeout.rs | 5 ++--- process/xargs.rs | 5 ++--- sccs/Cargo.toml | 4 +++- sccs/what.rs | 5 ++--- screen/Cargo.toml | 4 +++- screen/stty.rs | 5 ++--- screen/tabs.rs | 5 ++--- screen/tput.rs | 5 ++--- sys/getconf.rs | 5 ++--- sys/ipcrm.rs | 5 ++--- sys/ipcs.rs | 5 ++--- sys/uname.rs | 5 ++--- sys/who.rs | 6 +++--- text/asa.rs | 5 ++--- text/comm.rs | 5 ++--- text/csplit.rs | 5 ++--- text/cut.rs | 5 ++--- text/diff.rs | 5 ++--- text/expand.rs | 5 ++--- text/fold.rs | 5 ++--- text/grep.rs | 6 +++--- text/head.rs | 5 ++--- text/join.rs | 5 ++--- text/nl.rs | 5 ++--- text/paste.rs | 5 ++--- text/pr.rs | 5 ++--- text/sort.rs | 5 ++--- text/tail.rs | 6 +++--- text/tr.rs | 5 ++--- text/tsort.rs | 5 ++--- text/unexpand.rs | 6 +++--- text/uniq.rs | 6 +++--- text/wc.rs | 5 ++--- tree/chgrp.rs | 5 ++--- tree/chmod.rs | 6 +++--- tree/chown.rs | 5 ++--- tree/cp.rs | 5 ++--- tree/du.rs | 5 ++--- tree/link.rs | 5 ++--- tree/ln.rs | 5 ++--- tree/ls.rs | 6 +++--- tree/mkdir.rs | 6 +++--- tree/mkfifo.rs | 6 +++--- tree/mv.rs | 5 ++--- tree/readlink.rs | 5 ++--- tree/rm.rs | 5 ++--- tree/rmdir.rs | 5 ++--- tree/touch.rs | 5 ++--- tree/unlink.rs | 5 ++--- users/id.rs | 5 ++--- users/logger.rs | 5 ++--- users/mesg.rs | 5 ++--- users/pwd.rs | 5 ++--- users/talk.rs | 5 ++--- users/write.rs | 6 +++--- xform/cksum.rs | 5 ++--- xform/compress.rs | 5 ++--- xform/uncompress.rs | 5 ++--- xform/uudecode.rs | 5 ++--- xform/uuencode.rs | 5 ++--- 103 files changed, 224 insertions(+), 285 deletions(-) create mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 00000000..dbd057e4 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[env] +PROJECT_NAME = "posixutils-rs" diff --git a/awk/Cargo.toml b/awk/Cargo.toml index 8dfd0e02..e236368c 100644 --- a/awk/Cargo.toml +++ b/awk/Cargo.toml @@ -6,7 +6,6 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } gettext-rs.workspace = true clap.workspace = true libc.workspace = true @@ -16,6 +15,9 @@ lazy_static = "1.4" lexical = { version = "6.1", features = ["format"] } rand = {version = "0.8", default-features = false, features = ["small_rng"] } +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/awk/src/main.rs b/awk/src/main.rs index 5b0e9f35..302e2c43 100644 --- a/awk/src/main.rs +++ b/awk/src/main.rs @@ -12,7 +12,6 @@ use crate::interpreter::interpret; use clap::Parser; use compiler::SourceFile; use gettextrs::{bind_textdomain_codeset, gettext, textdomain}; -use plib::PROJECT_NAME; use std::error::Error; use std::fmt::Display; use std::io::Read; @@ -56,8 +55,8 @@ fn exit_if_error(r: Result) -> T { } fn main() -> Result<(), Box> { - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let args = Args::parse(); diff --git a/calc/Cargo.toml b/calc/Cargo.toml index e951ad67..8f0ef432 100644 --- a/calc/Cargo.toml +++ b/calc/Cargo.toml @@ -6,7 +6,6 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } gettext-rs.workspace = true regex.workspace = true clap.workspace = true @@ -16,6 +15,9 @@ lazy_static = "1.4" bigdecimal = "0.4" rustyline = { version = "14.0", default-features = false } +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/calc/bc.rs b/calc/bc.rs index ef0fe5c0..83a28b2d 100644 --- a/calc/bc.rs +++ b/calc/bc.rs @@ -16,7 +16,6 @@ use bc_util::{ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use rustyline::{error::ReadlineError, DefaultEditor, Result}; mod bc_util; @@ -45,8 +44,8 @@ fn print_output_or_error(result: ExecutionResult) { fn main() -> Result<()> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let args = Args::parse(); let mut interpreter = Interpreter::default(); diff --git a/calc/expr.rs b/calc/expr.rs index e99efd9e..51b1dbc2 100644 --- a/calc/expr.rs +++ b/calc/expr.rs @@ -8,7 +8,6 @@ // use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use regex::Regex; #[derive(Clone, Debug, PartialEq)] @@ -372,8 +371,8 @@ fn eval_expression(tokens: &[Token]) -> Result { fn main() -> Result<(), Box> { // initialize translations setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // tokenize and evaluate the expression let arg_tokens = tokenize(); diff --git a/datetime/Cargo.toml b/datetime/Cargo.toml index b5656e43..59bfae0b 100644 --- a/datetime/Cargo.toml +++ b/datetime/Cargo.toml @@ -7,12 +7,14 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } clap.workspace = true gettext-rs.workspace = true chrono.workspace = true libc.workspace = true +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/datetime/cal.rs b/datetime/cal.rs index b075909a..9d9cfc16 100644 --- a/datetime/cal.rs +++ b/datetime/cal.rs @@ -14,7 +14,6 @@ use chrono::Datelike; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; #[derive(Parser)] #[command(version, about = gettext("cal - print a calendar"))] @@ -98,8 +97,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // If no arguments are provided, display the current month if args.month.is_none() && args.year.is_none() { diff --git a/datetime/date.rs b/datetime/date.rs index bbad511d..5f900f9b 100644 --- a/datetime/date.rs +++ b/datetime/date.rs @@ -14,7 +14,6 @@ use chrono::{DateTime, Datelike, Local, LocalResult, TimeZone, Utc}; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; const DEF_TIMESTR: &str = "%a %b %e %H:%M:%S %Z %Y"; @@ -150,8 +149,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; match &args.timestr { None => show_time(args.utc, DEF_TIMESTR), diff --git a/datetime/sleep.rs b/datetime/sleep.rs index 9206a5b1..daffa775 100644 --- a/datetime/sleep.rs +++ b/datetime/sleep.rs @@ -10,7 +10,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; use libc::{signal, SIGALRM, SIG_IGN}; -use plib::PROJECT_NAME; use std::{thread, time}; #[derive(Parser)] @@ -28,8 +27,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; unsafe { // Ignore the SIGALRM signal diff --git a/datetime/time.rs b/datetime/time.rs index c96eb988..f49b02c0 100644 --- a/datetime/time.rs +++ b/datetime/time.rs @@ -14,7 +14,6 @@ use std::time::Instant; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; #[derive(Parser)] #[command( @@ -125,8 +124,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; if let Err(err) = time(args) { match err { diff --git a/dev/Cargo.toml b/dev/Cargo.toml index 23996156..168cad02 100644 --- a/dev/Cargo.toml +++ b/dev/Cargo.toml @@ -7,13 +7,15 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } clap.workspace = true gettext-rs.workspace = true object = { version = "0.35", features = ["read", "build", "elf"]} chrono.workspace = true ar = "0.9" +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/dev/nm.rs b/dev/nm.rs index ebae7ad8..4ce0046d 100644 --- a/dev/nm.rs +++ b/dev/nm.rs @@ -18,7 +18,6 @@ use object::{ use clap::{Parser, ValueEnum}; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::collections::HashMap; use std::fs; @@ -147,8 +146,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; show_object_file(&args)?; diff --git a/dev/strings.rs b/dev/strings.rs index 7666cb32..1edc3550 100644 --- a/dev/strings.rs +++ b/dev/strings.rs @@ -12,7 +12,6 @@ use std::ffi::OsString; use clap::{Parser, ValueEnum}; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; use object::{Object, ObjectSection}; -use plib::PROJECT_NAME; #[derive(Clone, Copy, ValueEnum)] enum OffsetFormat { @@ -188,8 +187,8 @@ where fn main() -> StringsResult { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let args = Args::parse(); match CharacterSet::from_env() { diff --git a/dev/strip.rs b/dev/strip.rs index e6eaa471..0af2b139 100644 --- a/dev/strip.rs +++ b/dev/strip.rs @@ -19,7 +19,6 @@ use object::{ build::elf::{Builder, Section, SectionData}, elf, }; -use plib::PROJECT_NAME; #[derive(Parser)] #[command(version, about = gettext("strip - remove unnecessary information from strippable files"))] @@ -145,8 +144,8 @@ fn strip_file(file: &OsStr) { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let args = Args::parse(); for file in args.input_files { diff --git a/display/Cargo.toml b/display/Cargo.toml index 41b419ee..39c10e7a 100644 --- a/display/Cargo.toml +++ b/display/Cargo.toml @@ -7,10 +7,12 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } clap.workspace = true gettext-rs.workspace = true +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/display/echo.rs b/display/echo.rs index 70c18645..5a9ba660 100644 --- a/display/echo.rs +++ b/display/echo.rs @@ -14,7 +14,6 @@ // use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Write}; fn translate_str(skip_nl: bool, s: &str) -> String { @@ -73,8 +72,8 @@ fn translate_str(skip_nl: bool, s: &str) -> String { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut args: Vec = std::env::args().collect(); args.remove(0); diff --git a/display/printf.rs b/display/printf.rs index 32e8c33d..2b41f697 100644 --- a/display/printf.rs +++ b/display/printf.rs @@ -12,7 +12,6 @@ // use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Write}; // the following structure is a printf format conversion specifier @@ -322,8 +321,8 @@ fn do_printf(format: &str, args: &[String]) -> io::Result<()> { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let args: Vec = std::env::args().collect(); diff --git a/file/cat.rs b/file/cat.rs index 9ed22378..f7cfa75b 100644 --- a/file/cat.rs +++ b/file/cat.rs @@ -14,7 +14,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Read, Write}; use std::path::PathBuf; @@ -54,8 +53,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // if no file args, read from stdin if args.files.is_empty() { diff --git a/file/cmp.rs b/file/cmp.rs index 17557fdc..b9a75bfa 100644 --- a/file/cmp.rs +++ b/file/cmp.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, ErrorKind, Read}; use std::path::PathBuf; use std::process::ExitCode; @@ -139,8 +138,8 @@ fn main() -> ExitCode { // Initialize translation system setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME).unwrap(); - bind_textdomain_codeset(PROJECT_NAME, "UTF-8").unwrap(); + textdomain(env!("PROJECT_NAME")).unwrap(); + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8").unwrap(); match cmp_main(&args) { Ok(x) => ExitCode::from(x), diff --git a/file/dd.rs b/file/dd.rs index 9c1a3ced..8227351a 100644 --- a/file/dd.rs +++ b/file/dd.rs @@ -8,7 +8,6 @@ // use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs; use std::io::{self, Read, Write}; @@ -382,8 +381,8 @@ fn parse_cmdline(args: &[String]) -> Result> fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let args: Vec = std::env::args().skip(1).collect(); let config = parse_cmdline(&args)?; diff --git a/file/file.rs b/file/file.rs index 7280314a..8690ed74 100644 --- a/file/file.rs +++ b/file/file.rs @@ -10,7 +10,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use regex::Regex; use std::{ error::Error, @@ -665,8 +664,8 @@ fn main() -> Result<(), Box> { // Initialize translation system setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME).unwrap(); - bind_textdomain_codeset(PROJECT_NAME, "UTF-8").unwrap(); + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; for file in &args.files { analyze_file(file.clone(), &args); diff --git a/file/find.rs b/file/find.rs index bafa20ee..0486b9fe 100644 --- a/file/find.rs +++ b/file/find.rs @@ -8,7 +8,6 @@ // use gettextrs::{bind_textdomain_codeset, textdomain}; -use plib::PROJECT_NAME; use regex::Regex; use std::collections::HashSet; use std::os::unix::fs::{FileTypeExt, MetadataExt, PermissionsExt}; @@ -484,8 +483,8 @@ fn find(args: Vec) -> Result<(), String> { } fn main() -> Result<(), Box> { - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let args: Vec = env::args().collect(); diff --git a/file/od.rs b/file/od.rs index 13a277f5..b8970006 100644 --- a/file/od.rs +++ b/file/od.rs @@ -10,7 +10,6 @@ use crate::io::ErrorKind; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs::File; use std::io::{self, BufReader, Error, Read, Seek, SeekFrom}; use std::num::ParseIntError; @@ -1138,8 +1137,8 @@ fn od(args: &Args) -> Result<(), Box> { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut args = Args::parse(); args.validate_args()?; diff --git a/file/split.rs b/file/split.rs index 65597e00..d27f84a5 100644 --- a/file/split.rs +++ b/file/split.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::cmp; use std::fs::{File, OpenOptions}; use std::io::{self, BufRead, Error, ErrorKind, Read, Write}; @@ -253,8 +252,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; if args.lines.is_none() && args.bytes.is_none() { args.lines = Some(1000); diff --git a/file/tee.rs b/file/tee.rs index 4ef22ed8..d534d283 100644 --- a/file/tee.rs +++ b/file/tee.rs @@ -10,7 +10,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; use libc::{signal, SIGINT, SIG_IGN}; -use plib::PROJECT_NAME; use std::fs::{File, OpenOptions}; use std::io::{self, Read, Write}; @@ -104,8 +103,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; if args.ignore { unsafe { diff --git a/fs/Cargo.toml b/fs/Cargo.toml index 4a9f2a2c..dcbbeb6e 100644 --- a/fs/Cargo.toml +++ b/fs/Cargo.toml @@ -7,11 +7,13 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } clap.workspace = true gettext-rs.workspace = true libc.workspace = true +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/fs/df.rs b/fs/df.rs index 905b4e76..f34da79a 100644 --- a/fs/df.rs +++ b/fs/df.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::ffi::{CStr, CString}; use std::io; @@ -265,8 +264,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut info = read_mount_info()?; diff --git a/i18n/gencat.rs b/i18n/gencat.rs index d6bc40cf..02fce962 100644 --- a/i18n/gencat.rs +++ b/i18n/gencat.rs @@ -1,7 +1,6 @@ use byteorder::{BigEndian, ByteOrder, LittleEndian, NativeEndian, WriteBytesExt}; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::{ cell::RefCell, collections::BTreeMap, @@ -779,8 +778,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/misc/Cargo.toml b/misc/Cargo.toml index 05ecc4c7..d80ff022 100644 --- a/misc/Cargo.toml +++ b/misc/Cargo.toml @@ -7,11 +7,13 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } clap.workspace = true libc.workspace = true gettext-rs.workspace = true +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/misc/test.rs b/misc/test.rs index 516fa59a..6624dfa7 100644 --- a/misc/test.rs +++ b/misc/test.rs @@ -12,7 +12,6 @@ // use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::os::unix::fs::FileTypeExt; use std::os::unix::fs::MetadataExt; use std::os::unix::fs::PermissionsExt; @@ -280,8 +279,8 @@ fn eval_binary(s1: &str, op_str: &str, s2: &str) -> bool { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut args: Vec = std::env::args().collect(); diff --git a/pathnames/Cargo.toml b/pathnames/Cargo.toml index 4dcf1479..243e0f46 100644 --- a/pathnames/Cargo.toml +++ b/pathnames/Cargo.toml @@ -7,11 +7,13 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } clap.workspace = true gettext-rs.workspace = true libc.workspace = true +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/pathnames/basename.rs b/pathnames/basename.rs index c2074cb1..62a8a79f 100644 --- a/pathnames/basename.rs +++ b/pathnames/basename.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::path::Path; #[derive(Parser)] @@ -56,8 +55,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; show_basename(&args); diff --git a/pathnames/dirname.rs b/pathnames/dirname.rs index e3ac3fe3..7cb46b33 100644 --- a/pathnames/dirname.rs +++ b/pathnames/dirname.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::ffi::OsString; use std::path::PathBuf; @@ -44,8 +43,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; show_dirname(&args); diff --git a/pathnames/pathchk.rs b/pathnames/pathchk.rs index 54bbcd2e..b379c0b4 100644 --- a/pathnames/pathchk.rs +++ b/pathnames/pathchk.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::ffi::CString; use std::path::{Component, Path}; @@ -146,8 +145,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/pathnames/realpath.rs b/pathnames/realpath.rs index 658d2430..8dd33833 100644 --- a/pathnames/realpath.rs +++ b/pathnames/realpath.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::path::{Component, Path, PathBuf}; /// realpath -- return resolved canonical path @@ -66,8 +65,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/plib/src/lib.rs b/plib/src/lib.rs index 706e5e9b..204c022d 100644 --- a/plib/src/lib.rs +++ b/plib/src/lib.rs @@ -18,8 +18,6 @@ pub mod sccsfile; pub mod testing; pub mod utmpx; -pub const PROJECT_NAME: &'static str = "posixutils-rs"; - pub const BUFSZ: usize = 8 * 1024; pub use testing::*; diff --git a/process/env.rs b/process/env.rs index 6b492db6..91a192e8 100644 --- a/process/env.rs +++ b/process/env.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::collections::HashMap; use std::env; use std::io; @@ -96,8 +95,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let (envs, util_args) = separate_ops(&args.operands); let new_env = merge_env(&envs, args.ignore_env); diff --git a/process/fuser.rs b/process/fuser.rs index 1541bd3e..4a95eba0 100644 --- a/process/fuser.rs +++ b/process/fuser.rs @@ -9,7 +9,6 @@ use clap::{CommandFactory, Parser}; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs::{metadata, Metadata}; use std::io::{self, Write}; use std::sync::mpsc; @@ -1357,8 +1356,8 @@ struct Args { } fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let Args { mount, user, file, .. diff --git a/process/kill.rs b/process/kill.rs index 8a865038..586cd519 100644 --- a/process/kill.rs +++ b/process/kill.rs @@ -8,7 +8,6 @@ // use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; #[cfg(target_os = "macos")] const SIGLIST: [(&str, u32); 31] = [ @@ -186,8 +185,8 @@ fn send_signal(prog_cfg: &Config, sig_no: u32) -> u32 { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let prog_cfg = parse_cmdline()?; diff --git a/process/nice.rs b/process/nice.rs index a9906aff..a4a499ae 100644 --- a/process/nice.rs +++ b/process/nice.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io; use std::os::unix::process::CommandExt; use std::process::{Command, Stdio}; @@ -55,8 +54,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let res = unsafe { libc::nice(args.niceval) }; if res < 0 { diff --git a/process/nohup.rs b/process/nohup.rs index 83d685c2..5781099d 100644 --- a/process/nohup.rs +++ b/process/nohup.rs @@ -10,7 +10,6 @@ use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; use libc::signal; use libc::{dup, dup2, SIGHUP, SIG_IGN}; -use plib::PROJECT_NAME; use std::env; use std::fs::{File, OpenOptions}; use std::io::{self, IsTerminal}; @@ -19,8 +18,8 @@ use std::process::{self, Command}; fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; unsafe { // Ignore the SIGHUP signal diff --git a/process/renice.rs b/process/renice.rs index 2ac55152..5d4b4d68 100644 --- a/process/renice.rs +++ b/process/renice.rs @@ -11,7 +11,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; use libc::{getpwnam, passwd}; use plib::priority::{getpriority, setpriority}; -use plib::PROJECT_NAME; use std::ffi::CString; const PRIO_MIN: i32 = -20; @@ -105,8 +104,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // which class of priority to modify let which: u32 = { diff --git a/process/timeout.rs b/process/timeout.rs index e06ffea2..40f3df5b 100644 --- a/process/timeout.rs +++ b/process/timeout.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::{ error::Error, os::unix::{ @@ -583,8 +582,8 @@ fn main() -> Result<(), Box> { }); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let exit_code = timeout(args); std::process::exit(exit_code); diff --git a/process/xargs.rs b/process/xargs.rs index 8c7497a6..de346181 100644 --- a/process/xargs.rs +++ b/process/xargs.rs @@ -16,7 +16,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Read}; use std::process::{Command, Stdio}; @@ -350,8 +349,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; read_and_spawn(&args)?; diff --git a/sccs/Cargo.toml b/sccs/Cargo.toml index ceba10a8..d64fc231 100644 --- a/sccs/Cargo.toml +++ b/sccs/Cargo.toml @@ -7,10 +7,12 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } clap.workspace = true gettext-rs.workspace = true +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/sccs/what.rs b/sccs/what.rs index 42f0e3ff..4f516036 100644 --- a/sccs/what.rs +++ b/sccs/what.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs::File; use std::io::{self, BufRead, BufReader}; use std::path::{Path, PathBuf}; @@ -54,8 +53,8 @@ fn main() -> io::Result<()> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; for file in &args.files { let path = Path::new(file); diff --git a/screen/Cargo.toml b/screen/Cargo.toml index 1199b403..e68a4215 100644 --- a/screen/Cargo.toml +++ b/screen/Cargo.toml @@ -7,13 +7,15 @@ license.workspace = true edition.workspace = true [dependencies] -plib = { path = "../plib" } clap.workspace = true gettext-rs.workspace = true terminfo = "0.8" termios = "0.3" libc.workspace = true +[dev-dependencies] +plib = { path = "../plib" } + [lints] workspace = true diff --git a/screen/stty.rs b/screen/stty.rs index ae9535fb..96b63baa 100644 --- a/screen/stty.rs +++ b/screen/stty.rs @@ -15,7 +15,6 @@ mod osdata; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; use osdata::{ParamType, PARG, PNEG}; -use plib::PROJECT_NAME; use std::collections::HashMap; use std::io::{self, Error, ErrorKind}; use termios::{ @@ -556,8 +555,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // load termio settings let ti = Termios::from_fd(libc::STDIN_FILENO)?; diff --git a/screen/tabs.rs b/screen/tabs.rs index 22da6c3a..7a658c89 100644 --- a/screen/tabs.rs +++ b/screen/tabs.rs @@ -14,7 +14,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Error, ErrorKind, Write}; use terminfo::{capability as cap, Database}; @@ -214,8 +213,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let info = match args.term { None => Database::from_env().unwrap(), diff --git a/screen/tput.rs b/screen/tput.rs index 06b49b44..e48f1ada 100644 --- a/screen/tput.rs +++ b/screen/tput.rs @@ -13,7 +13,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io; use terminfo::{capability as cap, Database}; @@ -76,8 +75,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let info = match args.term { None => Database::from_env().unwrap(), diff --git a/sys/getconf.rs b/sys/getconf.rs index 5cddd7f8..ff50b1c1 100644 --- a/sys/getconf.rs +++ b/sys/getconf.rs @@ -15,7 +15,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; use libc::{pathconf, sysconf}; -use plib::PROJECT_NAME; use std::collections::HashMap; use std::ffi::CString; @@ -329,8 +328,8 @@ fn main() -> Result<(), Box> { // Set locale and text domain for localization setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; if let Some(pathname) = args.pathname { let pathconf_mappings = load_pathconf_mapping(); diff --git a/sys/ipcrm.rs b/sys/ipcrm.rs index be844583..0576c698 100644 --- a/sys/ipcrm.rs +++ b/sys/ipcrm.rs @@ -12,7 +12,6 @@ use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleC #[cfg(not(target_os = "macos"))] use libc::{msgctl, msgget, msqid_ds}; use libc::{semctl, semget, shmctl, shmget, shmid_ds}; -use plib::PROJECT_NAME; use std::ffi::{c_int, c_ushort}; use std::io::{self, Error, ErrorKind}; use std::ptr; @@ -201,8 +200,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/sys/ipcs.rs b/sys/ipcs.rs index b7ebf7fb..671a9715 100644 --- a/sys/ipcs.rs +++ b/sys/ipcs.rs @@ -10,7 +10,6 @@ use chrono::Local; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; /// ipcs - report XSI interprocess communication facilities status #[derive(Parser)] @@ -262,8 +261,8 @@ fn main() -> Result<(), Box> { // Set locale and text domain for localization setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // Validate arguments and determine what to display if args.all { diff --git a/sys/uname.rs b/sys/uname.rs index 33fe0550..a550090b 100644 --- a/sys/uname.rs +++ b/sys/uname.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; /// uname - return system name #[derive(Parser)] @@ -77,8 +76,8 @@ fn main() -> Result<(), Box> { } setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/sys/who.rs b/sys/who.rs index 699ecaec..d9a3cece 100644 --- a/sys/who.rs +++ b/sys/who.rs @@ -13,7 +13,7 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::{platform, PROJECT_NAME}; +use plib::platform; use std::path::PathBuf; /// who - display who is on the system @@ -208,8 +208,8 @@ fn main() -> Result<(), Box> { } setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/text/asa.rs b/text/asa.rs index 6225cc80..ed02d561 100644 --- a/text/asa.rs +++ b/text/asa.rs @@ -13,7 +13,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, BufRead}; use std::path::PathBuf; @@ -129,8 +128,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // if no files, read from stdin if args.files.is_empty() { diff --git a/text/comm.rs b/text/comm.rs index 90c30d2e..b9f35a63 100644 --- a/text/comm.rs +++ b/text/comm.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs; use std::io::{self, BufRead, Write}; use std::path::PathBuf; @@ -150,8 +149,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mask = args_mask(&args); diff --git a/text/csplit.rs b/text/csplit.rs index 86e7428c..e0e3cc88 100644 --- a/text/csplit.rs +++ b/text/csplit.rs @@ -12,7 +12,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use regex::Regex; use std::fs::{self, File, OpenOptions}; use std::io::{self, BufRead, Error, ErrorKind, Read, Write}; @@ -597,8 +596,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let ctx = parse_operands(&args)?; diff --git a/text/cut.rs b/text/cut.rs index 8fe8e068..7f3f1636 100644 --- a/text/cut.rs +++ b/text/cut.rs @@ -11,7 +11,6 @@ use std::io::{self, BufRead, Error, ErrorKind, Read}; use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::path::PathBuf; /// Cut - cut out selected fields of each line of a file @@ -438,8 +437,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/text/diff.rs b/text/diff.rs index 07c8543f..8a88bacc 100644 --- a/text/diff.rs +++ b/text/diff.rs @@ -25,7 +25,6 @@ use diff_util::{ functions::check_existance, }; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; /// diff - compare two files #[derive(Parser, Clone)] @@ -105,8 +104,8 @@ impl From<&Args> for OutputFormat { fn check_difference(args: Args) -> io::Result { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let output_format: OutputFormat = (&args).into(); diff --git a/text/expand.rs b/text/expand.rs index 00c3ae5b..b04d3355 100644 --- a/text/expand.rs +++ b/text/expand.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, BufWriter, Read, Write}; use std::path::PathBuf; @@ -134,8 +133,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let tablist = { if let Some(ref tablist) = args.tablist { diff --git a/text/fold.rs b/text/fold.rs index 4f2bc35b..65543467 100644 --- a/text/fold.rs +++ b/text/fold.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Read, Write}; use std::path::PathBuf; @@ -169,8 +168,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // if no files, read from stdin if args.files.is_empty() { diff --git a/text/grep.rs b/text/grep.rs index 5c7423c6..3683b79f 100644 --- a/text/grep.rs +++ b/text/grep.rs @@ -10,7 +10,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, textdomain}; use libc::{regcomp, regex_t, regexec, regfree, REG_EXTENDED, REG_ICASE, REG_NOMATCH}; -use plib::PROJECT_NAME; use std::{ ffi::CString, fs::File, @@ -488,8 +487,9 @@ impl GrepModel { // 1 - No lines were selected. // >1 - An error occurred. fn main() -> Result<(), Box> { - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; + // Parse command line arguments let mut args = Args::parse(); diff --git a/text/head.rs b/text/head.rs index 88b0b1db..4689acb5 100644 --- a/text/head.rs +++ b/text/head.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Read, Write}; use std::path::PathBuf; @@ -85,8 +84,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // if no files, read from stdin if args.files.is_empty() { diff --git a/text/join.rs b/text/join.rs index 8d959ad6..458f198a 100644 --- a/text/join.rs +++ b/text/join.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::collections::HashMap; use std::fs::File; use std::io::{self, BufRead, BufReader}; @@ -182,8 +181,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/text/nl.rs b/text/nl.rs index f0a376c3..896fdf39 100644 --- a/text/nl.rs +++ b/text/nl.rs @@ -9,7 +9,6 @@ use clap::{Parser, ValueEnum}; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use regex::Regex; use std::fs; use std::io::{self, BufRead, Read}; @@ -325,8 +324,8 @@ fn main() -> ExitCode { // Initialize translation system setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME).unwrap(); - bind_textdomain_codeset(PROJECT_NAME, "UTF-8").unwrap(); + textdomain(env!("PROJECT_NAME")).unwrap(); + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8").unwrap(); match nl_main(&args) { Ok(_) => ExitCode::from(0), diff --git a/text/paste.rs b/text/paste.rs index 38f21449..b98b0ecc 100644 --- a/text/paste.rs +++ b/text/paste.rs @@ -16,7 +16,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::cell::Cell; use std::collections::hash_map::Entry; use std::collections::HashMap; @@ -430,8 +429,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let Args { delims, diff --git a/text/pr.rs b/text/pr.rs index 63e3c93d..0fb0facb 100644 --- a/text/pr.rs +++ b/text/pr.rs @@ -11,7 +11,6 @@ mod pr_util; use chrono::{DateTime, Local}; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fmt::Write as _; use std::fs; use std::io::{self, Read}; @@ -534,8 +533,8 @@ fn pr_merged(paths: &[PathBuf], params: &Parameters) -> io::Result<()> { fn main() -> ExitCode { // Initialize translation system setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME).unwrap(); - bind_textdomain_codeset(PROJECT_NAME, "UTF-8").unwrap(); + textdomain(env!("PROJECT_NAME")).unwrap(); + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8").unwrap(); let args = Args::parse_custom(); diff --git a/text/sort.rs b/text/sort.rs index 3e83d8ee..362adf7c 100644 --- a/text/sort.rs +++ b/text/sort.rs @@ -18,7 +18,6 @@ use std::{ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; /// Sort, merge, or sequence check text files #[derive(Parser)] @@ -1019,8 +1018,8 @@ fn main() -> Result<(), Box> { args.validate_args()?; setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/text/tail.rs b/text/tail.rs index 53ee89a0..fb5f10c2 100644 --- a/text/tail.rs +++ b/text/tail.rs @@ -3,7 +3,6 @@ use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; use notify_debouncer_full::new_debouncer; use notify_debouncer_full::notify::event::{ModifyKind, RemoveKind}; use notify_debouncer_full::notify::{EventKind, RecursiveMode, Watcher}; -use plib::PROJECT_NAME; use std::fs::File; use std::io::{self, BufRead, BufReader, Read, Seek, SeekFrom, Write}; use std::path::{Path, PathBuf}; @@ -409,8 +408,9 @@ fn tail(args: &Args) -> Result<(), Box> { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; + let mut args = Args::parse(); args.validate_args()?; let mut exit_code = 0; diff --git a/text/tr.rs b/text/tr.rs index fb564a2e..17895eda 100644 --- a/text/tr.rs +++ b/text/tr.rs @@ -1,7 +1,6 @@ use clap::Parser; use deunicode::deunicode_char; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use regex::Regex; use std::collections::{HashMap, HashSet}; use std::io::{self, Read}; @@ -996,8 +995,8 @@ fn tr(args: &Args) -> Result<(), Box> { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let args = Args::parse(); args.validate_args()?; diff --git a/text/tsort.rs b/text/tsort.rs index 115299ab..88b4f459 100644 --- a/text/tsort.rs +++ b/text/tsort.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, BufRead}; use std::path::PathBuf; use topological_sort::TopologicalSort; @@ -69,8 +68,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/text/unexpand.rs b/text/unexpand.rs index 84242800..e10ebe69 100644 --- a/text/unexpand.rs +++ b/text/unexpand.rs @@ -1,6 +1,5 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, BufRead, Write}; use std::path::PathBuf; @@ -25,8 +24,9 @@ fn parse_tablist(s: &str) -> Result, std::num::ParseIntError> { fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; + let args = Args::parse(); let mut exit_code = 0; diff --git a/text/uniq.rs b/text/uniq.rs index d31b9505..30131a74 100644 --- a/text/uniq.rs +++ b/text/uniq.rs @@ -1,6 +1,5 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs::File; use std::io::{self, BufRead, BufReader, Write}; use std::path::PathBuf; @@ -197,8 +196,9 @@ fn output_result( /// Returns an error if there is an issue with the arguments or the uniq function. fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; + let args = Args::parse(); args.validate_args()?; diff --git a/text/wc.rs b/text/wc.rs index 9c5441b5..43932ae6 100644 --- a/text/wc.rs +++ b/text/wc.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::ffi::OsStr; use std::io::{self, Read}; use std::path::PathBuf; @@ -187,8 +186,8 @@ fn main() -> Result<(), Box> { } setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; let mut totals = CountInfo::new(); diff --git a/tree/chgrp.rs b/tree/chgrp.rs index d790d9c6..6a54de41 100644 --- a/tree/chgrp.rs +++ b/tree/chgrp.rs @@ -12,7 +12,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::ffi::CString; use std::path::Path; use std::{fs, io}; @@ -97,8 +96,8 @@ fn main() -> Result<(), Box> { // initialize translations setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/tree/chmod.rs b/tree/chmod.rs index b1db2256..487461d6 100644 --- a/tree/chmod.rs +++ b/tree/chmod.rs @@ -10,7 +10,7 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; use modestr::{ChmodMode, ChmodSymbolic}; -use plib::{modestr, PROJECT_NAME}; +use plib::modestr; use std::os::unix::fs::PermissionsExt; use std::path::Path; use std::{fs, io}; @@ -80,8 +80,8 @@ fn main() -> Result<(), Box> { // initialize translations setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/tree/chown.rs b/tree/chown.rs index 2567cf0b..a3a49141 100644 --- a/tree/chown.rs +++ b/tree/chown.rs @@ -12,7 +12,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::ffi::CString; use std::os::unix::fs::MetadataExt; use std::path::Path; @@ -137,8 +136,8 @@ fn main() -> Result<(), Box> { // initialize translations setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/tree/cp.rs b/tree/cp.rs index f87bf5ea..171c0f91 100644 --- a/tree/cp.rs +++ b/tree/cp.rs @@ -12,7 +12,6 @@ mod common; use self::common::{copy_file, copy_files, error_string, CopyConfig}; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::collections::HashSet; use std::path::PathBuf; use std::{fs, io}; @@ -108,8 +107,8 @@ fn main() -> Result<(), Box> { // Initialize translation system setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; if args.files.len() < 2 { eprintln!("{}", gettext("Must supply a source and target for copy")); diff --git a/tree/du.rs b/tree/du.rs index d13d90a8..810bbad6 100644 --- a/tree/du.rs +++ b/tree/du.rs @@ -12,7 +12,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::os::unix::fs::MetadataExt; use std::path::Path; use std::{fs, io}; @@ -114,8 +113,8 @@ fn main() -> Result<(), Box> { // initialize translations setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; let mut total = 0; diff --git a/tree/link.rs b/tree/link.rs index 5a699d08..1fc1150f 100644 --- a/tree/link.rs +++ b/tree/link.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::{fs, io}; /// link - call link function @@ -33,8 +32,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/tree/ln.rs b/tree/ln.rs index 447e0b04..32416405 100644 --- a/tree/ln.rs +++ b/tree/ln.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::path::{Path, PathBuf}; use std::{fs, io}; @@ -52,8 +51,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; if args.files.len() < 2 { eprintln!("{}", gettext("Must supply a source and target for linking")); diff --git a/tree/ls.rs b/tree/ls.rs index a43a1846..0a83fb25 100644 --- a/tree/ls.rs +++ b/tree/ls.rs @@ -12,7 +12,7 @@ mod ls_util; use self::ls_util::{ls_from_utf8_lossy, Entry, LongFormatPadding, MultiColumnPadding}; use clap::{CommandFactory, FromArgMatches, Parser}; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::{platform::P_WINSIZE_REQUEST_CODE, PROJECT_NAME}; +use plib::platform::P_WINSIZE_REQUEST_CODE; use std::{ collections::HashMap, ffi::{CString, OsStr}, @@ -1323,8 +1323,8 @@ fn process_single_dir( fn main() -> ExitCode { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME).unwrap(); - bind_textdomain_codeset(PROJECT_NAME, "UTF-8").unwrap(); + textdomain(env!("PROJECT_NAME")).unwrap(); + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8").unwrap(); let (config, paths) = Config::new(); diff --git a/tree/mkdir.rs b/tree/mkdir.rs index b6b96240..0d00a7f1 100644 --- a/tree/mkdir.rs +++ b/tree/mkdir.rs @@ -10,7 +10,7 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; use modestr::ChmodMode; -use plib::{modestr, PROJECT_NAME}; +use plib::modestr; use std::ffi::CString; use std::io; use std::path::PathBuf; @@ -70,8 +70,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/tree/mkfifo.rs b/tree/mkfifo.rs index 9354a8f2..b4338f6e 100644 --- a/tree/mkfifo.rs +++ b/tree/mkfifo.rs @@ -10,7 +10,7 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; use modestr::ChmodMode; -use plib::{modestr, PROJECT_NAME}; +use plib::modestr; use std::io; /// mkfifo - make FIFO special files @@ -44,8 +44,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/tree/mv.rs b/tree/mv.rs index a572322b..4709ebc5 100644 --- a/tree/mv.rs +++ b/tree/mv.rs @@ -14,7 +14,6 @@ use self::common::{copy_file, error_string}; use clap::Parser; use common::CopyConfig; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::{ collections::{HashMap, HashSet}, ffi::CString, @@ -376,8 +375,8 @@ fn main() -> Result<(), Box> { // Initialize translation system setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; if args.files.len() < 2 { eprintln!( diff --git a/tree/readlink.rs b/tree/readlink.rs index ddbbf251..4b7723c7 100644 --- a/tree/readlink.rs +++ b/tree/readlink.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::Write; use std::path::PathBuf; use std::{fs, io}; @@ -58,8 +57,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/tree/rm.rs b/tree/rm.rs index 220d51ec..5e90cc88 100644 --- a/tree/rm.rs +++ b/tree/rm.rs @@ -13,7 +13,6 @@ use self::common::error_string; use clap::Parser; use ftw::{self, traverse_directory}; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::{ ffi::CString, fs, @@ -437,8 +436,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let is_tty = io::stdin().is_terminal(); let cfg = RmConfig { args, is_tty }; diff --git a/tree/rmdir.rs b/tree/rmdir.rs index 453c50ca..45e634cd 100644 --- a/tree/rmdir.rs +++ b/tree/rmdir.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs; use std::io::{self, Error, ErrorKind}; use std::path::Path; @@ -50,8 +49,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/tree/touch.rs b/tree/touch.rs index 040524ad..2b7e9636 100644 --- a/tree/touch.rs +++ b/tree/touch.rs @@ -10,7 +10,6 @@ use chrono::{DateTime, Datelike, LocalResult, TimeZone, Utc}; use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; /// touch - change file access and modification times #[derive(Parser)] @@ -253,8 +252,8 @@ fn main() -> Result<(), Box> { // initialize translations setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // default to changing both access and modification times if !args.access && !args.mtime { diff --git a/tree/unlink.rs b/tree/unlink.rs index 20a40434..af484e89 100644 --- a/tree/unlink.rs +++ b/tree/unlink.rs @@ -9,7 +9,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::{fs, io}; /// unlink - call the unlink function @@ -31,8 +30,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/users/id.rs b/users/id.rs index abbdf434..c91de4ec 100644 --- a/users/id.rs +++ b/users/id.rs @@ -12,7 +12,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::collections::HashMap; use std::io::Error; @@ -197,8 +196,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut userinfo = get_user_info(&args)?; get_group_info(&mut userinfo)?; diff --git a/users/logger.rs b/users/logger.rs index 8e110f85..d6ebd364 100644 --- a/users/logger.rs +++ b/users/logger.rs @@ -8,13 +8,12 @@ // use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use syslog::{Facility, Formatter3164}; fn main() -> Result<(), Box> { setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut args: Vec = std::env::args().collect(); args.remove(0); diff --git a/users/mesg.rs b/users/mesg.rs index 561a63bc..ea2a1bad 100644 --- a/users/mesg.rs +++ b/users/mesg.rs @@ -13,7 +13,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Error, ErrorKind, IsTerminal}; use std::mem; @@ -125,8 +124,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let (fd, stat) = stat_tty()?; diff --git a/users/pwd.rs b/users/pwd.rs index ba491d2a..6fdf5680 100644 --- a/users/pwd.rs +++ b/users/pwd.rs @@ -12,7 +12,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::ffi::OsStr; use std::path::{Component, Path}; @@ -57,8 +56,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut cwd = std::env::current_dir()?.into_os_string(); if args.env { diff --git a/users/talk.rs b/users/talk.rs index d9c0703b..7f951a10 100644 --- a/users/talk.rs +++ b/users/talk.rs @@ -8,7 +8,6 @@ use clap::{error::ErrorKind, Parser}; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use thiserror::Error; use binrw::{binrw, BinReaderExt, BinWrite, Endian}; @@ -1723,8 +1722,8 @@ fn main() -> Result<(), Box> { std::process::exit(1); }); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/users/write.rs b/users/write.rs index 88e38156..32463ff4 100644 --- a/users/write.rs +++ b/users/write.rs @@ -10,7 +10,7 @@ use chrono::Local; use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; -use plib::{platform, PROJECT_NAME}; +use plib::platform; use std::fs; use std::fs::OpenOptions; use std::io::{self, BufRead, Write}; @@ -217,8 +217,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let user_name = args.username; let terminal = match args.terminal { diff --git a/xform/cksum.rs b/xform/cksum.rs index 9f574227..f6cfba9f 100644 --- a/xform/cksum.rs +++ b/xform/cksum.rs @@ -19,7 +19,6 @@ mod crc32; use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::io::{self, Read}; use std::path::PathBuf; @@ -71,8 +70,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // if no file args, read from stdin if args.files.is_empty() { diff --git a/xform/compress.rs b/xform/compress.rs index a396ece1..03ce90fa 100644 --- a/xform/compress.rs +++ b/xform/compress.rs @@ -10,7 +10,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory}; use plib::lzw::UnixLZWWriter; -use plib::PROJECT_NAME; use std::fs::{self, File}; use std::io::{self, Write}; use std::path::{Path, PathBuf}; @@ -118,8 +117,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; if args.files.is_empty() { args.files.push(PathBuf::new()); diff --git a/xform/uncompress.rs b/xform/uncompress.rs index df3d5189..5ac868ea 100644 --- a/xform/uncompress.rs +++ b/xform/uncompress.rs @@ -14,7 +14,6 @@ use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; use plib::lzw::UnixLZWReader; -use plib::PROJECT_NAME; use std::io::{self, Write}; use std::path::PathBuf; @@ -64,8 +63,8 @@ fn main() -> Result<(), Box> { let mut args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; // if no file args, read from stdin if args.files.is_empty() { diff --git a/xform/uudecode.rs b/xform/uudecode.rs index 10aa218c..86ad4ad6 100644 --- a/xform/uudecode.rs +++ b/xform/uudecode.rs @@ -10,7 +10,6 @@ use base64::prelude::*; use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs::{remove_file, File}; use std::io::{self, Error, Read, Write}; use std::os::unix::fs::PermissionsExt; @@ -180,8 +179,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0; diff --git a/xform/uuencode.rs b/xform/uuencode.rs index f5cceec4..03f941d0 100644 --- a/xform/uuencode.rs +++ b/xform/uuencode.rs @@ -10,7 +10,6 @@ use base64::prelude::*; use clap::Parser; use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory}; -use plib::PROJECT_NAME; use std::fs::{File, Permissions}; use std::io::{self, Read, Write}; use std::os::unix::fs::PermissionsExt; @@ -180,8 +179,8 @@ fn main() -> Result<(), Box> { let args = Args::parse(); setlocale(LocaleCategory::LcAll, ""); - textdomain(PROJECT_NAME)?; - bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?; + textdomain(env!("PROJECT_NAME"))?; + bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?; let mut exit_code = 0;