[core] extfmt: support %% to escape a %

This commit is contained in:
Elly Jones 2012-01-20 11:12:03 -05:00 committed by Brian Anderson
parent 2a59ab8fa5
commit 059e243b16
2 changed files with 12 additions and 1 deletions

View File

@ -32,4 +32,4 @@ mod core {
mod std {
use std;
import std::test;
}
}

View File

@ -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;