Skip to content

Commit 2e67d58

Browse files
committed
Merge branch 'main' into naive_histo_diff
2 parents 1251776 + ba91157 commit 2e67d58

File tree

150 files changed

+6110
-2388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

150 files changed

+6110
-2388
lines changed

Cargo.lock

Lines changed: 195 additions & 130 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,18 @@ members = [
2727
"i18n"
2828
]
2929

30+
[workspace.package]
31+
repository = "https://github.com/rustcoreutils/posixutils-rs"
32+
license = "MIT"
33+
edition = "2021"
34+
3035
[workspace.dependencies]
3136
clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "error-context", "cargo"] }
3237
chrono = { version = "0.4", default-features = false, features = ["clock"] }
3338
libc = "0.2"
3439
regex = "1.10"
3540
gettext-rs = { path = "./gettext-rs" }
3641
errno = "0.3"
42+
43+
[workspace.lints]
44+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Because it is a FAQ, the major differences between this project and uutils are:
101101
- [x] strip (Development)
102102
- [x] tail
103103
- [x] time
104+
- [x] timeout
104105
- [x] tr
105106
- [x] true
106107
- [x] uncompress (compress cat.)
@@ -218,7 +219,6 @@ Because it is a FAQ, the major differences between this project and uutils are:
218219
- [ ] sed
219220
- [ ] sh -- Volunteer starting point at https://github.com/rustcoreutils/posixutils-rs/tree/shell
220221
- [ ] talk (status: in progress)
221-
- [ ] timeout (status: in progress)
222222

223223
## Installation
224224

awk/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[package]
22
name = "posixutils-awk"
33
version = "0.2.1"
4-
edition = "2021"
4+
repository.workspace = true
5+
license.workspace = true
6+
edition.workspace = true
57

68
[dependencies]
79
plib = { path = "../plib" }
@@ -14,6 +16,9 @@ lazy_static = "1.4"
1416
lexical = { version = "6.1", features = ["format"] }
1517
rand = {version = "0.8", default-features = false, features = ["small_rng"] }
1618

19+
[lints]
20+
workspace = true
21+
1722
[[bin]]
1823
name = "awk"
1924
path = "src/main.rs"

awk/src/interpreter/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,7 @@ fn swap_with_default<T: Default>(value: &mut T) -> T {
104104

105105
fn maybe_numeric_string<S: Into<AwkString>>(str: S) -> AwkString {
106106
let mut str = str.into();
107-
let numeric_string = is_valid_number(
108-
str.as_str()
109-
.trim()
110-
.trim_start_matches(|c| c == '+' || c == '-'),
111-
);
107+
let numeric_string = is_valid_number(str.as_str().trim().trim_start_matches(['+', '-']));
112108
str.is_numeric = numeric_string;
113109
str
114110
}

awk/src/main.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::compiler::compile_program;
1111
use crate::interpreter::interpret;
1212
use clap::Parser;
1313
use compiler::SourceFile;
14-
use gettextrs::{bind_textdomain_codeset, textdomain};
14+
use gettextrs::{bind_textdomain_codeset, gettext, textdomain};
1515
use plib::PROJECT_NAME;
1616
use std::error::Error;
1717
use std::fmt::Display;
@@ -22,19 +22,24 @@ mod interpreter;
2222
mod program;
2323
mod regex;
2424

25-
/// awk - pattern scanning and processing language
26-
#[derive(Debug, Parser)]
25+
#[derive(Parser)]
26+
#[command(version, about = gettext("awk - pattern scanning and processing language"))]
2727
struct Args {
28-
/// Define the input field separator
29-
#[arg(short = 'F')]
28+
#[arg(short = 'F', help = gettext("Define the input field separator"))]
3029
separator_string: Option<String>,
3130

32-
/// Specify the program files
33-
#[arg(short = 'f', action = clap::ArgAction::Append)]
31+
#[arg(
32+
short = 'f',
33+
action = clap::ArgAction::Append,
34+
help = gettext("Specify the program files")
35+
)]
3436
program_files: Vec<String>,
3537

