File: fix-nom.diff

package info (click to toggle)
rust-coreutils 0.0.30-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 17,388 kB
  • sloc: sh: 1,088; python: 407; javascript: 72; makefile: 51
file content (85 lines) | stat: -rw-r--r-- 2,723 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
Index: coreutils/src/uu/tr/src/operation.rs
===================================================================
--- coreutils.orig/src/uu/tr/src/operation.rs
+++ coreutils/src/uu/tr/src/operation.rs
@@ -25,6 +25,7 @@ use std::{
 };
 use uucore::error::{UError, UResult, USimpleError};
 use uucore::show_warning;
+use nom::sequence::pair;
 
 #[derive(Debug, Clone)]
 pub enum BadSequence {
@@ -496,39 +497,40 @@ impl Sequence {
         .parse(input)
     }
 
-    fn parse_char_equal(input: &[u8]) -> IResult<&[u8], Result<Self, BadSequence>> {
-        preceded(
-            tag("[="),
-            (
-                alt((
-                    value(Err(()), peek(tag("=]"))),
-                    map(Self::parse_backslash_or_char, Ok),
-                )),
-                map(terminated(take_until("=]"), tag("=]")), |v: &[u8]| {
-                    if v.is_empty() {
-                        Ok(())
-                    } else {
-                        Err(v)
-                    }
-                }),
-            ),
+fn parse_char_equal(input: &[u8]) -> IResult<&[u8], Result<Self, BadSequence>> {
+    preceded(
+        tag("[="),
+        pair(
+            alt((
+                value(Err(()), peek(tag("=]"))),
+                map(Self::parse_backslash_or_char, Ok),
+            )),
+            map(terminated(take_until("=]"), tag("=]")), |v: &[u8]| {
+                if v.is_empty() {
+                    Ok(())
+                } else {
+                    Err(v)
+                }
+            }),
+        ),
+    )
+    .parse(input)
+    .map(|(l, (a, b))| {
+        (
+            l,
+            match (a, b) {
+                (Err(()), _) => Err(BadSequence::MissingEquivalentClassChar),
+                (Ok(c), Ok(())) => Ok(Self::Char(c)),
+                (Ok(c), Err(v)) => Err(BadSequence::MultipleCharInEquivalence(format!(
+                    "{}{}",
+                    String::from_utf8_lossy(&[c]).into_owned(),
+                    String::from_utf8_lossy(v).into_owned()
+                ))),
+            },
         )
-        .parse(input)
-        .map(|(l, (a, b))| {
-            (
-                l,
-                match (a, b) {
-                    (Err(()), _) => Err(BadSequence::MissingEquivalentClassChar),
-                    (Ok(c), Ok(())) => Ok(Self::Char(c)),
-                    (Ok(c), Err(v)) => Err(BadSequence::MultipleCharInEquivalence(format!(
-                        "{}{}",
-                        String::from_utf8_lossy(&[c]).into_owned(),
-                        String::from_utf8_lossy(v).into_owned()
-                    ))),
-                },
-            )
-        })
-    }
+    })
+}
+
 }
 
 pub trait SymbolTranslator {