protected void FillBuff()

in src/main/csharp/Selector/SimpleCharStream.cs [71:105]


  protected void FillBuff() {
     if (maxNextCharInd == available) {
        if (available == bufsize) {
           if (tokenBegin > 2048) {
              bufpos = maxNextCharInd = 0;
              available = tokenBegin;
           } else if (tokenBegin < 0)
              bufpos = maxNextCharInd = 0;
           else
              ExpandBuff(false);
        } else if (available > tokenBegin)
           available = bufsize;
        else if ((tokenBegin - available) < 2048)
           ExpandBuff(true);
        else
           available = tokenBegin;
     }

     int i;
     try {
        if ((i = inputStream.Read(buffer, maxNextCharInd,
                                    available - maxNextCharInd)) == -1) {
           inputStream.Close();
           throw new System.IO.IOException();
        } else
           maxNextCharInd += i;
        return;
     } catch(System.IO.IOException e) {
        --bufpos;
        Backup(0);
        if (tokenBegin == -1)
           tokenBegin = bufpos;
        throw e;
     }
  }