summaryrefslogtreecommitdiffstats
path: root/debian/patches/progress-linux/0002-split-long-lines.patch
blob: 91fe23d063552552d179f933b8c0ca976e57d863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Author: Eric S. Raymond <esr@thyrsus.com>
Description: Automatically split long lines in irk.

diff -Naurp irker.orig/irk irker/irk
--- irker.orig/irk
+++ irker/irk
@@ -39,10 +39,15 @@ def irk(target, message, server = DEFAUL
 def main():
     target = sys.argv[1]
     message = " ".join(sys.argv[2:])
-    message = message.decode('string_escape')
+    if str == bytes:
+        message = message.decode('string_escape')
 
+    # The actual IRC limit is 512. Avoid any off-by-ones
+    chunksize = 511
     try:
-        irk(target, message)
+        while message[:chunksize]:
+            irk(target, message[:chunksize])
+            message = message[chunksize:]
     except socket.error as e:
         sys.stderr.write("irk: write to server failed: %r\n" % e)
         sys.exit(1)