GNU bug report logs - #45342
28.0.50; Native compiled function returns raw bytes, not string

Previous Next

Package: emacs;

Reported by: Alexander Miller <alexanderm <at> web.de>

Date: Sun, 20 Dec 2020 17:32:01 UTC

Severity: normal

Found in version 28.0.50

Done: Andrea Corallo <akrl <at> sdf.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Alexander Miller <alexanderm <at> web.de>
To: akrl <at> sdf.org
Cc: 45342 <at> debbugs.gnu.org
Subject: bug#45342: 28.0.50; Native compiled function returns raw bytes, not string
Date: Mon, 21 Dec 2020 14:45:04 +0100
Hi Andrea,

I can confirm that 72c1a41573 fixes the issue.

However there's still another problem that I thought was related, but
apparently it isn't. (I can open another bug for it if you like).

It looks like eval-when-compile is not working as expected. I am also
using small xpms for my modeline that are defined like this:

(defconst selected-window-xpm
   (eval-when-compile (doom-modeline--make-xpm 'modeline-xpm-face 5 30)))

The generating code looks like this:

(defun doom-modeline--make-xpm (face width height)
  "Create an XPM bitmap via FACE, WIDTH and HEIGHT. Inspired by 
`powerline''s `pl/make-xpm'."
  (when (and (display-graphic-p)
             (image-type-available-p 'xpm))
    (propertize
     " " 'display
     (let ((data (make-list height (make-list width 1)))
           (color (or (face-background face nil t) "None")))
       (ignore-errors
         (create-image
          (concat
           (format
            "/* XPM */\nstatic char * percent[] = {\n\"%i %i 2 
1\",\n\". c %s\",\n\"  c %s\","
            (length (car data)) (length data) color color)
           (apply #'concat
                  (cl-loop with idx = 0
                           with len = (length data)
                           for dl in data
                           do (cl-incf idx)
                           collect
                           (concat
                            "\""
                            (cl-loop for d in dl
                                     if (= d 0) collect (string-to-char 
" ")
                                     else collect (string-to-char "."))
                            (if (eq idx len) "\"};" "\",\n")))))
  'xpm t :ascent 'center))))))

When native-compiling I only get nil, with byte-compiling it works
without problems. The correct value should look like this:

#(" " 0 1
(display
(image :type xpm :data "/* XPM */
static char * percent[] = {
\"5 30 2 1\",
\". c #559955\",
\" c #559955\",\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\",
\".....\"};" :scale 1 :ascent center)))


This bug report was last modified 4 years and 237 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.