[MPlayer-cvslog] r32630 - in trunk: gui/interface.c libmenu/menu_pt.c mplayer.c path.c path.h
cboesch
subversion at mplayerhq.hu
Tue Nov 16 22:06:52 CET 2010
Author: cboesch
Date: Tue Nov 16 22:06:52 2010
New Revision: 32630
Log:
Export mp_basename in a function instead of duplicate macros in various places
Modified:
trunk/gui/interface.c
trunk/libmenu/menu_pt.c
trunk/mplayer.c
trunk/path.c
trunk/path.h
Modified: trunk/gui/interface.c
==============================================================================
--- trunk/gui/interface.c Tue Nov 16 20:58:54 2010 (r32629)
+++ trunk/gui/interface.c Tue Nov 16 22:06:52 2010 (r32630)
@@ -1134,8 +1134,6 @@ void * gtkSet( int cmd,float fparam, voi
return NULL;
}
-#define mp_basename(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1))
-
#include "playtree.h"
//This function adds/inserts one file into the gui playlist
Modified: trunk/libmenu/menu_pt.c
==============================================================================
--- trunk/libmenu/menu_pt.c Tue Nov 16 20:58:54 2010 (r32629)
+++ trunk/libmenu/menu_pt.c Tue Nov 16 22:06:52 2010 (r32630)
@@ -24,6 +24,7 @@
#include "config.h"
#include "mp_msg.h"
#include "help_mp.h"
+#include "path.h"
#include "libmpcodecs/img_format.h"
#include "libmpcodecs/mp_image.h"
@@ -38,8 +39,6 @@
#include "input/input.h"
#include "access_mpcontext.h"
-#define mp_basename(s) (strrchr((s),'/')==NULL?(char*)(s):(strrchr((s),'/')+1))
-
struct list_entry_s {
struct list_entry p;
play_tree_t* pt;
@@ -156,7 +155,7 @@ static int op(menu_t* menu, char* args)
for( ; i != NULL ; i = i->next ) {
e = calloc(1,sizeof(list_entry_t));
if(i->files)
- e->p.txt = mp_basename(i->files[0]);
+ e->p.txt = (char *)mp_basename(i->files[0]);
else
e->p.txt = "Group ...";
e->pt = i;
Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c Tue Nov 16 20:58:54 2010 (r32629)
+++ trunk/mplayer.c Tue Nov 16 22:06:52 2010 (r32630)
@@ -349,8 +349,6 @@ static int crash_debug = 0;
#include "cfg-mplayer.h"
-#define mp_basename2(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1))
-
const void *mpctx_get_video_out(MPContext *mpctx)
{
return mpctx->video_out;
@@ -456,7 +454,7 @@ char *get_metadata (metadata_t type) {
{
case META_NAME:
{
- return strdup (mp_basename2 (filename));
+ return strdup(mp_basename(filename));
}
case META_VIDEO_CODEC:
@@ -1046,8 +1044,6 @@ static int libmpdemux_was_interrupted(in
return eof;
}
-#define mp_basename(s) (strrchr(s,'\\')==NULL?(mp_basename2(s)):(strrchr(s,'\\')+1))
-
static int playtree_add_playlist(play_tree_t* entry)
{
play_tree_add_bpf(entry,filename);
@@ -3174,7 +3170,7 @@ while (player_idle_mode && !filename) {
mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Playing,
filename_recode(filename));
if(use_filename_title && vo_wintitle == NULL)
- vo_wintitle = strdup ( mp_basename2 (filename));
+ vo_wintitle = strdup(mp_basename(filename));
}
edl_loadfile();
@@ -3368,7 +3364,8 @@ if (mpctx->demuxer && mpctx->demuxer->ty
current_module="handle_demux_playlist";
while (ds_get_packet(mpctx->demuxer->video,&playlist_entry)>0)
{
- char *temp, *bname;
+ char *temp;
+ const char *bname;
mp_msg(MSGT_CPLAYER,MSGL_V,"Adding file %s to element entry.\n",
filename_recode(playlist_entry));
Modified: trunk/path.c
==============================================================================
--- trunk/path.c Tue Nov 16 20:58:54 2010 (r32629)
+++ trunk/path.c Tue Nov 16 22:06:52 2010 (r32630)
@@ -193,3 +193,16 @@ void set_codec_path(const char *path)
strcpy(codec_path, path);
needs_free = 1;
}
+
+const char *mp_basename(const char *path)
+{
+ char *s;
+
+#if HAVE_DOS_PATHS
+ s = strrchr(path, '\\');
+ if (s)
+ return s + 1;
+#endif
+ s = strrchr(path, '/');
+ return s ? s + 1 : s;
+}
Modified: trunk/path.h
==============================================================================
--- trunk/path.h Tue Nov 16 20:58:54 2010 (r32629)
+++ trunk/path.h Tue Nov 16 22:06:52 2010 (r32630)
@@ -26,5 +26,6 @@ extern char *codec_path;
char *get_path(const char *filename);
void set_path_env(void);
void set_codec_path(const char *path);
+const char *mp_basename(const char *path);
#endif /* MPLAYER_PATH_H */
More information about the MPlayer-cvslog
mailing list