exoni/packages/x11-wm/stumpwm/files/stumpwm-printing.patch

78 lines
2.9 KiB
Diff
Raw Normal View History

2013-05-16 19:58:00 +02:00
Source: Elias Pipping <pipping@exherbo.org>
Upstream: no (pasted on irc)
Reason: A window whose title contains the string ^\ cannot have it printed
From 56b478ae447ca8bf4b0d6d80e10fe00fb1c8d95b Mon Sep 17 00:00:00 2001
From: Elias Pipping <pipping@exherbo.org>
Date: Sat, 5 Jan 2013 22:03:53 +0100
Subject: [PATCH 1/2] Typo
---
primitives.lisp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/primitives.lisp b/primitives.lisp
index 50d062e..3d42012 100644
--- a/primitives.lisp
+++ b/primitives.lisp
@@ -753,7 +753,7 @@ do:
(format t "%~a~@[~a~]" len from-left-p)
(let* ((fmt (cadr (assoc (car cur) fmt-alist :test 'char=)))
(str (cond (fmt
- ;; it can return any type, not jut as string.
+ ;; it can return any type, not just a string.
(format nil "~a" (apply fmt args)))
((char= (car cur) #\%)
(string #\%))
--
1.8.0.3
From db588e4393567b3016c2be57511d35d3c01e4e46 Mon Sep 17 00:00:00 2001
From: Elias Pipping <pipping@exherbo.org>
Date: Sat, 5 Jan 2013 22:08:11 +0100
Subject: [PATCH 2/2] Escape window information before printing
Otherwise, a window with a title like ^\ will wreak havoc when
echo-string-list fails to parse it.
---
primitives.lisp | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/primitives.lisp b/primitives.lisp
index 3d42012..88b45d4 100644
--- a/primitives.lisp
+++ b/primitives.lisp
@@ -732,6 +732,15 @@ do:
;;;
;;; formatting routines
+(defun escape-string (str)
+ (let (buf)
+ (map nil #'(lambda (ch)
+ (push ch buf)
+ (when (char= ch #\^)
+ (push ch buf)))
+ str)
+ (coerce (reverse buf) 'string)))
+
(defun format-expand (fmt-alist fmt &rest args)
(let* ((chars (coerce fmt 'list))
(output "")
@@ -753,8 +762,11 @@ do:
(format t "%~a~@[~a~]" len from-left-p)
(let* ((fmt (cadr (assoc (car cur) fmt-alist :test 'char=)))
(str (cond (fmt
- ;; it can return any type, not just a string.
- (format nil "~a" (apply fmt args)))
+ ;; Any sequence that could be interpreted as
+ ;; a colorisation directive is escaped here
+ (escape-string
+ ;; it can return any type, not just a string.
+ (format nil "~a" (apply fmt args))))
((char= (car cur) #\%)
(string #\%))
(t
--
1.8.0.3