Fix the wrong color replacement problem in xpm images

With specific color combinations, some of the colors could be replaced twice.
This commit avoids that problem.
This commit is contained in:
kissge 2017-01-10 22:08:39 +09:00
parent 1b3ab62793
commit cc0e6f241c

View file

@ -318,9 +318,15 @@ If ICON-PATH is a string, return that."
"Get xpm image from ICON-PATH and reaplce REP-ALIST in file.
When NAME is non-nil, also replace the internal xpm image name."
(let ((case-fold-search t)
(img (mode-icons-get-xpm-string icon-path)))
(img (mode-icons-get-xpm-string icon-path))
(i 0))
(dolist (c rep-alist)
(setq img (replace-regexp-in-string (regexp-quote (car c)) (cdr c) img t t)))
(setq img (replace-regexp-in-string (regexp-quote (car c)) (format "COLOR<%d>" i) img t t)
i (1+ i)))
(let ((i 0))
(dolist (c rep-alist)
(setq img (replace-regexp-in-string (format "COLOR<%d>" i) (cdr c) img t t)
i (1+ i))))
(when name
(setq img (replace-regexp-in-string "^[ ]*static[ ]+char[ ]+[*][ ]+.*?\\[" (concat "static char * " name "[") img t t)))
img))