@@ -118,11 +118,19 @@ protected void FillBuff() throws java.io.IOException {
118
118
119
119
int i ;
120
120
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 ;
124
127
} 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
+ }
126
134
}
127
135
return ;
128
136
} catch (java .io .IOException e ) {
@@ -180,6 +188,14 @@ protected void UpdateLineColumn(char c) {
180
188
bufcolumn [bufpos ] = column ;
181
189
}
182
190
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
+
183
199
/**
184
200
* Read a character.
185
201
*/
@@ -192,7 +208,7 @@ public char readChar() throws java.io.IOException {
192
208
}
193
209
194
210
totalCharsRead ++;
195
- return buffer [ bufpos ] ;
211
+ return readChar ( bufpos ) ;
196
212
}
197
213
198
214
if (++bufpos >= maxNextCharInd ) {
@@ -201,7 +217,7 @@ public char readChar() throws java.io.IOException {
201
217
202
218
totalCharsRead ++;
203
219
204
- char c = buffer [ bufpos ] ;
220
+ char c = readChar ( bufpos ) ;
205
221
206
222
UpdateLineColumn (c );
207
223
return c ;
0 commit comments