Skip to content

Commit bd4bfcc

Browse files
committed
---
yaml --- r: 145139 b: refs/heads/try2 c: 76c3e8a h: refs/heads/master i: 145137: 674cd95 145135: 43b8782 v: v3
1 parent 11fd197 commit bd4bfcc

File tree

13 files changed

+413
-97
lines changed

13 files changed

+413
-97
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: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 507a7f093d51829ccde225542bda2a805be32ba2
8+
refs/heads/try2: 76c3e8a38cea2fe6342d83158c267e57a6b1f53f
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/rt.mk

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ else ifeq ($(OSTYPE_$(1)), apple-darwin)
102102
LIBUV_LIB_$(1)_$(2) := $$(RT_BUILD_DIR_$(1)_$(2))/libuv/libuv.a
103103
JEMALLOC_LIB_$(1)_$(2) := $$(RT_BUILD_DIR_$(1)_$(2))/jemalloc/lib/libjemalloc_pic.a
104104
else ifeq ($(OSTYPE_$(1)), unknown-freebsd)
105-
LIBUV_OSTYPE_$(1)_$(2) := freebsd
105+
LIBUV_OSTYPE_$(1)_$(2) := unix/freebsd
106106
LIBUV_LIB_$(1)_$(2) := $$(RT_BUILD_DIR_$(1)_$(2))/libuv/libuv.a
107107
JEMALLOC_LIB_$(1)_$(2) := $$(RT_BUILD_DIR_$(1)_$(2))/jemalloc/lib/libjemalloc_pic.a
108108
else ifeq ($(OSTYPE_$(1)), linux-androideabi)
109-
LIBUV_OSTYPE_$(1)_$(2) := android
109+
LIBUV_OSTYPE_$(1)_$(2) := unix/android
110110
LIBUV_LIB_$(1)_$(2) := $$(RT_BUILD_DIR_$(1)_$(2))/libuv/libuv.a
111111
JEMALLOC_LIB_$(1)_$(2) := $$(RT_BUILD_DIR_$(1)_$(2))/jemalloc/lib/libjemalloc_pic.a
112112
else
113-
LIBUV_OSTYPE_$(1)_$(2) := linux
113+
LIBUV_OSTYPE_$(1)_$(2) := unix/linux
114114
LIBUV_LIB_$(1)_$(2) := $$(RT_BUILD_DIR_$(1)_$(2))/libuv/libuv.a
115115
JEMALLOC_LIB_$(1)_$(2) := $$(RT_BUILD_DIR_$(1)_$(2))/jemalloc/lib/libjemalloc_pic.a
116116
endif
@@ -178,7 +178,6 @@ export PYTHONPATH := $(PYTHONPATH):$$(S)src/gyp/pylib
178178
$$(LIBUV_MAKEFILE_$(1)_$(2)): $$(LIBUV_DEPS)
179179
(cd $(S)src/libuv/ && \
180180
$$(CFG_PYTHON) ./gyp_uv -f make -Dtarget_arch=$$(LIBUV_ARCH_$(1)) -D ninja \
181-
-DOS=$$(LIBUV_OSTYPE_$(1)_$(2)) \
182181
-Goutput_dir=$$(@D) --generator-output $$(@D))
183182

184183
# XXX: Shouldn't need platform-specific conditions here

branches/try2/src/libstd/c_str.rs

Lines changed: 3 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use ops::Drop;
1515
use option::{Option, Some, None};
1616
use ptr::RawPtr;
1717
use ptr;
18-
use str;
1918
use str::StrSlice;
2019
use vec::{ImmutableVector, CopyableVector};
2120
use container::Container;
@@ -98,25 +97,15 @@ impl CString {
9897
/// # Failure
9998
///
10099
/// Fails if the CString is null.
101-
#[inline]
102100
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
101+
#[fixed_stack_segment]; #[inline(never)];
103102
if self.buf.is_null() { fail!("CString is null!"); }
104103
unsafe {
105-
let len = ptr::position(self.buf, |c| *c == 0);
104+
let len = libc::strlen(self.buf) as uint;
106105
cast::transmute((self.buf, len + 1))
107106
}
108107
}
109108

