Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 24137 | Differences between
and this patch

Collapse All | Expand All

(-)./xmms/playlist.c.old (-3 / +4 lines)
Lines 543-549 Link Here
543
		/* If there are entries */
543
		/* If there are entries */
544
		if (g_list_length(skinlist)) {
544
		if (g_list_length(skinlist)) {
545
			/* Get a random value to select the skin to use */
545
			/* Get a random value to select the skin to use */
546
			int randval = random() % (g_list_length(skinlist) + 1);
546
			int len = (g_list_length(skinlist) + 1); 
547
			int randval = (int)((double)random() / RAND_MAX * len);
547
			/* If the random value is 0, use the default skin */
548
			/* If the random value is 0, use the default skin */
548
			/* Otherwise subtract 1 from the random value and */
549
			/* Otherwise subtract 1 from the random value and */
549
			/* select the skin */
550
			/* select the skin */
Lines 1601-1614 Link Here
1601
	for (node = list, i = 0; i < len; node = g_list_next(node), i++)
1602
	for (node = list, i = 0; i < len; node = g_list_next(node), i++)
1602
		ptrs[i] = node;
1603
		ptrs[i] = node;
1603
1604
1604
	j = random() % len;
1605
	j = (gint)((double)random() / RAND_MAX * len); 
1605
	list = ptrs[j];
1606
	list = ptrs[j];
1606
	ptrs[j]->next = NULL;
1607
	ptrs[j]->next = NULL;
1607
	ptrs[j] = ptrs[0];
1608
	ptrs[j] = ptrs[0];
1608
1609
1609
	for (i = 1; i < len; i++)
1610
	for (i = 1; i < len; i++)
1610
	{
1611
	{
1611
		j = random() % (len - i);
1612
		j = (gint)((double)random() / RAND_MAX * (len - i));
1612
		list->prev = ptrs[i + j];
1613
		list->prev = ptrs[i + j];
1613
		ptrs[i + j]->next = list;
1614
		ptrs[i + j]->next = list;
1614
		list = ptrs[i + j];
1615
		list = ptrs[i + j];

Return to bug 24137