[MPlayer-dev-eng] [PATCH] Add support for directory-wide configuration overrides V2.0

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Aug 31 11:55:05 CEST 2009


On Mon, Aug 31, 2009 at 11:52:02AM +0300, Christian P. Schmidt wrote:
> Reimar Döffinger wrote:
> > On Mon, Aug 31, 2009 at 10:32:19AM +0300, Christian P. Schmidt wrote:
> >> Diego Biurrun wrote:
> >>> On Sun, Aug 30, 2009 at 03:04:12PM +0300, Christian P. Schmidt wrote:
> >>>> --- mplayer.c	(revision 29565)
> >>>> +++ mplayer.c	(working copy)
> >>>> @@ -916,10 +917,26 @@
> >>>>  
> >>>> +    if (use_filedir_conf)
> >>>> +    {
> >>> if (use_filedir_conf) {
> >> That breaks the style currently in use in the function. Is it ok to mix
> >> styles?
> > 
> > Sorry you already got the cosmetic comments, the more significant is
> > that there is already code to find the start of the file name a few
> > lines below, you should move that up and reuse instead of duplicating
> > it (so I'll only have to fix one place once I find the time to test on
> > Windows).
> 
> Right, redid the whole function.

I was thinking of something that makes the whole thing (patch and
resulting code) simpler, not more confusing.
Something similar to this untested patch:
Index: mplayer.c
===================================================================
--- mplayer.c   (revision 29603)
+++ mplayer.c   (working copy)
@@ -930,19 +930,27 @@
 static void load_per_file_config (m_config_t* conf, const char *const file)
 {
     char *confpath;
-    char cfg[strlen(file)+10];
+    char cfg[strlen(file)+14];
+    char bak[strlen(file)+14];
     char *name;
 
     sprintf (cfg, "%s.conf", file);
 
-    if (use_filedir_conf && try_load_config(conf, cfg))
-       return;
-
     if ((name = strrchr (cfg, '/')) == NULL)
        name = cfg;
     else
        name++;
 
+    if (use_filedir_conf) {
+        strcpy(bak, cfg);
+        strcpy(name, "mplayer.conf");
+        try_load_config(conf, cfg);
+        strcpy(cfg, bak);
+    }
+
+    if (use_filedir_conf && try_load_config(conf, cfg))
+       return;
+
     if ((confpath = get_path (name)) != NULL)
     {
        try_load_config(conf, confpath);



More information about the MPlayer-dev-eng mailing list