* admin/unidata/uvs.el: Use lexical-binding

This commit is contained in:
Stefan Monnier 2019-11-05 15:05:38 -05:00
parent ec5433f676
commit edec35aa94

View file

@ -1,4 +1,4 @@
;;; uvs.el --- utility for UVS (format 14) cmap subtables in OpenType fonts.
;;; uvs.el --- utility for UVS (format 14) cmap subtables in OpenType fonts -*- lexical-binding:t -*-
;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
@ -30,7 +30,7 @@
;;; Code:
(defun uvs-fields-total-size (fields)
(apply '+ (mapcar (lambda (field) (get field 'uvs-field-size)) fields)))
(apply #'+ (mapcar (lambda (field) (get field 'uvs-field-size)) fields)))
;;; Fields in Format 14 header.
(defconst uvs-format-14-header-fields
@ -85,7 +85,8 @@ where selectors and bases are sorted in ascending order."
"\\(?:" (regexp-quote collection-id) "\\)"
"[[:blank:]]*;[[:blank:]]*"
"\\([^\n[:blank:]]+\\)"
"[[:blank:]]*$") nil t)
"[[:blank:]]*$")
nil t)
(let* ((base (string-to-number (match-string 1) 16))
(selector (string-to-number (match-string 2) 16))
(sequence-id (match-string 3))
@ -105,7 +106,7 @@ where selectors and bases are sorted in ascending order."
"Convert integer VALUE to a list of SIZE bytes.
The most significant byte comes first."
(let (result)
(dotimes (i size)
(dotimes (_ size)
(push (logand value #xff) result)
(setq value (ash value -8)))
result))
@ -118,7 +119,7 @@ respectively. Byte length of each value is determined by the
(while fields
(let ((field (car fields))
(value (car values)))
(insert (apply 'unibyte-string
(insert (apply #'unibyte-string
(uvs-int-to-bytes value (get field 'uvs-field-size))))
(setq fields (cdr fields) values (cdr values)))))
@ -126,9 +127,9 @@ respectively. Byte length of each value is determined by the
"Insert UVS-ALIST as a sequence of bytes to the current buffer."
(let* ((nrecords (length uvs-alist)) ; # of selectors
(total-nmappings
(apply '+ (mapcar
(lambda (selector-bgs) (length (cdr selector-bgs)))
uvs-alist)))
(apply #'+ (mapcar
(lambda (selector-bgs) (length (cdr selector-bgs)))
uvs-alist)))
(non-default-offset
(+ uvs-format-14-header-size
(* uvs-variation-selector-record-size nrecords))))
@ -158,15 +159,15 @@ respectively. Byte length of each value is determined by the
(car base-glyph)
(cdr base-glyph))))))
(defun uvs-dump (&optional bytes-per-line separator separator-eol line-prefix)
(defun uvs-dump (&optional bytes-per-line separator separator-eol bol-prefix)
"Print the current buffer as in representation of C array contents."
(or bytes-per-line (setq bytes-per-line 8))
(or separator (setq separator ", "))
(or separator-eol (setq separator-eol ","))
(or line-prefix (setq line-prefix " "))
(or bol-prefix (setq bol-prefix " "))
(goto-char (point-min))
(while (> (- (point-max) (point)) bytes-per-line)
(princ line-prefix)
(princ bol-prefix)
(princ (mapconcat (lambda (byte) (format "0x%02x" byte))
(string-to-unibyte
(buffer-substring (point) (+ (point) bytes-per-line)))
@ -174,7 +175,7 @@ respectively. Byte length of each value is determined by the
(princ separator-eol)
(terpri)
(forward-char bytes-per-line))
(princ line-prefix)
(princ bol-prefix)
(princ (mapconcat (lambda (byte) (format "0x%02x" byte))
(string-to-unibyte
(buffer-substring (point) (point-max)))