From 629c2c4094929614bb1d24418cee3fee08bf64af Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 26 Nov 2021 21:56:58 -0800 Subject: [PATCH] SOUND=foo vs !defined(USER_SOUNDS) Give a better message than "Unknown config statement" if SOUNDDIR or SOUND directives are found in the configuration file being loaded by an executable built without support for USER_SOUNDS. And just give it for the first occurrence since when present there will likely be multiple SOUND instances. It doesn't attempt to deal with the case where the current interface does not support sound but USER_SOUNDS is enabled because another interface in the same executable does. --- include/decl.h | 3 +++ src/decl.c | 1 + src/files.c | 10 +++++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/decl.h b/include/decl.h index 7aae881dd..8a810488f 100644 --- a/include/decl.h +++ b/include/decl.h @@ -930,6 +930,9 @@ struct instance_globals { char *config_section_chosen; char *config_section_current; int nesting; + int no_sound_notified; /* run-time option processing: warn once if built + * without USER_SOUNDS and config file contains + * SOUND=foo or SOUNDDIR=bar */ int symset_count; /* for pick-list building only */ boolean chosen_symset_start; boolean chosen_symset_end; diff --git a/src/decl.c b/src/decl.c index 0c5c1c389..36c60defa 100644 --- a/src/decl.c +++ b/src/decl.c @@ -407,6 +407,7 @@ const struct instance_globals g_init = { NULL, /* config_section_chosen */ NULL, /* config_section_current */ 0, /* nesting */ + 0, /* no_sound_notified */ 0, /* symset_count */ FALSE, /* chosen_symset_start */ FALSE, /* chosen_symset_end */ diff --git a/src/files.c b/src/files.c index fe33836e1..fef6a2c3c 100644 --- a/src/files.c +++ b/src/files.c @@ -2773,7 +2773,15 @@ parse_config_line(char *origbuf) sounddir = dupstr(bufp); } else if (match_varname(buf, "SOUND", 5)) { add_sound_mapping(bufp); -#endif +#else /* !USER_SOUNDS */ + } else if (match_varname(buf, "SOUNDDIR", 8) + || match_varname(buf, "SOUND", 5)) { + if (!g.no_sound_notified++) { + config_error_add("SOUND and SOUNDDIR are not available."); + } + ; /* skip this and any further SOUND or SOUNDDIR lines + * but leave 'retval' set to True */ +#endif /* ?USER_SOUNDS */ } else if (match_varname(buf, "QT_TILEWIDTH", 12)) { #ifdef QT_GRAPHICS extern char *qt_tilewidth;