From: Michael Albinus Date: Wed, 4 Dec 2013 14:10:09 +0000 (+0100) Subject: * net/dbus.el (dbus-byte-array-to-string): Accept also byte arrays X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~562 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=81961e4cea57cd7b57b263ed0a570737c24d6f97;p=emacs.git * net/dbus.el (dbus-byte-array-to-string): Accept also byte arrays in D-Bus type syntax. (dbus-unescape-from-identifier): Use `byte-to-string' in order to preserve unibyte strings. (Bug#16048) --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 18b404f5362..9ead2f963a1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2013-12-04 Michael Albinus + + * net/dbus.el (dbus-byte-array-to-string): Accept also byte arrays + in D-Bus type syntax. + (dbus-unescape-from-identifier): Use `byte-to-string' in order to + preserve unibyte strings. (Bug#16048) + 2013-12-04 Stefan Monnier * emacs-lisp/eldoc.el (eldoc-minibuffer-message): @@ -21,7 +28,7 @@ 2013-12-03 Tom Regner (tiny change) * notifications.el (notifications-close-notification): Call the - D-Bus method with `id' being an `:uint32'. (Bug#16030) + D-Bus method with ID being a `:uint32'. (Bug#16030) 2013-12-03 Katsumi Yamaoka diff --git a/lisp/net/dbus.el b/lisp/net/dbus.el index a05452c430c..db444ae199f 100644 --- a/lisp/net/dbus.el +++ b/lisp/net/dbus.el @@ -829,8 +829,15 @@ STRING shall be UTF8 coded." (defun dbus-byte-array-to-string (byte-array) "Transforms BYTE-ARRAY into UTF8 coded string. -BYTE-ARRAY must be a list of structure (c1 c2 ...)." - (apply 'string byte-array)) +BYTE-ARRAY must be a list of structure (c1 c2 ...), or a byte +array as produced by `dbus-string-to-byte-array'." + (apply + 'string + (if (equal byte-array '(:array :signature "y")) + nil + (let (result) + (dolist (elt byte-array result) + (when (characterp elt) (setq result (append result `(,elt))))))))) (defun dbus-escape-as-identifier (string) "Escape an arbitrary STRING so it follows the rules for a C identifier. @@ -863,7 +870,7 @@ STRING must have been coded with `dbus-escape-as-identifier'" "" (replace-regexp-in-string "_.." - (lambda (x) (format "%c" (string-to-number (substring x 1) 16))) + (lambda (x) (byte-to-string (string-to-number (substring x 1) 16))) string)))