[MPlayer-cvslog] r32675 - in trunk: command.c mplayer.c sub/vobsub.c

cboesch subversion at mplayerhq.hu
Sat Dec 4 11:24:43 CET 2010


Author: cboesch
Date: Sat Dec  4 11:24:42 2010
New Revision: 32675

Log:
Make use of mp_basename in a few places.

Modified:
   trunk/command.c
   trunk/mplayer.c
   trunk/sub/vobsub.c

Modified: trunk/command.c
==============================================================================
--- trunk/command.c	Sat Dec  4 02:55:18 2010	(r32674)
+++ trunk/command.c	Sat Dec  4 11:24:42 2010	(r32675)
@@ -284,9 +284,8 @@ static int mp_property_filename(m_option
     char *f;
     if (!filename)
         return M_PROPERTY_UNAVAILABLE;
-    if (((f = strrchr(filename, '/')) || (f = strrchr(filename, '\\'))) && f[1])
-        f++;
-    else
+    f = (char *)mp_basename(filename);
+    if (!*f)
         f = filename;
     return m_property_string_ro(prop, action, arg, f);
 }
@@ -1467,10 +1466,7 @@ static int mp_property_sub(m_option_t *p
             sub_name = ass_track->name;
 #endif
         if (sub_name) {
-            char *tmp, *tmp2;
-            tmp = sub_name;
-            if ((tmp2 = strrchr(tmp, '/')))
-                tmp = tmp2 + 1;
+            const char *tmp = mp_basename(sub_name);
 
             snprintf(*(char **) arg, 63, "(%d) %s%s",
                      mpctx->set_of_sub_pos + 1,

Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c	Sat Dec  4 02:55:18 2010	(r32674)
+++ trunk/mplayer.c	Sat Dec  4 11:24:42 2010	(r32675)
@@ -978,7 +978,7 @@ static void load_per_file_config (m_conf
 {
     char *confpath;
     char cfg[PATH_MAX];
-    char *name;
+    const char *name;
 
     if (strlen(file) > PATH_MAX - 14) {
         mp_msg(MSGT_CPLAYER, MSGL_WARN, "Filename is too long, can not load file or directory specific config files\n");
@@ -986,20 +986,7 @@ static void load_per_file_config (m_conf
     }
     sprintf (cfg, "%s.conf", file);
 
-    name = strrchr(cfg, '/');
-    if (HAVE_DOS_PATHS) {
-        char *tmp = strrchr(cfg, '\\');
-        if (!name || tmp > name)
-            name = tmp;
-        tmp = strrchr(cfg, ':');
-        if (!name || tmp > name)
-            name = tmp;
-    }
-    if (!name)
-	name = cfg;
-    else
-	name++;
-
+    name = mp_basename(cfg);
     if (use_filedir_conf) {
         char dircfg[PATH_MAX];
         strcpy(dircfg, cfg);
@@ -2755,14 +2742,7 @@ int gui_no_filename=0;
       (!strcmp(argv[1], "-gui") || !strcmp(argv[1], "-nogui"))) {
     use_gui = !strcmp(argv[1], "-gui");
   } else
-  if ( argv[0] )
-  {
-    char *base = strrchr(argv[0], '/');
-    if (!base)
-      base = strrchr(argv[0], '\\');
-    if (!base)
-      base = argv[0];
-    if(strstr(base, "gmplayer"))
+  if (argv[0] && strstr(mp_basename(argv[0]), "gmplayer")) {
           use_gui=1;
   }
 
@@ -3205,14 +3185,8 @@ while (player_idle_mode && !filename) {
       vo_vobsub=vobsub_open(buf,spudec_ifo,0,&vo_spudec);
       /* try from ~/.mplayer/sub */
       if(!vo_vobsub && (psub = get_path( "sub/" ))) {
-          char *bname;
+          const char *bname = mp_basename(buf);
           int l;
-          bname = strrchr(buf,'/');
-#if defined(__MINGW32__) || defined(__CYGWIN__)
-          if(!bname) bname = strrchr(buf,'\\');
-#endif
-          if(bname) bname++;
-          else bname = buf;
           l = strlen(psub) + strlen(bname) + 1;
           psub = realloc(psub,l);
           strcat(psub,bname);

Modified: trunk/sub/vobsub.c
==============================================================================
--- trunk/sub/vobsub.c	Sat Dec  4 02:55:18 2010	(r32674)
+++ trunk/sub/vobsub.c	Sat Dec  4 11:24:42 2010	(r32675)
@@ -36,6 +36,7 @@
 #include "vobsub.h"
 #include "spudec.h"
 #include "mp_msg.h"
+#include "path.h"
 #include "unrar_exec.h"
 #include "libavutil/common.h"
 
@@ -95,11 +96,7 @@ static rar_stream_t *rar_open(const char
             strcat(rar_filename, ".rar");
         }
         /* get rid of the path if there is any */
-        if ((p = strrchr(filename, '/')) == NULL) {
-            p = filename;
-        } else {
-            p++;
-        }
+        p = mp_basename(filename);
         rc = unrar_exec_get(&stream->data, &stream->size, p, rar_filename);
         if (!rc) {
             /* There is no matching filename in the archive. However, sometimes


More information about the MPlayer-cvslog mailing list