Code

screen_browser: select/add for visual selection
[ncmpc.git] / src / strfsong.c
index f6b67930e91112856ccc8652f3f9b59e9a3275e0..714a0b0040c9fb932bfea7589d4003e2f725033c 100644 (file)
@@ -1,29 +1,24 @@
-/* 
- * $Id$
- *
- * Based on mpc's songToFormatedString modified for glib and ncmpc
- *
- *
- * (c) 2003-2004 by normalperson and Warren Dukes (shank@mercury.chem.pitt.edu)
- *              and Daniel Brown (danb@cs.utexas.edu)
- *              and Kalle Wallin (kaw@linux.se)
- *
+/* ncmpc (Ncurses MPD Client)
+ * (c) 2004-2009 The Music Player Daemon Project
+ * Project homepage: http://musicpd.org
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- *
+
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
+
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
 
 #include "strfsong.h"
-#include "support.h"
+#include "charset.h"
 
 #include <string.h>
 
@@ -33,11 +28,12 @@ skip(const gchar * p)
        gint stack = 0;
 
        while (*p != '\0') {
-               if(*p == '[') stack++;
-               if(*p == '#' && p[1] != '\0') {
+               if (*p == '[')
+                       stack++;
+               if (*p == '#' && p[1] != '\0') {
                        /* skip escaped stuff */
                        ++p;
-               } else if(stack) {
+               } else if (stack) {
                        if(*p == ']') stack--;
                } else {
                        if(*p == '&' || *p == '|' || *p == ']') {
@@ -63,7 +59,7 @@ _strfsong(gchar *s,
        gboolean found = FALSE;
 
        memset(s, 0, max);
-       if( song==NULL )
+       if (song == NULL)
                return 0;
 
        for (p = format; *p != '\0' && length<max;) {
@@ -170,7 +166,7 @@ _strfsong(gchar *s,
                        if( strstr(song->file, "://") )
                                temp = utf8_to_locale(song->file);
                        else
-                               temp = utf8_to_locale(basename(song->file));
+                               temp = utf8_to_locale(g_basename(song->file));
                } else if (strncmp("%time%", p, n) == 0) {
                        if (song->time != MPD_SONG_NO_TIME)  {
                                if (song->time > 3600) {
@@ -219,6 +215,6 @@ gsize
 strfsong(gchar *s, gsize max, const gchar *format,
         const struct mpd_song *song)
 {
-  return _strfsong(s, max, format, song, NULL);
+       return _strfsong(s, max, format, song, NULL);
 }
-     
+