[easytag/wip/easytag-next] Do not write COMMENT field for Vorbis and FLAC



commit 33e4b87d98546631743327884bbe5ee2707bcb6a
Author: David King <amigadave amigadave com>
Date:   Sat Jan 12 15:44:08 2013 +0000

    Do not write COMMENT field for Vorbis and FLAC
    
    DESCRIPTION is the field in the Vorbis comment specification for "a
    short text description of the contents" and so it should be used. The
    COMMENT field is not present in the specification. Fixes bug 690297.

 TODO           |    1 +
 src/flac_tag.c |   32 ++++----------------------------
 src/ogg_tag.c  |   11 ++---------
 3 files changed, 7 insertions(+), 37 deletions(-)
---
diff --git a/TODO b/TODO
index ef97ba6..a0ff403 100644
--- a/TODO
+++ b/TODO
@@ -17,6 +17,7 @@ General tidying
 * Use g_spawn_async() or g_app_info_launch() to spawn processes
 * Check usage and casting away of const
 * Check C-style casts for errors
+* Remove XMMS Vorbis comment compatibility
 
 After GTK+ 3
 ------------
diff --git a/src/flac_tag.c b/src/flac_tag.c
index 6ecaf57..8f8253b 100644
--- a/src/flac_tag.c
+++ b/src/flac_tag.c
@@ -71,7 +71,6 @@
  *  - ARTIST       : Track performer
  *  - ORGANIZATION : Name of the organization producing the track (i.e. the 'record label')
  *  - DESCRIPTION  : A short text description of the contents
- *  - COMMENT      : same than DESCRIPTION
  *  - GENRE        : A short text indication of music genre
  *  - DATE         : Date the track was recorded
  *  - LOCATION     : Location where track was recorded
@@ -433,28 +432,8 @@ gboolean Flac_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
                  * Comment *
                  ***********/
                 field_num = 0;
-                while ( 1 )
+                while ((field_num = FLAC__metadata_object_vorbiscomment_find_entry_from (block, field_num, "DESCRIPTION")) >= 0)
                 {
-                    gint field_num1, field_num2;
-
-                    // The comment field can take two forms...
-                    field_num1 = FLAC__metadata_object_vorbiscomment_find_entry_from(block,field_num,"DESCRIPTION");
-                    field_num2 = FLAC__metadata_object_vorbiscomment_find_entry_from(block,field_num,"COMMENT");
-
-                    if (field_num1 >= 0 && field_num2 >= 0)
-                        // Note : We set field_num to the last "comment" field to avoid to concatenate 
-                        // the DESCRIPTION and COMMENT field if there are both present (EasyTAG writes the both...)
-                        if (field_num1 < field_num2)
-                            field_num = field_num2;
-                        else
-                            field_num = field_num1;
-                    else if (field_num1 >= 0)
-                        field_num = field_num1;
-                    else if (field_num2 >= 0)
-                        field_num = field_num2;
-                    else
-                        break;
-
                     /* Extract field value */
                     field = &vc->comments[field_num++];
                     field_value = memchr(field->entry, '=', field->length);
@@ -468,10 +447,10 @@ gboolean Flac_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
                             field_value_tmp = g_strndup(field_value, field_len);
                             field_value = Try_To_Validate_Utf8_String(field_value_tmp);
                             g_free(field_value_tmp);
-                            if (FileTag->comment==NULL)
-                                FileTag->comment = g_strdup(field_value);
+                            if (FileTag->comment == NULL)
+                                FileTag->comment = g_strdup (field_value);
                             else
-                                FileTag->comment = g_strconcat(FileTag->comment,MULTIFIELD_SEPARATOR,field_value,NULL);
+                                FileTag->comment = g_strconcat(FileTag->comment, MULTIFIELD_SEPARATOR, field_value, NULL);
                             g_free(field_value);
                         }
                     }
@@ -633,7 +612,6 @@ gboolean Flac_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
                       && strncasecmp((gchar *)field->entry,"TRACKTOTAL=",  MIN(11, field->length)) != 0
                       && strncasecmp((gchar *)field->entry,"GENRE=",       MIN(6,  field->length)) != 0
                       && strncasecmp((gchar *)field->entry,"DESCRIPTION=", MIN(12, field->length)) != 0
