File tree Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Expand file tree Collapse file tree 3 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: fef8314c2e018d2e35c8bd91d3181de038e44de2
2
+ refs/heads/master: 4c7886de8008b07e892ea741be08291dae38f7bd
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import _vec.rustrt.vbuf;
5
5
native "rust" mod rustrt {
6
6
type sbuf ;
7
7
fn str_buf ( str s) -> sbuf ;
8
+ fn str_vec ( str s) -> vec[ u8 ] ;
8
9
fn str_byte_len ( str s) -> uint ;
9
10
fn str_alloc ( uint n_bytes ) -> str ;
10
11
fn str_from_vec ( vec[ mutable? u8 ] b ) -> str ;
@@ -126,10 +127,7 @@ fn buf(str s) -> sbuf {
126
127
}
127
128
128
129
fn bytes ( str s) -> vec[ u8 ] {
129
- fn ith ( str s, uint i) -> u8 {
130
- ret s. ( i) ;
131
- }
132
- ret _vec. init_fn [ u8] ( bind ith( s, _) , byte_len ( s) ) ;
130
+ ret rustrt. str_vec ( s) ;
133
131
}
134
132
135
133
fn from_bytes ( vec[ u8] v ) : is_utf8( v ) -> str {
Original file line number Diff line number Diff line change @@ -219,6 +219,32 @@ str_buf(rust_task *task, rust_str *s)
219
219
return (char const *)&s->data [0 ];
220
220
}
221
221
222
+ extern " C" CDECL rust_vec*
223
+ str_vec (rust_task *task, rust_str *s)
224
+ {
225
+ // FIXME: this should just upref s and return it, but we
226
+ // accidentally made too much of the language and runtime know
227
+ // and care about the difference between str and vec (trailing null);
228
+ // eliminate these differences and then rewrite this back to just
229
+ // the following:
230
+ //
231
+ // if (s->ref_count != CONST_REFCOUNT)
232
+ // s->ref();
233
+ // return s;
234
+
235
+ rust_str *v =
236
+ vec_alloc_with_data (task,
237
+ s->fill - 1 ,
238
+ s->fill - 1 ,
239
+ 1 ,
240
+ (s->fill - 1 ) ? (void *)s->data : NULL );
241
+ if (!v) {
242
+ task->fail (2 );
243
+ return NULL ;
244
+ }
245
+ return v;
246
+ }
247
+
222
248
extern " C" CDECL size_t
223
249
str_byte_len (rust_task *task, rust_str *s)
224
250
{
You can’t perform that action at this time.
0 commit comments