This commit is contained in:
sylvestre
2023-05-28 02:46:15 +00:00
parent 6a4dbcfb08
commit 040bec3cf3
58 changed files with 945 additions and 426 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
(function() {var implementors = {
"uu_numfmt":[["impl&lt;'a&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"uu_numfmt/format/struct.WhitespaceSplitter.html\" title=\"struct uu_numfmt::format::WhitespaceSplitter\">WhitespaceSplitter</a>&lt;'a&gt;"]],
"uu_tail":[["impl&lt;'a&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"uu_tail/chunks/struct.ReverseChunks.html\" title=\"struct uu_tail::chunks::ReverseChunks\">ReverseChunks</a>&lt;'a&gt;"]],
"uucore":[["impl&lt;B: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/std/io/trait.BufRead.html\" title=\"trait std::io::BufRead\">BufRead</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"uucore/lines/struct.Lines.html\" title=\"struct uucore::lines::Lines\">Lines</a>&lt;B&gt;"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"uucore/utmpx/struct.UtmpxIter.html\" title=\"struct uucore::utmpx::UtmpxIter\">UtmpxIter</a>"]]
"uucore":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"uucore/utmpx/struct.UtmpxIter.html\" title=\"struct uucore::utmpx::UtmpxIter\">UtmpxIter</a>"],["impl&lt;B: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/std/io/trait.BufRead.html\" title=\"trait std::io::BufRead\">BufRead</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/iter/traits/iterator/trait.Iterator.html\" title=\"trait core::iter::traits::iterator::Iterator\">Iterator</a> for <a class=\"struct\" href=\"uucore/lines/struct.Lines.html\" title=\"struct uucore::lines::Lines\">Lines</a>&lt;B&gt;"]]
};if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})()
+3 -3
View File
@@ -1,9 +1,9 @@
(function() {var implementors = {
"uu_cp":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_cp/enum.SparseMode.html\" title=\"enum uu_cp::SparseMode\">SparseMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_cp/enum.ClobberMode.html\" title=\"enum uu_cp::ClobberMode\">ClobberMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_cp/enum.OverwriteMode.html\" title=\"enum uu_cp::OverwriteMode\">OverwriteMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_cp/enum.ReflinkMode.html\" title=\"enum uu_cp::ReflinkMode\">ReflinkMode</a>"]],
"uu_cp":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_cp/enum.ReflinkMode.html\" title=\"enum uu_cp::ReflinkMode\">ReflinkMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_cp/enum.OverwriteMode.html\" title=\"enum uu_cp::OverwriteMode\">OverwriteMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_cp/enum.ClobberMode.html\" title=\"enum uu_cp::ClobberMode\">ClobberMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_cp/enum.SparseMode.html\" title=\"enum uu_cp::SparseMode\">SparseMode</a>"]],
"uu_kill":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_kill/enum.Mode.html\" title=\"enum uu_kill::Mode\">Mode</a>"]],
"uu_numfmt":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_numfmt/options/enum.RoundMethod.html\" title=\"enum uu_numfmt::options::RoundMethod\">RoundMethod</a>"]],
"uu_sort":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_sort/enum.GeneralF64ParseResult.html\" title=\"enum uu_sort::GeneralF64ParseResult\">GeneralF64ParseResult</a>"]],
"uu_stty":[["impl&lt;T: <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a>&gt; <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"struct\" href=\"uu_stty/struct.Flag.html\" title=\"struct uu_stty::Flag\">Flag</a>&lt;T&gt;"]],
"uu_tail":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_tail/args/enum.Signum.html\" title=\"enum uu_tail::args::Signum\">Signum</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_tail/args/enum.FollowMode.html\" title=\"enum uu_tail::args::FollowMode\">FollowMode</a>"]],
"uucore":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/fs/enum.MissingHandling.html\" title=\"enum uucore::fs::MissingHandling\">MissingHandling</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/encoding/enum.Format.html\" title=\"enum uucore::encoding::Format\">Format</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/fs/enum.ResolveMode.html\" title=\"enum uucore::fs::ResolveMode\">ResolveMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/backup_control/enum.BackupMode.html\" title=\"enum uucore::backup_control::BackupMode\">BackupMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/quoting_style/enum.Quotes.html\" title=\"enum uucore::quoting_style::Quotes\">Quotes</a>"]]
"uu_tail":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_tail/args/enum.FollowMode.html\" title=\"enum uu_tail::args::FollowMode\">FollowMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uu_tail/args/enum.Signum.html\" title=\"enum uu_tail::args::Signum\">Signum</a>"]],
"uucore":[["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/fs/enum.MissingHandling.html\" title=\"enum uucore::fs::MissingHandling\">MissingHandling</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/encoding/enum.Format.html\" title=\"enum uucore::encoding::Format\">Format</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/quoting_style/enum.Quotes.html\" title=\"enum uucore::quoting_style::Quotes\">Quotes</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/backup_control/enum.BackupMode.html\" title=\"enum uucore::backup_control::BackupMode\">BackupMode</a>"],["impl <a class=\"trait\" href=\"https://doc.rust-lang.org/1.69.0/core/marker/trait.Copy.html\" title=\"trait core::marker::Copy\">Copy</a> for <a class=\"enum\" href=\"uucore/fs/enum.ResolveMode.html\" title=\"enum uucore::fs::ResolveMode\">ResolveMode</a>"]]
};if (window.register_implementors) {window.register_implementors(implementors);} else {window.pending_implementors = implementors;}})()
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+5 -5
View File
File diff suppressed because one or more lines are too long
+14
View File
@@ -464,6 +464,13 @@
<a href="#464" id="464">464</a>
<a href="#465" id="465">465</a>
<a href="#466" id="466">466</a>
<a href="#467" id="467">467</a>
<a href="#468" id="468">468</a>
<a href="#469" id="469">469</a>
<a href="#470" id="470">470</a>
<a href="#471" id="471">471</a>
<a href="#472" id="472">472</a>
<a href="#473" id="473">473</a>
</pre><pre class="rust"><code><span class="comment">// This file is part of the uutils coreutils package.
//
// (c) Anthony Deschamps &lt;anthony.j.deschamps@gmail.com&gt;
@@ -728,6 +735,13 @@
<span class="prelude-val">Ok</span>(date) =&gt; {
<span class="comment">// GNU `date` uses `%N` for nano seconds, however crate::chrono uses `%f`
</span><span class="kw">let </span>format_string = <span class="kw-2">&amp;</span>format_string.replace(<span class="string">&quot;%N&quot;</span>, <span class="string">&quot;%f&quot;</span>);
<span class="comment">// Refuse to pass this string to chrono as it is crashing in this crate
</span><span class="kw">if </span>format_string.contains(<span class="string">&quot;%#z&quot;</span>) {
<span class="kw">return </span><span class="prelude-val">Err</span>(USimpleError::new(
<span class="number">1</span>,
<span class="macro">format!</span>(<span class="string">&quot;invalid format {}&quot;</span>, format_string.replace(<span class="string">&quot;%f&quot;</span>, <span class="string">&quot;%N&quot;</span>)),
));
}
<span class="comment">// Hack to work around panic in chrono,
// TODO - remove when a fix for https://github.com/chronotope/chrono/issues/623 is released
</span><span class="kw">let </span>format_items = StrftimeItems::new(format_string);
+98 -14
View File
@@ -771,6 +771,48 @@
<a href="#771" id="771">771</a>
<a href="#772" id="772">772</a>
<a href="#773" id="773">773</a>
<a href="#774" id="774">774</a>
<a href="#775" id="775">775</a>
<a href="#776" id="776">776</a>
<a href="#777" id="777">777</a>
<a href="#778" id="778">778</a>
<a href="#779" id="779">779</a>
<a href="#780" id="780">780</a>
<a href="#781" id="781">781</a>
<a href="#782" id="782">782</a>
<a href="#783" id="783">783</a>
<a href="#784" id="784">784</a>
<a href="#785" id="785">785</a>
<a href="#786" id="786">786</a>
<a href="#787" id="787">787</a>
<a href="#788" id="788">788</a>
<a href="#789" id="789">789</a>
<a href="#790" id="790">790</a>
<a href="#791" id="791">791</a>
<a href="#792" id="792">792</a>
<a href="#793" id="793">793</a>
<a href="#794" id="794">794</a>
<a href="#795" id="795">795</a>
<a href="#796" id="796">796</a>
<a href="#797" id="797">797</a>
<a href="#798" id="798">798</a>
<a href="#799" id="799">799</a>
<a href="#800" id="800">800</a>
<a href="#801" id="801">801</a>
<a href="#802" id="802">802</a>
<a href="#803" id="803">803</a>
<a href="#804" id="804">804</a>
<a href="#805" id="805">805</a>
<a href="#806" id="806">806</a>
<a href="#807" id="807">807</a>
<a href="#808" id="808">808</a>
<a href="#809" id="809">809</a>
<a href="#810" id="810">810</a>
<a href="#811" id="811">811</a>
<a href="#812" id="812">812</a>
<a href="#813" id="813">813</a>
<a href="#814" id="814">814</a>
<a href="#815" id="815">815</a>
</pre><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
// *
// * (c) Alex Lyon &lt;arcterus@mail.com&gt;
@@ -787,6 +829,7 @@
<span class="kw">use </span>clap::ArgAction;
<span class="kw">use </span>clap::{Arg, ArgMatches, Command};
<span class="kw">use </span>hex::encode;
<span class="kw">use </span>regex::Captures;
<span class="kw">use </span>regex::Regex;
<span class="kw">use </span>std::cmp::Ordering;
<span class="kw">use </span>std::error::Error;
@@ -1377,22 +1420,65 @@
// regular expression, otherwise we use the `{n}` modifier,
// where `n` is the number of bytes.
</span><span class="kw">let </span>bytes = options.digest.output_bits() / <span class="number">4</span>;
<span class="kw">let </span>modifier = <span class="kw">if </span>bytes &gt; <span class="number">0 </span>{
<span class="kw">let </span>bytes_marker = <span class="kw">if </span>bytes &gt; <span class="number">0 </span>{
<span class="macro">format!</span>(<span class="string">&quot;{{{bytes}}}&quot;</span>)
} <span class="kw">else </span>{
<span class="string">&quot;+&quot;</span>.to_string()
};
<span class="kw">let </span>gnu_re = Regex::new(<span class="kw-2">&amp;</span><span class="macro">format!</span>(
<span class="string">r&quot;^(?P&lt;digest&gt;[a-fA-F0-9]{modifier}) (?P&lt;binary&gt;[ \*])(?P&lt;fileName&gt;.*)&quot;</span>,
))
.map_err(|<span class="kw">_</span>| HashsumError::InvalidRegex)<span class="question-mark">?</span>;
<span class="comment">// BSD reversed mode format is similar to the default mode, but doesnt use a character to distinguish binary and text modes.
</span><span class="kw">let </span><span class="kw-2">mut </span>bsd_reversed = <span class="prelude-val">None</span>;
<span class="doccomment">/// Creates a Regex for parsing lines based on the given format.
/// The default value of `gnu_re` created with this function has to be recreated
/// after the initial line has been parsed, as this line dictates the format
/// for the rest of them, and mixing of formats is disallowed.
</span><span class="kw">fn </span>gnu_re_template(
bytes_marker: <span class="kw-2">&amp;</span>str,
format_marker: <span class="kw-2">&amp;</span>str,
) -&gt; <span class="prelude-ty">Result</span>&lt;Regex, HashsumError&gt; {
Regex::new(<span class="kw-2">&amp;</span><span class="macro">format!</span>(
<span class="string">r&quot;^(?P&lt;digest&gt;[a-fA-F0-9]{bytes_marker}) {format_marker}(?P&lt;fileName&gt;.*)&quot;
</span>))
.map_err(|<span class="kw">_</span>| HashsumError::InvalidRegex)
}
<span class="kw">let </span><span class="kw-2">mut </span>gnu_re = gnu_re_template(<span class="kw-2">&amp;</span>bytes_marker, <span class="string">r&quot;(?P&lt;binary&gt;[ \*])?&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>bsd_re = Regex::new(<span class="kw-2">&amp;</span><span class="macro">format!</span>(
<span class="string">r&quot;^{algorithm} \((?P&lt;fileName&gt;.*)\) = (?P&lt;digest&gt;[a-fA-F0-9]{digest_size})&quot;</span>,
algorithm = options.algoname,
digest_size = modifier,
digest_size = bytes_marker,
))
.map_err(|<span class="kw">_</span>| HashsumError::InvalidRegex)<span class="question-mark">?</span>;
<span class="kw">fn </span>handle_captures(
caps: <span class="kw-2">&amp;</span>Captures,
bytes_marker: <span class="kw-2">&amp;</span>str,
bsd_reversed: <span class="kw-2">&amp;mut </span><span class="prelude-ty">Option</span>&lt;bool&gt;,
gnu_re: <span class="kw-2">&amp;mut </span>Regex,
) -&gt; <span class="prelude-ty">Result</span>&lt;(String, String, bool), HashsumError&gt; {
<span class="kw">if </span>bsd_reversed.is_none() {
<span class="kw">let </span>is_bsd_reversed = caps.name(<span class="string">&quot;binary&quot;</span>).is_none();
<span class="kw">let </span>format_marker = <span class="kw">if </span>is_bsd_reversed {
<span class="string">&quot;&quot;
</span>} <span class="kw">else </span>{
<span class="string">r&quot;(?P&lt;binary&gt;[ \*])&quot;
</span>}
.to_string();
<span class="kw-2">*</span>bsd_reversed = <span class="prelude-val">Some</span>(is_bsd_reversed);
<span class="kw-2">*</span>gnu_re = gnu_re_template(bytes_marker, <span class="kw-2">&amp;</span>format_marker)<span class="question-mark">?</span>;
}
<span class="prelude-val">Ok</span>((
caps.name(<span class="string">&quot;fileName&quot;</span>).unwrap().as_str().to_string(),
caps.name(<span class="string">&quot;digest&quot;</span>).unwrap().as_str().to_ascii_lowercase(),
<span class="kw">if </span><span class="kw-2">*</span>bsd_reversed == <span class="prelude-val">Some</span>(<span class="bool-val">false</span>) {
caps.name(<span class="string">&quot;binary&quot;</span>).unwrap().as_str() == <span class="string">&quot;*&quot;
</span>} <span class="kw">else </span>{
<span class="bool-val">false
</span>},
))
}
<span class="kw">let </span>buffer = file;
<span class="kw">for </span>(i, maybe_line) <span class="kw">in </span>buffer.lines().enumerate() {
<span class="kw">let </span>line = <span class="kw">match </span>maybe_line {
@@ -1400,14 +1486,12 @@
<span class="prelude-val">Err</span>(e) =&gt; <span class="kw">return </span><span class="prelude-val">Err</span>(e.map_err_context(|| <span class="string">&quot;failed to read file&quot;</span>.to_string())),
};
<span class="kw">let </span>(ck_filename, sum, binary_check) = <span class="kw">match </span>gnu_re.captures(<span class="kw-2">&amp;</span>line) {
<span class="prelude-val">Some</span>(caps) =&gt; (
caps.name(<span class="string">&quot;fileName&quot;</span>).unwrap().as_str(),
caps.name(<span class="string">&quot;digest&quot;</span>).unwrap().as_str().to_ascii_lowercase(),
caps.name(<span class="string">&quot;binary&quot;</span>).unwrap().as_str() == <span class="string">&quot;*&quot;</span>,
),
<span class="prelude-val">Some</span>(caps) =&gt; {
handle_captures(<span class="kw-2">&amp;</span>caps, <span class="kw-2">&amp;</span>bytes_marker, <span class="kw-2">&amp;mut </span>bsd_reversed, <span class="kw-2">&amp;mut </span>gnu_re)<span class="question-mark">?
</span>}
<span class="prelude-val">None </span>=&gt; <span class="kw">match </span>bsd_re.captures(<span class="kw-2">&amp;</span>line) {
<span class="prelude-val">Some</span>(caps) =&gt; (
caps.name(<span class="string">&quot;fileName&quot;</span>).unwrap().as_str(),
caps.name(<span class="string">&quot;fileName&quot;</span>).unwrap().as_str().to_string(),
caps.name(<span class="string">&quot;digest&quot;</span>).unwrap().as_str().to_ascii_lowercase(),
<span class="bool-val">true</span>,
),
@@ -1428,7 +1512,7 @@
}
},
};
<span class="kw">let </span>f = <span class="kw">match </span>File::open(ck_filename) {
<span class="kw">let </span>f = <span class="kw">match </span>File::open(ck_filename.clone()) {
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; {
failed_open_file += <span class="number">1</span>;
<span class="macro">println!</span>(
@@ -1479,7 +1563,7 @@
)
.map_err_context(|| <span class="string">&quot;failed to read input&quot;</span>.to_string())<span class="question-mark">?</span>;
<span class="kw">if </span>options.tag {
<span class="macro">println!</span>(<span class="string">&quot;{} ({}) = {}&quot;</span>, options.algoname, filename.display(), sum);
<span class="macro">println!</span>(<span class="string">&quot;{} ({:?}) = {}&quot;</span>, options.algoname, filename.display(), sum);
} <span class="kw">else if </span>options.nonames {
<span class="macro">println!</span>(<span class="string">&quot;{sum}&quot;</span>);
} <span class="kw">else if </span>options.zero {
+119 -15
View File
@@ -573,6 +573,58 @@
<a href="#573" id="573">573</a>
<a href="#574" id="574">574</a>
<a href="#575" id="575">575</a>
<a href="#576" id="576">576</a>
<a href="#577" id="577">577</a>
<a href="#578" id="578">578</a>
<a href="#579" id="579">579</a>
<a href="#580" id="580">580</a>
<a href="#581" id="581">581</a>
<a href="#582" id="582">582</a>
<a href="#583" id="583">583</a>
<a href="#584" id="584">584</a>
<a href="#585" id="585">585</a>
<a href="#586" id="586">586</a>
<a href="#587" id="587">587</a>
<a href="#588" id="588">588</a>
<a href="#589" id="589">589</a>
<a href="#590" id="590">590</a>
<a href="#591" id="591">591</a>
<a href="#592" id="592">592</a>
<a href="#593" id="593">593</a>
<a href="#594" id="594">594</a>
<a href="#595" id="595">595</a>
<a href="#596" id="596">596</a>
<a href="#597" id="597">597</a>
<a href="#598" id="598">598</a>
<a href="#599" id="599">599</a>
<a href="#600" id="600">600</a>
<a href="#601" id="601">601</a>
<a href="#602" id="602">602</a>
<a href="#603" id="603">603</a>
<a href="#604" id="604">604</a>
<a href="#605" id="605">605</a>
<a href="#606" id="606">606</a>
<a href="#607" id="607">607</a>
<a href="#608" id="608">608</a>
<a href="#609" id="609">609</a>
<a href="#610" id="610">610</a>
<a href="#611" id="611">611</a>
<a href="#612" id="612">612</a>
<a href="#613" id="613">613</a>
<a href="#614" id="614">614</a>
<a href="#615" id="615">615</a>
<a href="#616" id="616">616</a>
<a href="#617" id="617">617</a>
<a href="#618" id="618">618</a>
<a href="#619" id="619">619</a>
<a href="#620" id="620">620</a>
<a href="#621" id="621">621</a>
<a href="#622" id="622">622</a>
<a href="#623" id="623">623</a>
<a href="#624" id="624">624</a>
<a href="#625" id="625">625</a>
<a href="#626" id="626">626</a>
<a href="#627" id="627">627</a>
</pre><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
// *
// * (c) Martin Kysel &lt;code@martinkysel.com&gt;
@@ -631,14 +683,16 @@
silent: bool,
clean_print: bool,
print_over: bool,
squeeze: bool,
}
<span class="kw">impl </span>Options {
<span class="kw">fn </span>from(matches: <span class="kw-2">&amp;</span>ArgMatches) -&gt; <span class="self">Self </span>{
<span class="self">Self </span>{
silent: matches.get_flag(options::SILENT),
clean_print: matches.get_flag(options::CLEAN_PRINT),
print_over: matches.get_flag(options::PRINT_OVER),
silent: matches.get_flag(options::SILENT),
squeeze: matches.get_flag(options::SQUEEZE),
}
}
}
@@ -733,6 +787,13 @@
.help(<span class="string">&quot;Do not scroll, clean screen and display text&quot;</span>)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::SQUEEZE)
.short(<span class="string">&#39;s&#39;</span>)
.long(options::SQUEEZE)
.help(<span class="string">&quot;Squeeze multiple blank lines into one&quot;</span>)
.action(ArgAction::SetTrue),
)
<span class="comment">// The commented arguments below are unimplemented:
/*
.arg(
@@ -747,12 +808,6 @@
.long(options::NO_PAUSE)
.help(&quot;Suppress pause after form feed&quot;),
)
.arg(
Arg::new(options::SQUEEZE)
.short(&#39;s&#39;)
.long(options::SQUEEZE)
.help(&quot;Squeeze multiple blank lines into one&quot;),
)
.arg(
Arg::new(options::PLAIN)
.short(&#39;u&#39;)
@@ -952,6 +1007,8 @@
next_file: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">&#39;a </span>str&gt;,
line_count: usize,
silent: bool,
squeeze: bool,
line_squeezed: usize,
}
<span class="kw">impl</span>&lt;<span class="lifetime">&#39;a</span>&gt; Pager&lt;<span class="lifetime">&#39;a</span>&gt; {
@@ -964,6 +1021,8 @@
next_file,
line_count,
silent: options.silent,
squeeze: options.squeeze,
line_squeezed: <span class="number">0</span>,
}
}
@@ -989,7 +1048,21 @@
}
<span class="kw">fn </span>page_up(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
<span class="self">self</span>.upper_mark = <span class="self">self</span>.upper_mark.saturating_sub(<span class="self">self</span>.content_rows.into());
<span class="kw">let </span>content_row_usize: usize = <span class="self">self</span>.content_rows.into();
<span class="self">self</span>.upper_mark = <span class="self">self
</span>.upper_mark
.saturating_sub(content_row_usize.saturating_add(<span class="self">self</span>.line_squeezed));
<span class="kw">if </span><span class="self">self</span>.squeeze {
<span class="kw">let </span>iter = <span class="self">self</span>.lines.iter().take(<span class="self">self</span>.upper_mark).rev();
<span class="kw">for </span>line <span class="kw">in </span>iter {
<span class="kw">if </span>line.is_empty() {
<span class="self">self</span>.upper_mark = <span class="self">self</span>.upper_mark.saturating_sub(<span class="number">1</span>);
} <span class="kw">else </span>{
<span class="kw">break</span>;
}
}
}
}
<span class="kw">fn </span>next_line(<span class="kw-2">&amp;mut </span><span class="self">self</span>) {
@@ -1005,7 +1078,7 @@
<span class="self">self</span>.content_rows = row.saturating_sub(<span class="number">1</span>);
}
<span class="kw">fn </span>draw(<span class="kw-2">&amp;</span><span class="self">self</span>, stdout: <span class="kw-2">&amp;mut </span>std::io::Stdout, wrong_key: <span class="prelude-ty">Option</span>&lt;char&gt;) {
<span class="kw">fn </span>draw(<span class="kw-2">&amp;mut </span><span class="self">self</span>, stdout: <span class="kw-2">&amp;mut </span>std::io::Stdout, wrong_key: <span class="prelude-ty">Option</span>&lt;char&gt;) {
<span class="kw">let </span>lower_mark = <span class="self">self
</span>.line_count
.min(<span class="self">self</span>.upper_mark.saturating_add(<span class="self">self</span>.content_rows.into()));
@@ -1014,13 +1087,44 @@
stdout.flush().unwrap();
}
<span class="kw">fn </span>draw_lines(<span class="kw-2">&amp;</span><span class="self">self</span>, stdout: <span class="kw-2">&amp;mut </span>std::io::Stdout) {
<span class="kw">fn </span>draw_lines(<span class="kw-2">&amp;mut </span><span class="self">self</span>, stdout: <span class="kw-2">&amp;mut </span>std::io::Stdout) {
<span class="macro">execute!</span>(stdout, terminal::Clear(terminal::ClearType::CurrentLine)).unwrap();
<span class="kw">let </span>displayed_lines = <span class="self">self
</span>.lines
.iter()
.skip(<span class="self">self</span>.upper_mark)
.take(<span class="self">self</span>.content_rows.into());
<span class="self">self</span>.line_squeezed = <span class="number">0</span>;
<span class="kw">let </span><span class="kw-2">mut </span>previous_line_blank = <span class="bool-val">false</span>;
<span class="kw">let </span><span class="kw-2">mut </span>displayed_lines = Vec::new();
<span class="kw">let </span><span class="kw-2">mut </span>iter = <span class="self">self</span>.lines.iter().skip(<span class="self">self</span>.upper_mark);
<span class="kw">while </span>displayed_lines.len() &lt; <span class="self">self</span>.content_rows <span class="kw">as </span>usize {
<span class="kw">match </span>iter.next() {
<span class="prelude-val">Some</span>(line) =&gt; {
<span class="kw">if </span><span class="self">self</span>.squeeze {
<span class="kw">match </span>(line.is_empty(), previous_line_blank) {
(<span class="bool-val">true</span>, <span class="bool-val">false</span>) =&gt; {
previous_line_blank = <span class="bool-val">true</span>;
displayed_lines.push(line);
}
(<span class="bool-val">false</span>, <span class="bool-val">true</span>) =&gt; {
previous_line_blank = <span class="bool-val">false</span>;
displayed_lines.push(line);
}
(<span class="bool-val">false</span>, <span class="bool-val">false</span>) =&gt; displayed_lines.push(line),
(<span class="bool-val">true</span>, <span class="bool-val">true</span>) =&gt; {
<span class="self">self</span>.line_squeezed += <span class="number">1</span>;
<span class="self">self</span>.upper_mark += <span class="number">1</span>;
}
}
} <span class="kw">else </span>{
displayed_lines.push(line);
}
}
<span class="comment">// if none the end of the file is reached
</span><span class="prelude-val">None </span>=&gt; {
<span class="self">self</span>.upper_mark = <span class="self">self</span>.line_count;
<span class="kw">break</span>;
}
}
}
<span class="kw">for </span>line <span class="kw">in </span>displayed_lines {
stdout.write_all(<span class="macro">format!</span>(<span class="string">&quot;\r{line}\n&quot;</span>).as_bytes()).unwrap();
+2
View File
@@ -35,6 +35,7 @@
<a href="#35" id="35">35</a>
<a href="#36" id="36">36</a>
<a href="#37" id="37">37</a>
<a href="#38" id="38">38</a>
</pre><pre class="rust"><code><span class="doccomment">//! Traits and implementations for iterating over lines in a file-like object.
//!
//! This module provides a [`WordCountable`] trait and implementations
@@ -65,6 +66,7 @@
<span class="self">self
</span>}
}
<span class="kw">impl </span>WordCountable <span class="kw">for </span>File {
<span class="kw">type </span>Buffered = BufReader&lt;<span class="self">Self</span>&gt;;
+646 -290
View File
File diff suppressed because it is too large Load Diff
-32
View File
@@ -29,22 +29,6 @@
<a href="#29" id="29">29</a>
<a href="#30" id="30">30</a>
<a href="#31" id="31">31</a>
<a href="#32" id="32">32</a>
<a href="#33" id="33">33</a>
<a href="#34" id="34">34</a>
<a href="#35" id="35">35</a>
<a href="#36" id="36">36</a>
<a href="#37" id="37">37</a>
<a href="#38" id="38">38</a>
<a href="#39" id="39">39</a>
<a href="#40" id="40">40</a>
<a href="#41" id="41">41</a>
<a href="#42" id="42">42</a>
<a href="#43" id="43">43</a>
<a href="#44" id="44">44</a>
<a href="#45" id="45">45</a>
<a href="#46" id="46">46</a>
<a href="#47" id="47">47</a>
</pre><pre class="rust"><code><span class="kw">use </span>std::cmp::max;
<span class="kw">use </span>std::ops::{Add, AddAssign};
@@ -76,21 +60,5 @@
<span class="kw-2">*</span><span class="self">self </span>= <span class="kw-2">*</span><span class="self">self </span>+ other;
}
}
<span class="kw">impl </span>WordCount {
<span class="kw">pub fn </span>with_title(<span class="self">self</span>, title: <span class="prelude-ty">Option</span>&lt;String&gt;) -&gt; TitledWordCount {
TitledWordCount { title, count: <span class="self">self </span>}
}
}
<span class="doccomment">/// This struct supplements the actual word count with an optional title that is
/// displayed to the user at the end of the program.
/// The reason we don&#39;t simply include title in the `WordCount` struct is that
/// it would result in unnecessary copying of `String`.
</span><span class="attr">#[derive(Debug, Default, Clone)]
</span><span class="kw">pub struct </span>TitledWordCount {
<span class="kw">pub </span>title: <span class="prelude-ty">Option</span>&lt;String&gt;,
<span class="kw">pub </span>count: WordCount,
}
</code></pre></div>
</section></main><div id="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="uu_wc" data-themes="" data-resource-suffix="" data-rustdoc-version="1.69.0 (84c898d65 2023-04-16)" data-search-js="search-8a59a8356673ec1f.js" data-settings-js="settings-f0c5c39777a9a2f6.js" data-settings-css="settings-0bcba95ff279c1db.css" ></div></body></html>
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More