Skip to content

Commit 72ae426

Browse files
committed
Call 'new' instead of 'old' extfmt code, preparing for snapshot
1 parent 9b4db17 commit 72ae426

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/libcore/extfmt.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ mod ct {
270270
}
271271
}
272272
273-
// OLD CODE -- eventually remove
273+
// Functions used by the fmt extension at runtime. For now there are a lot of
274+
// decisions made a runtime. If it proves worthwhile then some of these
275+
// conditions can be evaluated at compile-time. For now though it's cleaner to
276+
// implement it 0this way, I think.
274277
mod rt {
275278
#[legacy_exports];
276279
const flag_none : u32 = 0u32;
@@ -286,7 +289,7 @@ mod rt {
286289
type Conv = {flags: u32, width: Count, precision: Count, ty: Ty};
287290
288291
pure fn conv_int(cv: Conv, i: int) -> ~str {
289-
let radix = 10u;
292+
let radix = 10;
290293
let prec = get_int_precision(cv);
291294
let mut s : ~str = int_to_str_prec(i, radix, prec);
292295
if 0 <= i {
@@ -320,13 +323,13 @@ mod rt {
320323
let mut s = str::from_char(c);
321324
return unsafe { pad(cv, s, PadNozero) };
322325
}
323-
pure fn conv_str(cv: Conv, s: &str) -> ~str {
326+
pure fn conv_str(cv: Conv, +s: &str) -> ~str {
324327
// For strings, precision is the maximum characters
325328
// displayed
326329
let mut unpadded = match cv.precision {
327330
CountImplied => s.to_unique(),
328331
CountIs(max) => if max as uint < str::char_len(s) {
329-
str::substr(s, 0, max as uint)
332+
str::substr(s, 0u, max as uint)
330333
} else {
331334
s.to_unique()
332335
}
@@ -336,7 +339,7 @@ mod rt {
336339
pure fn conv_float(cv: Conv, f: float) -> ~str {
337340
let (to_str, digits) = match cv.precision {
338341
CountIs(c) => (float::to_str_exact, c as uint),
339-
CountImplied => (float::to_str, 6)
342+
CountImplied => (float::to_str, 6u)
340343
};
341344
let mut s = unsafe { to_str(f, digits) };
342345
if 0.0 <= f {
@@ -348,8 +351,8 @@ mod rt {
348351
}
349352
return unsafe { pad(cv, s, PadFloat) };
350353
}
351-
pure fn conv_poly<T>(cv: Conv, v: T) -> ~str {
352-
let s = sys::log_str(&v);
354+
pure fn conv_poly<T>(cv: Conv, v: &T) -> ~str {
355+
let s = sys::log_str(v);
353356
return conv_str(cv, s);
354357
}
355358
@@ -460,7 +463,7 @@ mod rt {
460463
}
461464
}
462465

463-
// NEW CODE
466+
// Remove after snapshot
464467

465468
// Functions used by the fmt extension at runtime. For now there are a lot of
466469
// decisions made a runtime. If it proves worthwhile then some of these

src/libsyntax/ext/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span,
3939
-> @ast::expr {
4040
fn make_path_vec(_cx: ext_ctxt, ident: @~str) -> ~[ast::ident] {
4141
let intr = _cx.parse_sess().interner;
42-
return ~[intr.intern(@~"extfmt"), intr.intern(@~"rt2"),
42+
return ~[intr.intern(@~"extfmt"), intr.intern(@~"rt"),
4343
intr.intern(ident)];
4444
}
4545
fn make_rt_path_expr(cx: ext_ctxt, sp: span, nm: @~str) -> @ast::expr {

0 commit comments

Comments
 (0)