This commit is contained in:
sylvestre
2023-02-17 02:56:05 +00:00
parent 8f6fdec72b
commit 7483cee4b1
38 changed files with 91 additions and 89 deletions
+3 -5
View File
@@ -645,7 +645,6 @@
<a href="#645" id="645">645</a>
<a href="#646" id="646">646</a>
<a href="#647" id="647">647</a>
<a href="#648" id="648">648</a>
</pre><pre class="rust"><code><span class="comment">// This file is part of the uutils coreutils package.
//
// (c) Jordi Boggiano &lt;j.boggiano@seld.be&gt;
@@ -681,11 +680,10 @@
</span><span class="kw">use </span>std::os::unix::fs::FileTypeExt;
<span class="attr">#[cfg(unix)]
</span><span class="kw">use </span>std::os::unix::net::UnixStream;
<span class="kw">use </span>uucore::format_usage;
<span class="kw">use </span>uucore::{format_usage, help_section, help_usage};
<span class="kw">static </span>USAGE: <span class="kw-2">&amp;</span>str = <span class="string">&quot;{} [OPTION]... [FILE]...&quot;</span>;
<span class="kw">static </span>ABOUT: <span class="kw-2">&amp;</span>str = <span class="string">&quot;Concatenate FILE(s), or standard input, to standard output
With no FILE, or when FILE is -, read standard input.&quot;</span>;
<span class="kw">const </span>USAGE: <span class="kw-2">&amp;</span>str = <span class="macro">help_usage!</span>(<span class="string">&quot;cat.md&quot;</span>);
<span class="kw">const </span>ABOUT: <span class="kw-2">&amp;</span>str = <span class="macro">help_section!</span>(<span class="string">&quot;about&quot;</span>, <span class="string">&quot;cat.md&quot;</span>);
<span class="attr">#[derive(Error, Debug)]
</span><span class="kw">enum </span>CatError {
+20 -20
View File
@@ -240,21 +240,12 @@
<span class="kw">pub const </span>TOTAL: <span class="kw-2">&amp;</span>str = <span class="string">&quot;total&quot;</span>;
}
<span class="kw">fn </span>mkdelim(col: usize, opts: <span class="kw-2">&amp;</span>ArgMatches) -&gt; String {
<span class="kw">let </span><span class="kw-2">mut </span>s = String::new();
<span class="kw">let </span>delim = <span class="kw">match </span>opts.get_one::&lt;String&gt;(options::DELIMITER).unwrap().as_str() {
<span class="string">&quot;&quot; </span>=&gt; <span class="string">&quot;\0&quot;</span>,
delim =&gt; delim,
};
<span class="kw">if </span>col &gt; <span class="number">1 </span>&amp;&amp; !opts.get_flag(options::COLUMN_1) {
s.push_str(delim.as_ref());
}
<span class="kw">if </span>col &gt; <span class="number">2 </span>&amp;&amp; !opts.get_flag(options::COLUMN_2) {
s.push_str(delim.as_ref());
}
s
<span class="kw">fn </span>column_width(col: <span class="kw-2">&amp;</span>str, opts: <span class="kw-2">&amp;</span>ArgMatches) -&gt; usize {
<span class="kw">if </span>opts.get_flag(col) {
<span class="number">0
</span>} <span class="kw">else </span>{
<span class="number">1
</span>}
}
<span class="kw">fn </span>ensure_nl(line: <span class="kw-2">&amp;mut </span>String) {
@@ -278,7 +269,16 @@
}
<span class="kw">fn </span>comm(a: <span class="kw-2">&amp;mut </span>LineReader, b: <span class="kw-2">&amp;mut </span>LineReader, opts: <span class="kw-2">&amp;</span>ArgMatches) {
<span class="kw">let </span>delim: Vec&lt;String&gt; = (<span class="number">0</span>..<span class="number">4</span>).map(|col| mkdelim(col, opts)).collect();
<span class="kw">let </span>delim = <span class="kw">match </span>opts.get_one::&lt;String&gt;(options::DELIMITER).unwrap().as_str() {
<span class="string">&quot;&quot; </span>=&gt; <span class="string">&quot;\0&quot;</span>,
delim =&gt; delim,
};
<span class="kw">let </span>width_col_1 = column_width(options::COLUMN_1, opts);
<span class="kw">let </span>width_col_2 = column_width(options::COLUMN_2, opts);
<span class="kw">let </span>delim_col_2 = delim.repeat(width_col_1);
<span class="kw">let </span>delim_col_3 = delim.repeat(width_col_1 + width_col_2);
<span class="kw">let </span>ra = <span class="kw-2">&amp;mut </span>String::new();
<span class="kw">let </span><span class="kw-2">mut </span>na = a.read_line(ra);
@@ -306,7 +306,7 @@
Ordering::Less =&gt; {
<span class="kw">if </span>!opts.get_flag(options::COLUMN_1) {
ensure_nl(ra);
<span class="macro">print!</span>(<span class="string">&quot;{}{}&quot;</span>, delim[<span class="number">1</span>], ra);
<span class="macro">print!</span>(<span class="string">&quot;{ra}&quot;</span>);
}
ra.clear();
na = a.read_line(ra);
@@ -315,7 +315,7 @@
Ordering::Greater =&gt; {
<span class="kw">if </span>!opts.get_flag(options::COLUMN_2) {
ensure_nl(rb);
<span class="macro">print!</span>(<span class="string">&quot;{}{}&quot;</span>, delim[<span class="number">2</span>], rb);
<span class="macro">print!</span>(<span class="string">&quot;{delim_col_2}{rb}&quot;</span>);
}
rb.clear();
nb = b.read_line(rb);
@@ -324,7 +324,7 @@
Ordering::Equal =&gt; {
<span class="kw">if </span>!opts.get_flag(options::COLUMN_3) {
ensure_nl(ra);
<span class="macro">print!</span>(<span class="string">&quot;{}{}&quot;</span>, delim[<span class="number">3</span>], ra);
<span class="macro">print!</span>(<span class="string">&quot;{delim_col_3}{ra}&quot;</span>);
}
ra.clear();
rb.clear();
@@ -336,7 +336,7 @@
}
<span class="kw">if </span>opts.get_flag(options::TOTAL) {
<span class="macro">println!</span>(<span class="string">&quot;{total_col_1}\t{total_col_2}\t{total_col_3}\ttotal&quot;</span>);
<span class="macro">println!</span>(<span class="string">&quot;{total_col_1}{delim}{total_col_2}{delim}{total_col_3}{delim}total&quot;</span>);
}
}
+3 -9
View File
@@ -1861,9 +1861,6 @@
<a href="#1861" id="1861">1861</a>
<a href="#1862" id="1862">1862</a>
<a href="#1863" id="1863">1863</a>
<a href="#1864" id="1864">1864</a>
<a href="#1865" id="1865">1865</a>
<a href="#1866" id="1866">1866</a>
</pre><pre class="rust"><code><span class="attr">#![allow(clippy::missing_safety_doc)]
#![allow(clippy::extra_unused_lifetimes)]
@@ -1906,7 +1903,7 @@
<span class="kw">use </span>uucore::fs::{
canonicalize, paths_refer_to_same_file, FileInformation, MissingHandling, ResolveMode,
};
<span class="kw">use </span>uucore::{crash, format_usage, prompt_yes, show_error, show_warning};
<span class="kw">use </span>uucore::{crash, format_usage, help_section, help_usage, prompt_yes, show_error, show_warning};
<span class="kw">use </span><span class="kw">crate</span>::copydir::copy_directory;
@@ -2094,13 +2091,10 @@
progress_bar: bool,
}
<span class="kw">static </span>ABOUT: <span class="kw-2">&amp;</span>str = <span class="string">&quot;Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.&quot;</span>;
<span class="kw">const </span>ABOUT: <span class="kw-2">&amp;</span>str = <span class="macro">help_section!</span>(<span class="string">&quot;about&quot;</span>, <span class="string">&quot;cp.md&quot;</span>);
<span class="kw">static </span>EXIT_ERR: i32 = <span class="number">1</span>;
<span class="kw">const </span>USAGE: <span class="kw-2">&amp;</span>str = <span class="string">&quot;\
{} [OPTION]... [-T] SOURCE DEST
{} [OPTION]... SOURCE... DIRECTORY
{} [OPTION]... -t DIRECTORY SOURCE...&quot;</span>;
<span class="kw">const </span>USAGE: <span class="kw-2">&amp;</span>str = <span class="macro">help_usage!</span>(<span class="string">&quot;cp.md&quot;</span>);
<span class="comment">// Argument constants
</span><span class="kw">mod </span>options {
+21 -11
View File
@@ -515,18 +515,24 @@
<a href="#515" id="515">515</a>
<a href="#516" id="516">516</a>
<a href="#517" id="517">517</a>
<a href="#518" id="518">518</a>
<a href="#519" id="519">519</a>
<a href="#520" id="520">520</a>
<a href="#521" id="521">521</a>
<a href="#522" id="522">522</a>
</pre><pre class="rust"><code><span class="comment">// * This file is part of the uutils coreutils package.
// *
// * For the full copyright and license information, please view the LICENSE
// * file that was distributed with this source code.
// spell-checker:ignore (ToDO) kqueue Signum
// spell-checker:ignore (ToDO) kqueue Signum fundu
</span><span class="kw">use </span><span class="kw">crate</span>::paths::Input;
<span class="kw">use crate</span>::{parse, platform, Quotable};
<span class="kw">use </span>atty::Stream;
<span class="kw">use </span>clap::crate_version;
<span class="kw">use </span>clap::{parser::ValueSource, Arg, ArgAction, ArgMatches, Command};
<span class="kw">use </span>fundu::DurationParser;
<span class="kw">use </span>same_file::Handle;
<span class="kw">use </span>std::collections::VecDeque;
<span class="kw">use </span>std::ffi::OsString;
@@ -665,16 +671,20 @@
settings.retry =
matches.get_flag(options::RETRY) || matches.get_flag(options::FOLLOW_RETRY);
<span class="kw">if let </span><span class="prelude-val">Some</span>(s) = matches.get_one::&lt;String&gt;(options::SLEEP_INT) {
settings.sleep_sec = <span class="kw">match </span>s.parse::&lt;f32&gt;() {
<span class="prelude-val">Ok</span>(s) =&gt; Duration::from_secs_f32(s),
<span class="prelude-val">Err</span>(<span class="kw">_</span>) =&gt; {
<span class="kw">return </span><span class="prelude-val">Err</span>(UUsageError::new(
<span class="number">1</span>,
<span class="macro">format!</span>(<span class="string">&quot;invalid number of seconds: {}&quot;</span>, s.quote()),
))
}
}
<span class="kw">if let </span><span class="prelude-val">Some</span>(source) = matches.get_one::&lt;String&gt;(options::SLEEP_INT) {
<span class="comment">// Advantage of `fundu` over `Duration::(try_)from_secs_f64(source.parse().unwrap())`:
// * doesn&#39;t panic on errors like `Duration::from_secs_f64` would.
// * no precision loss, rounding errors or other floating point problems.
// * evaluates to `Duration::MAX` if the parsed number would have exceeded
// `DURATION::MAX` or `infinity` was given
// * not applied here but it supports customizable time units and provides better error
// messages
</span>settings.sleep_sec =
DurationParser::without_time_units()
.parse(source)
.map_err(|<span class="kw">_</span>| {
UUsageError::new(<span class="number">1</span>, <span class="macro">format!</span>(<span class="string">&quot;invalid number of seconds: &#39;{source}&#39;&quot;</span>))
})<span class="question-mark">?</span>;
}
settings.use_polling = matches.get_flag(options::USE_POLLING);
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 -1
View File
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
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