diff options
| author | Elly Jones <elly@leptoquark.net> | 2012-01-20 11:12:03 -0500 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-01-21 13:12:02 -0800 |
| commit | 059e243b166d994ac8044a7e771d8d0b88b2ace7 (patch) | |
| tree | cd0b185e1307388e9501632bcbd8cc565d09305e /src | |
| parent | 2a59ab8fa54784688abb58c1306262290d415269 (diff) | |
[core] extfmt: support %% to escape a %
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/core.rs | 2 | ||||
| -rw-r--r-- | src/libcore/extfmt.rs | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/libcore/core.rs b/src/libcore/core.rs index 1e48890cfff..93fa3522fdb 100644 --- a/src/libcore/core.rs +++ b/src/libcore/core.rs @@ -32,4 +32,4 @@ mod core { mod std { use std; import std::test; -} \ No newline at end of file +} diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 61b6ec3c1b4..04600a628a0 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -101,6 +101,7 @@ mod ct { } let curr2 = str::substr(s, i, 1u); if str::eq(curr2, "%") { + buf += curr2; i += 1u; } else { buf = flush_buf(buf, pieces); @@ -451,6 +452,16 @@ mod rt { ret false; } } + +#[cfg(test)] +mod tests { + #[test] + fn test_percent() { + let s = #fmt["ab%%cd"]; + assert(s == "ab%cd"); + } +} + // Local Variables: // mode: rust; // fill-column: 78; |
