[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 1/4] line wrapping: Provide cr-fold-long-lines script



This is a reversible transformation which usually just introduces a \
where it splits lines.

We are going to use this to wrap the lines in our emails.  SMTP has a
999-byte length limit (including a CR-LF pair).  This can cause our
emails to go astray.  We don't really want our messages to be q-p or
base64-encoded if we can avoid it, and MTAs don't do that anyway (so
we would have to organise it).  So instead, we will simply wrap any
long lines that occur.

This transformation is not suitable for headers, but we don't intend
or want to generate long lines which would need further wrapping.  (A
reversible transformation suitable for headers would be quite ugly and
would only be right for a subset of headers anyway...)

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 cr-fold-long-lines | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100755 cr-fold-long-lines

diff --git a/cr-fold-long-lines b/cr-fold-long-lines
new file mode 100755
index 00000000..821c46a1
--- /dev/null
+++ b/cr-fold-long-lines
@@ -0,0 +1,22 @@
+#!/usr/bin/perl -wp
+#
+# long lines are broken by inserting \ plus spaces/tabs, somewhere
+# lines already ending with \ and maybe some $s have a $ postpended
+#   so they do not look broken
+#
+# unparsing:
+#      ooo\ | <SPC>bar     =>      ooobar   (<SPC> is >=0 tab/space)
+# then:
+#     ooo\$ | any          =>      ooo\ | any
+#    ooo\$$ | any          =>     ooo\$ | any
+#   ooo\$$$ | any          =>    ooo\$$ | any     etc.
+# others unchanged, specifically:
+#      ooo$ | any          =>      ooo$ | any
+#     ooo$$ | any          =>     ooo$$ | any
+#    ooo$$$ | any          =>    ooo$$$ | any     etc.
+# (where in these diagrams ` | ' means a newline)
+
+use strict;
+
+s{\\(\$*)\n}{\\$1\$\n}; # $-stuffing, now does not end in backslash
+s{.{500}}{$&\\\n }g; # insert \ \n SPC as needed
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.