The ~m
directive for printf
displays expressions via the pretty printer. printf
always outputs a line termination, even when there is none in the control string. Just one extra line termination is printed for the whole control string, not one per ~m
directive.
(%i1) for i thru 5 do printf(true, "~a", i);
12345(%o1) done
(%i2) for i thru 5 do printf(true, "~m", i);
1
2
3
4
5
(%o2) done
(%i3) for i thru 5 do printf(true, "~m ~m ~m", i, i+1, i+2);
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
(%o3) done
To handle ~m
, printf
calls AFORMAT, which punts to MFORMAT. I looked around in src/mformt,lisp and src/mforma.lisp, and I don't see an obvious way to suppress the line termination.
Perhaps it's the
mterpri
call inoutput-linear-one-line
in "displa.lisp". I commented out the call and your "~m" example prints "12345". But if I tryprintf(true, "~M~%", i)
, no new line is printed either. I guess whatever handles "~%" really need to force a new line. I didn't look into that.