emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Towards a cleaner build: bindat


From: Lars Ingebrigtsen
Subject: Re: Towards a cleaner build: bindat
Date: Sat, 15 Jun 2019 16:04:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

We're on the home stretch now...

In bindat--unpack-item:
emacs-lisp/bindat.el:267:10:Warning: `string-make-unibyte' is an obsolete
    function (as of 26.1); use `encode-coding-string'.
emacs-lisp/bindat.el:264:62:Warning: `string-make-unibyte' is an obsolete
    function (as of 26.1); use `encode-coding-string'.

It's this code:

   ((eq type 'str)
    (let ((s (substring bindat-raw bindat-idx (+ bindat-idx len))))
      (setq bindat-idx (+ bindat-idx len))
      (if (stringp s) s
        (string-make-unibyte (concat s)))))
   ((eq type 'strz)
    (let ((i 0) s)
      (while (and (< i len) (/= (aref bindat-raw (+ bindat-idx i)) 0))
        (setq i (1+ i)))
      (setq s (substring bindat-raw bindat-idx (+ bindat-idx i)))
      (setq bindat-idx (+ bindat-idx len))
      (if (stringp s) s
        (string-make-unibyte (concat s)))))

s is either a string or a vector, and if it's a vector, we transform it
to a unibyte string by running it through concat and
string-make-unibyte.

But as far as I can tell from poking at the code, the vector will always
be a vector of byte values; i.e., in the 0-255 region.  concat, indeed,
returns a multibyte string:

(multibyte-string-p (concat [250 255]))
=> t

So if we just avoid the concat and make a unibyte string from the vector
in, well, just about any other way, then the string-make-unibyte
should be unnecessary, right?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




reply via email to

[Prev in Thread] Current Thread [Next in Thread]