This repository was archived by the owner on Oct 3, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +646
-702
lines changed
java/java-ranger-regression/printtokens_eqchk Expand file tree Collapse file tree 5 files changed +646
-702
lines changed Original file line number Diff line number Diff line change 33import java .io .Reader ;
44
55public class IntReader extends Reader {
6- private char [] str ;
7- private int length ;
8- private int next = 0 ;
9-
10- public IntReader (char [] s ) {
11- str = s ;
12- length = s .length ;
6+ private char [] str ;
7+ private int length ;
8+ private int next = 0 ;
9+
10+ public IntReader (char [] s ) {
11+ str = s ;
12+ length = s .length ;
13+ }
14+
15+ public int read () throws IOException {
16+ if (next >= length ) {
17+ return -1 ;
18+ }
19+ else {
20+ char ch = str [next ];
21+ next = next + 1 ;
22+ return ch ;
1323 }
14-
15- // private void ensureOpen() throws IOException{
16- // if(str == null){
17- // throw new IOException("Stream Closed");
18- // }
19- // }
24+ }
2025
21- public int read () throws IOException {
22- // ensureOpen();
23- if (next >= length ){
24- return -1 ;
25- }
26- else {
27- char ch = str [next ];
28- next = next + 1 ;
29- return ch ;
30- }
26+ public void close () {
27+ str = null ;
28+ }
3129
30+ public int read (char [] cbuf , int off , int len ) throws IOException {
31+ if (off < 0 || off >= cbuf .length || len < 0 || off +len >= cbuf .length || off +len < 0 ) {
32+ throw new IndexOutOfBoundsException ();
3233 }
33-
34- public void close () {
35- str = null ;
34+ else if (len == 0 ) {
35+ return 0 ;
3636 }
37-
38- public int read (char [] cbuf , int off , int len ) throws IOException {
39- // ensureOpen();
40- if (off < 0 || off >= cbuf .length || len < 0 || off +len >= cbuf .length || off +len < 0 ){
41- throw new IndexOutOfBoundsException ();
42- }
43- else if (len == 0 ){
44- return 0 ;
45- }
46- if (next >= length ){
47- return -1 ;
48- }
49- int lenReader = -1 ;
50- int lenStr = length - next ;
51- if (lenStr > len ){
52- lenReader = len ;
53- }
54- else {
55- lenReader = lenStr ;
56- }
57- for (int i =0 ; i <lenReader ; i ++){
58- cbuf [off ] = str [next ];
59- off ++;
60- next ++;
61- }
62- return lenReader ;
63- }
64-
37+ if (next >= length ) {
38+ return -1 ;
39+ }
40+ int lenReader = -1 ;
41+ int lenStr = length - next ;
42+ if (lenStr > len ) {
43+ lenReader = len ;
44+ }
45+ else {
46+ lenReader = lenStr ;
47+ }
48+ for (int i =0 ; i <lenReader ; i ++) {
49+ cbuf [off ] = str [next ];
50+ off ++;
51+ next ++;
52+ }
53+ return lenReader ;
54+ }
6555}
You can’t perform that action at this time.
0 commit comments