[timidity++] Provide a new trysource config file directive (rhbz#815611)

Hans de Goede jwrdegoede at fedoraproject.org
Mon Apr 30 08:25:57 UTC 2012


commit 599bcbbb280287ff101cb7c8e66a412f72f2b745
Author: Hans de Goede <hdegoede at redhat.com>
Date:   Mon Apr 30 10:29:37 2012 +0200

    Provide a new trysource config file directive (rhbz#815611)

 0019-Add-trysource-conf-directive.patch |  250 +++++++++++++++++++++++++++++++
 timidity++.spec                         |   10 +-
 2 files changed, 259 insertions(+), 1 deletions(-)
---
diff --git a/0019-Add-trysource-conf-directive.patch b/0019-Add-trysource-conf-directive.patch
new file mode 100644
index 0000000..055f74f
--- /dev/null
+++ b/0019-Add-trysource-conf-directive.patch
@@ -0,0 +1,250 @@
+Subject: Add a trysource config file directive
+
+Add a "trysource" config file directive, which allows to try and source
+other config files, while continuing without error if the specified file
+is missing.
+
+Also cleanup the user config loading code using this new functionality.
+
+Signed-off-by: Hans de Goede <hdegoede at redhat.com>
+diff -up timidity/timidity/mac_main.c.trysource timidity/timidity/mac_main.c
+--- timidity/timidity/mac_main.c.trysource	2004-01-20 23:42:06.000000000 +0100
++++ timidity/timidity/mac_main.c	2012-04-30 09:41:12.835674406 +0200
+@@ -63,7 +63,6 @@ MAIN_INTERFACE int	timidity_pre_load_con
+ MAIN_INTERFACE int	timidity_post_load_configuration(void);
+ MAIN_INTERFACE void	timidity_init_player(void);
+ MAIN_INTERFACE int	timidity_play_main(int nfiles, char **files);
+-MAIN_INTERFACE int	read_config_file(char *name, int self);
+ MAIN_INTERFACE void	timidity_init_aq_buff(void);
+ 
+ extern char *wrdt_open_opts;
+diff -up timidity/timidity/timidity.c.trysource timidity/timidity/timidity.c
+--- timidity/timidity/timidity.c.trysource	2012-04-30 09:40:07.051496822 +0200
++++ timidity/timidity/timidity.c	2012-04-30 09:59:18.958096005 +0200
+@@ -1219,7 +1219,11 @@ static char *expand_variables(char *stri
+     reuse_mblock(&varbuf); \
+     close_file(tf); return 1; }
+ 
+-MAIN_INTERFACE int read_config_file(char *name, int self)
++#define READ_CONFIG_SUCCESS        0
++#define READ_CONFIG_ERROR          1
++#define READ_CONFIG_RECURSION      2 /* Too much recursion */
++#define READ_CONFIG_FILE_NOT_FOUND 3 /* Returned only w. allow_missing_file */
++static int read_config_file(char *name, int self, int allow_missing_file)
+ {
+     struct timidity_file *tf;
+     char buf[1024], *tmp, *w[MAXWORDS + 1], *cp;
+@@ -1244,9 +1248,9 @@ MAIN_INTERFACE int read_config_file(char
+ 	name = "(configuration)";
+     }
+     else
+-	tf = open_file(name, 1, OF_VERBOSE);
++	tf = open_file(name, 1, allow_missing_file ? OF_NORMAL : OF_VERBOSE);
+     if(tf == NULL)
+-	return 1;
++	return allow_missing_file ? 3 : 1;
+ 
+ 	init_mblock(&varbuf);
+ 	if (!self)
+@@ -2219,7 +2223,7 @@ MAIN_INTERFACE int read_config_file(char
+ 	    for(i = 1; i < words; i++)
+ 		add_to_pathlist(w[i]);
+ 	}
+-	else if(!strcmp(w[0], "source"))
++	else if(!strcmp(w[0], "source") || !strcmp(w[0], "trysource"))
+ 	{
+ 	    if(words < 2)
+ 	    {
+@@ -2232,19 +2236,20 @@ MAIN_INTERFACE int read_config_file(char
+ 	    {
+ 		int status;
+ 		rcf_count++;
+-		status = read_config_file(w[i], 0);
++		status = read_config_file(w[i], 0, !strcmp(w[0], "trysource"));
+ 		rcf_count--;
+-		if(status == 2)
+-		{
++		switch (status) {
++		case READ_CONFIG_SUCCESS:
++		    break;
++		case READ_CONFIG_ERROR:
++		    CHECKERRLIMIT;
++		    continue;
++		case READ_CONFIG_RECURSION:
+ 		    reuse_mblock(&varbuf);
+ 		    close_file(tf);
+ 		    return 2;
+-		}
+-		else if(status != 0)
+-		{
+-
+-		    CHECKERRLIMIT;
+-		    continue;
++		case READ_CONFIG_FILE_NOT_FOUND:
++		    break;
+ 		}
+ 	    }
+ 	}
+@@ -2482,58 +2487,40 @@ static int read_user_config_file(void)
+ {
+     char *home;
+     char path[BUFSIZ];
+-    int opencheck;
++    int status;
+ 
++    home = getenv("HOME");
+ #ifdef __W32__
+ /* HOME or home */
+-    home = getenv("HOME");
+     if(home == NULL)
+ 	home = getenv("home");
++#endif
+     if(home == NULL)
+     {
+ 	ctl->cmsg(CMSG_INFO, VERB_NOISY,
+ 		  "Warning: HOME environment is not defined.");
+ 	return 0;
+     }
+-/* .timidity.cfg or timidity.cfg */
++
++#ifdef __W32__
++/* timidity.cfg or _timidity.cfg or .timidity.cfg*/
+     sprintf(path, "%s" PATH_STRING "timidity.cfg", home);
+-    if((opencheck = open(path, 0)) < 0)
+-    {
+-	sprintf(path, "%s" PATH_STRING "_timidity.cfg", home);
+-	if((opencheck = open(path, 0)) < 0)
+-	{
+-	    sprintf(path, "%s" PATH_STRING ".timidity.cfg", home);
+-	    if((opencheck = open(path, 0)) < 0)
+-	    {
+-		ctl->cmsg(CMSG_INFO, VERB_NOISY, "%s: %s",
+-			  path, strerror(errno));
+-		return 0;
+-	    }
+-	}
+-    }
++    status = read_config_file(path, 0, 1);
++    if (status != READ_CONFIG_FILE_NOT_FOUND)
++        return status;
++
++    sprintf(path, "%s" PATH_STRING "_timidity.cfg", home);
++    status = read_config_file(path, 0, 1);
++    if (status != READ_CONFIG_FILE_NOT_FOUND)
++        return status;
++#endif
+ 
+-    close(opencheck);
+-    return read_config_file(path, 0);
+-#else
+-    home = getenv("HOME");
+-    if(home == NULL)
+-    {
+-	ctl->cmsg(CMSG_INFO, VERB_NOISY,
+-		  "Warning: HOME environment is not defined.");
+-	return 0;
+-    }
+     sprintf(path, "%s" PATH_STRING ".timidity.cfg", home);
++    status = read_config_file(path, 0, 1);
++    if (status != READ_CONFIG_FILE_NOT_FOUND)
++        return status;
+ 
+-    if((opencheck = open(path, 0)) < 0)
+-    {
+-	ctl->cmsg(CMSG_INFO, VERB_NOISY, "%s: %s",
+-		  path, strerror(errno));
+-	return 0;
+-    }
+-
+-    close(opencheck);
+-    return read_config_file(path, 0);
+-#endif /* __W32__ */
++    return 0;
+ }
+ 
+ MAIN_INTERFACE void tmdy_free_config(void)
+@@ -3029,7 +3016,7 @@ static inline int parse_opt_c(char *arg)
+ 	if (got_a_configuration == 1)
+ 		return 0;
+ #endif
+-	if (read_config_file(arg, 0))
++	if (read_config_file(arg, 0, 0))
+ 		return 1;
+ 	got_a_configuration = 1;
+ 	return 0;
+@@ -5301,7 +5288,7 @@ MAIN_INTERFACE int timidity_pre_load_con
+     if((check = open(local, 0)) >= 0)
+     {
+ 	close(check);
+-	if(!read_config_file(local, 0)) {
++	if(!read_config_file(local, 0, 0)) {
+ 	    got_a_configuration = 1;
+ 		return 0;
+ 	}
+@@ -5321,7 +5308,7 @@ MAIN_INTERFACE int timidity_pre_load_con
+ 	    if((check = open(local, 0)) >= 0)
+ 	    {
+ 		close(check);
+-		if(!read_config_file(local, 0)) {
++		if(!read_config_file(local, 0, 0)) {
+ 		    got_a_configuration = 1;
+ 			return 0;
+ 		}
+@@ -5336,7 +5323,7 @@ MAIN_INTERFACE int timidity_pre_load_con
+     if((check = open(local, 0)) >= 0)
+     {
+ 	close(check);
+-	if(!read_config_file(local, 0)) {
++	if(!read_config_file(local, 0, 0)) {
+ 	    got_a_configuration = 1;
+ 		return 0;
+ 	}
+@@ -5347,9 +5334,9 @@ MAIN_INTERFACE int timidity_pre_load_con
+ 
+ #else
+     /* UNIX */
+-    if(!read_config_file(CONFIG_FILE1, 0))
++    if(!read_config_file(CONFIG_FILE1, 0, 0))
+ 		got_a_configuration = 1;
+-    else if(!read_config_file(CONFIG_FILE2, 0))
++    else if(!read_config_file(CONFIG_FILE2, 0, 0))
+ 		got_a_configuration = 1;
+ #endif
+ 
+@@ -5358,10 +5345,12 @@ MAIN_INTERFACE int timidity_pre_load_con
+      * Please setup each user preference in $HOME/.timidity.cfg
+      * (or %HOME%/timidity.cfg for DOS)
+      */
++    if(read_user_config_file()) {
++	ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
++		  "Error: Syntax error in ~/.timidity.cfg");
++	return 1;
++    }
+ 
+-    if(read_user_config_file())
+-	ctl->cmsg(CMSG_INFO, VERB_NOISY,
+-		  "Warning: Can't read ~/.timidity.cfg correctly");
+     return 0;
+ }
+ 
+@@ -5444,9 +5433,9 @@ MAIN_INTERFACE int timidity_post_load_co
+ 
+     if(!got_a_configuration)
+     {
+-	if(try_config_again && !read_config_file(CONFIG_FILE1, 0))
++	if(try_config_again && !read_config_file(CONFIG_FILE1, 0, 0))
+ 	    got_a_configuration = 1;
+-	else if(try_config_again && !read_config_file(CONFIG_FILE2, 0))
++	else if(try_config_again && !read_config_file(CONFIG_FILE2, 0, 0))
+ 	    got_a_configuration = 1;
+     }
+ 
+@@ -5459,7 +5448,7 @@ MAIN_INTERFACE int timidity_post_load_co
+ 	{
+ 	    for(i = 0; config_string_list[i]; i++)
+ 	    {
+-		if(!read_config_file(config_string_list[i], 1))
++		if(!read_config_file(config_string_list[i], 1, 0))
+ 		    got_a_configuration = 1;
+ 		else
+ 		    cmderr++;
diff --git a/timidity++.spec b/timidity++.spec
index 5de3f75..8bc374d 100644
--- a/timidity++.spec
+++ b/timidity++.spec
@@ -3,7 +3,7 @@
 Summary: A software wavetable MIDI synthesizer
 Name: timidity++
 Version: 2.13.2
-Release: 30.%{cvs_version}%{?dist}
+Release: 31.%{cvs_version}%{?dist}
 Source0: timidity++-%{cvs_version}.tar.gz
 Source1: fedora-timidity.desktop
 Source2: timidity-xaw.desktop
@@ -26,6 +26,7 @@ Patch15: 0015-Get-rid-of-the-dynamic_control_mode-ControlMode.patch
 Patch16: 0016-Silence-dlsym-errors.patch
 Patch17: 0017-Fix-listing-of-dynamic-interfaces-in-help-output.patch
 Patch18: 0018-configure-Don-t-add-lX11-to-the-generic-LIBS.patch
+Patch19: 0019-Add-trysource-conf-directive.patch
 License: GPLv2
 BuildRequires: alsa-lib-devel ncurses-devel gtk2-devel Xaw3d-devel
 BuildRequires: libao-devel libvorbis-devel flac-devel speex-devel
@@ -33,6 +34,9 @@ BuildRequires: jack-audio-connection-kit-devel
 BuildRequires: desktop-file-utils
 BuildRequires: automake
 Requires: soundfont2-default hicolor-icon-theme
+# Make sure we get a version of fluid-soundfont-gm (which is the provider of
+# soundfont2-default) which ships with a valid /etc/timidity++.cfg
+Conflicts: fluid-soundfont-gm <= 3.1-7%{?dist}
 
 %description
 TiMidity++ is a MIDI format to wave table format converter and
@@ -76,6 +80,7 @@ The %{name}-Xaw3D-interface package contains a Xaw3D based UI for %{name}.
 %patch16 -p1
 %patch17 -p1
 %patch18 -p1
+%patch19 -p1
 autoreconf -f -i
 
 
@@ -154,6 +159,9 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
 
 
 %changelog
+* Mon Apr 30 2012 Hans de Goede <hdegoede at redhat.com> - 2.13.2-31.cvs20111110
+- Provide a new trysource config file directive (rhbz#815611)
+
 * Mon Feb 27 2012 Orion Poplawski <orion at cora.nwra.com> - 2.1.13.2-30.cvs20111110
 - Rebuild for Xaw3d 1.6.1 
 


More information about the scm-commits mailing list