Revert "Eliminate a copy in syntax::parse::new_parser_from_file"
This reverts commit 2bb3b63ec4.
(I was confused.)
This commit is contained in:
@@ -49,7 +49,7 @@ mod std {
|
||||
|
||||
#[doc = "
|
||||
A standard function to use to indicate unreachable code. Because the
|
||||
function is guaranteed to fail, typestate will correctly identify
|
||||
function is guaranteed to fail typestate will correctly identify
|
||||
any code paths following the appearance of this function as unreachable.
|
||||
"]
|
||||
fn unreachable() -> ! {
|
||||
|
||||
@@ -650,24 +650,6 @@ fn read_whole_file_str(file: str) -> result<str, str> {
|
||||
})
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the result as a unique boxed string rather than a string
|
||||
*/
|
||||
fn read_whole_file_ref(file: str) -> result<~str, str> {
|
||||
let f = os::as_c_charp(file, {|pathbuf|
|
||||
os::as_c_charp("r", {|modebuf|
|
||||
libc::fopen(pathbuf, modebuf)
|
||||
})
|
||||
});
|
||||
ret if f as uint == 0u { result::err("error opening " + file) }
|
||||
else unsafe {
|
||||
let buf : ~mut [const u8] = ~mut [const];
|
||||
let self = FILE_reader(f, true);
|
||||
while (!self.eof()) { *buf += self.read_bytes(2048u); }
|
||||
result::ok(str::unsafe::from_bytes_move(buf))
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME implement this in a low-level way. Going through the abstractions is
|
||||
// pointless. // #2004
|
||||
fn read_whole_file(file: str) -> result<[u8], str> {
|
||||
|
||||
@@ -123,19 +123,6 @@ fn from_bytes(vv: [u8]) -> str unsafe {
|
||||
ret unsafe::from_bytes(vv);
|
||||
}
|
||||
|
||||
#[doc = "
|
||||
Convert a unique vector of bytes (passed by move)
|
||||
to a unique boxed UTF-8 string
|
||||
|
||||
# Failure
|
||||
|
||||
Fails if invalid UTF-8
|
||||
"]
|
||||
fn from_bytes_move(-vv: ~mut [const u8]) -> ~str unsafe {
|
||||
assert is_utf8(::unsafe::reinterpret_cast(vv));
|
||||
ret unsafe::from_bytes_move(vv);
|
||||
}
|
||||
|
||||
#[doc = "
|
||||
Convert a byte to a UTF-8 string
|
||||
|
||||
@@ -1644,7 +1631,6 @@ mod unsafe {
|
||||
from_buf,
|
||||
from_c_str,
|
||||
from_bytes,
|
||||
from_bytes_move,
|
||||
slice_bytes,
|
||||
push_byte,
|
||||
pop_byte,
|
||||
@@ -1699,13 +1685,6 @@ mod unsafe {
|
||||
ret scopy;
|
||||
}
|
||||
|
||||
unsafe fn from_bytes_move(-v: ~mut [const u8]) -> ~str unsafe {
|
||||
*v += [0u8];
|
||||
let s: ~str = ::unsafe::reinterpret_cast(v);
|
||||
::unsafe::forget(v);
|
||||
s
|
||||
}
|
||||
|
||||
#[doc = "
|
||||
Converts a byte to a string.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user