Skip to content

Commit a0b1a2a

Browse files
committed
[newgrp] merge with main
2 parents 87210ed + a121aa8 commit a0b1a2a

File tree

135 files changed

+5639
-1736
lines changed

Some content is hidden

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

135 files changed

+5639
-1736
lines changed

.cargo/config.toml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[env]
2+
PROJECT_NAME = "posixutils-rs"

Cargo.lock

+107-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ members = [
3131
repository = "https://github.com/rustcoreutils/posixutils-rs"
3232
license = "MIT"
3333
edition = "2021"
34+
rust-version = "1.80.0"
3435

3536
[workspace.dependencies]
3637
clap = { version = "4", default-features = false, features = ["std", "derive", "help", "usage", "error-context", "cargo"] }

awk/Cargo.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ version = "0.2.1"
44
repository.workspace = true
55
license.workspace = true
66
edition.workspace = true
7+
rust-version.workspace = true
78

89
[dependencies]
9-
plib = { path = "../plib" }
1010
gettext-rs.workspace = true
1111
clap.workspace = true
1212
libc.workspace = true
@@ -16,6 +16,9 @@ lazy_static = "1.4"
1616
lexical = { version = "6.1", features = ["format"] }
1717
rand = {version = "0.8", default-features = false, features = ["small_rng"] }
1818

19+
[dev-dependencies]
20+
plib = { path = "../plib" }
21+
1922
[lints]
2023
workspace = true
2124

awk/src/compiler.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,8 @@ fn normalize_builtin_function_arguments(
343343
}
344344
}
345345

346-
#[derive(Debug, PartialEq, Eq)]
346+
#[cfg_attr(test, derive(Debug))]
347+
#[derive(PartialEq, Eq)]
347348
enum ExprKind {
348349
LValue,
349350
Number,
@@ -373,7 +374,8 @@ pub enum GlobalName {
373374
type NameMap = HashMap<String, GlobalName>;
374375
type LocalMap = HashMap<String, VarId>;
375376

376-
#[derive(Debug, Default)]
377+
#[cfg_attr(test, derive(Debug))]
378+
#[derive(Default)]
377379
struct Instructions {
378380
opcodes: Vec<OpCode>,
379381
source_locations: Vec<SourceLocation>,
@@ -1702,7 +1704,8 @@ fn location_end(loc: &InputLocation) -> usize {
17021704
}
17031705
}
17041706

1705-
#[derive(Debug, Clone)]
1707+
#[cfg_attr(test, derive(Debug))]
1708+
#[derive(Clone)]
17061709
pub struct CompilerErrors {
17071710
errors: Vec<PestError>,
17081711
}

awk/src/interpreter/array.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,24 @@ use std::{
1414

1515
use super::AwkValue;
1616

17-
#[derive(Debug, Clone, PartialEq)]
17+
#[cfg_attr(test, derive(Debug))]
18+
#[derive(Clone, PartialEq)]
1819
pub struct KeyIterator {
1920
index: usize,
2021
}
2122

2223
pub type Key = Rc<str>;
2324

24-
#[derive(Debug, Clone, Copy, PartialEq)]
25+
#[cfg_attr(test, derive(Debug))]
26+
#[derive(Clone, Copy, PartialEq)]
2527
pub struct ValueIndex {
2628
index: usize,
2729
}
2830

2931
pub type KeyValuePair = (Key, AwkValue);
3032

31-
#[derive(Debug, Clone, PartialEq, Default)]
33+
#[cfg_attr(test, derive(Debug))]
34+
#[derive(Clone, PartialEq, Default)]
3235
pub struct Array {
3336
key_map: HashMap<Key, usize>,
3437
pairs: Vec<Option<KeyValuePair>>,

awk/src/interpreter/format.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ pub fn parse_conversion_specifier_args(iter: &mut Chars) -> Result<(char, Format
314314
Ok((next, result))
315315
}
316316

317-
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
317+
#[cfg_attr(test, derive(Debug))]
318+
#[derive(PartialEq, Eq, Clone, Copy)]
318319
pub enum IntegerFormat {
319320
Decimal,
320321
Octal,

awk/src/interpreter/io.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl WritePipes {
286286
Entry::Vacant(e) => {
287287
let command: CString = command.try_into()?;
288288
let file = unsafe {
289-
let file = libc::popen(command.as_ptr(), "w\0".as_ptr() as *const i8);
289+
let file = libc::popen(command.as_ptr(), c"w".as_ptr());
290290
if file.is_null() {
291291
return Err("failed to open pipe".to_string());
292292
}
@@ -351,7 +351,7 @@ impl PipeRecordReader {
351351
pub fn open(command: &str) -> Result<Self, String> {
352352
let command = CString::new(command).map_err(|e| e.to_string())?;
353353
let file = unsafe {
354-
let file = libc::popen(command.as_ptr(), "r\0".as_ptr() as *const i8);
354+
let file = libc::popen(command.as_ptr(), c"r".as_ptr());
355355
if file.is_null() {
356356
return Err("failed to open pipe".to_string());
357357
}

awk/src/interpreter/mod.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,8 @@ fn is_valid_record_index(index: usize) -> Result<(), String> {
675675
}
676676
}
677677

678-
#[derive(Debug, Clone, PartialEq)]
678+
#[cfg_attr(test, derive(Debug))]
679+
#[derive(Clone, PartialEq)]
679680
enum AwkValueVariant {
680681
Number(f64),
681682
String(AwkString),
@@ -688,14 +689,16 @@ enum AwkValueVariant {
688689
UninitializedScalar,
689690
}
690691

691-
#[derive(Debug, Clone, Copy, PartialEq)]
692+
#[cfg_attr(test, derive(Debug))]
693+
#[derive(Clone, Copy, PartialEq)]
692694
enum AwkRefType {
693695
None,
694696
Field(u16),
695697
SpecialGlobalVar(SpecialVar),
696698
}
697699

698-
#[derive(Debug, Clone, PartialEq)]
700+
#[cfg_attr(test, derive(Debug))]
701+
#[derive(Clone, PartialEq)]
699702
struct AwkValue {
700703
value: AwkValueVariant,
701704
ref_type: AwkRefType,
@@ -889,14 +892,16 @@ impl From<Array> for AwkValue {
889892
}
890893
}
891894

892-
#[derive(Debug, Clone, PartialEq)]
895+
#[cfg_attr(test, derive(Debug))]
896+
#[derive(Clone, PartialEq)]
893897
struct ArrayIterator {
894898
array: *mut AwkValue,
895899
iter_var: *mut AwkValue,
896900
key_iter: KeyIterator,
897901
}
898902

899-
#[derive(Debug, Clone, PartialEq)]
903+
#[cfg_attr(test, derive(Debug))]
904+
#[derive(Clone, PartialEq)]
900905
struct ArrayElementRef {
901906
array: *mut AwkValue,
902907
value_index: ValueIndex,

awk/src/interpreter/string.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
use core::fmt;
1111
use std::{ffi::CString, ops::Deref, rc::Rc};
1212

13-
#[derive(Debug, Clone, PartialEq)]
13+
#[cfg_attr(test, derive(Debug))]
14+
#[derive(Clone, PartialEq)]
1415
enum AwkStringVariant {
1516
Owned(String),
1617
Shared(Rc<str>),
1718
}
1819

19-
#[derive(Debug, Clone)]
20+
#[cfg_attr(test, derive(Debug))]
21+
#[derive(Clone)]
2022
pub struct AwkString {
2123
value: AwkStringVariant,
2224
pub is_numeric: bool,

0 commit comments

Comments
 (0)