Skip to content

Commit be57428

Browse files
committed
i18n: Use compile-time macro env!
1 parent 88df556 commit be57428

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

i18n/gencat.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use byteorder::{BigEndian, ByteOrder, LittleEndian, NativeEndian, WriteBytesExt};
22
use clap::Parser;
33
use gettextrs::{bind_textdomain_codeset, gettext, setlocale, textdomain, LocaleCategory};
4-
use plib::PROJECT_NAME;
4+
use plib::io::input_stream;
55
use std::{
66
cell::RefCell,
77
collections::BTreeMap,
@@ -295,7 +295,7 @@ impl MessageCatalog {
295295
input_path: &PathBuf,
296296
catfile_catalog: Option<MessageCatalog>,
297297
) -> Result<Self, Box<dyn std::error::Error>> {
298-
let mut file = plib::io::input_stream(input_path, true)?;
298+
let mut file = input_stream(input_path, true)?;
299299

300300
let mut input = String::new();
301301
file.read_to_string(&mut input)?;
@@ -774,11 +774,11 @@ impl MessageCatalog {
774774
}
775775

776776
fn main() -> Result<(), Box<dyn std::error::Error>> {
777-
let args = Args::parse();
778-
779777
setlocale(LocaleCategory::LcAll, "");
780-
textdomain(PROJECT_NAME)?;
781-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
778+
textdomain(env!("PROJECT_NAME"))?;
779+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
780+
781+
let args = Args::parse();
782782

783783
let mut exit_code = 0;
784784

i18n/iconv.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use iconv_lib::{
1515
utf_32::{self, UTF32Variant},
1616
utf_8,
1717
};
18-
use plib::PROJECT_NAME;
18+
use plib::io::input_stream;
1919
use std::{
2020
collections::HashMap,
2121
env,
@@ -480,11 +480,11 @@ fn charmap_conversion(
480480
}
481481

482482
fn main() -> Result<(), Box<dyn std::error::Error>> {
483-
let args = Args::parse();
484-
485483
setlocale(LocaleCategory::LcAll, "");
486-
textdomain(PROJECT_NAME)?;
487-
bind_textdomain_codeset(PROJECT_NAME, "UTF-8")?;
484+
textdomain(env!("PROJECT_NAME"))?;
485+
bind_textdomain_codeset(env!("PROJECT_NAME"), "UTF-8")?;
486+
487+
let args = Args::parse();
488488

489489
if args.list_codesets {
490490
list_encodings();
@@ -517,7 +517,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
517517
let inputs: Vec<Box<dyn Read>> = match args.files {
518518
Some(files) => files
519519
.into_iter()
520-
.map(|file| plib::io::input_stream(&file, true))
520+
.map(|file| input_stream(&file, true))
521521
.collect::<Result<Vec<_>, _>>()?,
522522
None => vec![Box::new(io::stdin().lock())],
523523
};

i18n/tests/gencat/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// SPDX-License-Identifier: MIT
88
//
99

10-
use plib::{run_test_u8, TestPlanU8};
10+
use plib::testing::{run_test_u8, TestPlanU8};
1111
use std::env;
1212
use std::path::PathBuf;
1313
use std::{fs::File, io::Read};

i18n/tests/iconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//
99

1010
#![allow(non_snake_case)]
11-
use plib::{run_test_u8, TestPlanU8};
11+
use plib::testing::{run_test_u8, TestPlanU8};
1212
use std::env;
1313
use std::path::PathBuf;
1414
use std::{fs::File, io::Read};

plib/src/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use std::fs;
1111
use std::io::{self, Read};
1212
use std::path::PathBuf;
1313

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

0 commit comments

Comments
 (0)