@@ -61,9 +61,7 @@ use uucore::libc::{S_IXGRP, S_IXOTH, S_IXUSR};
6161use uucore:: libc:: { dev_t, major, minor} ;
6262use uucore:: line_ending:: LineEnding ;
6363use uucore:: locale:: { get_message, get_message_with_args} ;
64- use uucore:: quoting_style:: {
65- self , QuotingStyle , locale_aware_escape_dir_name, locale_aware_escape_name,
66- } ;
64+ use uucore:: quoting_style:: { QuotingStyle , locale_aware_escape_dir_name, locale_aware_escape_name} ;
6765use uucore:: {
6866 display:: Quotable ,
6967 error:: { UError , UResult , set_exit_code} ,
@@ -598,34 +596,15 @@ fn extract_hyperlink(options: &clap::ArgMatches) -> bool {
598596fn match_quoting_style_name ( style : & str , show_control : bool ) -> Option < QuotingStyle > {
599597 match style {
600598 "literal" => Some ( QuotingStyle :: Literal { show_control } ) ,
601- "shell" => Some ( QuotingStyle :: Shell {
602- escape : false ,
603- always_quote : false ,
604- show_control,
605- } ) ,
606- "shell-always" => Some ( QuotingStyle :: Shell {
607- escape : false ,
608- always_quote : true ,
609- show_control,
610- } ) ,
611- "shell-escape" => Some ( QuotingStyle :: Shell {
612- escape : true ,
613- always_quote : false ,
614- show_control,
615- } ) ,
616- "shell-escape-always" => Some ( QuotingStyle :: Shell {
617- escape : true ,
618- always_quote : true ,
619- show_control,
620- } ) ,
621- "c" => Some ( QuotingStyle :: C {
622- quotes : quoting_style:: Quotes :: Double ,
623- } ) ,
624- "escape" => Some ( QuotingStyle :: C {
625- quotes : quoting_style:: Quotes :: None ,
626- } ) ,
599+ "shell" => Some ( QuotingStyle :: SHELL ) ,
600+ "shell-always" => Some ( QuotingStyle :: SHELL_QUOTE ) ,
601+ "shell-escape" => Some ( QuotingStyle :: SHELL_ESCAPE ) ,
602+ "shell-escape-always" => Some ( QuotingStyle :: SHELL_ESCAPE_QUOTE ) ,
603+ "c" => Some ( QuotingStyle :: C_DOUBLE ) ,
604+ "escape" => Some ( QuotingStyle :: C_NO_QUOTES ) ,
627605 _ => None ,
628606 }
607+ . map ( |qs| qs. show_control ( show_control) )
629608}
630609
631610/// Extracts the quoting style to use based on the options provided.
@@ -651,13 +630,9 @@ fn extract_quoting_style(options: &clap::ArgMatches, show_control: bool) -> Quot
651630 } else if options. get_flag ( options:: quoting:: LITERAL ) {
652631 QuotingStyle :: Literal { show_control }
653632 } else if options. get_flag ( options:: quoting:: ESCAPE ) {
654- QuotingStyle :: C {
655- quotes : quoting_style:: Quotes :: None ,
656- }
633+ QuotingStyle :: C_NO_QUOTES
657634 } else if options. get_flag ( options:: quoting:: C ) {
658- QuotingStyle :: C {
659- quotes : quoting_style:: Quotes :: Double ,
660- }
635+ QuotingStyle :: C_DOUBLE
661636 } else if options. get_flag ( options:: DIRED ) {
662637 QuotingStyle :: Literal { show_control }
663638 } else {
@@ -684,11 +659,7 @@ fn extract_quoting_style(options: &clap::ArgMatches, show_control: bool) -> Quot
684659 // By default, `ls` uses Shell escape quoting style when writing to a terminal file
685660 // descriptor and Literal otherwise.
686661 if stdout ( ) . is_terminal ( ) {
687- QuotingStyle :: Shell {
688- escape : true ,
689- always_quote : false ,
690- show_control,
691- }
662+ QuotingStyle :: SHELL_ESCAPE . show_control ( show_control)
692663 } else {
693664 QuotingStyle :: Literal { show_control }
694665 }
@@ -2010,7 +1981,7 @@ fn show_dir_name(
20101981 config : & Config ,
20111982) -> std:: io:: Result < ( ) > {
20121983 let escaped_name =
2013- locale_aware_escape_dir_name ( path_data. p_buf . as_os_str ( ) , & config. quoting_style ) ;
1984+ locale_aware_escape_dir_name ( path_data. p_buf . as_os_str ( ) , config. quoting_style ) ;
20141985
20151986 let name = if config. hyperlink && !config. dired {
20161987 create_hyperlink ( & escaped_name, path_data)
@@ -2511,7 +2482,7 @@ fn display_items(
25112482 // option, print the security context to the left of the size column.
25122483
25132484 let quoted = items. iter ( ) . any ( |item| {
2514- let name = locale_aware_escape_name ( & item. display_name , & config. quoting_style ) ;
2485+ let name = locale_aware_escape_name ( & item. display_name , config. quoting_style ) ;
25152486 os_str_starts_with ( & name, b"'" )
25162487 } ) ;
25172488
@@ -3175,7 +3146,7 @@ fn display_item_name(
31753146 current_column : LazyCell < usize , Box < dyn FnOnce ( ) -> usize + ' _ > > ,
31763147) -> OsString {
31773148 // This is our return value. We start by `&path.display_name` and modify it along the way.
3178- let mut name = locale_aware_escape_name ( & path. display_name , & config. quoting_style ) ;
3149+ let mut name = locale_aware_escape_name ( & path. display_name , config. quoting_style ) ;
31793150
31803151 let is_wrap =
31813152 |namelen : usize | config. width != 0 && * current_column + namelen > config. width . into ( ) ;
@@ -3267,7 +3238,7 @@ fn display_item_name(
32673238 name. push ( path. p_buf . read_link ( ) . unwrap ( ) ) ;
32683239 } else {
32693240 name. push ( color_name (
3270- locale_aware_escape_name ( target. as_os_str ( ) , & config. quoting_style ) ,
3241+ locale_aware_escape_name ( target. as_os_str ( ) , config. quoting_style ) ,
32713242 path,
32723243 style_manager,
32733244 & mut state. out ,
@@ -3280,7 +3251,7 @@ fn display_item_name(
32803251 // Apply the right quoting
32813252 name. push ( locale_aware_escape_name (
32823253 target. as_os_str ( ) ,
3283- & config. quoting_style ,
3254+ config. quoting_style ,
32843255 ) ) ;
32853256 }
32863257 }
0 commit comments