Skip to content

Commit 09a9d2b

Browse files
author
A9G-Data-Droid
committed
Reduce scope of crlf variables
1 parent a4b63c7 commit 09a9d2b

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

TextFileConvert/ConvertLineEndings.vb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ Public Class ConvertLineEndings
1414
Ux2Mac
1515
End Enum
1616

17-
Const CR As Char = ChrW(13)
18-
Const LF As Char = ChrW(10)
19-
2017
''' <summary>
2118
''' Converts a DOS text file to have Unix line endings.
2219
''' </summary>
@@ -45,6 +42,9 @@ Public Class ConvertLineEndings
4542
''' <param name="convertMode">This is the type of conversion we are going to perform</param>
4643
''' <returns>Exit code.</returns>
4744
Private Shared Async Function ReplaceLineEndings(originalFile As String, newFile As String, convertMode As TextConvertMode) As Task(Of Integer)
45+
Const cr As Char = ChrW(13)
46+
Const lf As Char = ChrW(10)
47+
4848
' Attempt to detect encoding
4949
Dim fileEncoding As Encoding = GetEncoding(originalFile)
5050
If fileEncoding Is Nothing Then Return 4
@@ -61,22 +61,22 @@ Public Class ConvertLineEndings
6161
If readChars < 1 Then Exit Do
6262
Select Case convertMode
6363
Case TextConvertMode.Dos2Ux
64-
If readBuffer(0) = CR AndAlso oldFile.Peek() = 10 Then
64+
If readBuffer(0) = cr AndAlso oldFile.Peek() = 10 Then
6565
' Strip out CR chars if followed by LF
6666
Await oldFile.ReadAsync(readBuffer, 0, 1)
6767
End If
6868
Case TextConvertMode.Ux2Dos
69-
If readBuffer(0) = CR AndAlso oldFile.Peek() = 10 Then
69+
If readBuffer(0) = cr AndAlso oldFile.Peek() = 10 Then
7070
ReDim Preserve readBuffer(1)
7171
' This is a DOS line ending, keep it.
7272
Dim tempBuffer(1) As Char
7373
Await oldFile.ReadAsync(tempBuffer, 0, 1)
7474
readBuffer(1) = tempBuffer(0)
75-
ElseIf readBuffer(0) = LF Then
75+
ElseIf readBuffer(0) = lf Then
7676
ReDim readBuffer(1)
7777
' Add preceeding CR
78-
readBuffer(0) = CR
79-
readBuffer(1) = LF
78+
readBuffer(0) = cr
79+
readBuffer(1) = lf
8080
End If
8181
Case Else
8282
Debug.Print("Unimplemented text conversion mode")
@@ -109,7 +109,7 @@ Public Class ConvertLineEndings
109109
''' </summary>
110110
''' <param name="filename">The file to get the encoding pattern from.</param>
111111
''' <returns>Encoding type, defaults to ASCII</returns>
112-
Public Shared Function GetEncoding(ByVal filename As String) As Encoding
112+
Public Shared Function GetEncoding(filename As String) As Encoding
113113
Dim bom = New Byte(3) {}
114114

115115
Try

ux2dos/My Project/AssemblyInfo.vb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Imports System
2-
Imports System.Reflection
1+
Imports System.Reflection
32
Imports System.Runtime.InteropServices
43

54
' General Information about an assembly is controlled through the following

0 commit comments

Comments
 (0)