77// SPDX-License-Identifier: MIT
88//
99
10- use clap:: Parser ;
11- use gettextrs:: { bind_textdomain_codeset, setlocale, textdomain, LocaleCategory } ;
12- use plib:: PROJECT_NAME ;
1310use std:: error:: Error ;
1411use std:: io:: { self , Read , StdoutLock , Write } ;
1512use std:: path:: PathBuf ;
1613
14+ use clap:: Parser ;
15+ use gettextrs:: { bind_textdomain_codeset, setlocale, textdomain, LocaleCategory } ;
16+ use plib:: io:: input_stream;
17+ use plib:: BUFSZ ;
18+
1719const N_C_GROUP : & str = "N_C_GROUP" ;
1820
1921/// head - copy the first part of files.
@@ -48,7 +50,7 @@ fn head_file(
4850 want_header : bool ,
4951 stdout_lock : & mut StdoutLock ,
5052) -> Result < ( ) , Box < dyn Error > > {
51- const BUFFER_SIZE : usize = plib :: BUFSZ ;
53+ const BUFFER_SIZE : usize = BUFSZ ;
5254
5355 // print file header
5456 if want_header {
@@ -60,7 +62,7 @@ fn head_file(
6062 }
6163
6264 // open file, or stdin
63- let mut file = plib :: io :: input_stream ( pathname, false ) ?;
65+ let mut file = input_stream ( pathname, false ) ?;
6466
6567 let mut raw_buffer = [ 0_u8 ; BUFFER_SIZE ] ;
6668
@@ -141,7 +143,10 @@ fn head_file(
141143}
142144
143145fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
144- // parse command line arguments
146+ setlocale ( LocaleCategory :: LcAll , "" ) ;
147+ textdomain ( env ! ( "PROJECT_NAME" ) ) ?;
148+ bind_textdomain_codeset ( env ! ( "PROJECT_NAME" ) , "UTF-8" ) ?;
149+
145150 let mut args = Args :: parse ( ) ;
146151
147152 // bsdutils (FreeBSD) enforces n > 0 (and c > 0)
@@ -178,10 +183,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
178183 }
179184 } ;
180185
181- setlocale ( LocaleCategory :: LcAll , "" ) ;
182- textdomain ( PROJECT_NAME ) ?;
183- bind_textdomain_codeset ( PROJECT_NAME , "UTF-8" ) ?;
184-
185186 let files = & mut args. files ;
186187
187188 // if no files, read from stdin
0 commit comments