From: Ian Jackson Date: Sun, 10 May 2026 10:23:37 +0000 (+0100) Subject: LitLinesCrlf: expect input without the final empty line X-Git-Tag: debian/1.3.3~5^2~6 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=8f6606228fb0f222ec4efec1d2e8b5966fdcb315;p=hippotat.git LitLinesCrlf: expect input without the final empty line Before we got rid of the macro, this was handled by the way the `{}` were embedded in the format string. Then it was present in the source, stripped by LitLinesCrlf and then added back by lines_crlf. Now it is only handled by lines_crlf and everything is reasonably straightforward. Signed-off-by: Ian Jackson --- diff --git a/client/client.rs b/client/client.rs index e45d165..28d39bc 100644 --- a/client/client.rs +++ b/client/client.rs @@ -24,7 +24,7 @@ macro_rules! lines_crlf { { $($content:expr),* $(,)? } => { /// Displays as the lines of `s`, deindented, with CRLFs /// -/// TODO has anomalous handling of the last line. +/// Missing trailing newline turns into missing trailing `\r\n` pub struct LitLinesCrlf<'s>(pub &'s str); impl Display for LitLinesCrlf<'_> { @@ -42,7 +42,6 @@ impl Display for LitLinesCrlf<'_> { .flatten() .collect::(); - let output = output.strip_suffix("\r\n").expect("XXXX bad input"); write!(f, "{output}") } } @@ -112,7 +111,6 @@ fn submit_request<'r, 'c:'r>( r#"--b Content-Type: text/plain; charset="utf-8" Content-Disposition: form-data; name="m" - "#), &c.ic.link.client, token, @@ -128,13 +126,11 @@ fn submit_request<'r, 'c:'r>( --b Content-Type: application/octet-stream Content-Disposition: form-data; name="d" - "#), ); let suffix = lines_crlf!(&LitLinesCrlf( r#" - --b-- - "#), + --b--"#), ); macro_rules! content { {