diff --git a/src/cmdline.c b/src/cmdline.c index 0187603..e62c3d2 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -94,7 +94,6 @@ _set_program_name(const char *argv0) int cmdline_parse(int argc, char *argv[], int *ret_p) { - int ch; const char *playlistFile = NULL; unsigned int verbosity = 0; const char *err_str; @@ -103,6 +102,8 @@ cmdline_parse(int argc, char *argv[], int *ret_p) optind = 1; for (;;) { + int ch; + ch = getopt(argc, argv, OPTSTRING); if (0 > ch) break; @@ -155,7 +156,6 @@ cmdline_parse(int argc, char *argv[], int *ret_p) if (playlistFile) { playlist_t pl; - const char *entry; if (0 > playlist_init()) { *ret_p = 1; @@ -169,6 +169,8 @@ cmdline_parse(int argc, char *argv[], int *ret_p) if (pl == NULL) { *ret_p = 1; } else { + const char *entry; + playlist_shuffle(pl); while (NULL != (entry = playlist_get_next(pl))) printf("%s\n", entry); diff --git a/src/playlist.c b/src/playlist.c index 7e26d42..5e2f659 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -277,7 +277,6 @@ playlist_program(const char *filename) void playlist_free(struct playlist **pl_p) { - size_t i; struct playlist *pl; if (pl_p == NULL || (pl = *pl_p) == NULL) @@ -290,6 +289,8 @@ playlist_free(struct playlist **pl_p) if (pl->list != NULL) { if (pl->size > 0) { + size_t i; + for (i = 0; i < pl->size / sizeof(char *); i++) { if (pl->list[i] != NULL) { xfree(pl->list[i]); @@ -403,13 +404,15 @@ playlist_reread(struct playlist **plist) void playlist_shuffle(struct playlist *pl) { - size_t d, i, range; + size_t d, i; char *temp; if (pl->program || pl->num < 2) return; for (i = 0; i < pl->num; i++) { + size_t range; + range = pl->num - i; /*