You've already forked uutils.github.io
mirror of
https://github.com/uutils/uutils.github.io.git
synced 2026-06-10 16:12:28 -07:00
deploy: f0e8d44e6e
This commit is contained in:
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
@@ -3156,6 +3156,7 @@
|
||||
<a href="#3156" id="3156">3156</a>
|
||||
<a href="#3157" id="3157">3157</a>
|
||||
<a href="#3158" id="3158">3158</a>
|
||||
<a href="#3159" id="3159">3159</a>
|
||||
</pre></div><pre class="rust"><code><span class="comment">// This file is part of the uutils coreutils package.
|
||||
//
|
||||
// (c) Jeremiah Peschka <jeremiah.peschka@gmail.com>
|
||||
@@ -4360,6 +4361,7 @@
|
||||
Arg::new(options::quoting::LITERAL)
|
||||
.short(<span class="string">'N'</span>)
|
||||
.long(options::quoting::LITERAL)
|
||||
.alias(<span class="string">"l"</span>)
|
||||
.help(<span class="string">"Use literal quoting style. Equivalent to `--quoting-style=literal`"</span>)
|
||||
.overrides_with_all([
|
||||
options::QUOTING_STYLE,
|
||||
|
||||
@@ -572,7 +572,7 @@
|
||||
.short(<span class="string">'b'</span>)
|
||||
.long(options::BODY_NUMBERING)
|
||||
.help(<span class="string">"use STYLE for numbering body lines"</span>)
|
||||
.value_name(<span class="string">"SYNTAX"</span>),
|
||||
.value_name(<span class="string">"STYLE"</span>),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::SECTION_DELIMITER)
|
||||
|
||||
@@ -59,18 +59,11 @@
|
||||
<a href="#59" id="59">59</a>
|
||||
<a href="#60" id="60">60</a>
|
||||
<a href="#61" id="61">61</a>
|
||||
<a href="#62" id="62">62</a>
|
||||
<a href="#63" id="63">63</a>
|
||||
<a href="#64" id="64">64</a>
|
||||
<a href="#65" id="65">65</a>
|
||||
<a href="#66" id="66">66</a>
|
||||
<a href="#67" id="67">67</a>
|
||||
<a href="#68" id="68">68</a>
|
||||
</pre></div><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 numberparse argtype
|
||||
// spell-checker:ignore numberparse
|
||||
</span><span class="doccomment">//! Errors returned by seq.
|
||||
</span><span class="kw">use </span>std::error::Error;
|
||||
<span class="kw">use </span>std::fmt::Display;
|
||||
@@ -93,29 +86,11 @@
|
||||
/// The parameter is the increment argument as a [`String`] as read
|
||||
/// from the command line.
|
||||
</span>ZeroIncrement(String),
|
||||
|
||||
<span class="doccomment">/// No arguments were passed to this function, 1 or more is required
|
||||
</span>NoArguments,
|
||||
}
|
||||
|
||||
<span class="kw">impl </span>SeqError {
|
||||
<span class="doccomment">/// The [`String`] argument as read from the command-line.
|
||||
</span><span class="kw">fn </span>arg(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="kw-2">&</span>str {
|
||||
<span class="kw">match </span><span class="self">self </span>{
|
||||
<span class="self">Self</span>::ParseError(s, <span class="kw">_</span>) => s,
|
||||
<span class="self">Self</span>::ZeroIncrement(s) => s,
|
||||
}
|
||||
}
|
||||
|
||||
<span class="doccomment">/// The type of argument that is causing the error.
|
||||
</span><span class="kw">fn </span>argtype(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="kw-2">&</span>str {
|
||||
<span class="kw">match </span><span class="self">self </span>{
|
||||
<span class="self">Self</span>::ParseError(<span class="kw">_</span>, e) => <span class="kw">match </span>e {
|
||||
ParseNumberError::Float => <span class="string">"floating point argument"</span>,
|
||||
ParseNumberError::Nan => <span class="string">"'not-a-number' argument"</span>,
|
||||
ParseNumberError::Hex => <span class="string">"hexadecimal argument"</span>,
|
||||
},
|
||||
<span class="self">Self</span>::ZeroIncrement(<span class="kw">_</span>) => <span class="string">"Zero increment value"</span>,
|
||||
}
|
||||
}
|
||||
}
|
||||
<span class="kw">impl </span>UError <span class="kw">for </span>SeqError {
|
||||
<span class="doccomment">/// Always return 1.
|
||||
</span><span class="kw">fn </span>code(<span class="kw-2">&</span><span class="self">self</span>) -> i32 {
|
||||
@@ -131,7 +106,18 @@
|
||||
|
||||
<span class="kw">impl </span>Display <span class="kw">for </span>SeqError {
|
||||
<span class="kw">fn </span>fmt(<span class="kw-2">&</span><span class="self">self</span>, f: <span class="kw-2">&mut </span>std::fmt::Formatter<<span class="lifetime">'_</span>>) -> std::fmt::Result {
|
||||
<span class="macro">write!</span>(f, <span class="string">"invalid {}: {}"</span>, <span class="self">self</span>.argtype(), <span class="self">self</span>.arg().quote())
|
||||
<span class="kw">match </span><span class="self">self </span>{
|
||||
<span class="self">Self</span>::ParseError(s, e) => {
|
||||
<span class="kw">let </span>error_type = <span class="kw">match </span>e {
|
||||
ParseNumberError::Float => <span class="string">"floating point"</span>,
|
||||
ParseNumberError::Nan => <span class="string">"'not-a-number'"</span>,
|
||||
ParseNumberError::Hex => <span class="string">"hexadecimal"</span>,
|
||||
};
|
||||
<span class="macro">write!</span>(f, <span class="string">"invalid {error_type} argument: {}"</span>, s.quote())
|
||||
}
|
||||
<span class="self">Self</span>::ZeroIncrement(s) => <span class="macro">write!</span>(f, <span class="string">"invalid Zero increment value: {}"</span>, s.quote()),
|
||||
<span class="self">Self</span>::NoArguments => <span class="macro">write!</span>(f, <span class="string">"missing operand"</span>),
|
||||
}
|
||||
}
|
||||
}
|
||||
</code></pre></div></section></main></body></html>
|
||||
@@ -356,6 +356,9 @@
|
||||
<a href="#356" id="356">356</a>
|
||||
<a href="#357" id="357">357</a>
|
||||
<a href="#358" id="358">358</a>
|
||||
<a href="#359" id="359">359</a>
|
||||
<a href="#360" id="360">360</a>
|
||||
<a href="#361" id="361">361</a>
|
||||
</pre></div><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
|
||||
@@ -416,10 +419,13 @@
|
||||
</span><span class="kw">pub fn </span>uumain(args: <span class="kw">impl </span>uucore::Args) -> UResult<()> {
|
||||
<span class="kw">let </span>matches = uu_app().try_get_matches_from(args)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="kw">let </span>numbers = matches
|
||||
.get_many::<String>(ARG_NUMBERS)
|
||||
.unwrap()
|
||||
.collect::<Vec<<span class="kw">_</span>>>();
|
||||
<span class="kw">let </span>numbers_option = matches.get_many::<String>(ARG_NUMBERS);
|
||||
|
||||
<span class="kw">if </span>numbers_option.is_none() {
|
||||
<span class="kw">return </span><span class="prelude-val">Err</span>(SeqError::NoArguments.into());
|
||||
}
|
||||
|
||||
<span class="kw">let </span>numbers = numbers_option.unwrap().collect::<Vec<<span class="kw">_</span>>>();
|
||||
|
||||
<span class="kw">let </span>options = SeqOptions {
|
||||
separator: matches
|
||||
|
||||
@@ -350,15 +350,6 @@
|
||||
<a href="#350" id="350">350</a>
|
||||
<a href="#351" id="351">351</a>
|
||||
<a href="#352" id="352">352</a>
|
||||
<a href="#353" id="353">353</a>
|
||||
<a href="#354" id="354">354</a>
|
||||
<a href="#355" id="355">355</a>
|
||||
<a href="#356" id="356">356</a>
|
||||
<a href="#357" id="357">357</a>
|
||||
<a href="#358" id="358">358</a>
|
||||
<a href="#359" id="359">359</a>
|
||||
<a href="#360" id="360">360</a>
|
||||
<a href="#361" id="361">361</a>
|
||||
</pre></div><pre class="rust"><code><span class="kw">use </span>std::cmp::Ordering;
|
||||
|
||||
<span class="doccomment">/// Compares the non-digit parts of a version.
|
||||
@@ -467,7 +458,7 @@
|
||||
<span class="comment">// 1. Compare leading non-numerical part
|
||||
// 2. Compare leading numerical part
|
||||
// 3. Repeat
|
||||
</span><span class="kw">loop </span>{
|
||||
</span><span class="kw">while </span>!a.is_empty() || !b.is_empty() {
|
||||
<span class="kw">let </span>a_numerical_start = a.find(|c: char| c.is_ascii_digit()).unwrap_or(a.len());
|
||||
<span class="kw">let </span>b_numerical_start = b.find(|c: char| c.is_ascii_digit()).unwrap_or(b.len());
|
||||
|
||||
@@ -500,12 +491,9 @@
|
||||
|
||||
a = <span class="kw-2">&</span>a[a_numerical_end..];
|
||||
b = <span class="kw-2">&</span>b[b_numerical_end..];
|
||||
|
||||
<span class="kw">if </span>a.is_empty() && b.is_empty() {
|
||||
<span class="comment">// Default to the lexical comparison.
|
||||
</span><span class="kw">return </span>str_cmp;
|
||||
}
|
||||
}
|
||||
|
||||
Ordering::Equal
|
||||
}
|
||||
|
||||
<span class="attr">#[cfg(test)]
|
||||
@@ -590,14 +578,14 @@
|
||||
<span class="comment">// Leading zeroes
|
||||
</span><span class="macro">assert_eq!</span>(
|
||||
version_cmp(<span class="string">"012"</span>, <span class="string">"12"</span>),
|
||||
Ordering::Less,
|
||||
<span class="string">"A single leading zero can make a difference"
|
||||
Ordering::Equal,
|
||||
<span class="string">"A single leading zero does not make a difference"
|
||||
</span>);
|
||||
|
||||
<span class="macro">assert_eq!</span>(
|
||||
version_cmp(<span class="string">"000800"</span>, <span class="string">"0000800"</span>),
|
||||
Ordering::Greater,
|
||||
<span class="string">"Leading number of zeroes is used even if both non-zero number of zeros"
|
||||
Ordering::Equal,
|
||||
<span class="string">"Multiple leading zeros do not make a difference"
|
||||
</span>);
|
||||
|
||||
<span class="comment">// Numbers and other characters combined
|
||||
@@ -641,14 +629,8 @@
|
||||
|
||||
<span class="macro">assert_eq!</span>(
|
||||
version_cmp(<span class="string">"aa10aa0022"</span>, <span class="string">"aa010aa022"</span>),
|
||||
Ordering::Greater,
|
||||
<span class="string">"The leading zeroes of the first number has priority."
|
||||
</span>);
|
||||
|
||||
<span class="macro">assert_eq!</span>(
|
||||
version_cmp(<span class="string">"aa10aa0022"</span>, <span class="string">"aa10aa022"</span>),
|
||||
Ordering::Less,
|
||||
<span class="string">"The leading zeroes of other numbers than the first are used."
|
||||
Ordering::Equal,
|
||||
<span class="string">"Test multiple numeric values with leading zeros"
|
||||
</span>);
|
||||
|
||||
<span class="macro">assert_eq!</span>(
|
||||
@@ -668,7 +650,7 @@
|
||||
|
||||
<span class="macro">assert_eq!</span>(
|
||||
version_cmp(<span class="string">"aa2000000000000000000000bb"</span>, <span class="string">"aa002000000000000000000000bb"</span>),
|
||||
Ordering::Greater,
|
||||
Ordering::Equal,
|
||||
<span class="string">"Leading zeroes for numbers larger than u64::MAX are \
|
||||
handled correctly without crashing"
|
||||
</span>);
|
||||
|
||||
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
Reference in New Issue
Block a user