summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJackson Doak (Noskcaj) <noskcaj@ubuntu.com>2014-02-16 17:42:21 +1100
committerJackson Doak (Noskcaj) <noskcaj@ubuntu.com>2014-02-16 17:42:21 +1100
commitb380f841f764543f477b658af25194c4d9f8a1eb (patch)
treeda7b318a1ab8ce408bba700186fbabdc5fdc7b10 /src
parentc423357c93592bfb48ee7edbfba8936f20987cf7 (diff)
Imported Upstream version 3.4.3
Diffstat (limited to 'src')
-rw-r--r--src/audacious/adder.c10
-rw-r--r--src/audacious/config.c8
-rw-r--r--src/audacious/playlist-files.c14
-rw-r--r--src/audacious/plugin-init.c8
-rw-r--r--src/audacious/ui_preferences.c176
-rw-r--r--src/audacious/ui_preferences.h9
-rw-r--r--src/audacious/util.c59
-rw-r--r--src/audtool/main.c6
-rw-r--r--src/libaudcore/core.h17
-rw-r--r--src/libaudcore/hook.c10
-rw-r--r--src/libaudcore/strpool.c55
-rw-r--r--src/libaudcore/tuple_compiler.c23
-rw-r--r--src/libaudcore/tuple_compiler.h2
-rw-r--r--src/libaudcore/vfs.c5
-rw-r--r--src/libaudcore/vfs.h1
-rw-r--r--src/libaudgui/about.c2
-rw-r--r--src/libaudgui/list.c33
-rw-r--r--src/libaudtag/id3/id3v24.c8
-rw-r--r--src/libaudtag/util.c4
-rw-r--r--src/libaudtag/util.h2
20 files changed, 123 insertions, 329 deletions
diff --git a/src/audacious/adder.c b/src/audacious/adder.c
index 4fd39e7..5d3a138 100644
--- a/src/audacious/adder.c
+++ b/src/audacious/adder.c
@@ -281,9 +281,6 @@ static void add_folder (char * filename, PlaylistFilterFunc filter,
return;
}
- if (unix_name[strlen (unix_name) - 1] == '/')
- unix_name[strlen (unix_name) - 1] = 0;
-
GList * files = NULL;
DIR * folder = opendir (unix_name);
if (! folder)
@@ -293,8 +290,7 @@ static void add_folder (char * filename, PlaylistFilterFunc filter,
while ((entry = readdir (folder)))
{
if (entry->d_name[0] != '.')
- files = g_list_prepend (files, g_strdup_printf ("%s"
- G_DIR_SEPARATOR_S "%s", unix_name, entry->d_name));
+ files = g_list_prepend (files, g_build_filename (unix_name, entry->d_name, NULL));
}
closedir (folder);
@@ -303,7 +299,11 @@ static void add_folder (char * filename, PlaylistFilterFunc filter,
while (files)
{
struct stat info;
+#ifdef S_ISLNK
+ if (lstat (files->data, & info) < 0)
+#else
if (stat (files->data, & info) < 0)
+#endif
goto NEXT;
if (S_ISREG (info.st_mode))
diff --git a/src/audacious/config.c b/src/audacious/config.c
index 8b1a06b..c40de94 100644
--- a/src/audacious/config.c
+++ b/src/audacious/config.c
@@ -98,12 +98,6 @@ static GHashTable * defaults;
static GKeyFile * keyfile;
static bool_t modified;
-/* str_unref() may be a macro */
-static void str_unref_cb (void * str)
-{
- str_unref (str);
-}
-
void config_load (void)
{
g_return_if_fail (! defaults && ! keyfile);
@@ -200,7 +194,7 @@ void config_set_defaults (const char * section, const char * const * entries)
GHashTable * table = g_hash_table_lookup (defaults, section);
if (! table)
{
- table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, str_unref_cb);
+ table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) str_unref);
g_hash_table_replace (defaults, g_strdup (section), table);
}
diff --git a/src/audacious/playlist-files.c b/src/audacious/playlist-files.c
index 6943dae..795042e 100644
--- a/src/audacious/playlist-files.c
+++ b/src/audacious/playlist-files.c
@@ -47,10 +47,9 @@ static PluginHandle * get_plugin (const char * filename, bool_t saving)
if (! plugin)
{
- char * error = str_printf (_("Cannot %s %s: unsupported file "
- "extension."), saving ? _("save") : _("load"), filename);
+ SPRINTF (error, _("Cannot %s %s: unsupported file extension."),
+ saving ? _("save") : _("load"), filename);
interface_show_error (error);
- str_unref (error);
return NULL;
}
@@ -127,7 +126,14 @@ bool_t playlist_save (int list, const char * filename)
return FALSE;
PlaylistPlugin * pp = plugin_get_header (plugin);
- g_return_val_if_fail (pp && PLUGIN_HAS_FUNC (pp, load), FALSE);
+ g_return_val_if_fail (pp, FALSE);
+
+ if (! PLUGIN_HAS_FUNC (pp, save))
+ {
+ SPRINTF (error, _("Cannot save %s: plugin does not support saving."), filename);
+ interface_show_error (error);
+ return FALSE;
+ }
bool_t fast = get_bool (NULL, "metadata_on_play");
diff --git a/src/audacious/plugin-init.c b/src/audacious/plugin-init.c
index fcfccf6..0992bf5 100644
--- a/src/audacious/plugin-init.c
+++ b/src/audacious/plugin-init.c
@@ -220,6 +220,8 @@ static bool_t enable_single (int type, PluginHandle * p)
{
PluginHandle * old = table[type].u.s.get_current ();
+ plugin_misc_cleanup (old);
+
AUDDBG ("Switching from %s to %s.\n", plugin_get_name (old),
plugin_get_name (p));
plugin_set_enabled (old, FALSE);
@@ -243,6 +245,9 @@ static bool_t enable_single (int type, PluginHandle * p)
static bool_t enable_multi (int type, PluginHandle * p, bool_t enable)
{
+ if (! enable)
+ plugin_misc_cleanup (p);
+
AUDDBG ("%sabling %s.\n", enable ? "En" : "Dis", plugin_get_name (p));
plugin_set_enabled (p, enable);
@@ -269,9 +274,6 @@ bool_t plugin_enable (PluginHandle * plugin, bool_t enable)
if (! enable == ! plugin_get_enabled (plugin))
return TRUE;
- if (! enable)
- plugin_misc_cleanup (plugin);
-
int type = plugin_get_type (plugin);
if (table[type].is_single)
diff --git a/src/audacious/ui_preferences.c b/src/audacious/ui_preferences.c
index 6599b5c..96dab5b 100644
--- a/src/audacious/ui_preferences.c
+++ b/src/audacious/ui_preferences.c
@@ -112,15 +112,6 @@ static ComboBoxElements bitdepth_elements[] = {
{GINT_TO_POINTER (0), N_("Floating point")},
};
-typedef struct {
- void *next;
- GtkWidget *container;
- const char * pg_name;
- const char * img_url;
-} CategoryQueueEntry;
-
-CategoryQueueEntry *category_queue = NULL;
-
static void * create_output_plugin_box (void);
static void output_bit_depth_changed (void);
@@ -243,8 +234,6 @@ static const char * const titlestring_preset_names[TITLESTRING_NPRESETS] = {
N_("ARTIST [ ALBUM ] - TRACK. TITLE"),
N_("ALBUM - TITLE")};
-static void prefswin_page_queue_destroy(CategoryQueueEntry *ent);
-
static void
change_category(GtkNotebook * notebook,
GtkTreeSelection * selection)
@@ -261,14 +250,6 @@ change_category(GtkNotebook * notebook,
}
static void
-editable_insert_text(GtkEditable * editable,
- const char * text,
- int * pos)
-{
- gtk_editable_insert_text(editable, text, strlen(text), pos);
-}
-
-static void
titlestring_tag_menu_callback(GtkMenuItem * menuitem,
void * data)
{
@@ -279,12 +260,10 @@ titlestring_tag_menu_callback(GtkMenuItem * menuitem,
pos = gtk_editable_get_position(GTK_EDITABLE(titlestring_entry));
/* insert separator as needed */
- if (g_utf8_strlen(gtk_entry_get_text(GTK_ENTRY(titlestring_entry)), -1) > 0)
- editable_insert_text(GTK_EDITABLE(titlestring_entry), separator, &pos);
-
- editable_insert_text(GTK_EDITABLE(titlestring_entry), _(title_field_tags[item].tag),
- &pos);
+ if (gtk_entry_get_text(GTK_ENTRY(titlestring_entry))[0])
+ gtk_editable_insert_text(GTK_EDITABLE(titlestring_entry), separator, -1, &pos);
+ gtk_editable_insert_text(GTK_EDITABLE(titlestring_entry), _(title_field_tags[item].tag), -1, &pos);
gtk_editable_set_position(GTK_EDITABLE(titlestring_entry), pos);
}
@@ -450,7 +429,6 @@ static void fill_category_list (GtkTreeView * treeview, GtkNotebook * notebook)
GtkTreeSelection *selection;
GtkTreeIter iter;
GdkPixbuf *img;
- CategoryQueueEntry *qlist;
int i;
column = gtk_tree_view_column_new();
@@ -493,18 +471,6 @@ static void fill_category_list (GtkTreeView * treeview, GtkNotebook * notebook)
g_signal_connect_swapped(selection, "changed",
G_CALLBACK(change_category), notebook);
-
- /* mark the treeview widget as available to third party plugins */
- category_treeview = GTK_WIDGET(treeview);
-
- /* prefswin_page_queue_destroy already pops the queue forward for us. */
- for (qlist = category_queue; qlist != NULL; qlist = category_queue)
- {
- CategoryQueueEntry *ent = (CategoryQueueEntry *) qlist;
-
- prefswin_page_new(ent->container, ent->pg_name, ent->img_url);
- prefswin_page_queue_destroy(ent);
- }
}
static void on_radio_button_toggled (GtkWidget * button, const PreferencesWidget * widget)
@@ -1251,8 +1217,7 @@ prefswin_destroy(GtkWidget *window, GdkEvent *event, void * data)
return TRUE;
}
-/* GtkWidget * * create_prefs_window (void) */
-void * * create_prefs_window (void)
+static void create_prefs_window (void)
{
char *aud_version_string;
@@ -1349,8 +1314,6 @@ void * * create_prefs_window (void)
gtk_label_set_markup( GTK_LABEL(audversionlabel) , aud_version_string );
g_free(aud_version_string);
gtk_widget_show_all(vbox);
-
- return & prefswin;
}
void
@@ -1367,137 +1330,8 @@ void show_prefs_window (void)
gtk_window_present ((GtkWindow *) prefswin);
}
-void
-hide_prefs_window(void)
+void hide_prefs_window (void)
{
g_return_if_fail(prefswin);
gtk_widget_hide(GTK_WIDGET(prefswin));
}
-
-static void prefswin_page_queue_new (GtkWidget * container, const char * name,
- const char * imgurl)
-{
- CategoryQueueEntry *ent = g_new0(CategoryQueueEntry, 1);
-
- ent->container = container;
- ent->pg_name = name;
- ent->img_url = imgurl;
-
- if (category_queue)
- ent->next = category_queue;
-
- category_queue = ent;
-}
-
-static void
-prefswin_page_queue_destroy(CategoryQueueEntry *ent)
-{
- category_queue = ent->next;
- g_free(ent);
-}
-
-/*
- * Public APIs for adding new pages to the prefs window.
- *
- * Basically, the concept here is that third party components can register themselves in the root
- * preferences window.
- *
- * From a usability standpoint this makes the application look more "united", instead of cluttered
- * and malorganised. Hopefully this option will be used further in the future.
- *
- * - nenolod
- */
-/* int prefswin_page_new (GtkWidget * container, const char * name,
- const char * imgurl) */
-int prefswin_page_new (void * container, const char * name, const char *
- imgurl)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GdkPixbuf *img = NULL;
- GtkTreeView *treeview = GTK_TREE_VIEW(category_treeview);
- int id;
-
- if (treeview == NULL || category_notebook == NULL)
- {
- prefswin_page_queue_new(container, name, imgurl);
- return -1;
- }
-
- model = gtk_tree_view_get_model(treeview);
-
- if (model == NULL)
- {
- prefswin_page_queue_new(container, name, imgurl);
- return -1;
- }
-
- /* Make sure the widgets are visible. */
- gtk_widget_show(container);
- id = gtk_notebook_append_page(GTK_NOTEBOOK(category_notebook), container, NULL);
-
- if (id == -1)
- return -1;
-
- if (imgurl != NULL)
- img = gdk_pixbuf_new_from_file(imgurl, NULL);
-
- gtk_list_store_append(GTK_LIST_STORE(model), &iter);
- gtk_list_store_set(GTK_LIST_STORE(model), &iter,
- CATEGORY_VIEW_COL_ICON, img,
- CATEGORY_VIEW_COL_NAME,
- name, CATEGORY_VIEW_COL_ID, id, -1);
-
- if (img != NULL)
- g_object_unref(img);
-
- return id;
-}
-
-void
-prefswin_page_destroy(GtkWidget *container)
-{
- GtkTreeModel *model;
- GtkTreeIter iter;
- GtkTreeView *treeview = GTK_TREE_VIEW(category_treeview);
- bool_t ret;
- int id;
- int index = -1;
-
- if (category_notebook == NULL || treeview == NULL || container == NULL)
- return;
-
- id = gtk_notebook_page_num(GTK_NOTEBOOK(category_notebook), container);
-
- if (id == -1)
- return;
-
- gtk_notebook_remove_page(GTK_NOTEBOOK(category_notebook), id);
-
- model = gtk_tree_view_get_model(treeview);
-
- if (model == NULL)
- return;
-
- ret = gtk_tree_model_get_iter_first(model, &iter);
-
- while (ret == TRUE)
- {
- gtk_tree_model_get(model, &iter, CATEGORY_VIEW_COL_ID, &index, -1);
-
- if (index == id)
- {
- gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
- ret = gtk_tree_model_get_iter_first(model, &iter);
- continue;
- }
-
- if (index > id)
- {
- index--;
- gtk_list_store_set(GTK_LIST_STORE(model), &iter, CATEGORY_VIEW_COL_ID, index, -1);
- }
-
- ret = gtk_tree_model_iter_next(model, &iter);
- }
-}
diff --git a/src/audacious/ui_preferences.h b/src/audacious/ui_preferences.h
index 408fb50..ab91f1b 100644
--- a/src/audacious/ui_preferences.h
+++ b/src/audacious/ui_preferences.h
@@ -24,18 +24,9 @@
#include "preferences.h"
-/* GtkWidget * * create_prefs_window (void); */
-void * * create_prefs_window (void);
-void destroy_prefs_window(void);
void show_prefs_window(void);
void hide_prefs_window(void);
-/* int prefswin_page_new (GtkWidget * container, const char * name,
- const char * imgurl); */
-int prefswin_page_new (void * container, const char * name, const char *
- imgurl);
-void prefswin_page_destroy(GtkWidget *container);
-
/* plugin-preferences.c */
void plugin_make_about_window (PluginHandle * plugin);
void plugin_make_config_window (PluginHandle * plugin);
diff --git a/src/audacious/util.c b/src/audacious/util.c
index dd960b7..37455b5 100644
--- a/src/audacious/util.c
+++ b/src/audacious/util.c
@@ -211,40 +211,45 @@ char * get_path_to_self (void)
#endif
}
-/* Strips various common top-level folders from a URI. The string passed will
- * not be modified, but the string returned will share the same memory.
+/* Strips various common top-level folders from a filename. The string passed
+ * will not be modified, but the string returned will share the same memory.
* Examples:
- * "file:///home/john/folder/file.mp3" -> "folder/file.mp3"
- * "file:///folder/file.mp3" -> "folder/file.mp3" */
+ * "/home/john/folder/file.mp3" -> "folder/file.mp3"
+ * "/folder/file.mp3" -> "folder/file.mp3" */
static char * skip_top_folders (char * name)
{
- static char * home;
+ static const char * home;
static int len;
if (! home)
{
- home = filename_to_uri (g_get_home_dir ());
+ home = g_get_home_dir ();
len = strlen (home);
- if (len > 0 && home[len - 1] == '/')
+ if (len > 0 && home[len - 1] == G_DIR_SEPARATOR)
len --;
}
#ifdef _WIN32
- if (! g_ascii_strncasecmp (name, home, len) && name[len] == '/')
+ if (! g_ascii_strncasecmp (name, home, len) && name[len] == '\\')
#else
if (! strncmp (name, home, len) && name[len] == '/')
#endif
return name + len + 1;
- if (! strncmp (name, "file:///", 8))
- return name + 8;
+#ifdef _WIN32
+ if (g_ascii_isalpha (name[0]) && name[1] == ':' && name[2] == '\\')
+ return name + 3;
+#else
+ if (name[0] == '/')
+ return name + 1;
+#endif
return name;
}
-/* Divides a URI into the base name, the lowest folder, and the
+/* Divides a filename into the base name, the lowest folder, and the
* second lowest folder. The string passed will be modified, and the strings
* returned will use the same memory. May return NULL for <first> and <second>.
* Examples:
@@ -259,7 +264,7 @@ static void split_filename (char * name, char * * base, char * * first,
char * c;
- if ((c = strrchr (name, '/')))
+ if ((c = strrchr (name, G_DIR_SEPARATOR)))
{
* base = c + 1;
* c = 0;
@@ -270,7 +275,7 @@ static void split_filename (char * name, char * * base, char * * first,
goto DONE;
}
- if ((c = strrchr (name, '/')))
+ if ((c = strrchr (name, G_DIR_SEPARATOR)))
{
* first = c + 1;
* c = 0;
@@ -281,7 +286,7 @@ static void split_filename (char * name, char * * base, char * * first,
goto DONE;
}
- if ((c = strrchr (name, '/')))
+ if ((c = strrchr (name, G_DIR_SEPARATOR)))
* second = c + 1;
else
* second = name;
@@ -364,16 +369,17 @@ DONE:
return;
}
- char buf[strlen (name) + 1];
- memcpy (buf, name, sizeof buf);
-
- if (! strncmp (buf, "file:///", 8))
+ if (! strncmp (name, "file:///", 8))
{
+ char * filename = uri_to_display (name);
+ if (! filename)
+ goto DONE;
+
char * base, * first, * second;
- split_filename (skip_top_folders (buf), & base, & first, & second);
+ split_filename (skip_top_folders (filename), & base, & first, & second);
if (! title)
- title = str_get_decoded (base);
+ title = str_get (base);
for (int i = 0; i < G_N_ELEMENTS (skip); i ++)
{
@@ -387,17 +393,22 @@ DONE:
{
if (second && ! artist && ! album)
{
- artist = str_get_decoded (second);
- album = str_get_decoded (first);
+ artist = str_get (second);
+ album = str_get (first);
}
else if (! artist)
- artist = str_get_decoded (first);
+ artist = str_get (first);
else if (! album)
- album = str_get_decoded (first);
+ album = str_get (first);
}
+
+ free (filename);
}
else
{
+ char buf[strlen (name) + 1];
+ strcpy (buf, name);
+
if (! title)
{
title = str_get_decoded (stream_name (buf));
diff --git a/src/audtool/main.c b/src/audtool/main.c
index 4057ea3..0fc45f7 100644
--- a/src/audtool/main.c
+++ b/src/audtool/main.c
@@ -89,9 +89,9 @@ struct commandhandler handlers[] = {
{"playback-pause", playback_pause, "(un)pauses song playback", 0},
{"playback-playpause", playback_playpause, "plays/(un)pauses song playback", 0},
{"playback-stop", playback_stop, "stops song playback", 0},
- {"playback-playing", playback_playing, "returns OK if audacious is playing", 0},
- {"playback-paused", playback_paused, "returns OK if audacious is paused", 0},
- {"playback-stopped", playback_stopped, "returns OK if audacious is stopped", 0},
+ {"playback-playing", playback_playing, "returns OK if Audacious is playing", 0},
+ {"playback-paused", playback_paused, "returns OK if Audacious is paused", 0},
+ {"playback-stopped", playback_stopped, "returns OK if Audacious is stopped", 0},
{"playback-status", playback_status, "returns the playback status", 0},
{"playback-seek", playback_seek, "performs an absolute seek", 1},
{"playback-seek-relative", playback_seek_relative, "performs a seek relative to the current position", 1},
diff --git a/src/libaudcore/core.h b/src/libaudcore/core.h
index 76934a0..b92c500 100644
--- a/src/libaudcore/core.h
+++ b/src/libaudcore/core.h
@@ -20,8 +20,6 @@
#ifndef LIBAUDCORE_CORE_H
#define LIBAUDCORE_CORE_H
-/* #define STRPOOL_DEBUG */
-
#undef NULL
#ifdef __cplusplus /* *sigh* */
#define NULL 0
@@ -59,34 +57,19 @@
* In either case, returns the copy. Because this copy may be shared by other
* parts of the code, it should not be modified. If <str> is NULL, simply
* returns NULL with no side effects. */
-#ifdef STRPOOL_DEBUG
-char * str_get_debug (const char * str, const char * file, int line);
-#define str_get(str) str_get_debug (str, __FILE__, __LINE__)
-#else
char * str_get (const char * str);
-#endif
/* Increments the reference count of <str>, where <str> is the address of a
* string already in the pool. Faster than calling str_get() a second time.
* Returns <str> for convenience. If <str> is NULL, simply returns NULL with no
* side effects. */
-#ifdef STRPOOL_DEBUG
-char * str_ref_debug (char * str, const char * file, int line);
-#define str_ref(str) str_ref_debug (str, __FILE__, __LINE__)
-#else
char * str_ref (char * str);
-#endif
/* Decrements the reference count of <str>, where <str> is the address of a
* string in the pool. If the reference count drops to zero, releases the
* memory used by <str>. If <str> is NULL, simply returns NULL with no side
* effects. */
-#ifdef STRPOOL_DEBUG
-void str_unref_debug (char * str, const char * file, int line);
-#define str_unref(str) str_unref_debug (str, __FILE__, __LINE__)
-#else
void str_unref (char * str);
-#endif
/* Calls str_get() on the first <len> characters of <str>. If <str> has less
* than or equal to <len> characters, equivalent to str_get(). */
diff --git a/src/libaudcore/hook.c b/src/libaudcore/hook.c
index 5daddd7..00d69c8 100644
--- a/src/libaudcore/hook.c
+++ b/src/libaudcore/hook.c
@@ -33,19 +33,13 @@ typedef struct {
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static GHashTable * hooks; /* of (GQueue of (HookItem *) *) */
-/* str_unref() may be a macro */
-static void str_unref_cb (void * str)
-{
- str_unref (str);
-}
-
EXPORT void hook_associate (const char * name, HookFunction func, void * user)
{
pthread_mutex_lock (& mutex);
if (! hooks)
- hooks = g_hash_table_new_full (g_str_hash, g_str_equal, str_unref_cb,
- (GDestroyNotify) g_queue_free);
+ hooks = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) str_unref, (GDestroyNotify) g_queue_free);
GQueue * list = g_hash_table_lookup (hooks, name);
diff --git a/src/libaudcore/strpool.c b/src/libaudcore/strpool.c
index b11f904..634a84d 100644
--- a/src/libaudcore/strpool.c
+++ b/src/libaudcore/strpool.c
@@ -33,40 +33,13 @@
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
static GHashTable * table;
-#ifdef STRPOOL_DEBUG
-static GHashTable * logged;
-
-static void str_log (const char * str, const char * op, const char * file, int line)
-{
- if (! logged)
- logged = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-
- GList * list = g_hash_table_lookup (logged, str);
- list = g_list_prepend (list, g_strdup_printf ("%s by %s:%d", op, file, line));
- g_hash_table_insert (logged, g_strdup (str), list);
-}
-
-static void str_log_dump (const char * str)
-{
- if (! logged)
- return;
-
- for (GList * node = g_hash_table_lookup (logged, str); node; node = node->next)
- printf (" - %s\n", (char *) node->data);
-}
-#endif
-
static void str_destroy (void * str)
{
* ((char *) str - 1) = 0;
free ((char *) str - 5);
}
-#ifdef STRPOOL_DEBUG
-EXPORT char * str_get_debug (const char * str, const char * file, int line)
-#else
EXPORT char * str_get (const char * str)
-#endif
{
if (! str)
return NULL;
@@ -74,10 +47,6 @@ EXPORT char * str_get (const char * str)
char * copy;
pthread_mutex_lock (& mutex);
-#ifdef STRPOOL_DEBUG
- str_log (str, "get", file, line);
-#endif
-
if (! table)
table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, str_destroy);
@@ -102,11 +71,7 @@ EXPORT char * str_get (const char * str)
return copy;
}
-#ifdef STRPOOL_DEBUG
-EXPORT char * str_ref_debug (char * str, const char * file, int line)
-#else
EXPORT char * str_ref (char * str)
-#endif
{
if (! str)
return NULL;
@@ -114,10 +79,6 @@ EXPORT char * str_ref (char * str)
pthread_mutex_lock (& mutex);
STR_CHECK (str);
-#ifdef STRPOOL_DEBUG
- str_log (str, "ref", file, line);
-#endif
-
void * mem = str - 5;
(* (int32_t *) mem) ++;
@@ -125,11 +86,7 @@ EXPORT char * str_ref (char * str)
return str;
}
-#ifdef STRPOOL_DEBUG
-EXPORT void str_unref_debug (char * str, const char * file, int line)
-#else
EXPORT void str_unref (char * str)
-#endif
{
if (! str)
return;
@@ -137,10 +94,6 @@ EXPORT void str_unref (char * str)
pthread_mutex_lock (& mutex);
STR_CHECK (str);
-#ifdef STRPOOL_DEBUG
- str_log (str, "unref", file, line);
-#endif
-
void * mem = str - 5;
if (! -- (* (int32_t *) mem))
g_hash_table_remove (table, str);
@@ -150,7 +103,7 @@ EXPORT void str_unref (char * str)
EXPORT char * str_nget (const char * str, int len)
{
- if (strlen (str) <= len)
+ if (memchr (str, 0, len))
return str_get (str);
char buf[len + 1];
@@ -180,18 +133,12 @@ EXPORT char * str_printf (const char * format, ...)
EXPORT void strpool_abort (char * str)
{
fprintf (stderr, "String not in pool: %s\n", str);
-#ifdef STRPOOL_DEBUG
- str_log_dump (str);
-#endif
abort ();
}
static void str_leaked (void * key, void * str, void * unused)
{
fprintf (stderr, "String not freed: %s\n", (char *) str);
-#ifdef STRPOOL_DEBUG
- str_log_dump (str);
-#endif
}
EXPORT void strpool_shutdown (void)
diff --git a/src/libaudcore/tuple_compiler.c b/src/libaudcore/tuple_compiler.c
index d59feb8..4834e17 100644
--- a/src/libaudcore/tuple_compiler.c
+++ b/src/libaudcore/tuple_compiler.c
@@ -221,15 +221,16 @@ void tuple_evalnode_free(TupleEvalNode *expr)
}
-static TupleEvalNode *tuple_compiler_pass1(int *level, TupleEvalContext *ctx, char **expression);
+static TupleEvalNode *tuple_compiler_pass1(int *level, TupleEvalContext *ctx, const char **expression);
static bool_t tc_get_item(TupleEvalContext *ctx,
- char **str, char *buf, gssize max,
- char endch, bool_t *literal, char *errstr, char *item)
+ const char **str, char *buf, gssize max,
+ char endch, bool_t *literal, char *errstr, const char *item)
{
gssize i = 0;
- char *s = *str, tmpendch;
+ const char *s = *str;
+ char tmpendch;
if (*s == '"') {
if (*literal == FALSE) {
@@ -306,7 +307,8 @@ static int tc_get_variable(TupleEvalContext *ctx, char *name, int type)
}
-static bool_t tc_parse_construct(TupleEvalContext *ctx, TupleEvalNode **res, char *item, char **c, int *level, int opcode)
+static bool_t tc_parse_construct(TupleEvalContext *ctx, TupleEvalNode **res,
+ const char *item, const char **c, int *level, int opcode)
{
char tmps1[MAX_STR], tmps2[MAX_STR];
bool_t literal1 = TRUE, literal2 = TRUE;
@@ -344,10 +346,11 @@ static bool_t tc_parse_construct(TupleEvalContext *ctx, TupleEvalNode **res, cha
* A "simple" straight compilation is sufficient in first pass, later
* passes can perform subexpression removal and other optimizations.
*/
-static TupleEvalNode *tuple_compiler_pass1(int *level, TupleEvalContext *ctx, char **expression)
+static TupleEvalNode *tuple_compiler_pass1(int *level, TupleEvalContext *ctx, const char **expression)
{
TupleEvalNode *res = NULL, *tmp = NULL;
- char *c = *expression, *item, tmps1[MAX_STR];
+ const char *c = *expression, *item;
+ char tmps1[MAX_STR];
bool_t literal, end = FALSE;
(*level)++;
@@ -363,7 +366,7 @@ static TupleEvalNode *tuple_compiler_pass1(int *level, TupleEvalContext *ctx, ch
item = c++;
if (*c == '{') {
int opcode;
- char *expr = ++c;
+ const char *expr = ++c;
switch (*c) {
case '?': c++;
@@ -535,10 +538,10 @@ ret_error:
}
-TupleEvalNode *tuple_formatter_compile(TupleEvalContext *ctx, char *expr)
+TupleEvalNode *tuple_formatter_compile(TupleEvalContext *ctx, const char *expr)
{
int level = 0;
- char *tmpexpr = expr;
+ const char *tmpexpr = expr;
TupleEvalNode *res1;
res1 = tuple_compiler_pass1(&level, ctx, &tmpexpr);
diff --git a/src/libaudcore/tuple_compiler.h b/src/libaudcore/tuple_compiler.h
index c5f3aa3..0e2ba54 100644
--- a/src/libaudcore/tuple_compiler.h
+++ b/src/libaudcore/tuple_compiler.h
@@ -35,7 +35,7 @@ void tuple_evalctx_free(TupleEvalContext *ctx);
void tuple_evalnode_free(TupleEvalNode *expr);
-TupleEvalNode *tuple_formatter_compile(TupleEvalContext *ctx, char *expr);
+TupleEvalNode *tuple_formatter_compile(TupleEvalContext *ctx, const char *expr);
void tuple_formatter_eval (TupleEvalContext * ctx, TupleEvalNode * expr,
const Tuple * tuple, GString * out);
diff --git a/src/libaudcore/vfs.c b/src/libaudcore/vfs.c
index 05c0ffa..b1c3b03 100644
--- a/src/libaudcore/vfs.c
+++ b/src/libaudcore/vfs.c
@@ -417,7 +417,7 @@ vfs_file_test(const char * path, int test)
{
struct stat st;
if (lstat (path2, & st) < 0)
- return FALSE;
+ goto DONE;
if (S_ISLNK (st.st_mode))
test &= ~VFS_IS_SYMLINK;
@@ -428,7 +428,7 @@ vfs_file_test(const char * path, int test)
{
struct stat st;
if (stat (path2, & st) < 0)
- return FALSE;
+ goto DONE;
if (S_ISREG (st.st_mode))
test &= ~VFS_IS_REGULAR;
@@ -440,6 +440,7 @@ vfs_file_test(const char * path, int test)
test &= ~VFS_EXISTS;
}
+DONE:
g_free (path2);
return ! test;
diff --git a/src/libaudcore/vfs.h b/src/libaudcore/vfs.h
index face5fb..006c3b7 100644
--- a/src/libaudcore/vfs.h
+++ b/src/libaudcore/vfs.h
@@ -105,6 +105,7 @@ int64_t vfs_fwrite (const void * ptr, int64_t size, int64_t nmemb, VFSFile * fil
int vfs_getc (VFSFile * stream) WARN_RETURN;
int vfs_ungetc (int c, VFSFile * stream) WARN_RETURN;
char * vfs_fgets (char * s, int n, VFSFile * stream) WARN_RETURN;
+int vfs_fputs (const char * s, VFSFile * stream) WARN_RETURN;
bool_t vfs_feof (VFSFile * file) WARN_RETURN;
int vfs_fprintf (VFSFile * stream, char const * format, ...) __attribute__
((__format__ (__printf__, 2, 3)));
diff --git a/src/libaudgui/about.c b/src/libaudgui/about.c
index 5feff23..613bf4e 100644
--- a/src/libaudgui/about.c
+++ b/src/libaudgui/about.c
@@ -26,7 +26,7 @@
static const char about_text[] =
"<big><b>Audacious " VERSION "</b></big>\n"
- "Copyright © 2001-2013 Audacious developers and others";
+ "Copyright © 2001-2014 Audacious developers and others";
static const char website[] = "http://audacious-media-player.org";
diff --git a/src/libaudgui/list.c b/src/libaudgui/list.c
index aab64a8..751a7d5 100644
--- a/src/libaudgui/list.c
+++ b/src/libaudgui/list.c
@@ -534,6 +534,7 @@ static void destroy_cb (GtkWidget * list, ListModel * model)
NULL, model);
stop_autoscroll (model);
+ g_list_free (model->column_types);
g_object_unref (model);
}
@@ -737,6 +738,35 @@ EXPORT void audgui_list_update_rows (GtkWidget * list, int at, int rows)
gtk_tree_path_free (path);
}
+static void move_cursor_away (GtkWidget * list, ListModel * model, int at, int rows)
+{
+ GtkTreePath * path = NULL;
+ gtk_tree_view_get_cursor ((GtkTreeView *) list, & path, NULL);
+
+ if (! path)
+ return;
+
+ int row = gtk_tree_path_get_indices (path)[0];
+
+ gtk_tree_path_free (path);
+
+ if (row < at || row >= at + rows)
+ return;
+
+ if (at + rows < model->rows)
+ row = at + rows;
+ else
+ row = at - 1;
+
+ if (row >= 0)
+ path = gtk_tree_path_new_from_indices (row, -1);
+ else
+ path = gtk_tree_path_new ();
+
+ gtk_tree_view_set_cursor ((GtkTreeView *) list, path, NULL, FALSE);
+ gtk_tree_path_free (path);
+}
+
EXPORT void audgui_list_delete_rows (GtkWidget * list, int at, int rows)
{
ListModel * model = (ListModel *) gtk_tree_view_get_model
@@ -752,6 +782,9 @@ EXPORT void audgui_list_delete_rows (GtkWidget * list, int at, int rows)
model->frozen = TRUE;
model->blocked = TRUE;
+ /* prevent a warning when GTK+ tries to move the cursor to a deleted row */
+ move_cursor_away (list, model, at, rows);
+
GtkTreePath * path = gtk_tree_path_new_from_indices (at, -1);
while (rows --)
diff --git a/src/libaudtag/id3/id3v24.c b/src/libaudtag/id3/id3v24.c
index 3e21475..15b78bd 100644
--- a/src/libaudtag/id3/id3v24.c
+++ b/src/libaudtag/id3/id3v24.c
@@ -110,12 +110,6 @@ GenericFrame;
#define ID3_FRAME_SYNCSAFE 0x0002
#define ID3_FRAME_HAS_LENGTH 0x0001
-/* str_unref() may be a macro */
-static void str_unref_cb (void * str)
-{
- str_unref (str);
-}
-
static bool_t skip_extended_header_3 (VFSFile * handle, int * _size)
{
uint32_t size;
@@ -980,7 +974,7 @@ static bool_t id3v24_write_tag (const Tuple * tuple, VFSFile * f)
//read all frames into generic frames;
GHashTable * dict = g_hash_table_new_full (g_str_hash, g_str_equal,
- str_unref_cb, (GDestroyNotify) free_frame_list);
+ (GDestroyNotify) str_unref, (GDestroyNotify) free_frame_list);
read_all_frames (f, version, syncsafe, data_size, dict);
//make the new frames from tuple and replace in the dictionary the old frames with the new ones
diff --git a/src/libaudtag/util.c b/src/libaudtag/util.c
index 9daee73..15ffe55 100644
--- a/src/libaudtag/util.c
+++ b/src/libaudtag/util.c
@@ -177,12 +177,12 @@ bool_t cut_beginning_tag (VFSFile * handle, int64_t tag_size)
return vfs_ftruncate (handle, offset) == 0;
}
-char *convert_numericgenre_to_text(int numericgenre)
+const char *convert_numericgenre_to_text(int numericgenre)
{
const struct
{
int numericgenre;
- char *genre;
+ const char *genre;
}
table[] =
{
diff --git a/src/libaudtag/util.h b/src/libaudtag/util.h
index e3284a0..27cfd80 100644
--- a/src/libaudtag/util.h
+++ b/src/libaudtag/util.h
@@ -188,7 +188,7 @@ bool_t write_LEuint64(VFSFile *fd, uint64_t val);
uint64_t read_LEint64(VFSFile *fd);
bool_t cut_beginning_tag (VFSFile * handle, int64_t tag_size);
-char *convert_numericgenre_to_text(int numericgenre);
+const char *convert_numericgenre_to_text(int numericgenre);
uint32_t unsyncsafe32 (uint32_t x);
uint32_t syncsafe32 (uint32_t x);