Skip to content

Commit 059e243

Browse files
Elly Jonesbrson
authored andcommitted
[core] extfmt: support %% to escape a %
1 parent 2a59ab8 commit 059e243

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/libcore/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ mod core {
3232
mod std {
3333
use std;
3434
import std::test;
35-
}
35+
}

src/libcore/extfmt.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ mod ct {
101101
}
102102
let curr2 = str::substr(s, i, 1u);
103103
if str::eq(curr2, "%") {
104+
buf += curr2;
104105
i += 1u;
105106
} else {
106107
buf = flush_buf(buf, pieces);
@@ -451,6 +452,16 @@ mod rt {
451452
ret false;
452453
}
453454
}
455+
456+
#[cfg(test)]
457+
mod tests {
458+
#[test]
459+
fn test_percent() {
460+
let s = #fmt["ab%%cd"];
461+
assert(s == "ab%cd");
462+
}
463+
}
464+
454465
// Local Variables:
455466
// mode: rust;
456467
// fill-column: 78;

0 commit comments

Comments
 (0)