Skip to content
Merged
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
4 changes: 3 additions & 1 deletion awk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
plib = { path = "../plib" }
gettext-rs.workspace = true
clap.workspace = true
libc.workspace = true
Expand All @@ -17,6 +16,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
8 changes: 4 additions & 4 deletions awk/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use crate::compiler::compile_program;
use crate::interpreter::interpret;
use clap::Parser;
use compiler::SourceFile;
use gettextrs::{bind_textdomain_codeset, gettext, textdomain};
use plib::PROJECT_NAME;
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
use std::error::Error;
use std::fmt::Display;
use std::io::Read;
Expand Down Expand Up @@ -56,8 +55,9 @@ 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")?;
setlocale(LocaleCategory::LcAll, "");
textdomain(env!("PROJECT_NAME"))?;
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;

let args = Args::parse();

Expand Down
2 changes: 1 addition & 1 deletion awk/tests/integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use plib::{run_test, run_test_with_checker, TestPlan};
use plib::testing::{run_test, run_test_with_checker, TestPlan};

fn test_awk(args: Vec<String>, expected_output: &str) {
run_test(TestPlan {
Expand Down
4 changes: 3 additions & 1 deletion calc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition.workspace = true
rust-version.workspace = true

[dependencies]
plib = { path = "../plib" }
gettext-rs.workspace = true
regex.workspace = true
clap.workspace = true
Expand All @@ -17,6 +16,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
6 changes: 3 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,10 +44,11 @@ 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();

if args.define_math_functions {
Expand Down
6 changes: 2 additions & 4 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 @@ -370,10 +369,9 @@ 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
2 changes: 1 addition & 1 deletion calc/tests/bc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// SPDX-License-Identifier: MIT
//

use plib::{run_test, TestPlan};
use plib::testing::{run_test, TestPlan};

fn test_bc(program: &str, expected_output: &str) {
run_test(TestPlan {
Expand Down
2 changes: 1 addition & 1 deletion calc/tests/expr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// SPDX-License-Identifier: MIT
//

use plib::{run_test, TestPlan};
use plib::testing::{run_test, TestPlan};

fn expr_test(args: &[&str], expected_output: &str) {
let str_args: Vec<String> = args.iter().map(|s| String::from(*s)).collect();
Expand Down
4 changes: 3 additions & 1 deletion dev/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ edition.workspace = true
rust-version.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
10 changes: 4 additions & 6 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 @@ -143,12 +142,11 @@ fn show_object_file(args: &Args) -> Result<(), Box<dyn std::error::Error>> {
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
// parse command line arguments
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 = Args::parse();

show_object_file(&args)?;

Expand Down
6 changes: 3 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,10 +187,11 @@ 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() {
CharacterSet::Utf8 => {
for file in args.input_files {
Expand Down
15 changes: 7 additions & 8 deletions dev/strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@
// SPDX-License-Identifier: MIT
//

use std::{
ffi::{OsStr, OsString},
io::Read,
};

use clap::Parser;
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
use object::{
archive,
build::elf::{Builder, Section, SectionData},
elf,
};
use plib::PROJECT_NAME;
use std::{
ffi::{OsStr, OsString},
io::Read,
};

#[derive(Parser)]
#[command(version, about = gettext("strip - remove unnecessary information from strippable files"))]
Expand Down Expand Up @@ -145,10 +143,11 @@ 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 {
strip_file(&file);
}
Expand Down
2 changes: 1 addition & 1 deletion dev/tests/dev-tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use object::{Object, ObjectSection, ObjectSymbol};
use plib::{run_test, run_test_with_checker, TestPlan};
use plib::testing::{run_test, run_test_with_checker, TestPlan};
use std::fs;

fn ar_compare_test(
Expand Down
12 changes: 6 additions & 6 deletions i18n/gencat.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use byteorder::{BigEndian, ByteOrder, LittleEndian, NativeEndian, WriteBytesExt};
use clap::Parser;
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
use plib::PROJECT_NAME;
use plib::io::input_stream;
use std::{
cell::RefCell,
collections::BTreeMap,
Expand Down Expand Up @@ -295,7 +295,7 @@ impl MessageCatalog {
input_path: &PathBuf,
catfile_catalog: Option<MessageCatalog>,
) -> Result<Self, Box<dyn std::error::Error>> {
let mut file = plib::io::input_stream(input_path, true)?;
let mut file = input_stream(input_path, true)?;

let mut input = String::new();
file.read_to_string(&mut input)?;
Expand Down Expand Up @@ -774,11 +774,11 @@ impl MessageCatalog {
}

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")?;

let args = Args::parse();

let mut exit_code = 0;

Expand Down
12 changes: 6 additions & 6 deletions i18n/iconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use iconv_lib::{
utf_32::{self, UTF32Variant},
utf_8,
};
use plib::PROJECT_NAME;
use plib::io::input_stream;
use std::{
collections::HashMap,
env,
Expand Down Expand Up @@ -480,11 +480,11 @@ fn charmap_conversion(
}

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")?;

let args = Args::parse();

if args.list_codesets {
list_encodings();
Expand Down Expand Up @@ -517,7 +517,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let inputs: Vec<Box<dyn Read>> = match args.files {
Some(files) => files
.into_iter()
.map(|file| plib::io::input_stream(&file, true))
.map(|file| input_stream(&file, true))
.collect::<Result<Vec<_>, _>>()?,
None => vec![Box::new(io::stdin().lock())],
};
Expand Down
2 changes: 1 addition & 1 deletion i18n/tests/gencat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// SPDX-License-Identifier: MIT
//

use plib::{run_test_u8, TestPlanU8};
use plib::testing::{run_test_u8, TestPlanU8};
use std::env;
use std::path::PathBuf;
use std::{fs::File, io::Read};
Expand Down
2 changes: 1 addition & 1 deletion i18n/tests/iconv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
//

#![allow(non_snake_case)]
use plib::{run_test_u8, TestPlanU8};
use plib::testing::{run_test_u8, TestPlanU8};
use std::env;
use std::path::PathBuf;
use std::{fs::File, io::Read};
Expand Down
2 changes: 1 addition & 1 deletion plib/src/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use std::fs;
use std::io::{self, Read};
use std::path::PathBuf;

/// open file, or stdin
pub fn input_stream(pathname: &PathBuf, dashed_stdin: bool) -> io::Result<Box<dyn Read>> {
// open file, or stdin
let path_str = pathname.as_os_str();
let file: Box<dyn Read> =
if (dashed_stdin && path_str == "-") || (!dashed_stdin && path_str.is_empty()) {
Expand Down