From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: master 64e25cd: More robust NS hex colour string parsing Date: Sat, 13 Jun 2020 19:56:02 +0200 Message-ID: References: <20200608120746.30163.87810@vcs0.savannah.gnu.org> <20200608120747.80E8E20A2E@vcs0.savannah.gnu.org> <83r1uk429y.fsf@gnu.org> <3C92A091-F389-4179-B2F0-B3AA5ABD6CCE@acm.org> <83pna43xrl.fsf@gnu.org> <9259B4A6-F3CC-4243-9F08-2882993C9B2C@acm.org> <83a71741mr.fsf@gnu.org> <83y2or2c0o.fsf@gnu.org> <82DE05DD-0F2A-4722-AB75-D9D95F58BAF4@acm.org> <83v9ju3nbl.fsf@gnu.org> <83sgey3m3i.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_DF1D45F9-6A8E-4501-9943-D765E50A9433" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="123989"; mail-complaints-to="usenet@ciao.gmane.io" Cc: pipcet@gmail.com, emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 13 19:56:52 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jkAOi-000WDx-4m for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Jun 2020 19:56:52 +0200 Original-Received: from localhost ([::1]:39012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkAOh-00016M-6u for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Jun 2020 13:56:51 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41262) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkAO4-0000WU-SH for emacs-devel@gnu.org; Sat, 13 Jun 2020 13:56:12 -0400 Original-Received: from mail210c50.megamailservers.eu ([91.136.10.220]:53710 helo=mail194c50.megamailservers.eu) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkAO2-0005n6-RM; Sat, 13 Jun 2020 13:56:12 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1592070966; bh=CRH/pByJQE60AZ2JrFdoTc2HqMvTTtVT5DhO2uyTTvk=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=sTPwXtK4gHqDEgBnpoetRJCQZWMCdfX3qo4D+DfuD/LCNCrTlCI4KsaBJEcQq+le+ 45/feHQYL2+BtEnf92FfXLkixBhbbikLGD+pkMnR+ve+LSyxxZDqQefrclU+Dltpul GSxxMbpwd54ibe5y7wGdBFNvn6ilxFzBrVUpeZyg= Feedback-ID: mattiase@acm.or Original-Received: from [192.168.0.4] (c188-150-171-71.bredband.comhem.se [188.150.171.71]) (authenticated bits=0) by mail194c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 05DHu2LB020469; Sat, 13 Jun 2020 17:56:05 +0000 In-Reply-To: <83sgey3m3i.fsf@gnu.org> X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F19.5EE51336.0016, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: 0.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=KsozJleN c=1 sm=1 tr=0 a=SF+I6pRkHZhrawxbOkkvaA==:117 a=SF+I6pRkHZhrawxbOkkvaA==:17 a=M51BFTxLslgA:10 a=mDV3o1hIAAAA:8 a=j8gvZXSf7insxO4HaVEA:9 a=CjuIK1q_8ugA:10 a=3AzUsQxcQTNn1yNZmDYA:9 a=B2y7HmGcmWMA:10 a=_FVE-zBwftR9WsbkzFJk:22 Received-SPF: softfail client-ip=91.136.10.220; envelope-from=mattiase@acm.org; helo=mail194c50.megamailservers.eu X-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/13 13:56:07 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x (no timestamps) [generic] X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:252196 Archived-At: --Apple-Mail=_DF1D45F9-6A8E-4501-9943-D765E50A9433 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 13 juni 2020 kl. 19.35 skrev Eli Zaretskii : > But it isn't rejected by the current code. Which was my point all > along. Since "#12345" is malformed it should be rejected, and will be. >>> Then color-values-from-color-spec, I guess. >>=20 >> Thank you, but a smidgen too many 'color' in there. >=20 > I don't think so, no. Very well, I have no strong opinion here so let's go with it. Updated patch attached, with the name change, and the warning found by = Basil fixed. --Apple-Mail=_DF1D45F9-6A8E-4501-9943-D765E50A9433 Content-Disposition: attachment; filename=0001-Consolidate-RGB-string-parsers.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Consolidate-RGB-string-parsers.patch" Content-Transfer-Encoding: quoted-printable =46rom=20a06d9d76f94f8bc3afdf92962fa88d43fff67d09=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Fri,=2012=20Jun=202020=2018:12:37=20+0200=0A= Subject:=20[PATCH]=20Consolidate=20#RGB=20string=20parsers=0A=0AUse=20a=20= single=20parser=20of=20colour=20strings=20in=20the=20#RGB,=20rgb:R/G/B=20= and=0Argbi:R/G/B=20formats,=20replacing=20four=20existing=20ones.=20=20= Previously,=0Aerror-checking=20was=20spotty,=20handling=20of=20the=20= rgbi:=20format=20not=20always=0Apresent,=20and=20normalisation=20of=20= the=20result=20was=20sometimes=20incorrect.=0A=0A*=20src/dispextern.h:=20= New=20prototype.=0A*=20src/xfaces.c=20(parse_hex_comp,=20= parse_float_comp,=20parse_color_spec)=0A(Fcolor_values_from_color_spec):=20= New=20functions.=0A*=20test/src/xfaces-tests.el=20= (xfaces-color-values-from-color-spec):=0ANew=20test.=0A*=20= lisp/term/tty-colors.el=20(tty-color-standard-values):=0AUse=20= color-values-from-color-spec,=20replacing=20old=20parser.=0A*=20= src/nsterm.m=20(ns_get_color):=0A*=20src/w32fns.c=20(x_to_w32_color):=0A= *=20src/xterm.c=20(x_parse_color):=20Use=20parse_color_spec,=20replacing=20= old=0Aparsers.=0A(HEX_COLOR_NAME_LENGTH):=20Remove=20#define.=0A---=0A=20= lisp/term/tty-colors.el=20=20|=20=2058=20+--------------=0A=20= src/dispextern.h=20=20=20=20=20=20=20=20=20|=20=20=202=20+=0A=20= src/nsterm.m=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=2059=20= +++++----------=0A=20src/w32fns.c=20=20=20=20=20=20=20=20=20=20=20=20=20= |=20157=20++-------------------------------------=0A=20src/xfaces.c=20=20= =20=20=20=20=20=20=20=20=20=20=20|=20112=20++++++++++++++++++++++++++++=0A= =20src/xterm.c=20=20=20=20=20=20=20=20=20=20=20=20=20=20|=20=2051=20= ++++---------=0A=20test/src/xfaces-tests.el=20|=20=2023=20++++++=0A=207=20= files=20changed,=20176=20insertions(+),=20286=20deletions(-)=0A=0Adiff=20= --git=20a/lisp/term/tty-colors.el=20b/lisp/term/tty-colors.el=0Aindex=20= 39ca2d3627..dda7fcc369=20100644=0A---=20a/lisp/term/tty-colors.el=0A+++=20= b/lisp/term/tty-colors.el=0A@@=20-923,62=20+923,8=20@@=20= tty-color-standard-values=0A=20COLOR=20(see=20the=20info=20node=20= `(emacs)=20Colors'),=20regardless=20of=20whether=0A=20the=20terminal=20= can=20display=20it,=20so=20the=20return=20value=20should=20be=20the=0A=20= same=20regardless=20of=20what=20display=20is=20being=20used."=0A-=20=20= (let=20((len=20(length=20color)))=0A-=20=20=20=20(cond=20((and=20(>=3D=20= len=204)=20;;=20HTML/CSS/SVG-style=20"#XXYYZZ"=20color=20spec=0A-=09=09= (eq=20(aref=20color=200)=20?#)=0A-=09=09(member=20(aref=20color=201)=0A-=09= =09=09'(?0=20?1=20?2=20?3=20?4=20?5=20?6=20?7=20?8=20?9=0A-=09=09=09=20=20= =20=20=20?a=20?b=20?c=20?d=20?e=20?f=0A-=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?A=20?B=20?C=20?D=20= ?E=20?F)))=0A-=09=20=20=20;;=20Translate=20the=20string=20"#XXYYZZ"=20= into=20a=20list=20of=20numbers=0A-=09=20=20=20;;=20(XX=20YY=20ZZ),=20= scaling=20each=20to=20the=20{0..65535}=20range.=20=20This=0A-=09=20=20=20= ;;=20follows=20the=20HTML=20color=20convention,=20where=20both=20"#fff"=20= and=0A-=09=20=20=20;;=20"#ffffff"=20represent=20the=20same=20color,=20= white.=0A-=09=20=20=20(let*=20((ndig=20(/=20(-=20len=201)=203))=0A-=09=09= =20=20(maxval=20(1-=20(ash=201=20(*=204=20ndig))))=0A-=09=09=20=20(i1=20= 1)=0A-=09=09=20=20(i2=20(+=20i1=20ndig))=0A-=09=09=20=20(i3=20(+=20i2=20= ndig))=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(i4=20(+=20= i3=20ndig)))=0A-=09=20=20=20=20=20(list=0A-=09=20=20=20=20=20=20(/=20(*=20= (string-to-number=0A-=09=09=20=20=20=20=20(substring=20color=20i1=20i2)=20= 16)=0A-=09=09=20=20=20=2065535)=0A-=09=09=20maxval)=0A-=09=20=20=20=20=20= =20(/=20(*=20(string-to-number=0A-=09=09=20=20=20=20=20(substring=20= color=20i2=20i3)=2016)=0A-=09=09=20=20=20=2065535)=0A-=09=09=20maxval)=0A= -=09=20=20=20=20=20=20(/=20(*=20(string-to-number=0A-=09=09=20=20=20=20=20= (substring=20color=20i3=20i4)=2016)=0A-=09=09=20=20=20=2065535)=0A-=09=09= =20maxval))))=0A-=09=20=20((and=20(>=3D=20len=209)=20;;=20X-style=20= rgb:xx/yy/zz=20color=20spec=0A-=09=09(string=3D=20(substring=20color=200=20= 4)=20"rgb:"))=0A-=09=20=20=20;;=20Translate=20the=20string=20= "rgb:XX/YY/ZZ"=20into=20a=20list=20of=0A-=09=20=20=20;;=20numbers=20(XX=20= YY=20ZZ),=20scaling=20each=20to=20the=20{0..65535}=0A-=09=20=20=20;;=20= range.=20=20"rgb:F/F/F"=20is=20white.=0A-=09=20=20=20(let*=20((ndig=20(/=20= (-=20len=203)=203))=0A-=09=09=20=20(maxval=20(1-=20(ash=201=20(*=204=20= (-=20ndig=201)))))=0A-=09=09=20=20(i1=204)=0A-=09=09=20=20(i2=20(+=20i1=20= ndig))=0A-=09=09=20=20(i3=20(+=20i2=20ndig))=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20(i4=20(+=20i3=20ndig)))=0A-=09=20=20=20=20=20= (list=0A-=09=20=20=20=20=20=20(/=20(*=20(string-to-number=0A-=09=09=20=20= =20=20=20(substring=20color=20i1=20(-=20i2=201))=2016)=0A-=09=09=20=20=20= =2065535)=0A-=09=09=20maxval)=0A-=09=20=20=20=20=20=20(/=20(*=20= (string-to-number=0A-=09=09=20=20=20=20=20(substring=20color=20i2=20(-=20= i3=201))=2016)=0A-=09=09=20=20=20=2065535)=0A-=09=09=20maxval)=0A-=09=20=20= =20=20=20=20(/=20(*=20(string-to-number=0A-=09=09=20=20=20=20=20= (substring=20color=20i3=20(1-=20i4))=2016)=0A-=09=09=20=20=20=2065535)=0A= -=09=09=20maxval))))=0A-=09=20=20(t=0A-=09=20=20=20(cdr=20(assoc=20color=20= color-name-rgb-alist))))))=0A+=20=20(or=20(color-values-from-color-spec=20= color)=0A+=20=20=20=20=20=20(cdr=20(assoc=20color=20= color-name-rgb-alist))))=0A=20=0A=20(defun=20tty-color-translate=20= (color=20&optional=20frame)=0A=20=20=20"Given=20a=20color=20COLOR,=20= return=20the=20index=20of=20the=20corresponding=20TTY=20color.=0Adiff=20= --git=20a/src/dispextern.h=20b/src/dispextern.h=0Aindex=20= 0b1f3d14ae..e1d6eddc41=20100644=0A---=20a/src/dispextern.h=0A+++=20= b/src/dispextern.h=0A@@=20-3514,6=20+3514,8=20@@=20#define=20= RGB_PIXEL_COLOR=20COLORREF=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= Lisp_Object);=0A=20extern=20bool=20tty_defined_color=20(struct=20frame=20= *,=20const=20char=20*,=20Emacs_Color=20*,=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20bool,=20= bool);=0A+bool=20parse_color_spec=20(const=20char=20*,=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20unsigned=20short=20= *,=20unsigned=20short=20*,=20unsigned=20short=20*);=0A=20=0A=20= Lisp_Object=20tty_color_name=20(struct=20frame=20*,=20int);=0A=20void=20= clear_face_cache=20(bool);=0Adiff=20--git=20a/src/nsterm.m=20= b/src/nsterm.m=0Aindex=203dc7e1db7c..0e405fc017=20100644=0A---=20= a/src/nsterm.m=0A+++=20b/src/nsterm.m=0A@@=20-2341,9=20+2341,6=20@@=20so=20= some=20key=20presses=20(TAB)=20are=20swallowed=20by=20the=20system.=20=20= */=0A=20=20=20=20See=20= https://lists.gnu.org/r/emacs-devel/2009-07/msg01203.html.=20=20*/=0A=20= {=0A=20=20=20NSColor=20*new=20=3D=20nil;=0A-=20=20static=20char=20= hex[20];=0A-=20=20int=20scaling=20=3D=200;=0A-=20=20float=20r=20=3D=20= -1.0,=20g,=20b;=0A=20=20=20NSString=20*nsname=20=3D=20[NSString=20= stringWithUTF8String:=20name];=0A=20=0A=20=20=20NSTRACE=20= ("ns_get_color(%s,=20**)",=20name);=0A@@=20-2386,51=20+2383,31=20@@=20so=20= some=20key=20presses=20(TAB)=20are=20swallowed=20by=20the=20system.=20=20= */=0A=20=20=20=20=20}=0A=20=0A=20=20=20/*=20First,=20check=20for=20some=20= sort=20of=20numeric=20specification.=20=20*/=0A-=20=20hex[0]=20=3D=20= '\0';=0A-=0A-=20=20if=20(name[0]=20=3D=3D=20'0'=20||=20name[0]=20=3D=3D=20= '1'=20||=20name[0]=20=3D=3D=20'.')=20=20/*=20RGB=20decimal=20*/=0A+=20=20= unsigned=20short=20r16,=20g16,=20b16;=0A+=20=20if=20(parse_color_spec=20= (name,=20&r16,=20&g16,=20&b16))=0A=20=20=20=20=20{=0A-=20=20=20=20=20=20= NSScanner=20*scanner=20=3D=20[NSScanner=20scannerWithString:=20nsname];=0A= -=20=20=20=20=20=20[scanner=20scanFloat:=20&r];=0A-=20=20=20=20=20=20= [scanner=20scanFloat:=20&g];=0A-=20=20=20=20=20=20[scanner=20scanFloat:=20= &b];=0A-=20=20=20=20}=0A-=20=20else=20if=20(!strncmp(name,=20"rgb:",=20= 4))=20=20/*=20A=20newer=20X11=20format=20--=20rgb:r/g/b=20*/=0A-=20=20=20= =20scaling=20=3D=20(snprintf=20(hex,=20sizeof=20hex,=20"%s",=20name=20+=20= 4)=20-=202)=20/=203;=0A-=20=20else=20if=20(name[0]=20=3D=3D=20'#')=20=20=20= =20=20=20=20=20/*=20An=20old=20X11=20format;=20convert=20to=20newer=20*/=0A= -=20=20=20=20{=0A-=20=20=20=20=20=20int=20len=20=3D=200;=0A-=20=20=20=20=20= =20while=20(isxdigit=20(name[len=20+=201]))=0A-=20=20=20=20=20=20=20=20= len++;=0A-=20=20=20=20=20=20if=20(name[len=20+=201]=20=3D=3D=20'\0'=20&&=20= len=20>=3D=201=20&&=20len=20<=3D=2012=20&&=20len=20%=203=20=3D=3D=200)=0A= -=20=20=20=20=20=20=20=20{=0A-=20=20=20=20=20=20=20=20=20=20scaling=20=3D=20= len=20/=203;=0A-=20=20=20=20=20=20=20=20=20=20for=20(int=20i=20=3D=200;=20= i=20<=203;=20i++)=0A-=20=20=20=20=20=20=20=20=20=20=20=20sprintf=20(hex=20= +=20i=20*=20(scaling=20+=201),=20"%.*s/",=20scaling,=0A-=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20name=20+=201=20+=20i=20*=20= scaling);=0A-=20=20=20=20=20=20=20=20=20=20hex[3=20*=20(scaling=20+=201)=20= -=201]=20=3D=20'\0';=0A-=20=20=20=20=20=20=20=20}=0A+=20=20=20=20=20=20= *col=20=3D=20[NSColor=20colorForEmacsRed:=20r16=20/=2065535.0=0A+=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20green:=20g16=20/=2065535.0=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= blue:=20b16=20/=2065535.0=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20alpha:=201.0];=0A+=20= =20=20=20=20=20unblock_input=20();=0A+=20=20=20=20=20=20return=200;=0A=20= =20=20=20=20}=0A-=0A-=20=20if=20(hex[0])=0A+=20=20else=20if=20(name[0]=20= =3D=3D=20'0'=20||=20name[0]=20=3D=3D=20'1'=20||=20name[0]=20=3D=3D=20= '.')=0A=20=20=20=20=20{=0A-=20=20=20=20=20=20unsigned=20int=20rr,=20gg,=20= bb;=0A-=20=20=20=20=20=20float=20fscale=20=3D=20(1=20<<=20(scaling=20*=20= 4))=20-=201;=0A-=20=20=20=20=20=20if=20(sscanf=20(hex,=20"%x/%x/%x",=20= &rr,=20&gg,=20&bb))=0A+=20=20=20=20=20=20/*=20RGB=20decimal=20*/=0A+=20=20= =20=20=20=20NSScanner=20*scanner=20=3D=20[NSScanner=20scannerWithString:=20= nsname];=0A+=20=20=20=20=20=20float=20r,=20g,=20b;=0A+=20=20=20=20=20=20= if=20(=20=20=20[scanner=20scanFloat:=20&r]=20&&=20r=20>=3D=200=20&&=20r=20= <=3D=201=0A+=20=20=20=20=20=20=20=20=20=20&&=20[scanner=20scanFloat:=20= &g]=20&&=20g=20>=3D=200=20&&=20g=20<=3D=201=0A+=20=20=20=20=20=20=20=20=20= =20&&=20[scanner=20scanFloat:=20&b]=20&&=20b=20>=3D=200=20&&=20b=20<=3D=20= 1)=0A=20=20=20=20=20=20=20=20=20{=0A-=20=20=20=20=20=20=20=20=20=20r=20=3D= =20rr=20/=20fscale;=0A-=20=20=20=20=20=20=20=20=20=20g=20=3D=20gg=20/=20= fscale;=0A-=20=20=20=20=20=20=20=20=20=20b=20=3D=20bb=20/=20fscale;=0A+=20= =20=20=20=20=20=20=20=20=20*col=20=3D=20[NSColor=20colorForEmacsRed:=20r=20= green:=20g=20blue:=20b=20alpha:=201.0];=0A+=20=20=20=20=20=20=20=20=20=20= unblock_input=20();=0A+=20=20=20=20=20=20=20=20=20=20return=200;=0A=20=20= =20=20=20=20=20=20=20}=0A=20=20=20=20=20}=0A=20=0A-=20=20if=20(r=20>=3D=20= 0.0F)=0A-=20=20=20=20{=0A-=20=20=20=20=20=20*col=20=3D=20[NSColor=20= colorForEmacsRed:=20r=20green:=20g=20blue:=20b=20alpha:=201.0];=0A-=20=20= =20=20=20=20unblock_input=20();=0A-=20=20=20=20=20=20return=200;=0A-=20=20= =20=20}=0A-=0A=20=20=20/*=20Otherwise,=20color=20is=20expected=20to=20be=20= from=20a=20list=20*/=0A=20=20=20{=0A=20=20=20=20=20NSEnumerator=20= *lenum,=20*cenum;=0Adiff=20--git=20a/src/w32fns.c=20b/src/w32fns.c=0A= index=20e595b0285a..ab864332e7=20100644=0A---=20a/src/w32fns.c=0A+++=20= b/src/w32fns.c=0A@@=20-864,161=20+864,14=20@@=20x_to_w32_color=20(const=20= char=20*=20colorname)=0A=20=0A=20=20=20block_input=20();=0A=20=0A-=20=20= if=20(colorname[0]=20=3D=3D=20'#')=0A+=20=20unsigned=20short=20r,=20g,=20= b;=0A+=20=20if=20(parse_color_spec=20(colorname,=20&r,=20&g,=20&b))=0A=20= =20=20=20=20{=0A-=20=20=20=20=20=20/*=20Could=20be=20an=20old-style=20= RGB=20Device=20specification.=20=20*/=0A-=20=20=20=20=20=20int=20size=20= =3D=20strlen=20(colorname=20+=201);=0A-=20=20=20=20=20=20char=20*color=20= =3D=20alloca=20(size=20+=201);=0A-=0A-=20=20=20=20=20=20strcpy=20(color,=20= colorname=20+=201);=0A-=20=20=20=20=20=20if=20(size=20=3D=3D=203=20||=20= size=20=3D=3D=206=20||=20size=20=3D=3D=209=20||=20size=20=3D=3D=2012)=0A= -=09{=0A-=09=20=20UINT=20colorval;=0A-=09=20=20int=20i,=20pos;=0A-=09=20=20= pos=20=3D=200;=0A-=09=20=20size=20/=3D=203;=0A-=09=20=20colorval=20=3D=20= 0;=0A-=0A-=09=20=20for=20(i=20=3D=200;=20i=20<=203;=20i++)=0A-=09=20=20=20= =20{=0A-=09=20=20=20=20=20=20char=20*end;=0A-=09=20=20=20=20=20=20char=20= t;=0A-=09=20=20=20=20=20=20unsigned=20long=20value;=0A-=0A-=09=20=20=20=20= =20=20/*=20The=20check=20for=20'x'=20in=20the=20following=20conditional=20= takes=20into=0A-=09=09=20account=20the=20fact=20that=20strtol=20allows=20= a=20"0x"=20in=20front=20of=0A-=09=09=20our=20numbers,=20and=20we=20= don't.=20=20*/=0A-=09=20=20=20=20=20=20if=20(!isxdigit=20(color[0])=20||=20= color[1]=20=3D=3D=20'x')=0A-=09=09break;=0A-=09=20=20=20=20=20=20t=20=3D=20= color[size];=0A-=09=20=20=20=20=20=20color[size]=20=3D=20'\0';=0A-=09=20=20= =20=20=20=20value=20=3D=20strtoul=20(color,=20&end,=2016);=0A-=09=20=20=20= =20=20=20color[size]=20=3D=20t;=0A-=09=20=20=20=20=20=20if=20(errno=20=3D=3D= =20ERANGE=20||=20end=20-=20color=20!=3D=20size)=0A-=09=09break;=0A-=09=20= =20=20=20=20=20switch=20(size)=0A-=09=09{=0A-=09=09case=201:=0A-=09=09=20= =20value=20=3D=20value=20*=200x10;=0A-=09=09=20=20break;=0A-=09=09case=20= 2:=0A-=09=09=20=20break;=0A-=09=09case=203:=0A-=09=09=20=20value=20/=3D=20= 0x10;=0A-=09=09=20=20break;=0A-=09=09case=204:=0A-=09=09=20=20value=20/=3D= =200x100;=0A-=09=09=20=20break;=0A-=09=09}=0A-=09=20=20=20=20=20=20= colorval=20|=3D=20(value=20<<=20pos);=0A-=09=20=20=20=20=20=20pos=20+=3D=20= 0x8;=0A-=09=20=20=20=20=20=20if=20(i=20=3D=3D=202)=0A-=09=09{=0A-=09=09=20= =20unblock_input=20();=0A-=09=09=20=20XSETINT=20(ret,=20colorval);=0A-=09= =09=20=20return=20ret;=0A-=09=09}=0A-=09=20=20=20=20=20=20color=20=3D=20= end;=0A-=09=20=20=20=20}=0A-=09}=0A-=20=20=20=20}=0A-=20=20else=20if=20= (strnicmp=20(colorname,=20"rgb:",=204)=20=3D=3D=200)=0A-=20=20=20=20{=0A= -=20=20=20=20=20=20const=20char=20*color;=0A-=20=20=20=20=20=20UINT=20= colorval;=0A-=20=20=20=20=20=20int=20i,=20pos;=0A-=20=20=20=20=20=20pos=20= =3D=200;=0A-=0A-=20=20=20=20=20=20colorval=20=3D=200;=0A-=20=20=20=20=20=20= color=20=3D=20colorname=20+=204;=0A-=20=20=20=20=20=20for=20(i=20=3D=20= 0;=20i=20<=203;=20i++)=0A-=09{=0A-=09=20=20char=20*end;=0A-=09=20=20= unsigned=20long=20value;=0A-=0A-=09=20=20/*=20The=20check=20for=20'x'=20= in=20the=20following=20conditional=20takes=20into=0A-=09=20=20=20=20=20= account=20the=20fact=20that=20strtol=20allows=20a=20"0x"=20in=20front=20= of=0A-=09=20=20=20=20=20our=20numbers,=20and=20we=20don't.=20=20*/=0A-=09= =20=20if=20(!isxdigit=20(color[0])=20||=20color[1]=20=3D=3D=20'x')=0A-=09= =20=20=20=20break;=0A-=09=20=20value=20=3D=20strtoul=20(color,=20&end,=20= 16);=0A-=09=20=20if=20(errno=20=3D=3D=20ERANGE)=0A-=09=20=20=20=20break;=0A= -=09=20=20switch=20(end=20-=20color)=0A-=09=20=20=20=20{=0A-=09=20=20=20=20= case=201:=0A-=09=20=20=20=20=20=20value=20=3D=20value=20*=200x10=20+=20= value;=0A-=09=20=20=20=20=20=20break;=0A-=09=20=20=20=20case=202:=0A-=09=20= =20=20=20=20=20break;=0A-=09=20=20=20=20case=203:=0A-=09=20=20=20=20=20=20= value=20/=3D=200x10;=0A-=09=20=20=20=20=20=20break;=0A-=09=20=20=20=20= case=204:=0A-=09=20=20=20=20=20=20value=20/=3D=200x100;=0A-=09=20=20=20=20= =20=20break;=0A-=09=20=20=20=20default:=0A-=09=20=20=20=20=20=20value=20= =3D=20ULONG_MAX;=0A-=09=20=20=20=20}=0A-=09=20=20if=20(value=20=3D=3D=20= ULONG_MAX)=0A-=09=20=20=20=20break;=0A-=09=20=20colorval=20|=3D=20(value=20= <<=20pos);=0A-=09=20=20pos=20+=3D=200x8;=0A-=09=20=20if=20(i=20=3D=3D=20= 2)=0A-=09=20=20=20=20{=0A-=09=20=20=20=20=20=20if=20(*end=20!=3D=20'\0')=0A= -=09=09break;=0A-=09=20=20=20=20=20=20unblock_input=20();=0A-=09=20=20=20= =20=20=20XSETINT=20(ret,=20colorval);=0A-=09=20=20=20=20=20=20return=20= ret;=0A-=09=20=20=20=20}=0A-=09=20=20if=20(*end=20!=3D=20'/')=0A-=09=20=20= =20=20break;=0A-=09=20=20color=20=3D=20end=20+=201;=0A-=09}=0A+=20=20=20=20= =20=20unblock_input=20();=0A+=20=20=20=20=20=20/*=20Throw=20away=20the=20= low=208=20bits=20and=20return=200xBBGGRR.=20=20*/=0A+=20=20=20=20=20=20= return=20make_fixnum=20((b=20&=200xff00)=20<<=208=20|=20(g=20&=200xff00)=20= |=20r=20>>=208);=0A=20=20=20=20=20}=0A-=20=20else=20if=20(strnicmp=20= (colorname,=20"rgbi:",=205)=20=3D=3D=200)=0A-=20=20=20=20{=0A-=20=20=20=20= =20=20/*=20This=20is=20an=20RGB=20Intensity=20specification.=20=20*/=0A-=20= =20=20=20=20=20const=20char=20*color;=0A-=20=20=20=20=20=20UINT=20= colorval;=0A-=20=20=20=20=20=20int=20i,=20pos;=0A-=20=20=20=20=20=20pos=20= =3D=200;=0A-=0A-=20=20=20=20=20=20colorval=20=3D=200;=0A-=20=20=20=20=20=20= color=20=3D=20colorname=20+=205;=0A-=20=20=20=20=20=20for=20(i=20=3D=20= 0;=20i=20<=203;=20i++)=0A-=09{=0A-=09=20=20char=20*end;=0A-=09=20=20= double=20value;=0A-=09=20=20UINT=20val;=0A=20=0A-=09=20=20value=20=3D=20= strtod=20(color,=20&end);=0A-=09=20=20if=20(errno=20=3D=3D=20ERANGE)=0A-=09= =20=20=20=20break;=0A-=09=20=20if=20(value=20<=200.0=20||=20value=20>=20= 1.0)=0A-=09=20=20=20=20break;=0A-=09=20=20val=20=3D=20(UINT)(0x100=20*=20= value);=0A-=09=20=20/*=20We=20used=200x100=20instead=20of=200xFF=20to=20= give=20a=20continuous=0A-=09=20=20=20=20=20range=20between=200.0=20and=20= 1.0=20inclusive.=20=20The=20next=20statement=0A-=09=20=20=20=20=20fixes=20= the=201.0=20case.=20=20*/=0A-=09=20=20if=20(val=20=3D=3D=200x100)=0A-=09=20= =20=20=20val=20=3D=200xFF;=0A-=09=20=20colorval=20|=3D=20(val=20<<=20= pos);=0A-=09=20=20pos=20+=3D=200x8;=0A-=09=20=20if=20(i=20=3D=3D=202)=0A= -=09=20=20=20=20{=0A-=09=20=20=20=20=20=20if=20(*end=20!=3D=20'\0')=0A-=09= =09break;=0A-=09=20=20=20=20=20=20unblock_input=20();=0A-=09=20=20=20=20=20= =20XSETINT=20(ret,=20colorval);=0A-=09=20=20=20=20=20=20return=20ret;=0A= -=09=20=20=20=20}=0A-=09=20=20if=20(*end=20!=3D=20'/')=0A-=09=20=20=20=20= break;=0A-=09=20=20color=20=3D=20end=20+=201;=0A-=09}=0A-=20=20=20=20}=0A= =20=20=20/*=20I=20am=20not=20going=20to=20attempt=20to=20handle=20any=20= of=20the=20CIE=20color=20schemes=0A=20=20=20=20=20=20or=20TekHVC,=20= since=20I=20don't=20know=20the=20algorithms=20for=20conversion=20to=0A=20= =20=20=20=20=20RGB.=20=20*/=0Adiff=20--git=20a/src/xfaces.c=20= b/src/xfaces.c=0Aindex=20cf155288bd..0a2dec1cff=20100644=0A---=20= a/src/xfaces.c=0A+++=20b/src/xfaces.c=0A@@=20-220,6=20+220,7=20@@=20= Copyright=20(C)=201993-1994,=201998-2020=20Free=20Software=20Foundation,=20= Inc.=0A=20#include=20"sysstdio.h"=0A=20#include=20=0A=20= #include=20=0A+#include=20=0A=20=0A=20#include=20= "lisp.h"=0A=20#include=20"character.h"=0A@@=20-819,6=20+820,116=20@@=20= load_pixmap=20(struct=20frame=20*f,=20Lisp_Object=20name)=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= Color=20Handling=0A=20=20= ***********************************************************************/=0A= =20=0A+/*=20Parse=20fractional=20hex=20digits=20at=20S=20ending=20right=20= before=20E.=0A+=20=20=20Set=20*DST=20to=20the=20value=20normalised=20to=20= 65535=20and=20return=20true=20on=20success,=0A+=20=20=20false=20= otherwise.=20=20*/=0A+static=20bool=0A+parse_hex_comp=20(const=20char=20= *s,=20const=20char=20*e,=20unsigned=20short=20*dst)=0A+{=0A+=20=20int=20= n=20=3D=20e=20-=20s;=0A+=20=20if=20(n=20<=3D=200=20||=20n=20>=204)=0A+=20= =20=20=20return=20false;=0A+=20=20int=20val=20=3D=200;=0A+=20=20for=20(;=20= s=20<=20e;=20s++)=0A+=20=20=20=20{=0A+=20=20=20=20=20=20int=20digit;=0A+=20= =20=20=20=20=20if=20(*s=20>=3D=20'0'=20&&=20*s=20<=3D=20'9')=0A+=20=20=20= =20=20=20=20=20digit=20=3D=20*s=20-=20'0';=0A+=20=20=20=20=20=20else=20= if=20(*s=20>=3D=20'A'=20&&=20*s=20<=3D=20'F')=0A+=20=20=20=20=20=20=20=20= digit=20=3D=20*s=20-=20'A'=20+=2010;=0A+=20=20=20=20=20=20else=20if=20= (*s=20>=3D=20'a'=20&&=20*s=20<=3D=20'f')=0A+=20=20=20=20=20=20=20=20= digit=20=3D=20*s=20-=20'a'=20+=2010;=0A+=20=20=20=20=20=20else=0A+=20=20=20= =20=20=20=20=20return=20false;=0A+=20=20=20=20=20=20val=20=3D=20(val=20= <<=204)=20|=20digit;=0A+=20=20=20=20}=0A+=20=20int=20maxval=20=3D=20(1=20= <<=20(n=20*=204))=20-=201;=0A+=20=20*dst=20=3D=20(unsigned)val=20*=20= 65535=20/=20maxval;=0A+=20=20return=20true;=0A+}=0A+=0A+/*=20Parse=20= floating-point=20number=20at=20S=20ending=20right=20before=20E.=0A+=20=20= =20Return=20the=20number=20if=20in=20the=20range=20[0,1];=20otherwise=20= -1.=20=20*/=0A+static=20double=0A+parse_float_comp=20(const=20char=20*s,=20= const=20char=20*e)=0A+{=0A+=20=20char=20*end;=0A+=20=20double=20x=20=3D=20= strtod=20(s,=20&end);=0A+=20=20return=20(end=20=3D=3D=20e=20&&=20x=20>=3D=20= 0=20&&=20x=20<=3D=201)=20?=20x=20:=20-1;=0A+}=0A+=0A+/*=20Parse=20S=20as=20= a=20numeric=20colour=20specification=20and=20set=20*R,=20*G=20and=20*B.=0A= +=20=20=20Return=20true=20on=20success,=20false=20on=20failure.=0A+=20=20= =20Recognised=20formats:=0A+=0A+=20=20=20=20"#RGB",=20with=20R,=20G=20= and=20B=20hex=20strings=20of=20equal=20length,=201-4=20digits=20each=0A+=20= =20=20=20"rgb:R/G/B",=20with=20R,=20G=20and=20B=20hex=20strings,=201-4=20= digits=20each=0A+=20=20=20=20"rgbi:R/G/B",=20with=20R,=20G=20and=20B=20= numbers=20in=20[0,1]=0A+=0A+=20=20=20The=20result=20is=20normalised=20to=20= a=20maximum=20value=20of=2065535=20per=20component.=20=20*/=0A+bool=0A= +parse_color_spec=20(const=20char=20*s,=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20unsigned=20short=20*r,=20unsigned=20short=20*g,=20= unsigned=20short=20*b)=0A+{=0A+=20=20int=20len=20=3D=20strlen=20(s);=0A+=20= =20if=20(s[0]=20=3D=3D=20'#')=0A+=20=20=20=20{=0A+=20=20=20=20=20=20if=20= ((len=20-=201)=20%=203=20=3D=3D=200)=0A+=20=20=20=20=20=20=20=20{=0A+=20=20= =20=20=20=20=20=20=20=20int=20n=20=3D=20(len=20-=201)=20/=203;=0A+=20=20=20= =20=20=20=20=20=20=20return=20(=20=20=20parse_hex_comp=20(s=20+=201=20+=20= 0=20*=20n,=20s=20+=201=20+=201=20*=20n,=20r)=0A+=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20&&=20parse_hex_comp=20(s=20+=201=20+=201=20*=20= n,=20s=20+=201=20+=202=20*=20n,=20g)=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20&&=20parse_hex_comp=20(s=20+=201=20+=202=20*=20n,=20= s=20+=201=20+=203=20*=20n,=20b));=0A+=20=20=20=20=20=20=20=20}=0A+=20=20=20= =20}=0A+=20=20else=20if=20(strncmp=20(s,=20"rgb:",=204)=20=3D=3D=200)=0A= +=20=20=20=20{=0A+=20=20=20=20=20=20char=20*sep1,=20*sep2;=0A+=20=20=20=20= =20=20return=20((sep1=20=3D=20strchr=20(s=20+=204,=20'/'))=20!=3D=20NULL=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20&&=20(sep2=20=3D=20strchr=20= (sep1=20+=201,=20'/'))=20!=3D=20NULL=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20&&=20parse_hex_comp=20(s=20+=204,=20sep1,=20r)=0A+=20=20=20=20=20= =20=20=20=20=20=20=20=20=20&&=20parse_hex_comp=20(sep1=20+=201,=20sep2,=20= g)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20&&=20parse_hex_comp=20= (sep2=20+=201,=20s=20+=20len,=20b));=0A+=20=20=20=20}=0A+=20=20else=20if=20= (strncmp=20(s,=20"rgbi:",=205)=20=3D=3D=200)=0A+=20=20=20=20{=0A+=20=20=20= =20=20=20char=20*sep1,=20*sep2;=0A+=20=20=20=20=20=20double=20red,=20= green,=20blue;=0A+=20=20=20=20=20=20if=20((sep1=20=3D=20strchr=20(s=20+=20= 5,=20'/'))=20!=3D=20NULL=0A+=20=20=20=20=20=20=20=20=20=20&&=20(sep2=20=3D= =20strchr=20(sep1=20+=201,=20'/'))=20!=3D=20NULL=0A+=20=20=20=20=20=20=20= =20=20=20&&=20(red=20=3D=20parse_float_comp=20(s=20+=205,=20sep1))=20>=3D=20= 0=0A+=20=20=20=20=20=20=20=20=20=20&&=20(green=20=3D=20parse_float_comp=20= (sep1=20+=201,=20sep2))=20>=3D=200=0A+=20=20=20=20=20=20=20=20=20=20&&=20= (blue=20=3D=20parse_float_comp=20(sep2=20+=201,=20s=20+=20len))=20>=3D=20= 0)=0A+=20=20=20=20=20=20=20=20{=0A+=20=20=20=20=20=20=20=20=20=20*r=20=3D=20= lrint=20(red=20*=2065535);=0A+=20=20=20=20=20=20=20=20=20=20*g=20=3D=20= lrint=20(green=20*=2065535);=0A+=20=20=20=20=20=20=20=20=20=20*b=20=3D=20= lrint=20(blue=20*=2065535);=0A+=20=20=20=20=20=20=20=20=20=20return=20= true;=0A+=20=20=20=20=20=20=20=20}=0A+=20=20=20=20}=0A+=20=20return=20= false;=0A+}=0A+=0A+DEFUN=20("color-values-from-color-spec",=0A+=20=20=20=20= =20=20=20Fcolor_values_from_color_spec,=20Scolor_values_from_color_spec,=0A= +=20=20=20=20=20=20=201,=201,=200,=0A+=20=20=20=20=20=20=20doc:=20/*=20= Parse=20STRING=20as=20a=20numeric=20colour=20and=20return=20(R=20G=20B).=0A= +Recognised=20formats=20are:=0A+=0A+=20#RGB,=20where=20R,=20G=20and=20B=20= are=20hex=20strings=20of=20equal=20length,=201-4=20digits=20each=0A+=20= rgb:R/G/B,=20where=20R,=20G,=20and=20B=20are=20hex=20strings,=201-4=20= digits=20each=0A+=20rgbi:R/G/B,=20where=20R,=20G=20and=20B=20are=20= numbers=20in=20[0,1].=0A+=0A+The=20result=20is=20normalised=20to=20a=20= maximum=20value=20of=2065535=20per=20component.=0A+If=20STRING=20is=20= not=20in=20one=20of=20the=20above=20forms,=20return=20nil.=20=20*/)=0A+=20= =20(Lisp_Object=20string)=0A+{=0A+=20=20unsigned=20short=20r,=20g,=20b;=0A= +=20=20return=20(parse_color_spec=20(SSDATA=20(string),=20&r,=20&g,=20= &b)=0A+=20=20=20=20=20=20=20=20=20=20?=20list3i=20(r,=20g,=20b)=0A+=20=20= =20=20=20=20=20=20=20=20:=20Qnil);=0A+}=0A+=0A=20/*=20Parse=20RGB_LIST,=20= and=20fill=20in=20the=20RGB=20fields=20of=20COLOR.=0A=20=20=20=20= RGB_LIST=20should=20contain=20(at=20least)=203=20lisp=20integers.=0A=20=20= =20=20Return=20true=20iff=20RGB_LIST=20is=20OK.=20=20*/=0A@@=20-7018,4=20= +7129,5=20@@=20syms_of_xfaces=20(void)=0A=20=20=20defsubr=20= (&Sinternal_face_x_get_resource);=0A=20=20=20defsubr=20= (&Sx_family_fonts);=0A=20#endif=0A+=20=20defsubr=20= (&Scolor_values_from_color_spec);=0A=20}=0Adiff=20--git=20a/src/xterm.c=20= b/src/xterm.c=0Aindex=207989cecec7..6340700cb8=20100644=0A---=20= a/src/xterm.c=0A+++=20b/src/xterm.c=0A@@=20-2376,8=20+2376,6=20@@=20= x_query_frame_background_color=20(struct=20frame=20*f,=20XColor=20= *bgcolor)=0A=20=20=20x_query_colors=20(f,=20bgcolor,=201);=0A=20}=0A=20=0A= -#define=20HEX_COLOR_NAME_LENGTH=2032=0A-=0A=20/*=20On=20frame=20F,=20= translate=20the=20color=20name=20to=20RGB=20values.=20=20Use=20cached=0A=20= =20=20=20information,=20if=20possible.=0A=20=0A@@=20-2389,44=20+2387,23=20= @@=20#define=20HEX_COLOR_NAME_LENGTH=2032=0A=20Status=20x_parse_color=20= (struct=20frame=20*f,=20const=20char=20*color_name,=0A=20=09=09=20=20=20=20= =20=20XColor=20*color)=0A=20{=0A+=20=20/*=20Don't=20pass=20#RGB=20= strings=20directly=20to=20XParseColor,=20because=20that=0A+=20=20=20=20=20= follows=20the=20X=20convention=20of=20zero-extending=20each=20channel=0A= +=20=20=20=20=20value:=20#f00=20means=20#f00000.=20=20We=20want=20the=20= convention=20of=20scaling=0A+=20=20=20=20=20channel=20values,=20so=20= #f00=20means=20#ff0000,=20just=20as=20it=20does=20for=0A+=20=20=20=20=20= HTML,=20SVG,=20and=20CSS.=20=20*/=0A+=20=20unsigned=20short=20r,=20g,=20= b;=0A+=20=20if=20(parse_color_spec=20(color_name,=20&r,=20&g,=20&b))=0A+=20= =20=20=20{=0A+=20=20=20=20=20=20color->red=20=3D=20r;=0A+=20=20=20=20=20=20= color->green=20=3D=20g;=0A+=20=20=20=20=20=20color->blue=20=3D=20b;=0A+=20= =20=20=20=20=20return=201;=0A+=20=20=20=20}=0A+=0A=20=20=20Display=20= *dpy=20=3D=20FRAME_X_DISPLAY=20(f);=0A=20=20=20Colormap=20cmap=20=3D=20= FRAME_X_COLORMAP=20(f);=0A=20=20=20struct=20color_name_cache_entry=20= *cache_entry;=0A-=0A-=20=20if=20(color_name[0]=20=3D=3D=20'#')=0A-=20=20=20= =20{=0A-=20=20=20=20=20=20/*=20Don't=20pass=20#RGB=20strings=20directly=20= to=20XParseColor,=20because=20that=0A-=09=20follows=20the=20X=20= convention=20of=20zero-extending=20each=20channel=0A-=09=20value:=20#f00=20= means=20#f00000.=20=20We=20want=20the=20convention=20of=20scaling=0A-=09=20= channel=20values,=20so=20#f00=20means=20#ff0000,=20just=20as=20it=20does=20= for=0A-=09=20HTML,=20SVG,=20and=20CSS.=0A-=0A-=09=20So=20we=20translate=20= #f00=20to=20rgb:f/0/0,=20which=20X=20handles=0A-=09=20differently.=20*/=0A= -=20=20=20=20=20=20char=20rgb_color_name[HEX_COLOR_NAME_LENGTH];=0A-=20=20= =20=20=20=20int=20len=20=3D=20strlen=20(color_name);=0A-=20=20=20=20=20=20= int=20digits_per_channel;=0A-=20=20=20=20=20=20if=20(len=20=3D=3D=204)=0A= -=09digits_per_channel=20=3D=201;=0A-=20=20=20=20=20=20else=20if=20(len=20= =3D=3D=207)=0A-=09digits_per_channel=20=3D=202;=0A-=20=20=20=20=20=20= else=20if=20(len=20=3D=3D=2010)=0A-=09digits_per_channel=20=3D=203;=0A-=20= =20=20=20=20=20else=20if=20(len=20=3D=3D=2013)=0A-=09digits_per_channel=20= =3D=204;=0A-=20=20=20=20=20=20else=0A-=09return=200;=0A-=0A-=20=20=20=20=20= =20snprintf=20(rgb_color_name,=20sizeof=20rgb_color_name,=20= "rgb:%.*s/%.*s/%.*s",=0A-=09=09digits_per_channel,=20color_name=20+=201,=0A= -=09=09digits_per_channel,=20color_name=20+=20digits_per_channel=20+=20= 1,=0A-=09=09digits_per_channel,=20color_name=20+=202=20*=20= digits_per_channel=20+=201);=0A-=0A-=20=20=20=20=20=20/*=20The=20rgb=20= form=20is=20parsed=20directly=20by=20XParseColor=20without=0A-=09=20= talking=20to=20the=20X=20server.=20=20No=20need=20for=20caching.=20=20*/=0A= -=20=20=20=20=20=20return=20XParseColor=20(dpy,=20cmap,=20= rgb_color_name,=20color);=0A-=20=20=20=20}=0A-=0A=20=20=20for=20= (cache_entry=20=3D=20FRAME_DISPLAY_INFO=20(f)->color_names;=20= cache_entry;=0A=20=20=20=20=20=20=20=20cache_entry=20=3D=20= cache_entry->next)=0A=20=20=20=20=20{=0Adiff=20--git=20= a/test/src/xfaces-tests.el=20b/test/src/xfaces-tests.el=0Aindex=20= 5ed16c9e51..72bfba5192=20100644=0A---=20a/test/src/xfaces-tests.el=0A+++=20= b/test/src/xfaces-tests.el=0A@@=20-24,4=20+24,27=20@@=20= xfaces-color-distance=0A=20=20=20(should=20(equal=20(color-distance=20= "#222222"=20"#ffffff")=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20(color-distance=20"#ffffff"=20"#222222"))))=0A=20=0A+(ert-deftest=20= xfaces-color-values-from-color-spec=20()=0A+=20=20(should=20(equal=20= (color-values-from-color-spec=20"#f05")=0A+=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20'(#xffff=20#x0000=20#x5555)))=0A+=20=20(should=20= (equal=20(color-values-from-color-spec=20"#1fb0C5")=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20'(#x1f1f=20#xb0b0=20#xc5c5)))=0A+=20=20= (should=20(equal=20(color-values-from-color-spec=20"#1f8b0AC5e")=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'(#x1f81=20#xb0aa=20= #xc5eb)))=0A+=20=20(should=20(equal=20(color-values-from-color-spec=20= "#1f83b0ADC5e2")=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= '(#x1f83=20#xb0ad=20#xc5e2)))=0A+=20=20(should=20(equal=20= (color-values-from-color-spec=20"#1f83b0ADC5e2g")=20nil))=0A+=20=20= (should=20(equal=20(color-values-from-color-spec=20"#1f83b0ADC5e20")=20= nil))=0A+=20=20(should=20(equal=20(color-values-from-color-spec=20= "#12345")=20nil))=0A+=20=20(should=20(equal=20= (color-values-from-color-spec=20"rgb:f/23/28a")=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20'(#xffff=20#x2323=20#x28a2)))=0A+=20=20= (should=20(equal=20(color-values-from-color-spec=20"rgb:1234/5678/09ab")=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'(#x1234=20#x5678=20= #x09ab)))=0A+=20=20(should=20(equal=20(color-values-from-color-spec=20= "rgb:0//0")=20nil))=0A+=20=20(should=20(equal=20= (color-values-from-color-spec=20"rgbi:0/0.5/0.1")=0A+=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20'(0=2032768=206554)))=0A+=20=20(should=20= (equal=20(color-values-from-color-spec=20"rgbi:1e-3/1.0e-2/1e0")=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'(66=20655=2065535)))=0A+=20= =20(should=20(equal=20(color-values-from-color-spec=20"rgbi:0/0.5/10")=20= nil)))=0A+=0A=20(provide=20'xfaces-tests)=0A--=20=0A2.21.1=20(Apple=20= Git-122.3)=0A=0A= --Apple-Mail=_DF1D45F9-6A8E-4501-9943-D765E50A9433--