File tree Expand file tree Collapse file tree 10 files changed +16
-11
lines changed Expand file tree Collapse file tree 10 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -440,6 +440,7 @@ mod rt {
440
440
let head = s[ 0 ] ;
441
441
if head == '+' as u8 || head == '-' as u8 || head == ' ' as u8 {
442
442
let headstr = str:: unsafe_from_bytes ( [ head] ) ;
443
+ // FIXME: not UTF-8 safe
443
444
let bytelen = str:: byte_len ( s) ;
444
445
let numpart = str:: substr ( s, 1 u, bytelen - 1 u) ;
445
446
ret headstr + padstr + numpart;
Original file line number Diff line number Diff line change @@ -129,7 +129,8 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
129
129
/// followed by a path separator
130
130
fn get_exe_path ( ) -> option:: t < fs:: path > unsafe {
131
131
let bufsize = 1023 u;
132
- let path = str:: unsafe_from_bytes ( vec:: init_elt ( bufsize, 0u8 ) ) ;
132
+ // FIXME: path "strings" will likely need fixing...
133
+ let path = str:: from_bytes ( vec:: init_elt ( bufsize, 0u8 ) ) ;
133
134
let mib = [ libc_constants:: CTL_KERN ,
134
135
libc_constants:: KERN_PROC ,
135
136
libc_constants:: KERN_PROC_PATHNAME , -1i32 ] ;
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ fn getenv(n: str) -> option::t<str> {
75
75
unsafe {
76
76
vec:: unsafe:: set_len ( v, res) ;
77
77
}
78
- ret option:: some ( str:: unsafe_from_bytes ( v) ) ;
78
+ ret option:: some ( str:: from_bytes ( v) ) ; // UTF-8 or fail
79
79
} else { nsize = res; }
80
80
}
81
81
fail;
Original file line number Diff line number Diff line change @@ -125,7 +125,8 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; }
125
125
/// followed by a path separator
126
126
fn get_exe_path ( ) -> option:: t < fs:: path > {
127
127
let bufsize = 1023 u;
128
- let path = str:: unsafe_from_bytes ( vec:: init_elt ( bufsize, 0u8 ) ) ;
128
+ // FIXME: path "strings" will likely need fixing...
129
+ let path = str:: from_bytes ( vec:: init_elt ( bufsize, 0u8 ) ) ;
129
130
ret str:: as_buf ( "/proc/self/exe" , { |proc_self_buf|
130
131
str:: as_buf ( path, { |path_buf|
131
132
if libc:: readlink ( proc_self_buf, path_buf, bufsize) != -1 {
Original file line number Diff line number Diff line change @@ -133,8 +133,9 @@ fn dylib_filename(base: str) -> str { ret "lib" + base + ".dylib"; }
133
133
134
134
fn get_exe_path ( ) -> option:: t < fs:: path > {
135
135
// FIXME: This doesn't handle the case where the buffer is too small
136
+ // FIXME: path "strings" will likely need fixing...
136
137
let bufsize = 1023u32 ;
137
- let path = str:: unsafe_from_bytes ( vec:: init_elt ( bufsize as uint , 0u8 ) ) ;
138
+ let path = str:: from_bytes ( vec:: init_elt ( bufsize as uint , 0u8 ) ) ;
138
139
ret str:: as_buf ( path, { |path_buf|
139
140
if mac_libc:: _NSGetExecutablePath ( path_buf,
140
141
ptr:: mut_addr_of ( bufsize) ) == 0i32 {
Original file line number Diff line number Diff line change @@ -216,7 +216,7 @@ fn read_all(rd: io::reader) -> str {
216
216
let buf = "" ;
217
217
while !rd. eof ( ) {
218
218
let bytes = rd. read_bytes ( 4096 u) ;
219
- buf += str:: unsafe_from_bytes ( bytes) ;
219
+ buf += str:: from_bytes ( bytes) ;
220
220
}
221
221
ret buf;
222
222
}
@@ -347,7 +347,7 @@ mod tests {
347
347
let buf = "" ;
348
348
while !reader. eof ( ) {
349
349
let bytes = reader. read_bytes ( 4096 u) ;
350
- buf += str:: unsafe_from_bytes ( bytes) ;
350
+ buf += str:: from_bytes ( bytes) ;
351
351
}
352
352
os:: fclose ( file) ;
353
353
ret buf;
Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ fn test_http() {
131
131
unsafe {
132
132
log ( error, len) ;
133
133
let buf = vec:: unsafe:: from_buf ( buf, len as uint ) ;
134
- let str = str:: unsafe_from_bytes ( buf) ;
134
+ let str = str:: from_bytes ( buf) ;
135
135
#error ( "read something" ) ;
136
136
io:: println ( str) ;
137
137
}
@@ -146,4 +146,4 @@ fn test_http() {
146
146
}
147
147
join_thread ( thread) ;
148
148
delete_thread ( thread) ;
149
- }
149
+ }
Original file line number Diff line number Diff line change @@ -113,8 +113,9 @@ fn getcwd() -> str { ret rustrt::rust_getcwd(); }
113
113
114
114
fn get_exe_path ( ) -> option:: t < fs:: path > {
115
115
// FIXME: This doesn't handle the case where the buffer is too small
116
+ // FIXME: path "strings" will likely need fixing...
116
117
let bufsize = 1023 u;
117
- let path = str:: unsafe_from_bytes ( vec:: init_elt ( bufsize, 0u8 ) ) ;
118
+ let path = str:: from_bytes ( vec:: init_elt ( bufsize, 0u8 ) ) ;
118
119
ret str:: as_buf ( path, { |path_buf|
119
120
if kernel32:: GetModuleFileNameA ( 0 u, path_buf,
120
121
bufsize as u32 ) != 0u32 {
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ import comm::recv;
32
32
import comm:: send;
33
33
34
34
fn map ( & & filename: [ u8 ] , emit : map_reduce:: putter < [ u8 ] , int > ) {
35
- let f = io:: file_reader ( str:: unsafe_from_bytes ( filename) ) ;
35
+ let f = io:: file_reader ( str:: from_bytes ( filename) ) ;
36
36
37
37
while true {
38
38
alt read_word ( f) {
Original file line number Diff line number Diff line change @@ -81,7 +81,7 @@ mod map_reduce {
81
81
mapper_done { num_mappers -= 1 ; }
82
82
find_reducer ( k, cc) {
83
83
let c;
84
- alt reducers. find ( str:: unsafe_from_bytes ( k) ) {
84
+ alt reducers. find ( str:: from_bytes ( k) ) {
85
85
some ( _c) { c = _c; }
86
86
none { c = 0 ; }
87
87
}
You can’t perform that action at this time.
0 commit comments