Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[env]
PROJECT_NAME = "posixutils-rs"
4 changes: 3 additions & 1 deletion awk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ license.workspace = true
edition.workspace = true

[dependencies]
plib = { path = "../plib" }
gettext-rs.workspace = true
clap.workspace = true
libc.workspace = true
Expand All @@ -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

Expand Down
5 changes: 2 additions & 3 deletions awk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -56,8 +55,8 @@ fn exit_if_error<T, U: Display>(r: Result<T, U>) -> T {
}

fn main() -> Result<(), Box<dyn Error>> {
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();

Expand Down
4 changes: 3 additions & 1 deletion calc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ license.workspace = true
edition.workspace = true

[dependencies]
plib = { path = "../plib" }
gettext-rs.workspace = true
regex.workspace = true
clap.workspace = true
Expand All @@ -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

Expand Down
5 changes: 2 additions & 3 deletions calc/bc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -45,8 +44,8 @@ fn print_output_or_error(result: ExecutionResult<String>) {

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();
Expand Down
5 changes: 2 additions & 3 deletions calc/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
//

use gettextrs::{bind_textdomain_codeset, setlocale, textdomain, LocaleCategory};
use plib::PROJECT_NAME;
use regex::Regex;

#[derive(Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -372,8 +371,8 @@ fn eval_expression(tokens: &[Token]) -> Result<Token, &'static str> {
fn main() -> Result<(), Box<dyn std::error::Error>> {
// 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();
Expand Down
4 changes: 3 additions & 1 deletion datetime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions datetime/cal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -98,8 +97,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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() {
Expand Down
5 changes: 2 additions & 3 deletions datetime/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -150,8 +149,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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),
Expand Down
5 changes: 2 additions & 3 deletions datetime/sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -28,8 +27,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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
Expand Down
5 changes: 2 additions & 3 deletions datetime/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -125,8 +124,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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 {
Expand Down
4 changes: 3 additions & 1 deletion dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions dev/nm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -147,8 +146,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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)?;

Expand Down
5 changes: 2 additions & 3 deletions dev/strings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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() {
Expand Down
5 changes: 2 additions & 3 deletions dev/strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -145,8 +144,8 @@ fn strip_file(file: &OsStr) {

fn main() -> Result<(), Box<dyn std::error::Error>> {
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 {
Expand Down
4 changes: 3 additions & 1 deletion display/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 2 additions & 3 deletions display/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -73,8 +72,8 @@ fn translate_str(skip_nl: bool, s: &str) -> String {

fn main() -> Result<(), Box<dyn std::error::Error>> {
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<String> = std::env::args().collect();
args.remove(0);
Expand Down
5 changes: 2 additions & 3 deletions display/printf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -322,8 +321,8 @@ fn do_printf(format: &str, args: &[String]) -> io::Result<()> {

fn main() -> Result<(), Box<dyn std::error::Error>> {
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<String> = std::env::args().collect();

Expand Down
5 changes: 2 additions & 3 deletions file/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -54,8 +53,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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() {
Expand Down
5 changes: 2 additions & 3 deletions file/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down
5 changes: 2 additions & 3 deletions file/dd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -382,8 +381,8 @@ fn parse_cmdline(args: &[String]) -> Result<Config, Box<dyn std::error::Error>>

fn main() -> Result<(), Box<dyn std::error::Error>> {
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<String> = std::env::args().skip(1).collect();
let config = parse_cmdline(&args)?;
Expand Down
5 changes: 2 additions & 3 deletions file/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -665,8 +664,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

// 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);
Expand Down
Loading