Changeset 707 for trunk


Ignore:
Timestamp:
Jun 29, 2009, 12:27:18 AM (15 years ago)
Author:
イグトランス (egtra)
Message:

標準入力からの読込時、Ctrl+Zを検知して以後EOFと扱うように修正。
(#243)

File:
1 edited

Legend:

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

    r687 r707  
    691691Protected
    692692    Override Function Underflow() As Boolean
    693         Dim b = Buffer
    694         Dim currentBufLength = b.Length
    695         b.Length = currentBufLength + 256
    696         Dim p = StrPtr(b)
    697         Dim read As DWord
    698         If ReadConsole(h, VarPtr(p[currentBufLength]), 256 * SizeOf (TCHAR), read, 0) = 0 Then
    699             IO.Detail.ThrowWinLastErrorIOException()
    700         End If
    701         b.Length = currentBufLength + read
    702         Underflow = read <> 0
     693        If eofReached Then
     694            Underflow = 0
     695        Else
     696            Dim b = Buffer
     697            Dim currentBufLength = b.Length
     698            b.Length = currentBufLength + 256
     699            Dim p = StrPtr(b)
     700            Dim read As DWord
     701            If ReadConsole(h, VarPtr(p[currentBufLength]), 256 * SizeOf (TCHAR), read, 0) = 0 Then
     702                IO.Detail.ThrowWinLastErrorIOException()
     703            End If
     704            Dim eofPos = ActiveBasic.Strings.ChrFind(VarPtr(p[currentBufLength]) As PCTSTR, read As SIZE_T, &h1A As TCHAR)
     705            If eofPos <> -1 Then
     706                eofReached = True
     707                read = eofPos
     708            End If
     709            b.Length = currentBufLength + read
     710            Underflow = read <> 0
     711        End If
    703712    End Function
    704713
    705714Private
    706715    h As HANDLE
     716    eofReached As Boolean
    707717End Class
    708718
Note: See TracChangeset for help on using the changeset viewer.