Enlightenment CVS committal

Author  : tsauerbeck
Project : misc
Module  : eplayer

Dir     : misc/eplayer/src


Modified Files:
        playlist.c 


Log Message:
Misc playlist fixes
===================================================================
RCS file: /cvsroot/enlightenment/misc/eplayer/src/playlist.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -3 -r1.8 -r1.9
--- playlist.c  7 Nov 2003 22:33:28 -0000       1.8
+++ playlist.c  10 Nov 2003 19:02:41 -0000      1.9
@@ -3,6 +3,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <dirent.h>
+#include <unistd.h>
 #include "playlist.h"
 #include "utils.h"
 
@@ -228,17 +229,19 @@
        PlayListItem *pli = NULL;
        Evas_List *tmp = NULL;
        FILE *fp;
-       char buf[1024], path[PATH_MAX + 1], *dir, *ptr;
+       char buf[PATH_MAX + 1], path[PATH_MAX + 1], dir[PATH_MAX + 1];
+       char *ptr;
 
        if (!pl || !(fp = fopen(file, "r")))
                return 0;
 
-       /* get the directory */
-       dir = strdup(file);
-       ptr = strrchr(dir, '/');
-       *ptr = 0;
+       if ((ptr = strrchr(file, '/'))) {
+               snprintf(dir, sizeof(dir), "%s", file);
+               dir[ptr - file] = 0;
+       } else
+               getcwd(dir, sizeof(dir));
 
-       while (fgets(buf, sizeof (buf), fp)) {
+       while (fgets(buf, sizeof(buf), fp)) {
                if (!(ptr = strstrip(buf)) || !*ptr || *ptr == '#')
                        continue;
                else if (*ptr != '/') {
@@ -254,7 +257,6 @@
        }
 
        fclose(fp);
-       free(dir);
 
        tmp = evas_list_reverse(tmp);
        
@@ -278,15 +280,15 @@
  * @return Boolean success or failure.
  */
 int playlist_load_any(PlayList *pl, const char *path, int append) {
-       char *ptr = NULL;
+       int len;
        
        if (is_dir(path))
                return playlist_load_dir(pl, path, append);
 
        /* FIXME we check for m3u using the suffix :/ */
-       ptr = (char *) &path[strlen(path) - 3];
-
-       if (!strcasecmp(ptr, "m3u"))
+       len = strlen(path) - 3;
+       
+       if (len >= 0 && !strcasecmp(&path[len], "m3u"))
                return playlist_load_m3u(pl, path, append);
        else
                return playlist_load_file(pl, path, append);




-------------------------------------------------------
This SF.Net email sponsored by: ApacheCon 2003,
16-19 November in Las Vegas. Learn firsthand the latest
developments in Apache, PHP, Perl, XML, Java, MySQL,
WebDAV, and more! http://www.apachecon.com/
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to