36-
/// Globals assignments, executed before the start of the program
37-
#[arg(short = 'v', action = clap::ArgAction::Append)]
38+
#[arg(
39+
short = 'v',
40+
action = clap::ArgAction::Append,
41+
help = gettext("Globals assignments, executed before the start of the program")
42+
)]
3843
assignments: Vec<String>,
3944

4045
arguments: Vec<String>,

calc/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
[package]
22
name = "posixutils-calc"
33
version = "0.2.1"
4-
edition = "2021"
4+
repository.workspace = true
5+
license.workspace = true
6+
edition.workspace = true
57

68
[dependencies]
79
plib = { path = "../plib" }
@@ -14,6 +16,9 @@ lazy_static = "1.4"
1416
bigdecimal = "0.4"
1517
rustyline = { version = "14.0", default-features = false }
1618

19+
[lints]
20+
workspace = true
21+
1722
[[bin]]
1823
name = "expr"
1924
path = "./expr.rs"

calc/bc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use rustyline::{error::ReadlineError, DefaultEditor, Result};
2222
mod bc_util;
2323

2424
/// bc - arbitrary-precision arithmetic language
25-
#[derive(Debug, Parser)]
26-
#[command(author, version, about, long_about)]
25+
#[derive(Parser)]
26+
#[command(version, about)]
2727
struct Args {
2828
#[arg(short = 'l')]
2929
define_math_functions: bool,

calc/bc_util/number.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,22 +100,21 @@ impl Number {
100100
}
101101

102102
/// Convert the number to a string in the given base.
103-
pub fn to_string(mut self, base: u64) -> String {
104-
if self.is_zero() {
103+
pub fn to_string(&self, base: u64) -> String {
104+
let mut number = self.0.clone();
105+
if number.is_zero() {
105106
return "0".to_string();
106107
}
107108

108-
let scale = self.scale();
109-
110109
let mut result = String::new();
111110
if self.0.is_negative() {
112111
result.push('-');
113-
self.0 = -self.0;
112+
number = -number;
114113
}
115114

116115
let base_ilog10 = base.ilog10();
117-
let integer_part = self.0.with_scale(0);
118-
let mut fractional_part = self.0 - &integer_part;
116+
let integer_part = number.with_scale(0);
117+
let mut fractional_part = number - &integer_part;
119118

120119
if integer_part.is_zero() {
121120
result.push('0');
@@ -145,6 +144,7 @@ impl Number {
145144

146145
result.push('.');
147146
let mut temp = BigDecimal::one();
147+
let scale = self.scale();
148148
// The standard doesn't specify how many fractional digits to print.
149149
// Here, we set the scale of the number to the value smallest value of
150150
// i such that: (base ^ i).digits() > scale.
@@ -557,4 +557,11 @@ mod tests {
557557
assert_eq!(n.scale(), 1);
558558
assert_eq!(n.to_string(10), "1.0");
559559
}
560+
561+
#[test]
562+
fn test_to_string() {
563+
let n = Number::parse("4.5", 10).unwrap().negate();
564+
assert_eq!(n.to_string(10), "-4.5");
565+
assert_eq!(n.to_string(10), "-4.5");
566+
}
560567
}

datetime/Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "posixutils-datetime"
33
version = "0.2.1"
4-
edition = "2021"
54
authors = ["Jeff Garzik"]
6-
license = "MIT"
7-
repository = "https://github.com/rustcoreutils/posixutils-rs.git"
5+
repository.workspace = true
6+
license.workspace = true
7+
edition.workspace = true
88

99
[dependencies]
1010
plib = { path = "../plib" }
@@ -13,6 +13,9 @@ gettext-rs.workspace = true
1313
chrono.workspace = true
1414
libc.workspace = true
1515

16+
[lints]
17+
workspace = true
18+
1619
[[bin]]
1720
name = "cal"
1821
path = "./cal.rs"

0 commit comments

Comments
 (0)