Changeset 1851
- Timestamp:
- 2/18/2010 11:38:06 PM (3 years ago)
- File:
-
- 1 edited
-
branches/eraser6/6.0/Eraser/Program.cs (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eraser6/6.0/Eraser/Program.cs
r1784 r1851 774 774 //Check that the first parameter is not a \ otherwise this comma 775 775 //is escaped 776 if (commaPos == 0 || //No possibility of escaping 777 (commaPos >= 1 && param[commaPos - 1] != '\\') || //Second character 778 (commaPos >= 2 && param[commaPos - 2] == '\\')) //Cannot be a \\ which is an escape 776 if (commaPos == 0 || (commaPos > 0 && CountEscapes(param, commaPos) % 2 == 0)) 779 777 { 780 778 //Extract the current subparameter, and dissect the subparameter … … 791 789 UnescapeCommandLine(subParam), null)); 792 790 } 793 else if (equalPos == 0 || //No possibility of escaping 794 (equalPos >= 1 && subParam[equalPos - 1] != '\\') ||//Second character 795 (equalPos >= 2 && subParam[equalPos - 2] == '\\')) //Double \\ which is an escape 791 else if (equalPos == 0 || 792 (equalPos > 0 && CountEscapes(param, equalPos) % 2 == 0)) 796 793 { 797 794 result.Add(new KeyValuePair<string, string>( … … 812 809 813 810 return result; 811 } 812 813 /// <summary> 814 /// Gets the number of escapes the current token has. 815 /// </summary> 816 /// <param name="param">The parameter.</param> 817 /// <param name="index">The index of the character escaped.</param> 818 /// <returns>The number of escapes. Multiples of two indicate backslashes, odd 819 /// numbers indicate the current character is escaped.</returns> 820 private static int CountEscapes(string param, int index) 821 { 822 if (index == 0) 823 return 0; 824 825 for (int i = 0; index != 0; ++i) 826 if (param[--index] != '\\') 827 return i; 828 829 return 0; 814 830 } 815 831
Note: See TracChangeset
for help on using the changeset viewer.
