diff options
| author | Graydon Hoare <[email protected]> | 2011-03-16 16:45:41 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2011-03-16 16:47:27 -0700 |
| commit | 6a6a30b7924d2a12a73cf3243a736c0efe26c6b4 (patch) | |
| tree | afcebfd983fa7b0cdd5ac7b5d20840074305e429 /src | |
| parent | Add a "rustllvm.def" file for Windows' linker to use. This allows us to creat... (diff) | |
| download | rust-6a6a30b7924d2a12a73cf3243a736c0efe26c6b4.tar.xz rust-6a6a30b7924d2a12a73cf3243a736c0efe26c6b4.zip | |
Remove uses of 'break' in std lib; rustc doesn't support it yet, this is easier for now.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/io.rs | 5 | ||||
| -rw-r--r-- | src/lib/posix_fs.rs | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/lib/io.rs b/src/lib/io.rs index 7135c2bc..a84fbbe9 100644 --- a/src/lib/io.rs +++ b/src/lib/io.rs @@ -52,7 +52,8 @@ state obj FILE_reader(os.libc.FILE f, bool must_close) { auto buf = ""; while (true) { auto ch = os.libc.fgetc(f); - if (ch == -1) {break;} if (ch == 10) {break;} + if (ch == -1) { ret buf; } + if (ch == 10) { ret buf; } buf += _str.unsafe_from_bytes(vec(ch as u8)); } ret buf; @@ -61,7 +62,7 @@ state obj FILE_reader(os.libc.FILE f, bool must_close) { auto buf = ""; while (true) { auto ch = os.libc.fgetc(f); - if (ch < 1) {break;} + if (ch < 1) { ret buf; } buf += _str.unsafe_from_bytes(vec(ch as u8)); } ret buf; diff --git a/src/lib/posix_fs.rs b/src/lib/posix_fs.rs index 676d4150..0a37f85d 100644 --- a/src/lib/posix_fs.rs +++ b/src/lib/posix_fs.rs @@ -9,7 +9,10 @@ impure fn list_dir(str path) -> vec[str] { let vec[str] result = vec(); while (true) { auto ent = os.libc.readdir(dir); - if (ent as int == 0) {break;} + if (ent as int == 0) { + os.libc.closedir(dir); + ret result; + } _vec.push[str](result, rustrt.rust_dirent_filename(ent)); } os.libc.closedir(dir); |