From: Bo YU Date: Fri, 27 Apr 2018 11:14:34 +0000 (+0800) Subject: Move IDN version string to mutt/idna.c X-Git-Tag: neomutt-20180512~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d2d63f77ee51b5cbd82a4fcb3f23b323e0b95977;p=neomutt Move IDN version string to mutt/idna.c --- diff --git a/mutt/idna.c b/mutt/idna.c index ceb893f17..c1fb360ad 100644 --- a/mutt/idna.c +++ b/mutt/idna.c @@ -35,6 +35,11 @@ #include "logging.h" #include "memory.h" #include "string2.h" +#ifdef HAVE_STRINGPREP_H +#include +#elif defined(HAVE_IDN_STRINGPREP_H) +#include +#endif #ifdef HAVE_IDN2_H #include #elif defined(HAVE_IDN_IDN2_H) @@ -265,3 +270,24 @@ cleanup: return mailbox; } + +/** + * mutt_idna_print_version - Create an IDN version string + * @retval str Version string + * + * @note This is a static string and must not be freed. + */ +const char *mutt_idna_print_version(void) +{ + static char vstring[STRING]; + +#ifdef HAVE_IDN2_H + snprintf(vstring, sizeof(vstring), "libidn2: %s (compiled with %s)", + idn2_check_version(NULL), IDN2_VERSION); +#elif defined(HAVE_LIBIDN) + snprintf(vstring, sizeof(vstring), "libidn: %s (compiled with %s)", + stringprep_check_version(NULL), STRINGPREP_VERSION); +#endif + + return vstring; +} diff --git a/mutt/idna2.h b/mutt/idna2.h index bd20a1753..7715d721c 100644 --- a/mutt/idna2.h +++ b/mutt/idna2.h @@ -33,5 +33,7 @@ extern bool IdnEncode; int mutt_idna_to_ascii_lz(const char *input, char **output, int flags); char *mutt_idna_intl_to_local(const char *user, const char *domain, int flags); char *mutt_idna_local_to_intl(const char *user, const char *domain); +const char *mutt_idna_print_version(void); + #endif /* _MUTT_IDNA_H */ diff --git a/version.c b/version.c index 36d880841..d0e6f21bd 100644 --- a/version.c +++ b/version.c @@ -36,20 +36,6 @@ #include #include "mutt/mutt.h" #include "mutt_curses.h" -#ifdef HAVE_STRINGPREP_H -#include -#elif defined(HAVE_IDN_STRINGPREP_H) -#include -#endif -#ifdef HAVE_IDN2_H -#include -#elif defined(HAVE_IDN_IDN2_H) -#include -#elif defined(HAVE_IDNA_H) -#include -#elif defined(HAVE_IDN_IDNA_H) -#include -#endif /* #include "protos.h" */ const char *mutt_make_version(void); @@ -392,10 +378,8 @@ void print_version(void) printf("\nlibiconv: %d.%d", _LIBICONV_VERSION >> 8, _LIBICONV_VERSION & 0xff); #endif -#ifdef HAVE_IDN2_H - printf("\nlibidn: %s (compiled with %s)", idn2_check_version(NULL), IDN2_VERSION); -#elif defined(HAVE_LIBIDN) - printf("\nlibidn: %s (compiled with %s)", stringprep_check_version(NULL), STRINGPREP_VERSION); +#ifdef HAVE_LIBIDN + printf("\n%s", mutt_idna_print_version()); #endif #ifdef USE_HCACHE