code generation: only use scanf/printf on newline('\n') terminated strings
This commit is contained in:
parent
692a34c257
commit
7dd6352760
1 changed files with 6 additions and 6 deletions
|
@ -25,15 +25,15 @@ pub fn generate_lib(
|
|||
|
||||
if let Ok(_) = laddertypes::subtype_unify(
|
||||
&inst.ty.src_type,
|
||||
&dict.parse("<Seq~<ValueTerminated 0> Char~Ascii~native.UInt8>").expect("")
|
||||
&dict.parse("<Seq~<ValueTerminated '\\n'> Char~Ascii~native.UInt8>").expect("")
|
||||
) {
|
||||
c_source.push_str("scanf(\"%s\", bufIn);");
|
||||
c_source.push_str("scanf(\"%s\", bufIn);\n");
|
||||
} else {
|
||||
c_source.push_str("read(0, bufIn, sizeof(bufIn));");
|
||||
c_source.push_str("read(0, bufIn, sizeof(bufIn));\n");
|
||||
}
|
||||
|
||||
c_source.push_str(
|
||||
&format!(r#"FUSE( {}, (void const*)bufIn, (void*)bufOut );"#,
|
||||
&format!(r#"FUSE( {}, (void const*)bufIn, (void*)bufOut );\n"#,
|
||||
inst.instantiated_symbol_name(dict, &HashMap::new()))
|
||||
);
|
||||
|
||||
|
@ -41,9 +41,9 @@ pub fn generate_lib(
|
|||
&inst.ty.dst_type,
|
||||
&dict.parse("<Seq~<ValueTerminated 0> native.UInt8>").expect("")
|
||||
) {
|
||||
c_source.push_str("printf(\"%s\\n\", bufOut);");
|
||||
c_source.push_str("printf(\"%s\\n\", bufOut);\n");
|
||||
} else {
|
||||
c_source.push_str("write(1, bufOut, sizeof(bufOut));");
|
||||
c_source.push_str("write(1, bufOut, sizeof(bufOut));\n");
|
||||
}
|
||||
c_source.push_str("
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue