@@ -7,79 +7,79 @@ namespace MatthiWare.CommandLine.Core
77 internal static class Extensions
88 {
99
10- public static IEnumerable < string > SplitOnWhitespace ( this string input )
11- {
12- if ( string . IsNullOrWhiteSpace ( input ) ) yield return null ;
10+ // public static IEnumerable<string> SplitOnWhitespace(this string input)
11+ // {
12+ // if (string.IsNullOrWhiteSpace(input)) yield return input ;
1313
14- int len = input . Length ;
14+ // int len = input.Length;
1515
16- int totalRead = 0 ;
16+ // int totalRead = 0;
1717
18- while ( totalRead < len )
19- {
20- var word = FindNextWord ( input . AsSpan ( totalRead ) , out int read ) ;
21- totalRead += read ;
18+ // while (totalRead < len)
19+ // {
20+ // var word = FindNextWord(input.AsSpan(totalRead), out int read);
21+ // totalRead += read;
2222
23- if ( word != null )
24- yield return word ;
25- }
23+ // if (word != null)
24+ // yield return word;
25+ // }
2626
2727
28- }
28+ // }
2929
30- private static string FindNextWord ( ReadOnlySpan < char > src , out int read )
31- {
32- read = 0 ;
30+ // private static string FindNextWord(ReadOnlySpan<char> src, out int read)
31+ // {
32+ // read = 0;
3333
34- if ( src . IsEmpty ) return null ;
34+ // if (src.IsEmpty) return null;
3535
36- int lastIndex = 0 ;
37- bool inDoubleQuotes = false ;
38- bool inLiteral = false ;
39- bool exitedDoubleQuotes = false ;
40- bool exitedLiteral = false ;
36+ // int lastIndex = 0;
37+ // bool inDoubleQuotes = false;
38+ // bool inLiteral = false;
39+ // bool exitedDoubleQuotes = false;
40+ // bool exitedLiteral = false;
4141
42- for ( int i = 0 ; i < src . Length ; i ++ )
43- {
44- read ++ ;
42+ // for (int i = 0; i < src.Length; i++)
43+ // {
44+ // read++;
4545
46- if ( src [ i ] == DoubleQuote )
47- {
48- inDoubleQuotes = ! inDoubleQuotes ;
49- exitedDoubleQuotes = true ;
50- }
51- else if ( src [ i ] == SingleQuote )
52- {
53- inLiteral = ! inLiteral ;
54- exitedLiteral = true ;
55- }
46+ // if (src[i] == DoubleQuote)
47+ // {
48+ // inDoubleQuotes = !inDoubleQuotes;
49+ // exitedDoubleQuotes = true;
50+ // }
51+ // else if (src[i] == SingleQuote)
52+ // {
53+ // inLiteral = !inLiteral;
54+ // exitedLiteral = true;
55+ // }
5656
57- if ( ( exitedDoubleQuotes || exitedLiteral ) && ! inDoubleQuotes && ! inLiteral )
58- {
59- var endOffset = exitedDoubleQuotes ? 1 : 2 ;
57+ // if ((exitedDoubleQuotes || exitedLiteral) && !inDoubleQuotes && !inLiteral)
58+ // {
59+ // var endOffset = exitedDoubleQuotes ? 1 : 2;
6060
61- var substr = src . Substring ( 1 , i - lastIndex - endOffset ) ;
61+ // var substr = src.Substring(1, i - lastIndex - endOffset);
6262
63- lastIndex = i + 1 ;
63+ // lastIndex = i + 1;
6464
65- exitedLiteral = false ;
66- exitedDoubleQuotes = false ;
65+ // exitedLiteral = false;
66+ // exitedDoubleQuotes = false;
6767
68- if ( ! substr . IsEmpty ) return substr . ToString ( ) ;
69- }
68+ // if (!substr.IsEmpty) return substr.ToString();
69+ // }
7070
71- if ( ! inDoubleQuotes && ! inLiteral && src [ i ] == Space )
72- {
73- var substr = src . Substring ( lastIndex , i - lastIndex ) ;
71+ // if (!inDoubleQuotes && !inLiteral && src[i] == Space)
72+ // {
73+ // var substr = src.Substring(lastIndex, i - lastIndex);
7474
75- lastIndex = i + 1 ;
75+ // lastIndex = i + 1;
7676
77- if ( ! substr . IsEmpty ) return substr . ToString ( ) ;
78- }
79- }
77+ // if (!substr.IsEmpty) return substr.ToString();
78+ // }
79+ // }
8080
81- return src . ToString ( ) ;
82- }
81+ // return src.ToString();
82+ // }
8383
8484 public static ReadOnlySpan < char > Substring ( this ReadOnlySpan < char > src , int start , int len )
8585 {
@@ -88,29 +88,29 @@ public static ReadOnlySpan<char> Substring(this ReadOnlySpan<char> src, int star
8888 return src . Slice ( start , len ) ;
8989 }
9090
91- public static string RemoveLiteralsAndQuotes ( this ReadOnlySpan < char > value )
92- {
93- if ( value . IsEmpty ) return new string ( value . ToArray ( ) ) ;
91+ // public static string RemoveLiteralsAndQuotes(this ReadOnlySpan<char> value)
92+ // {
93+ // if (value.IsEmpty) return new string(value.ToArray());
9494
95- int startTrim = 0 , endTrim = 0 ;
96- int len = value . Length - 1 ;
95+ // int startTrim = 0, endTrim = 0;
96+ // int len = value.Length - 1;
9797
98- if ( value . Length == 0 ) return new string ( value . ToArray ( ) ) ;
98+ // if (value.Length == 0) return new string(value.ToArray());
9999
100- if ( value [ 0 ] == DoubleQuote || value [ 0 ] == SingleQuote )
101- startTrim = 1 ;
100+ // if (value[0] == DoubleQuote || value[0] == SingleQuote)
101+ // startTrim = 1;
102102
103- if ( value [ len ] == DoubleQuote || value [ len ] == SingleQuote )
104- endTrim = 1 ;
103+ // if (value[len] == DoubleQuote || value[len] == SingleQuote)
104+ // endTrim = 1;
105105
106- if ( startTrim == 0 && endTrim == 0 ) return new string ( value . ToArray ( ) ) ;
106+ // if (startTrim == 0 && endTrim == 0) return new string(value.ToArray());
107107
108- return new string ( value . Substring ( startTrim , len - endTrim ) . ToArray ( ) ) ;
109- }
108+ // return new string(value.Substring(startTrim, len - endTrim).ToArray());
109+ // }
110110
111- private const char DoubleQuote = '"' ;
112- private const char SingleQuote = '\' ' ;
113- private const char Space = ' ' ;
111+ // private const char DoubleQuote = '"';
112+ // private const char SingleQuote = '\'';
113+ // private const char Space = ' ';
114114
115115 }
116116}
0 commit comments