@@ -18,17 +18,15 @@ mod numeric_str_cmp;
1818mod tmp_dir;
1919
2020use bigdecimal:: BigDecimal ;
21- use chunks:: LineData ;
2221use clap:: builder:: ValueParser ;
2322use clap:: { Arg , ArgAction , Command } ;
24- use custom_str_cmp:: custom_str_cmp;
25- use ext_sort:: ext_sort;
2623use fnv:: FnvHasher ;
2724#[ cfg( target_os = "linux" ) ]
2825use nix:: libc:: { RLIMIT_NOFILE , getrlimit, rlimit} ;
29- use numeric_str_cmp:: { NumInfo , NumInfoParseSettings , human_numeric_str_cmp, numeric_str_cmp} ;
3026use rand:: { Rng , rng} ;
3127use rayon:: prelude:: * ;
28+ use thiserror:: Error ;
29+
3230use std:: cmp:: Ordering ;
3331use std:: env;
3432use std:: ffi:: { OsStr , OsString } ;
@@ -37,23 +35,28 @@ use std::hash::{Hash, Hasher};
3735use std:: io:: { BufRead , BufReader , BufWriter , Read , Write , stdin, stdout} ;
3836use std:: num:: IntErrorKind ;
3937use std:: ops:: Range ;
40- use std:: path:: Path ;
41- use std:: path:: PathBuf ;
38+ use std:: path:: { Path , PathBuf } ;
4239use std:: str:: Utf8Error ;
43- use thiserror :: Error ;
40+
4441use uucore:: display:: Quotable ;
45- use uucore:: error:: { FromIo , strip_errno} ;
46- use uucore:: error:: { UError , UResult , USimpleError , UUsageError , set_exit_code} ;
42+ use uucore:: error:: {
43+ FromIo , UError , UResult , USimpleError , UUsageError , set_exit_code, strip_errno,
44+ } ;
4745use uucore:: extendedbigdecimal:: ExtendedBigDecimal ;
48- use uucore:: format_usage ;
46+ use uucore:: i18n :: date :: { self , locale_parse_abbr_month } ;
4947use uucore:: line_ending:: LineEnding ;
5048use uucore:: parser:: num_parser:: { ExtendedParser , ExtendedParserError } ;
5149use uucore:: parser:: parse_size:: { ParseSizeError , Parser } ;
5250use uucore:: parser:: shortcut_value_parser:: ShortcutValueParser ;
53- use uucore:: show_error;
54- use uucore:: translate;
5551use uucore:: version_cmp:: version_cmp;
56-
52+ use uucore:: { format_usage, show_error, translate} ;
53+
54+ use crate :: chunks:: LineData ;
55+ use crate :: custom_str_cmp:: custom_str_cmp;
56+ use crate :: ext_sort:: ext_sort;
57+ use crate :: numeric_str_cmp:: {
58+ NumInfo , NumInfoParseSettings , human_numeric_str_cmp, numeric_str_cmp,
59+ } ;
5760use crate :: tmp_dir:: TmpDirWrapper ;
5861
5962mod options {
@@ -599,7 +602,9 @@ impl<'a> Line<'a> {
599602 . enumerate ( )
600603 . skip_while ( |( _, c) | c. is_ascii_whitespace ( ) ) ;
601604
602- let month = if month_parse ( initial_selection) == Month :: Unknown {
605+ let month = if locale_parse_abbr_month ( initial_selection. trim_ascii_start ( ) )
606+ == date:: Month :: Unknown
607+ {
603608 // We failed to parse a month, which is equivalent to matching nothing.
604609 // Add the "no match for key" marker to the first non-whitespace character.
605610 let first_non_whitespace = month_chars. next ( ) ;
@@ -1871,47 +1876,9 @@ fn random_shuffle(a: &[u8], b: &[u8], salt: &[u8]) -> Ordering {
18711876 da. cmp ( & db)
18721877}
18731878
1874- #[ derive( Eq , Ord , PartialEq , PartialOrd , Clone , Copy ) ]
1875- enum Month {
1876- Unknown ,
1877- January ,
1878- February ,
1879- March ,
1880- April ,
1881- May ,
1882- June ,
1883- July ,
1884- August ,
1885- September ,
1886- October ,
1887- November ,
1888- December ,
1889- }
1890-
1891- /// Parse the beginning string into a Month, returning [`Month::Unknown`] on errors.
1892- fn month_parse ( line : & [ u8 ] ) -> Month {
1893- let line = line. trim_ascii_start ( ) ;
1894-
1895- match line. get ( ..3 ) . map ( |x| x. to_ascii_uppercase ( ) ) . as_deref ( ) {
1896- Some ( b"JAN" ) => Month :: January ,
1897- Some ( b"FEB" ) => Month :: February ,
1898- Some ( b"MAR" ) => Month :: March ,
1899- Some ( b"APR" ) => Month :: April ,
1900- Some ( b"MAY" ) => Month :: May ,
1901- Some ( b"JUN" ) => Month :: June ,
1902- Some ( b"JUL" ) => Month :: July ,
1903- Some ( b"AUG" ) => Month :: August ,
1904- Some ( b"SEP" ) => Month :: September ,
1905- Some ( b"OCT" ) => Month :: October ,
1906- Some ( b"NOV" ) => Month :: November ,
1907- Some ( b"DEC" ) => Month :: December ,
1908- _ => Month :: Unknown ,
1909- }
1910- }
1911-
19121879fn month_compare ( a : & [ u8 ] , b : & [ u8 ] ) -> Ordering {
1913- let ma = month_parse ( a ) ;
1914- let mb = month_parse ( b ) ;
1880+ let ma = locale_parse_abbr_month ( a . trim_ascii_start ( ) ) ;
1881+ let mb = locale_parse_abbr_month ( b . trim_ascii_start ( ) ) ;
19151882
19161883 ma. cmp ( & mb)
19171884}
0 commit comments