From d1621e7230fbdf63a39c7baca4c8a02fcb46b122 Mon Sep 17 00:00:00 2001 From: Scott Mcdermott Date: Mon, 8 Apr 2024 01:55:25 -0700 Subject: [PATCH 1/3] [mailcap] make a meson 'test-mailcap' option that only builds mailcap tests Not all 'test' compiled, and only needed to test mailcap, so separated it out. It will still be built with 'test' option like before. --- meson_options.txt | 1 + src/mime/backend/meson.build | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/meson_options.txt b/meson_options.txt index 7f55c4dd..b5f178e6 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -73,6 +73,7 @@ option('dgi', type: 'boolean', value: false, description: 'DOS Gateway Interface option('mujs', type: 'boolean', value: false, description: 'use mujs library') option('codepoint', type: 'boolean', value: true, description: 'whether check codepoints on Linux console') option('test', type: 'boolean', value: false, description: 'whether build test programs') +option('test-mailcap', type: 'boolean', value: false, description: 'whether build test mailcap program') option('doc', type: 'boolean', value: true, description: 'whether build documentation') option('docdir', type: 'string', value: '', description: 'Documentation installation directory. Default $prefix/share/doc/elinks.') option('apidoc', type: 'boolean', value: true, description: 'whether to generate API docs with doxygen') diff --git a/src/mime/backend/meson.build b/src/mime/backend/meson.build index 99a68c03..fe4e4231 100644 --- a/src/mime/backend/meson.build +++ b/src/mime/backend/meson.build @@ -10,7 +10,7 @@ endif srcs += files('common.c', 'default.c') -if conf_data.get('CONFIG_MAILCAP') and get_option('test') +if conf_data.get('CONFIG_MAILCAP') and (get_option('test-mailcap') or get_option('test')) mailcap_cache_files = files('common.c', 'mailcap.c', meson.source_root()+'/src/osdep/osdep.c') if conf_data.get('CONFIG_NLS') and not conf_data.get('CONFIG_GETTEXT') From afc5ac5deb30611d33954262292f74c23225a700 Mon Sep 17 00:00:00 2001 From: Scott Mcdermott Date: Mon, 8 Apr 2024 02:14:19 -0700 Subject: [PATCH 2/3] [mailcap] silence compiler warning about get_mailcap_path() const qualifier it's declared "const char *path" in "struct option_init", but we're using it as char *, so cast it --- src/mime/backend/mailcap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index 58e3b0b1..97ea6627 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -416,7 +416,7 @@ init_mailcap_map(void) if (!mailcap_map) return NULL; /* Try to setup mailcap_path */ - path = get_mailcap_path(); + path = (char *)get_mailcap_path(); if (!path || !*path) path = getenv("MAILCAP"); if (!path) path = (char *)DEFAULT_MAILCAP_PATH; From dbdd49718d73e493bc1110950f0ea25f02879213 Mon Sep 17 00:00:00 2001 From: Scott Mcdermott Date: Mon, 8 Apr 2024 02:22:43 -0700 Subject: [PATCH 3/3] [mailcap] allow to run 'mailcap-cache' test with --display=0/1 or yes/no the tests do not allow ever matching the entries with DISPLAY=:0 test, since it's hardcoded to force $DISPLAY unset leave default unchanged, (forced unset), but just add a command line flag if user wants to match the entry with $DISPLAY set in mailcap --- src/mime/backend/mailcap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mime/backend/mailcap.c b/src/mime/backend/mailcap.c index 97ea6627..6939f506 100644 --- a/src/mime/backend/mailcap.c +++ b/src/mime/backend/mailcap.c @@ -809,6 +809,7 @@ main(int argc, char *argv[]) { char *format = "description,ask,block,program"; int has_gotten = 0; + int setenv_display = 0; int i; for (i = 1; i < argc; i++) { @@ -826,6 +827,10 @@ main(int argc, char *argv[]) } else if (get_test_opt(&arg, "format", &i, argc, argv, "a string")) { format = arg; + } else if (get_test_opt(&arg, "display", &i, argc, argv, "a string")) { + if (strcmp(arg, "1") == 0 || strcmp(arg, "yes") == 0) + setenv_display = 1; + } else if (get_test_opt(&arg, "get", &i, argc, argv, "a string")) { struct mime_handler *handler; @@ -833,7 +838,7 @@ main(int argc, char *argv[]) printf("\n"); has_gotten = 1; printf("type: %s\n", arg); - handler = get_mime_handler_mailcap(arg, 0); + handler = get_mime_handler_mailcap(arg, setenv_display); if (!handler) continue; if (strstr(format, "description"))