Skip to content

Commit 173f724

Browse files
authored
Merge branch 'main' into rishadbaniya/gencat
2 parents 963e15b + 86206d4 commit 173f724

File tree

6 files changed

+44
-31
lines changed

6 files changed

+44
-31
lines changed

Cargo.lock

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

m4/Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
[package]
2-
name = "m4"
2+
name = "posixutils-m4"
33
version = "0.1.0"
44
edition = "2021"
5+
description = "m4 - macro language processor"
6+
authors = ["Luke Frisken"]
7+
license = "MIT"
8+
repository = "https://github.com/rustcoreutils/posixutils-rs.git"
9+
10+
[[bin]]
11+
name = "m4"
12+
path = "src/main.rs"
513

614
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
715

m4/build.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,12 @@ fn main() {
189189
//! using the following command:
190190
//! `cargo run -p m4-test-manager update-snapshots`
191191
use similar_asserts::assert_eq;
192+
use posixutils_m4::error::GetExitCode;
192193
use std::process::ExitStatus;
193194
use std::os::unix::ffi::OsStrExt;
194195
use std::os::unix::process::ExitStatusExt;
195196
use std::fs::read_to_string;
196197
use std::path::Path;
197-
use m4::error::GetExitCode;
198198
use m4_test_manager::TestSnapshot;
199199
200200
fn init() {
@@ -256,11 +256,11 @@ fn run_command(input: &Path) -> std::process::Output {
256256
257257
let stdout = StdoutRef::default();
258258
let mut stderr: Vec<u8> = Vec::new();
259-
let args = m4::Args {
259+
let args = posixutils_m4::Args {
260260
files: vec![input.into()],
261-
..m4::Args::default()
261+
..posixutils_m4::Args::default()
262262
};
263-
let result = m4::run(stdout.clone(), &mut stderr, args);
263+
let result = posixutils_m4::run(stdout.clone(), &mut stderr, args);
264264
let status = ExitStatus::from_raw(result.get_exit_code() as i32);
265265
(stdout.into_inner(), stderr, status)
266266
}

m4/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ impl ArgumentDefine {
5151
}
5252
}
5353

54+
/// Define a symbol name to have some value [`DefineDirective::Define`] or NULL
55+
/// [`DefineDirective::Undefine`].
5456
#[derive(Debug, Clone)]
5557
pub enum DefineDirective {
5658
/// `name[=val]`
@@ -66,6 +68,7 @@ pub struct Args {
6668
/// Enable line synchronization output for the c99 preprocessor phase (that is, #line
6769
/// directives).
6870
pub line_synchronization: bool,
71+
/// See [`DefineDirective`].
6972
pub define_directives: Vec<DefineDirective>,
7073
/// Whether to read input from a file.
7174
pub files: Vec<PathBuf>,
@@ -77,12 +80,14 @@ impl Args {
7780
.arg(
7881
clap::Arg::new("line_synchronization")
7982
.short('s')
83+
.help("Output line synchronization directives, suitable for cpp")
8084
.action(clap::ArgAction::SetTrue),
8185
)
8286
.arg(
8387
clap::Arg::new("define")
8488
.short('D')
85-
.value_name("name[=val]")
89+
.value_name("name[=value]")
90+
.help("Define the symbol name to have some value (or NULL)")
8691
.num_args(1)
8792
.action(clap::ArgAction::Append),
8893
)

m4/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use std::process::ExitCode;
22

3-
use m4::error::GetExitCode;
3+
use posixutils_m4::error::GetExitCode;
44

55
fn main() -> ExitCode {
66
env_logger::init();
7-
let args = m4::Args::parse();
7+
let args = posixutils_m4::Args::parse();
88

99
let stdout = std::io::stdout();
1010
let mut stderr = std::io::stderr();
11-
if let Err(error) = m4::run(stdout, &mut stderr, args) {
11+
if let Err(error) = posixutils_m4::run(stdout, &mut stderr, args) {
1212
ExitCode::from(u8::try_from(error.get_exit_code()).unwrap_or_else(|e| {
1313
eprintln!("Error casting exit code {e} into platform agnostic u8");
1414
1

m4/tests/integration_test.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//! You can regenerate the tests (which are based on the fixtures in `fixtures/integration_tests/`)
33
//! using the following command:
44
//! `cargo run -p m4-test-manager update-snapshots`
5-
use m4::error::GetExitCode;
65
use m4_test_manager::TestSnapshot;
6+
use posixutils_m4::error::GetExitCode;
77
use similar_asserts::assert_eq;
88
use std::fs::read_to_string;
99
use std::os::unix::ffi::OsStrExt;
@@ -61,11 +61,11 @@ fn run_command(input: &Path) -> std::process::Output {
6161

6262
let stdout = StdoutRef::default();
6363
let mut stderr: Vec<u8> = Vec::new();
64-
let args = m4::Args {
64+
let args = posixutils_m4::Args {
6565
files: vec![input.into()],
66-
..m4::Args::default()
66+
..posixutils_m4::Args::default()
6767
};
68-
let result = m4::run(stdout.clone(), &mut stderr, args);
68+
let result = posixutils_m4::run(stdout.clone(), &mut stderr, args);
6969
let status = ExitStatus::from_raw(result.get_exit_code() as i32);
7070
(stdout.into_inner(), stderr, status)
7171
}

0 commit comments

Comments
 (0)