File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,8 @@ state obj FILE_reader(os.libc.FILE f, bool must_close) {
52
52
auto buf = "" ;
53
53
while ( true ) {
54
54
auto ch = os. libc . fgetc ( f) ;
55
- if ( ch == -1 ) { break ; } if ( ch == 10 ) { break ; }
55
+ if ( ch == -1 ) { ret buf; }
56
+ if ( ch == 10 ) { ret buf; }
56
57
buf += _str. unsafe_from_bytes ( vec ( ch as u8 ) ) ;
57
58
}
58
59
ret buf;
@@ -61,7 +62,7 @@ state obj FILE_reader(os.libc.FILE f, bool must_close) {
61
62
auto buf = "" ;
62
63
while ( true ) {
63
64
auto ch = os. libc . fgetc ( f) ;
64
- if ( ch < 1 ) { break ; }
65
+ if ( ch < 1 ) { ret buf ; }
65
66
buf += _str. unsafe_from_bytes ( vec ( ch as u8 ) ) ;
66
67
}
67
68
ret buf;
Original file line number Diff line number Diff line change @@ -9,7 +9,10 @@ impure fn list_dir(str path) -> vec[str] {
9
9
let vec[ str] result = vec ( ) ;
10
10
while ( true ) {
11
11
auto ent = os. libc . readdir ( dir) ;
12
- if ( ent as int == 0 ) { break ; }
12
+ if ( ent as int == 0 ) {
13
+ os. libc . closedir ( dir) ;
14
+ ret result;
15
+ }
13
16
_vec. push [ str] ( result, rustrt. rust_dirent_filename ( ent) ) ;
14
17
}
15
18
os. libc . closedir ( dir) ;
You can’t perform that action at this time.
0 commit comments