Skip to content

Commit 4d2a359

Browse files
committed
screen: Use compile-time macro env!
1 parent fa5d194 commit 4d2a359

File tree

5 files changed

+19
-25
lines changed

5 files changed

+19
-25
lines changed

Cargo.lock

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

screen/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ edition.workspace = true
88
rust-version.workspace = true
99

1010
[dependencies]
11-
plib = { path = "../plib" }
1211
clap.workspace = true
1312
gettext-rs.workspace = true
1413
terminfo = "0.8"
@@ -29,4 +28,3 @@ path = "./tabs.rs"
2928
[[bin]]
3029
name = "tput"
3130
path = "./tput.rs"
32-

screen/stty.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
mod osdata;
1414

15+
use std::collections::HashMap;
16+
use std::io::{self, Error, ErrorKind};
17+
1518
use clap::Parser;
1619
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
1720
use osdata::{ParamType, PARG, PNEG};
18-
use plib::PROJECT_NAME;
19-
use std::collections::HashMap;
20-
use std::io::{self, Error, ErrorKind};
2121
use termios::{
2222
cc_t, cfgetispeed, cfgetospeed, cfsetispeed, cfsetospeed, speed_t, tcflag_t, tcsetattr,
2323
Termios, TCSANOW,
@@ -552,12 +552,11 @@ fn stty_set(ti: Termios, args: &Args) -> io::Result<()> {
552552
}
553553

554554
fn main() -> Result<(), Box<dyn std::error::Error>> {
555-
// parse command line arguments
556-
let args = Args::parse();
557-
558555
setlocale(LocaleCategory::LcAll, "");
559-
textdomain(PROJECT_NAME)?;
560-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
556+
textdomain(env!("PROJECT_NAME"))?;
557+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
558+
559+
let args = Args::parse();
561560

562561
// load termio settings
563562
let ti = Termios::from_fd(libc::STDIN_FILENO)?;

screen/tabs.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
// - gettext("Specify repetitive tab stops separated by ({}) columns")
1313
//
1414

15+
use std::io::{self, Error, ErrorKind, Write};
16+
1517
use clap::Parser;
1618
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
17-
use plib::PROJECT_NAME;
18-
use std::io::{self, Error, ErrorKind, Write};
1919
use terminfo::{capability as cap, Database};
2020

2121
// arbitrarily chosen. todo: search if POSIX-ly correct.
@@ -210,12 +210,11 @@ fn set_hw_tabs(info: &Database, tabstops: &Vec<u16>) -> io::Result<()> {
210210
}
211211

212212
fn main() -> Result<(), Box<dyn std::error::Error>> {
213-
// parse command line arguments
214-
let args = Args::parse();
215-
216213
setlocale(LocaleCategory::LcAll, "");
217-
textdomain(PROJECT_NAME)?;
218-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
214+
textdomain(env!("PROJECT_NAME"))?;
215+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
216+
217+
let args = Args::parse();
219218

220219
let info = match args.term {
221220
None => Database::from_env().unwrap(),

screen/tput.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
// - read init-file and reset-file data from filesystem
1212
//
1313

14+
use std::io;
15+
1416
use clap::Parser;
1517
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
16-
use plib::PROJECT_NAME;
17-
use std::io;
1818
use terminfo::{capability as cap, Database};
1919

2020
#[derive(Parser)]
@@ -72,12 +72,11 @@ fn tput_clear(info: Database) -> terminfo::Result<()> {
7272
}
7373

7474
fn main() -> Result<(), Box<dyn std::error::Error>> {
75-
// parse command line arguments
76-
let args = Args::parse();
77-
7875
setlocale(LocaleCategory::LcAll, "");
79-
textdomain(PROJECT_NAME)?;
80-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
76+
textdomain(env!("PROJECT_NAME"))?;
77+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
78+
79+
let args = Args::parse();
8180

8281
let info = match args.term {
8382
None => Database::from_env().unwrap(),

0 commit comments

Comments
 (0)