Changeset 621 for trunk


Ignore:
Timestamp:
Sep 2, 2008, 2:22:49 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

GC_mallocがNULLを返さなくなったことへの対応

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/String.ab

    r531 r621  
    6161
    6262        Sub String(initStr As String)
    63             If Not String.IsNullOrEmpty(initStr) Then
     63            If Not IsNullOrEmpty(initStr) Then
    6464                Assign(initStr.Chars, initStr.m_Length)
    6565            End If
     
    234234        Function CompareTo(y As Object) As Long
    235235            If Not Object.Equals(This.GetType(), y.GetType()) Then
    236                 Throw New ArgumentException("String.CompareTo: The type of the argument y is not String.", "y")
     236                Throw New ArgumentException("String.CompareTo: y is not String.", "y")
    237237            End If
    238238            Return CompareTo(y As String)
     
    260260#ifdef UNICODE
    261261            Dim textLengthW = MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, 0, 0)
    262             If AllocStringBuffer(textLengthW) <> 0 Then
    263                 MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, Chars, textLengthW)
    264                 Chars[textLengthW] = 0
    265             End If
     262            AllocStringBuffer(textLengthW)
     263            MultiByteToWideChar(CP_THREAD_ACP, 0, text, textLengthA, Chars, textLengthW)
     264            Chars[textLengthW] = 0
    266265#else
    267266            AssignFromCharPtr(text, textLengthA)
     
    274273#else
    275274            Dim textLengthA = WideCharToMultiByte(CP_THREAD_ACP, 0, text, textLengthW, 0, 0, 0, 0)
    276             If AllocStringBuffer(textLengthA) <> 0 Then
    277                 WideCharToMultiByte(CP_THREAD_ACP, 0, text, textLengthW, Chars, textLengthA, 0, 0)
    278                 Chars[textLengthA] = 0
    279             End If
     275            AllocStringBuffer(textLengthA)
     276            WideCharToMultiByte(CP_THREAD_ACP, 0, text, textLengthW, Chars, textLengthA, 0, 0)
     277            Chars[textLengthA] = 0
    280278#endif
    281279        End Sub
     
    323321
    324322        Static Function Concat(x As String, y As String) As String
    325             If String.IsNullOrEmpty(x) Then
     323            If IsNullOrEmpty(x) Then
    326324                Return y
    327325            Else
     
    359357
    360358        Const Function Contains(s As String) As Boolean
    361             If Object.ReferenceEquals(s, Nothing) Then
     359            If ActiveBasic.IsNothing(s) Then
    362360                Throw New ArgumentNullException("String.Contains: An argument is null value.", "s")
    363361            ElseIf s = "" Then
     
    399397        Const Function IndexOf(s As String, startIndex As Long, count As Long) As Long
    400398            rangeCheck(startIndex, count)
    401             If Object.ReferenceEquals(s, Nothing) Then
     399            If ActiveBasic.IsNothing(s) Then
    402400                Throw New ArgumentNullException("String.IndexOf: An argument is out of range value.", "s")
    403401            End If
     
    458456
    459457        Const Function LastIndexOf(s As String, start As Long, count As Long) As Long
    460             If Object.ReferenceEquals(s, Nothing) Then
     458            If ActiveBasic.IsNothing(s) Then
    461459                Throw New ArgumentNullException("String.LastIndexOf: An argument is out of range value.", "s")
    462460            End If
     
    684682        End Function
    685683    Private
    686         Function AllocStringBuffer(textLength As Long) As *Char
     684        Sub AllocStringBuffer(textLength As Long)
    687685            If textLength < 0 Then
    688                 Return 0
    689             End If
    690             AllocStringBuffer = GC_malloc_atomic(SizeOf(Char) * (textLength + 1))
    691             If AllocStringBuffer = 0 Then
    692                 'Throw New OutOfMemoryException
    693             End If
     686                Throw New ArgumentException
     687            End If
     688            Chars = GC_malloc_atomic(SizeOf(Char) * (textLength + 1))
    694689            m_Length = textLength
    695             Chars = AllocStringBuffer
    696         End Function
     690        End Sub
    697691
    698692        Sub AssignFromCharPtr(text As *Char, textLength As Long)
     
    704698        Const Sub rangeCheck(index As Long)
    705699            If index < 0 Or index > m_Length Then
    706                 Throw New ArgumentOutOfRangeException("String: An arguments is out of range value.", "index")
     700                Throw New ArgumentOutOfRangeException("String: An argument is out of range value.", "index")
    707701            End If
    708702        End Sub
Note: See TracChangeset for help on using the changeset viewer.