On Sun, Apr 05, 2009 at 12:43:07PM -0600, Bob Beck wrote:
>       Someone please have a look, and either commit it or tell me to.

If you add the following patch to the port's makefile, it's ok:

Index: Makefile
===================================================================
RCS file: /cvs/ports/audio/mpd/Makefile,v
retrieving revision 1.16
diff -u -p -r1.16 Makefile
--- Makefile    28 Oct 2008 15:21:48 -0000      1.16
+++ Makefile    5 Apr 2009 19:12:26 -0000
@@ -2,7 +2,7 @@
 
 COMMENT=               Music Player Daemon
 DISTNAME=              mpd-0.13.2
-PKGNAME=               ${DISTNAME}p2
+PKGNAME=               ${DISTNAME}p3
 CATEGORIES=            audio
 HOMEPAGE=              http://www.musicpd.org/
 MAINTAINER=            Tobias Ulmer <tobi...@tmux.org>

> 
>       -Bob
> 
> ----8<----
> Index: patch-src_playlist_c
> ===================================================================
> RCS file: patch-src_playlist_c
> diff -N patch-src_playlist_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patch-src_playlist_c      5 Apr 2009 18:27:42 -0000
> @@ -0,0 +1,57 @@
> +--- src/playlist.c.orig      Sun Apr  5 12:11:54 2009
> ++++ src/playlist.c   Sun Apr  5 12:06:13 2009
> +@@ -1189,15 +1189,23 @@
> +             }
> +     }
> + 
> +-    for (i = start; i <= end; i++) {
> +-            ri = random() % (end - start + 1) + start;
> +-            if (ri == playlist.current)
> +-                    playlist.current = i;
> +-            else if (i == playlist.current)
> +-                    playlist.current = ri;
> +-            swapOrder(i, ri);
> ++    /*
> ++     * Shuffle the Order.
> ++     * Use an unbiased Fisher-Yates shuffle.
> ++     */
> ++    i = end + 1;
> ++    while (i > start + 1) {
> ++            ri = random() % (i - start); /* 0 <= ri <= len */
> ++            ri += start;
> ++            i--; /* i is now the last pertinent index */
> ++            if (i != ri)  { /* do nothing if i == ri */
> ++                    if (ri == playlist.current)
> ++                            playlist.current = i;
> ++                    else if (i == playlist.current)
> ++                            playlist.current = ri;
> ++                    swapOrder(i, ri);
> ++            }
> +     }
> +-
> + }
> + 
> + int setPlaylistRandomStatus(int fd, int status)
> +@@ -1281,12 +1289,17 @@
> +                     i = 0;
> +                     playlist.current = -1;
> +             }
> +-            /* shuffle the rest of the list */
> +-            for (; i < playlist.length; i++) {
> +-                    ri = random() % (playlist.length - 1) + 1;
> +-                    swapSongs(i, ri);
> ++            /*
> ++             * shuffle the rest of the list
> ++             * Use an unbiased Fisher-Yates shuffle.
> ++             */
> ++            i = playlist.length;
> ++            while (i > 1) {
> ++                    ri = random() % i; /* 0 <= ri <= len */
> ++                    i--; /* i is now the last pertinent index */
> ++                    if (i != ri) /* do nothing if i == ri */
> ++                            swapSongs(i, ri);
> +             }
> +-
> +             incrPlaylistVersion();
> +     }
> + 
> 
> 
> 
>       

-- 
Echte Männer [tm] lieben Autos. Und wenn Macs schon Mädchencomputer sind,
muss man das ja irgendwie kompensieren.
                -- Markus Hippeli in de.comp.sys.mac.{misc,soc}

Reply via email to