Skip to content

Commit 1c9a8b5

Browse files
committed
---
yaml --- r: 40310 b: refs/heads/dist-snap c: 9aadfc3 h: refs/heads/master v: v3
1 parent 9d33497 commit 1c9a8b5

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
99
refs/heads/incoming: e90142e536c150df0d9b4b2f11352152177509b5
10-
refs/heads/dist-snap: c8b4dea4e0261b1e8c079c1fcf3c61ea9cc15e6e
10+
refs/heads/dist-snap: 9aadfc3f4b5df00a7f8e9b362385118ae1dba73e
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1313
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/librusti/rusti.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -267,16 +267,18 @@ pub fn main() {
267267
stmts: ~""
268268
};
269269

270-
do rl::complete |line, suggest| {
271-
if line.starts_with(":") {
272-
suggest(~":clear");
273-
suggest(~":exit");
274-
suggest(~":help");
270+
unsafe {
271+
do rl::complete |line, suggest| {
272+
if line.starts_with(":") {
273+
suggest(~":clear");
274+
suggest(~":exit");
275+
suggest(~":help");
276+
}
275277
}
276278
}
277279

278280
while repl.running {
279-
let result = rl::read(repl.prompt);
281+
let result = unsafe { rl::read(repl.prompt) };
280282

281283
if result.is_none() {
282284
break;
@@ -290,7 +292,7 @@ pub fn main() {
290292
loop;
291293
}
292294

293-
rl::add_history(line);
295+
unsafe { rl::add_history(line) };
294296

295297
if line.starts_with(~":") {
296298
let full = line.substr(1, line.len() - 1);

branches/dist-snap/src/libstd/rl.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// FIXME #3921. This is unsafe because linenoise uses global mutable
2+
// state without mutexes.
3+
14
use libc::{c_char, c_int};
25

36
extern mod rustrt {
@@ -12,33 +15,33 @@ extern mod rustrt {
1215
}
1316

1417
/// Add a line to history
15-
pub fn add_history(line: ~str) -> bool {
18+
pub unsafe fn add_history(line: ~str) -> bool {
1619
do str::as_c_str(line) |buf| {
1720
rustrt::linenoiseHistoryAdd(buf) == 1 as c_int
1821
}
1922
}
2023

2124
/// Set the maximum amount of lines stored
22-
pub fn set_history_max_len(len: int) -> bool {
25+
pub unsafe fn set_history_max_len(len: int) -> bool {
2326
rustrt::linenoiseHistorySetMaxLen(len as c_int) == 1 as c_int
2427
}
2528

2629
/// Save line history to a file
27-
pub fn save_history(file: ~str) -> bool {
30+
pub unsafe fn save_history(file: ~str) -> bool {
2831
do str::as_c_str(file) |buf| {
2932
rustrt::linenoiseHistorySave(buf) == 1 as c_int
3033
}
3134
}
3235

3336
/// Load line history from a file
34-
pub fn load_history(file: ~str) -> bool {
37+
pub unsafe fn load_history(file: ~str) -> bool {
3538
do str::as_c_str(file) |buf| {
3639
rustrt::linenoiseHistoryLoad(buf) == 1 as c_int
3740
}
3841
}
3942

4043
/// Print out a prompt and then wait for input and return it
41-
pub fn read(prompt: ~str) -> Option<~str> {
44+
pub unsafe fn read(prompt: ~str) -> Option<~str> {
4245
do str::as_c_str(prompt) |buf| unsafe {
4346
let line = rustrt::linenoise(buf);
4447

@@ -52,7 +55,7 @@ pub type CompletionCb = fn~(~str, fn(~str));
5255
fn complete_key(_v: @CompletionCb) {}
5356

5457
/// Bind to the main completion callback
55-
pub fn complete(cb: CompletionCb) unsafe {
58+
pub unsafe fn complete(cb: CompletionCb) unsafe {
5659
task::local_data::local_data_set(complete_key, @(move cb));
5760

5861
extern fn callback(line: *c_char, completions: *()) unsafe {

0 commit comments

Comments
 (0)