From eclipse7 at gmx.net Wed Sep 22 22:54:08 2021 From: eclipse7 at gmx.net (Alexander Strasser) Date: Wed, 22 Sep 2021 21:54:08 +0200 Subject: [MPlayer-dev-eng] [PATCH 2/4] libmpdemux/mf: Refactor into one function per pattern type In-Reply-To: References: <936e7c71bcdf33e6768bf453c7902825caaeb6d3.1622577107.git.eclipse7@gmx.net> Message-ID: <20210922195408.GA2946@akuma.local> On 2021-06-01 22:05 +0200, Alexander Strasser wrote: [...] > @@ -158,14 +158,45 @@ mf_t* open_mf(char * filename){ > // mp_msg( MSGT_STREAM,MSGL_V,"[mf] added file %d.: %s\n",mf->nr_of_files,mf->names[mf->nr_of_files] ); > mf->nr_of_files++; > } > - > - fname = NULL; > } > > mp_msg( MSGT_STREAM,MSGL_INFO,"[mf] number of files: %d\n",mf->nr_of_files ); > + return 1; > +} > + > + > +mf_t* open_mf(char * filename){ > +#if defined(HAVE_GLOB) || defined(__MINGW32__) > + mf_t * mf; > + int init_success = 0; > + > + mf=calloc( 1,sizeof( mf_t ) ); > + > + if( filename[0] == '@' ) > + { > + init_success = init_mf_from_list_file(mf, filename); > + } > + /* only try one more init method depending on filename */ Despite this comment the following wasn't really understand: > + if( !init_success && strchr( filename,',') ) > + { > + init_success = init_mf_from_comma_delimited_paths(mf, filename); > + } > + else if ( !init_success && !strchr( filename,'%' ) ) > + { > + init_success = init_mf_from_glob_pattern(mf, filename); > + } > + else if ( !init_success ) > + { > + init_success = init_mf_from_printf_format(mf, filename); > + } I applied this fixup locally to make it more readable (amended patch attached): --->8--- --- a/libmpdemux/mf.c +++ b/libmpdemux/mf.c @@ -197,19 +197,21 @@ mf_t* open_mf(char * filename){ init_success = init_mf_from_list_file(mf, filename); } - /* only try one more init method depending on filename */ - if( !init_success && strchr( filename,',') ) + if( !init_success ) + { + if( strchr( filename,',') ) { init_success = init_mf_from_comma_delimited_paths(mf, filename); } - else if ( !init_success && !strchr( filename,'%' ) ) + else if ( !strchr( filename,'%' ) ) { init_success = init_mf_from_glob_pattern(mf, filename); } - else if ( !init_success ) + else { init_success = init_mf_from_printf_format(mf, filename); } + } if (!init_success) { ---8<--- I want to apply the whole patch set without much of a warning soon-ish. If there are any more comments, now would be a good time. Thanks, Alexander > + > + if (!init_success) > + { > + free(mf); > + return NULL; > + } > > -exit_mf: > - free( fname ); > return mf; > #else > mp_msg(MSGT_STREAM,MSGL_FATAL,"[mf] mf support is disabled on your os\n"); -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-libmpdemux-mf-Refactor-into-one-function-per-pattern.patch Type: text/x-diff Size: 4918 bytes Desc: not available URL: From Reimar.Doeffinger at gmx.de Sun Sep 26 21:10:56 2021 From: Reimar.Doeffinger at gmx.de (=?utf-8?Q?Reimar_D=C3=B6ffinger?=) Date: Sun, 26 Sep 2021 20:10:56 +0200 Subject: [MPlayer-dev-eng] [PATCH 2/4] libmpdemux/mf: Refactor into one function per pattern type In-Reply-To: <20210922195408.GA2946@akuma.local> References: <936e7c71bcdf33e6768bf453c7902825caaeb6d3.1622577107.git.eclipse7@gmx.net> <20210922195408.GA2946@akuma.local> Message-ID: <9EB309E1-9994-41FF-B7A2-6DF71CF9C035@gmx.de> > On 22 Sep 2021, at 21:54, Alexander Strasser wrote: > > - /* only try one more init method depending on filename */ > - if( !init_success && strchr( filename,',') ) > + if( !init_success ) > + { > + if( strchr( filename,',') ) > { > init_success = init_mf_from_comma_delimited_paths(mf, filename); > } > - else if ( !init_success && !strchr( filename,'%' ) ) > + else if ( !strchr( filename,'%' ) ) > { > init_success = init_mf_from_glob_pattern(mf, filename); > } > - else if ( !init_success ) > + else > { > init_success = init_mf_from_printf_format(mf, filename); > } > + } Possibly minor simplification/consistency change: Flip the last 2 cases to remove the negation for the second strchr