Skip to content

Commit 6a6a30b

Browse files
committed
Remove uses of 'break' in std lib; rustc doesn't support it yet, this is easier for now.
1 parent e1d2899 commit 6a6a30b

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/lib/io.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ state obj FILE_reader(os.libc.FILE f, bool must_close) {
5252
auto buf = "";
5353
while (true) {
5454
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; }
5657
buf += _str.unsafe_from_bytes(vec(ch as u8));
5758
}
5859
ret buf;
@@ -61,7 +62,7 @@ state obj FILE_reader(os.libc.FILE f, bool must_close) {
6162
auto buf = "";
6263
while (true) {
6364
auto ch = os.libc.fgetc(f);
64-
if (ch < 1) {break;}
65+
if (ch < 1) { ret buf; }
6566
buf += _str.unsafe_from_bytes(vec(ch as u8));
6667
}
6768
ret buf;

src/lib/posix_fs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ impure fn list_dir(str path) -> vec[str] {
99
let vec[str] result = vec();
1010
while (true) {
1111
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+
}
1316
_vec.push[str](result, rustrt.rust_dirent_filename(ent));
1417
}
1518
os.libc.closedir(dir);

0 commit comments

Comments
 (0)