comparison lisp/net/dbus.el @ 100855:4502d2277f2c

* net/dbus.el (dbus-string-to-byte-array): Handle empty array.
author Michael Albinus <michael.albinus@gmx.de>
date Sat, 03 Jan 2009 14:55:10 +0000
parents 6d3b706e1a28
children 5951f5343bb5
comparison
equal deleted inserted replaced
100854:63cba20d8dca 100855:4502d2277f2c
1 ;;; dbus.el --- Elisp bindings for D-Bus. 1 ;;; dbus.el --- Elisp bindings for D-Bus.
2 2
3 ;; Copyright (C) 2007, 2008 Free Software Foundation, Inc. 3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
4 4
5 ;; Author: Michael Albinus <michael.albinus@gmx.de> 5 ;; Author: Michael Albinus <michael.albinus@gmx.de>
6 ;; Keywords: comm, hardware 6 ;; Keywords: comm, hardware
7 7
8 ;; This file is part of GNU Emacs. 8 ;; This file is part of GNU Emacs.
245 ;;; D-Bus type conversion. 245 ;;; D-Bus type conversion.
246 246
247 (defun dbus-string-to-byte-array (string) 247 (defun dbus-string-to-byte-array (string)
248 "Transforms STRING to list (:array :byte c1 :byte c2 ...). 248 "Transforms STRING to list (:array :byte c1 :byte c2 ...).
249 STRING shall be UTF8 coded." 249 STRING shall be UTF8 coded."
250 (let (result) 250 (if (zerop (length string))
251 (dolist (elt (string-to-list string) (append '(:array) result)) 251 '(:array :signature "y")
252 (setq result (append result (list :byte elt)))))) 252 (let (result)
253 (dolist (elt (string-to-list string) (append '(:array) result))
254 (setq result (append result (list :byte elt)))))))
253 255
254 (defun dbus-byte-array-to-string (byte-array) 256 (defun dbus-byte-array-to-string (byte-array)
255 "Transforms BYTE-ARRAY into UTF8 coded string. 257 "Transforms BYTE-ARRAY into UTF8 coded string.
256 BYTE-ARRAY must be a list of structure (c1 c2 ...)." 258 BYTE-ARRAY must be a list of structure (c1 c2 ...)."
257 (apply 'string byte-array)) 259 (apply 'string byte-array))