Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7dda8890
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7dda8890
编写于
10月 18, 2012
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3803 from tychosci/readclose
Make some string operations UTF-8 safe
上级
55f043d2
6ce4cf76
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
18 deletion
+24
-18
src/libcore/run.rs
src/libcore/run.rs
+16
-12
src/rustdoc/markdown_writer.rs
src/rustdoc/markdown_writer.rs
+8
-6
未找到文件。
src/libcore/run.rs
浏览文件 @
7dda8890
...
...
@@ -248,12 +248,14 @@ fn finish() -> int { finish_repr(&self.r) }
}
fn
read_all
(
rd
:
io
::
Reader
)
->
~
str
{
let
mut
buf
=
~
""
;
while
!
rd
.eof
()
{
let
bytes
=
rd
.read_bytes
(
4096u
);
buf
+=
str
::
from_bytes
(
bytes
);
}
move
buf
let
buf
=
io
::
with_bytes_writer
(|
wr
|
{
let
mut
bytes
=
[
mut
0
,
..
4096
];
while
!
rd
.eof
()
{
let
nread
=
rd
.read
(
bytes
,
bytes
.len
());
wr
.write
(
bytes
.view
(
0
,
nread
));
}
});
str
::
from_bytes
(
buf
)
}
/**
...
...
@@ -341,13 +343,15 @@ fn writeclose(fd: c_int, s: ~str) {
fn
readclose
(
fd
:
c_int
)
->
~
str
{
let
file
=
os
::
fdopen
(
fd
);
let
reader
=
io
::
FILE_reader
(
file
,
false
);
let
mut
buf
=
~
""
;
while
!
reader
.eof
()
{
let
bytes
=
reader
.read_bytes
(
4096u
);
buf
+=
str
::
from_bytes
(
bytes
);
}
let
buf
=
io
::
with_bytes_writer
(|
writer
|
{
let
mut
bytes
=
[
mut
0
,
..
4096
];
while
!
reader
.eof
()
{
let
nread
=
reader
.read
(
bytes
,
bytes
.len
());
writer
.write
(
bytes
.view
(
0
,
nread
));
}
});
os
::
fclose
(
file
);
move
buf
str
::
from_bytes
(
buf
)
}
/// Waits for a process to exit and returns the exit code
...
...
src/rustdoc/markdown_writer.rs
浏览文件 @
7dda8890
...
...
@@ -136,13 +136,15 @@ fn readclose(fd: libc::c_int) -> ~str {
// Copied from run::program_output
let
file
=
os
::
fdopen
(
fd
);
let
reader
=
io
::
FILE_reader
(
file
,
false
);
let
mut
buf
=
~
""
;
while
!
reader
.eof
()
{
let
bytes
=
reader
.read_bytes
(
4096u
);
buf
+=
str
::
from_bytes
(
bytes
);
}
let
buf
=
io
::
with_bytes_writer
(|
writer
|
{
let
mut
bytes
=
[
mut
0
,
..
4096
];
while
!
reader
.eof
()
{
let
nread
=
reader
.read
(
bytes
,
bytes
.len
());
writer
.write
(
bytes
.view
(
0
,
nread
));
}
});
os
::
fclose
(
file
);
return
buf
;
str
::
from_bytes
(
buf
)
}
fn
generic_writer
(
+
process
:
fn
~
(
markdown
:
~
str
))
->
Writer
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录