@@ -118,11 +118,19 @@ protected void FillBuff() throws java.io.IOException {
118118
119119 int i ;
120120 try {
121- if ((i = inputStream .read (buffer , maxNextCharInd , available - maxNextCharInd )) == -1 ) {
122- inputStream .close ();
123- throw new java .io .IOException ();
121+ if (inputStream instanceof StringProvider ) {
122+ i = ((StringProvider ) inputStream )._string .length ();
123+ if (maxNextCharInd == i ) {
124+ throw new java .io .IOException ();
125+ }
126+ maxNextCharInd = i ;
124127 } else {
125- maxNextCharInd += i ;
128+ if ((i = inputStream .read (buffer , maxNextCharInd , available - maxNextCharInd )) == -1 ) {
129+ inputStream .close ();
130+ throw new java .io .IOException ();
131+ } else {
132+ maxNextCharInd += i ;
133+ }
126134 }
127135 return ;
128136 } catch (java .io .IOException e ) {
@@ -180,6 +188,14 @@ protected void UpdateLineColumn(char c) {
180188 bufcolumn [bufpos ] = column ;
181189 }
182190
191+ private char readChar (int pos ) {
192+ if (this .inputStream instanceof StringProvider ) {
193+ return ((StringProvider ) inputStream )._string .charAt (pos );
194+ } else {
195+ return buffer [pos ];
196+ }
197+ }
198+
183199 /**
184200 * Read a character.
185201 */
@@ -192,7 +208,7 @@ public char readChar() throws java.io.IOException {
192208 }
193209
194210 totalCharsRead ++;
195- return buffer [ bufpos ] ;
211+ return readChar ( bufpos ) ;
196212 }
197213
198214 if (++bufpos >= maxNextCharInd ) {
@@ -201,7 +217,7 @@ public char readChar() throws java.io.IOException {
201217
202218 totalCharsRead ++;
203219
204- char c = buffer [ bufpos ] ;
220+ char c = readChar ( bufpos ) ;
205221
206222 UpdateLineColumn (c );
207223 return c ;
0 commit comments