[MPlayer-dev-eng] [PATCH 2/4] libmpdemux/mf: Refactor into one function per pattern type

Alexander Strasser eclipse7 at gmx.net
Wed Sep 22 22:54:08 EEST 2021


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: <https://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20210922/345fab6e/attachment.patch>


More information about the MPlayer-dev-eng mailing list