Merge pull request #239 from rust-lang/fix/expandloadu
Escape { and } in inline asm
This commit is contained in:
commit
3c03c8f048
22
src/asm.rs
22
src/asm.rs
@ -381,15 +381,19 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
|||||||
for piece in template {
|
for piece in template {
|
||||||
match *piece {
|
match *piece {
|
||||||
InlineAsmTemplatePiece::String(ref string) => {
|
InlineAsmTemplatePiece::String(ref string) => {
|
||||||
// TODO(@Commeownist): switch to `Iterator::intersperse` once it's stable
|
for char in string.chars() {
|
||||||
let mut iter = string.split('%');
|
// TODO(antoyo): might also need to escape | if rustc doesn't do it.
|
||||||
if let Some(s) = iter.next() {
|
let escaped_char =
|
||||||
template_str.push_str(s);
|
match char {
|
||||||
}
|
'%' => "%%",
|
||||||
|
'{' => "%{",
|
||||||
for s in iter {
|
'}' => "%}",
|
||||||
template_str.push_str("%%");
|
_ => {
|
||||||
template_str.push_str(s);
|
template_str.push(char);
|
||||||
|
continue;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
template_str.push_str(escaped_char);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InlineAsmTemplatePiece::Placeholder { operand_idx, modifier, span: _ } => {
|
InlineAsmTemplatePiece::Placeholder { operand_idx, modifier, span: _ } => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user