From 301a4014a72964a8ec0078055c273d045d94fe42 Mon Sep 17 00:00:00 2001 From: Ted Zlatanov Date: Thu, 11 Dec 2014 17:55:36 -0500 Subject: [PATCH] Always define `gnutls-available-p' even if GnuTLS is not available. Fixes: debbugs:19346 * gnutls.c (Fgnutls_available_p syms_of_gnutls): Move later for clarity. Let the availability check return Qnil when the GnuTLS integration is not available, instead of erroring out. * gnutls.h: Always declare syms_of_gnutls. * emacs.c (main): Always include gnutls.h and run syms_of_gnutls. --- src/ChangeLog | 11 ++++++++++ src/emacs.c | 4 ---- src/gnutls.c | 56 ++++++++++++++++++++++++++++++++------------------- src/gnutls.h | 4 ++-- 4 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index b8663bcf7c0..90139535e30 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2014-12-11 Teodor Zlatanov + + * emacs.c (main): Always include gnutls.h and run syms_of_gnutls. + + * gnutls.h: Always declare syms_of_gnutls. + + * gnutls.c (Fgnutls_available_p syms_of_gnutls): Move later for + clarity. Let the availability check return Qnil when the GnuTLS + integration is not available, instead of erroring out. + (Bug#19346) + 2014-12-10 Eli Zaretskii * xdisp.c (move_it_in_display_line_to, display_line): Don't diff --git a/src/emacs.c b/src/emacs.c index 4c3857e698d..7367e0d35ea 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -82,9 +82,7 @@ along with GNU Emacs. If not, see . */ #include "syntax.h" #include "systime.h" -#ifdef HAVE_GNUTLS #include "gnutls.h" -#endif #if (defined PROFILING \ && (defined __FreeBSD__ || defined GNU_LINUX || defined __MINGW32__)) @@ -1502,9 +1500,7 @@ Using an Emacs configured with --with-x-toolkit=lucid does not have this problem syms_of_fontset (); #endif /* HAVE_NS */ -#ifdef HAVE_GNUTLS syms_of_gnutls (); -#endif #ifdef HAVE_GFILENOTIFY syms_of_gfilenotify (); diff --git a/src/gnutls.c b/src/gnutls.c index 03c29d03014..d1713d379a9 100644 --- a/src/gnutls.c +++ b/src/gnutls.c @@ -673,27 +673,6 @@ See also `gnutls-init'. */) return emacs_gnutls_deinit (proc); } -DEFUN ("gnutls-available-p", Fgnutls_available_p, Sgnutls_available_p, 0, 0, 0, - doc: /* Return t if GnuTLS is available in this instance of Emacs. */) - (void) -{ -#ifdef WINDOWSNT - Lisp_Object found = Fassq (Qgnutls_dll, Vlibrary_cache); - if (CONSP (found)) - return XCDR (found); - else - { - Lisp_Object status; - status = init_gnutls_functions () ? Qt : Qnil; - Vlibrary_cache = Fcons (Fcons (Qgnutls_dll, status), Vlibrary_cache); - return status; - } -#else - return Qt; -#endif -} - - /* Initializes global GnuTLS state to defaults. Call `gnutls-global-deinit' when GnuTLS usage is no longer needed. Returns zero on success. */ @@ -1179,6 +1158,26 @@ This function may also return `gnutls-e-again', or return gnutls_make_error (ret); } +DEFUN ("gnutls-available-p", Fgnutls_available_p, Sgnutls_available_p, 0, 0, 0, + doc: /* Return t if GnuTLS is available in this instance of Emacs. */) + (void) +{ +#ifdef WINDOWSNT + Lisp_Object found = Fassq (Qgnutls_dll, Vlibrary_cache); + if (CONSP (found)) + return XCDR (found); + else + { + Lisp_Object status; + status = init_gnutls_functions () ? Qt : Qnil; + Vlibrary_cache = Fcons (Fcons (Qgnutls_dll, status), Vlibrary_cache); + return status; + } +#else + return Qt; +#endif +} + void syms_of_gnutls (void) { @@ -1233,4 +1232,19 @@ are as per the GnuTLS logging conventions. */); global_gnutls_log_level = 0; } +#else + +DEFUN ("gnutls-available-p", Fgnutls_available_p, Sgnutls_available_p, 0, 0, 0, + doc: /* Return t if GnuTLS is available in this instance of Emacs. */) + (void) +{ + return Qnil; +} + +void +syms_of_gnutls (void) +{ + defsubr (&Sgnutls_available_p); +} + #endif /* HAVE_GNUTLS */ diff --git a/src/gnutls.h b/src/gnutls.h index 8a667c00568..8a18976cf1b 100644 --- a/src/gnutls.h +++ b/src/gnutls.h @@ -82,8 +82,8 @@ extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err); #endif extern Lisp_Object emacs_gnutls_deinit (Lisp_Object); -extern void syms_of_gnutls (void); - #endif +extern void syms_of_gnutls (void); + #endif -- 2.39.2