GNU bug report logs - #60311
json-available-p: make dynamically correct for Windows

Previous Next

Package: emacs;

Reported by: Mattias Engdegård <mattias.engdegard <at> gmail.com>

Date: Sun, 25 Dec 2022 14:33:01 UTC

Severity: normal

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Mattias Engdegård <mattias.engdegard <at> gmail.com>
Subject: bug#60311: closed (Re: bug#60311: json-available-p: make
 dynamically correct for Windows)
Date: Mon, 26 Dec 2022 13:31:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#60311: json-available-p: make dynamically correct for Windows

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 60311 <at> debbugs.gnu.org.

-- 
60311: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=60311
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Mattias Engdegård <mattias.engdegard <at> gmail.com>
Cc: 60311-done <at> debbugs.gnu.org
Subject: Re: bug#60311: json-available-p: make dynamically correct for Windows
Date: Mon, 26 Dec 2022 15:29:58 +0200
> From: Mattias Engdegård <mattias.engdegard <at> gmail.com>
> Date: Mon, 26 Dec 2022 13:11:21 +0100
> Cc: 60311 <at> debbugs.gnu.org
> 
> 25 dec. 2022 kl. 16.40 skrev Eli Zaretskii <eliz <at> gnu.org>:
> 
> > Yes, you are right.  But please come up with a smaller changeset which
> > only changes what strictly needs to be changed.  Or if you want, I can
> > do this myself.
> 
> Since you have very specific ideas about how to go about it it's better that you make the change yourself.

Done.

> > why not just
> > 
> >  (and (fboundp 'json--available-p)
> >       (json--available-p))
> 
> Calling `fboundp` at run time is wasteful, and that patch used the presence of json--available-p to indicate whether it needs to be called at run time (on Windows only, but it's good to keep that platform-dependency in one place).

Yes, but using eval-when-compile precludes defining json--available-p
at run time, something that I don't like doing in Emacs, since it's
IMO against the Emacs's spirit of being interpreter based.

So I went with the simpler definition that doesn't assume functions
are only defined at byte-compile time.

Thanks, I'm now closing the bug.

[Message part 3 (message/rfc822, inline)]
From: Mattias Engdegård <mattias.engdegard <at> gmail.com>
To: Emacs Bug Report <bug-gnu-emacs <at> gnu.org>
Subject: json-available-p: make dynamically correct for Windows
Date: Sun, 25 Dec 2022 15:32:06 +0100
[Message part 4 (text/plain, inline)]
The implementation of `json-available-p`,

  (and (fboundp 'json-serialize)
       (condition-case nil
           (json-serialize t)
         (:success t)
         (json-unavailable nil))))

probably isn't quite right on Windows: `json-serialize` is pure so it will be called at compile time and the result, "true", used in the code (actually not even that since the result is never used). Thus, if libjansson could not be loaded during actual Emacs use (as opposed to when Emacs was built), this would never be detected and json-available-p would still return t.

The patch below should take care of this. Would someone please help testing it on Windows?

[json-available-p.diff (application/octet-stream, attachment)]

This bug report was last modified 2 years and 202 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.