Skip to content

Commit 59990ec

Browse files
committed
---
yaml --- r: 36215 b: refs/heads/try2 c: 9aadfc3 h: refs/heads/master i: 36213: 1573e46 36211: a89684b 36207: 4c210f9 v: v3
1 parent 5fbeea1 commit 59990ec

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
55
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: c8b4dea4e0261b1e8c079c1fcf3c61ea9cc15e6e
8+
refs/heads/try2: 9aadfc3f4b5df00a7f8e9b362385118ae1dba73e
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
1010
refs/heads/dist-snap: 22efa39382d41b084fde1719df7ae8ce5697d8c9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try2/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/try2/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)