I've come across a problem that happens on some and not all MACs - approx 5% of our MAC users. It does not appear to have anything to do with 32/64bit or OS version or Hardware type.
It is to do with a custom search and replace routine to fix CR/LF in a string that is up to 2,000 characters long.
Here's the routine:
Public Function FixCRLF(ByVal InputString As String) As String
Return FixCR(FixLF(InputString))
End Function
Public Function FixCR(ByVal InputString As String) As String
If InputString Is Nothing Then Return Nothing
Dim result As New StringBuilder()
Dim oldValue As String = vbCr
Dim lenOldValue As Integer = oldValue.Length
Dim curPosition As Integer = 0
Dim idxNext As Integer = InputString.IndexOf(oldValue)
While idxNext >= 0
result.Append(InputString, curPosition, idxNext - curPosition)
If Not InputString.IndexOf(vbLf, idxNext) = idxNext + 1 Then
result.Append(vbCrLf)
Else
result.Append(vbCr)
End If
curPosition = idxNext + 1
idxNext = InputString.IndexOf(oldValue, curPosition)
End While
result.Append(InputString, curPosition, InputString.Length - curPosition)
Return result.ToString()
End Function
Public Function FixLF(ByVal InputString As String) As String
If InputString Is Nothing Then Return Nothing
Dim result As New StringBuilder()
Dim oldValue As String = vbLf
Dim lenOldValue As Integer = oldValue.Length
Dim curPosition As Integer = 0
Dim idxNext As Integer = InputString.IndexOf(oldValue)
While idxNext >= 0
result.Append(InputString, curPosition, idxNext - curPosition)
Dim idxBack As Integer = idxNext - 1
If Not InputString.IndexOf(vbCr, idxBack) = idxBack Then
result.Append(vbCrLf)
Else
result.Append(vbLf)
End If
curPosition = idxNext + 1
idxNext = InputString.IndexOf(oldValue, curPosition)
End While
result.Append(InputString, curPosition, InputString.Length - curPosition)
Return result.ToString()
End Function
We see the CPU spike to 100% for approx 5 to 25 minutes showing the pinwheel (busy) cursor then eventually return.
Windows SL5 runtimes do not experience this problem.
Is this a runtime bug or an error in my coding?
Graeme