110-
/// Converts the CString into a `&str` without copying.
111-
/// Returns None if the CString is not UTF-8 or is null.
112-
#[inline]
113-
pub fn as_str<'a>(&'a self) -> Option<&'a str> {
114-
if self.buf.is_null() { return None; }
115-
let buf = self.as_bytes();
116-
let buf = buf.slice_to(buf.len()-1); // chop off the trailing NUL
117-
str::from_utf8_slice_opt(buf)
118-
}
119-
120109
/// Return a CString iterator.
121110
pub fn iter<'a>(&'a self) -> CStringIterator<'a> {
122111
CStringIterator {
@@ -249,7 +238,7 @@ mod tests {
249238
use option::{Some, None};
250239

251240
#[test]
252-
fn test_str_to_c_str() {
241+
fn test_to_c_str() {
253242
do "".to_c_str().with_ref |buf| {
254243
unsafe {
255244
assert_eq!(*ptr::offset(buf, 0), 0);
@@ -268,37 +257,6 @@ mod tests {
268257
}
269258
}
270259

271-
#[test]
272-
fn test_vec_to_c_str() {
273-
let b: &[u8] = [];
274-
do b.to_c_str().with_ref |buf| {
275-
unsafe {
276-
assert_eq!(*ptr::offset(buf, 0), 0);
277-
}
278-
}
279-
280-
do bytes!("hello").to_c_str().with_ref |buf| {
281-
unsafe {
282-
assert_eq!(*ptr::offset(buf, 0), 'h' as libc::c_char);
283-
assert_eq!(*ptr::offset(buf, 1), 'e' as libc::c_char);
284-
assert_eq!(*ptr::offset(buf, 2), 'l' as libc::c_char);
285-
assert_eq!(*ptr::offset(buf, 3), 'l' as libc::c_char);
286-
assert_eq!(*ptr::offset(buf, 4), 'o' as libc::c_char);
287-
assert_eq!(*ptr::offset(buf, 5), 0);
288-
}
289-
}
290-
291-
do bytes!("foo", 0xff).to_c_str().with_ref |buf| {
292-
unsafe {
293-
assert_eq!(*ptr::offset(buf, 0), 'f' as libc::c_char);
294-
assert_eq!(*ptr::offset(buf, 1), 'o' as libc::c_char);
295-
assert_eq!(*ptr::offset(buf, 2), 'o' as libc::c_char);
296-
assert_eq!(*ptr::offset(buf, 3), 0xff);
297-
assert_eq!(*ptr::offset(buf, 4), 0);
298-
}
299-
}
300-
}
301-
302260
#[test]
303261
fn test_is_null() {
304262
let c_str = unsafe { CString::new(ptr::null(), false) };
@@ -391,33 +349,4 @@ mod tests {
391349
}
392350
}
393351
}
394-
395-
#[test]
396-
fn test_as_bytes() {
397-
let c_str = "hello".to_c_str();
398-
assert_eq!(c_str.as_bytes(), bytes!("hello", 0));
399-
let c_str = "".to_c_str();
400-
assert_eq!(c_str.as_bytes(), bytes!(0));
401-
let c_str = bytes!("foo", 0xff).to_c_str();
402-
assert_eq!(c_str.as_bytes(), bytes!("foo", 0xff, 0));
403-
}
404-
405-
#[test]
406-
#[should_fail]
407-
fn test_as_bytes_fail() {
408-
let c_str = unsafe { CString::new(ptr::null(), false) };
409-
c_str.as_bytes();
410-
}
411-
412-
#[test]
413-
fn test_as_str() {
414-
let c_str = "hello".to_c_str();
415-
assert_eq!(c_str.as_str(), Some("hello"));
416-
let c_str = "".to_c_str();
417-
assert_eq!(c_str.as_str(), Some(""));
418-
let c_str = bytes!("foo", 0xff).to_c_str();
419-
assert_eq!(c_str.as_str(), None);
420-
let c_str = unsafe { CString::new(ptr::null(), false) };
421-
assert_eq!(c_str.as_str(), None);
422-
}
423352
}

branches/try2/src/libstd/logging.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
use option::*;
1414
use os;
1515
use rt;
16-
use rt::logging::{Logger, StdErrLogger, OwnedString};
16+
use rt::logging::{Logger, StdErrLogger};
17+
use send_str::SendStrOwned;
1718

1819
/// Turns on logging to stdout globally
1920
pub fn console_on() {
@@ -56,12 +57,12 @@ fn newsched_log_str(msg: ~str) {
5657
match optional_task {
5758
Some(local) => {
5859
// Use the available logger
59-
(*local).logger.log(OwnedString(msg));
60+
(*local).logger.log(SendStrOwned(msg));
6061
}
6162
None => {
6263
// There is no logger anywhere, just write to stderr
6364
let mut logger = StdErrLogger;
64-
logger.log(OwnedString(msg));
65+
logger.log(SendStrOwned(msg));
6566
}
6667
}
6768
}

branches/try2/src/libstd/prelude.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub use path::PosixPath;
6666
pub use path::WindowsPath;
6767
pub use ptr::RawPtr;
6868
pub use ascii::{Ascii, AsciiCast, OwnedAsciiCast, AsciiStr, ToBytesConsume};
69+
pub use send_str::{SendStr, SendStrOwned, SendStrStatic, IntoSendStr};
6970
pub use str::{Str, StrVector, StrSlice, OwnedStr};
7071
pub use from_str::FromStr;
7172
pub use to_bytes::IterBytes;

branches/try2/src/libstd/rt/logging.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use str::raw::from_c_str;
1717
use u32;
1818
use vec::ImmutableVector;
1919
use cast::transmute;
20+
use send_str::{SendStr, SendStrOwned, SendStrStatic};
2021

2122
struct LogDirective {
2223
name: Option<~str>,
@@ -168,32 +169,26 @@ fn update_log_settings(crate_map: *u8, settings: ~str) {
168169
}
169170
}
170171

171-
/// Represent a string with `Send` bound.
172-
pub enum SendableString {
173-
OwnedString(~str),
174-
StaticString(&'static str)
175-
}
176-
177172
pub trait Logger {
178-
fn log(&mut self, msg: SendableString);
173+
fn log(&mut self, msg: SendStr);
179174
}
180175

181176
pub struct StdErrLogger;
182177

183178
impl Logger for StdErrLogger {
184-
fn log(&mut self, msg: SendableString) {
179+
fn log(&mut self, msg: SendStr) {
185180
use io::{Writer, WriterUtil};
186181

187182
if !should_log_console() {
188183
return;
189184
}
190185

191186
let s: &str = match msg {
192-
OwnedString(ref s) => {
187+
SendStrOwned(ref s) => {
193188
let slc: &str = *s;
194189
slc
195190
},
196-
StaticString(s) => s,
191+
SendStrStatic(s) => s,
197192
};
198193

199194
// Truncate the string

0 commit comments

Comments
 (0)