-                      && strncasecmp((gchar *)field->entry,"COMMENT=",     MIN(8,  field->length)) != 0
                       && strncasecmp((gchar *)field->entry,"COMPOSER=",    MIN(9,  field->length)) != 0
                       && strncasecmp((gchar *)field->entry,"PERFORMER=",   MIN(10, field->length)) != 0
                       && strncasecmp((gchar *)field->entry,"COPYRIGHT=",   MIN(10, field->length)) != 0
@@ -987,9 +965,7 @@ gboolean Flac_Tag_Write_File_Tag (ET_File *ETFile)
         /***********
          * Comment *
          ***********/
-        // We write the comment using the "both" format
         Flac_Set_Tag(vc_block,"DESCRIPTION=",FileTag->comment,VORBIS_SPLIT_FIELD_COMMENT);
-        Flac_Set_Tag(vc_block,"COMMENT=",FileTag->comment,VORBIS_SPLIT_FIELD_COMMENT);
 
         /************
          * Composer *
diff --git a/src/ogg_tag.c b/src/ogg_tag.c
index f0fcbae..51d60dd 100644
--- a/src/ogg_tag.c
+++ b/src/ogg_tag.c
@@ -100,7 +100,6 @@
  * PART        : a division within a work; eg, a movement of a symphony. Some tracks contain several parts. Use a single PART tag for each part contained in a track. ie, PART="Oh sole mio"
  * PARTNUMBER  : The part number goes in here. You can use any format you like, such as Roman numerals, regular numbers, or whatever. The numbers should be entered in such a way that an alphabetical sort on this tag will correctly show the proper ordering of all the oggs that contain the contain the piece of music.
  * LOCATION    : location of recording, or other location of interest
- * COMMENT     : additional comments of any nature.
  */
 
 
@@ -357,7 +356,6 @@ gboolean Ogg_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
     field_num = 0;
     string1 = NULL; // Cause it may be not updated into the 'while' condition
     while ( ((string2 = vorbis_comment_query(vc,"DESCRIPTION",field_num)) != NULL )   // New specifications
-         || ((string  = vorbis_comment_query(vc,"COMMENT",    field_num)) != NULL )   // Old : Winamp format (for EasyTAG 1.99.11 and older)
          || ((string1 = vorbis_comment_query(vc,"",           field_num)) != NULL ) ) // Old : Xmms format   (for EasyTAG 1.99.11 and older)
     {
         string  = Try_To_Validate_Utf8_String(string);
@@ -564,7 +562,6 @@ gboolean Ogg_Tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
           && strncasecmp(vc->user_comments[i],"TRACKTOTAL=",      11) != 0
           && strncasecmp(vc->user_comments[i],"GENRE=",            6) != 0
           && strncasecmp(vc->user_comments[i],"DESCRIPTION=",     12) != 0
-          && strncasecmp(vc->user_comments[i],"COMMENT=",          8) != 0
           && strncasecmp(vc->user_comments[i],"=",                 1) != 0
           && strncasecmp(vc->user_comments[i],"COMPOSER=",         9) != 0
           && strncasecmp(vc->user_comments[i],"PERFORMER=",       10) != 0
@@ -751,16 +748,12 @@ gboolean Ogg_Tag_Write_File_Tag (ET_File *ETFile)
     /***********
      * Comment *
      ***********/
-    // We write the comment using the two formats "DESCRIPTION" and "COMMENT" to be compatible with old versions
-    // Format of new specification
+    /* Format of new specification. */
     Ogg_Set_Tag(vc,"DESCRIPTION=",FileTag->comment,VORBIS_SPLIT_FIELD_COMMENT);
 
-    // Format used in winamp plugin
-    Ogg_Set_Tag(vc,"COMMENT=",FileTag->comment,VORBIS_SPLIT_FIELD_COMMENT);
-
     if (OGG_TAG_WRITE_XMMS_COMMENT)
     {
-        // Format used into xmms-1.2.5
+        /* Format used with xmms-1.2.5. */
         Ogg_Set_Tag(vc,"=",FileTag->comment,VORBIS_SPLIT_FIELD_COMMENT);
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]