예제 #1
0
        /// <summary>Reads from the stdin reader, unbuffered, until the specified condition is met.</summary>
        private static unsafe void ReadStdinUnbufferedUntil(
            StdInStreamReader reader, 
            byte* buffer, int bufferSize, 
            ref int bytesRead, ref int pos, 
            Func<byte, bool> condition)
        {
            while (true)
            {
                for (; pos < bytesRead && !condition(buffer[pos]); pos++) ;
                if (pos < bytesRead) return;

                bytesRead = reader.ReadStdinUnbuffered(buffer, bufferSize);
                pos = 0;
            }
        }