* Hard-to-understand line in xfaces.c
@ 2024-07-22 14:20 Stefan Kangas
2024-07-22 14:35 ` Andrea Corallo
2024-07-22 14:38 ` Pip Cet
0 siblings, 2 replies; 5+ messages in thread
From: Stefan Kangas @ 2024-07-22 14:20 UTC (permalink / raw)
To: emacs-devel
Could someone explain this line in xfaces.c:7184?
len -= 0 < len && name[len - 1] == '\n';
It seems rather mysterious to me; for example, does it actually do
anything?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Hard-to-understand line in xfaces.c
2024-07-22 14:20 Hard-to-understand line in xfaces.c Stefan Kangas
@ 2024-07-22 14:35 ` Andrea Corallo
2024-07-22 14:59 ` Eli Zaretskii
2024-07-22 15:55 ` Stefan Kangas
2024-07-22 14:38 ` Pip Cet
1 sibling, 2 replies; 5+ messages in thread
From: Andrea Corallo @ 2024-07-22 14:35 UTC (permalink / raw)
To: Stefan Kangas; +Cc: emacs-devel
Stefan Kangas <stefankangas@gmail.com> writes:
> Could someone explain this line in xfaces.c:7184?
>
> len -= 0 < len && name[len - 1] == '\n';
>
> It seems rather mysterious to me; for example, does it actually do
> anything?
If len is greater than zero and name[len - 1] is '\n' then is decreasing
len by one. Only form the line I don't have the context of why is doing
that.
Andrea
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Hard-to-understand line in xfaces.c
2024-07-22 14:35 ` Andrea Corallo
@ 2024-07-22 14:59 ` Eli Zaretskii
2024-07-22 15:55 ` Stefan Kangas
1 sibling, 0 replies; 5+ messages in thread
From: Eli Zaretskii @ 2024-07-22 14:59 UTC (permalink / raw)
To: Andrea Corallo; +Cc: stefankangas, emacs-devel
> From: Andrea Corallo <acorallo@gnu.org>
> Cc: emacs-devel@gnu.org
> Date: Mon, 22 Jul 2024 10:35:18 -0400
>
> Stefan Kangas <stefankangas@gmail.com> writes:
>
> > Could someone explain this line in xfaces.c:7184?
> >
> > len -= 0 < len && name[len - 1] == '\n';
> >
> > It seems rather mysterious to me; for example, does it actually do
> > anything?
>
> If len is greater than zero and name[len - 1] is '\n' then is decreasing
> len by one. Only form the line I don't have the context of why is doing
> that.
It wants to exclude the newline from the name of the color (which is
the last field on each line).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Hard-to-understand line in xfaces.c
2024-07-22 14:35 ` Andrea Corallo
2024-07-22 14:59 ` Eli Zaretskii
@ 2024-07-22 15:55 ` Stefan Kangas
1 sibling, 0 replies; 5+ messages in thread
From: Stefan Kangas @ 2024-07-22 15:55 UTC (permalink / raw)
To: Andrea Corallo; +Cc: emacs-devel
Andrea Corallo <acorallo@gnu.org> writes:
> Stefan Kangas <stefankangas@gmail.com> writes:
>
>> Could someone explain this line in xfaces.c:7184?
>>
>> len -= 0 < len && name[len - 1] == '\n';
>>
>> It seems rather mysterious to me; for example, does it actually do
>> anything?
>
> If len is greater than zero and name[len - 1] is '\n' then is decreasing
> len by one.
Doh! Thanks for clearing it up for me.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Hard-to-understand line in xfaces.c
2024-07-22 14:20 Hard-to-understand line in xfaces.c Stefan Kangas
2024-07-22 14:35 ` Andrea Corallo
@ 2024-07-22 14:38 ` Pip Cet
1 sibling, 0 replies; 5+ messages in thread
From: Pip Cet @ 2024-07-22 14:38 UTC (permalink / raw)
To: Stefan Kangas; +Cc: emacs-devel
On Monday, July 22nd, 2024 at 14:20, Stefan Kangas <stefankangas@gmail.com> wrote:
> Could someone explain this line in xfaces.c:7184?
>
> len -= 0 < len && name[len - 1] == '\n';
>
> It seems rather mysterious to me; for example, does it actually do
> anything?
I'd rewrite it as
if (len > 0 && name[len - 1] == '\n')
len--;
though I'd test it actually does the same thing first :-)
Pip
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-07-22 15:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-22 14:20 Hard-to-understand line in xfaces.c Stefan Kangas
2024-07-22 14:35 ` Andrea Corallo
2024-07-22 14:59 ` Eli Zaretskii
2024-07-22 15:55 ` Stefan Kangas
2024-07-22 14:38 ` Pip Cet
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).