aboutsummaryrefslogtreecommitdiff
path: root/src/idop.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/idop.c')
-rw-r--r--src/idop.c59
1 files changed, 40 insertions, 19 deletions
diff --git a/src/idop.c b/src/idop.c
index 063ff78..c3a3ce2 100644
--- a/src/idop.c
+++ b/src/idop.c
@@ -189,8 +189,29 @@ safe_id3_file_update_and_close(struct id3_file *file)
}
+static int
+frame_encoding_is_8bit(struct id3_frame const *frame)
+{
+ union id3_field const *field;
+
+ if (!frame)
+ return 0;
+ field = id3_frame_field(frame, 0);
+ if (!field)
+ return 0;
+ return id3_field_gettextencoding(field) == ID3_FIELD_TEXTENCODING_ISO_8859_1;
+}
+
+static int
+frame_is_genre(struct id3_frame const *frame)
+{
+ if (!frame)
+ return 0;
+ return strcmp(frame->id, ID3_FRAME_GENRE) == 0;
+}
+
char *
-idest_ucs4_cvt(id3_ucs4_t const *ucs4)
+idest_ucs4_cvt(id3_ucs4_t const *ucs4, struct id3_frame const *frame)
{
- if (broken_8bit_charset) {
+ if (broken_8bit_charset && frame_encoding_is_8bit(frame)) {
char *tempval = (char*)id3_ucs4_latin1duplicate(ucs4);
char *output;
@@ -206,5 +227,6 @@ idest_ucs4_cvt(id3_ucs4_t const *ucs4)
static void
-add_stringlist(gl_list_t list, union id3_field *field, int isgenre,
+add_stringlist(gl_list_t list, union id3_field *field,
+ struct id3_frame const *frame,
size_t *psize)
{
@@ -219,7 +241,7 @@ add_stringlist(gl_list_t list, union id3_field *field, int isgenre,
if (!ucs4)
continue;
- if (isgenre)
+ if (frame_is_genre(frame))
ucs4 = id3_genre_name(ucs4);
- str = idest_ucs4_cvt(ucs4);
+ str = idest_ucs4_cvt(ucs4, frame);
size += strlen(str);
gl_list_add_last(list, str);
@@ -285,5 +307,5 @@ field_binary_from_string(union id3_field *field, const char *str)
char *
-field_to_string(union id3_field *field, int isgenre)
+field_to_string(union id3_field *field, struct id3_frame const *frame)
{
id3_ucs4_t const *ucs4;
@@ -313,11 +335,11 @@ field_to_string(union id3_field *field, int isgenre)
case ID3_FIELD_TYPE_STRING:
ucs4 = id3_field_getstring(field);;
- if (ucs4)
- ret = idest_ucs4_cvt(ucs4);
+ if (ucs4)
+ ret = idest_ucs4_cvt(ucs4, frame);
break;
case ID3_FIELD_TYPE_STRINGFULL:
ucs4 = id3_field_getfullstring(field);
- ret = idest_ucs4_cvt(ucs4);
+ ret = idest_ucs4_cvt(ucs4, frame);
break;
@@ -329,5 +351,5 @@ field_to_string(union id3_field *field, int isgenre)
list = new_string_list(true);
- add_stringlist(list, field, isgenre, &sz);
+ add_stringlist(list, field, frame, &sz);
ret = xmalloc(sz + 1);
ret[0] = 0;
@@ -529,13 +551,17 @@ update_frames(struct id3_tag *tag)
static void
-collect_text_frames(struct id3_tag *tag)
+fixup_charset(struct id3_tag *tag)
{
struct id3_frame *frame;
unsigned i;
+ if (!broken_8bit_charset)
+ return;
+
for (i = 0; (frame = id3_tag_findframe(tag, NULL, i)); i++) {
struct ed_item itm;
const struct idest_frametab *ft =
idest_frame_lookup(frame->id);
+
if (!ft) {
if (verbose_option)
@@ -546,4 +572,7 @@ collect_text_frames(struct id3_tag *tag)
}
+ if (!frame_encoding_is_8bit(frame))
+ continue;
+
ed_item_zero(&itm);
itm.name = xstrdup(frame->id);
@@ -561,12 +590,4 @@ collect_text_frames(struct id3_tag *tag)
}
-static void
-fixup_charset(struct id3_tag *tag)
-{
- if (!broken_8bit_charset)
- return;
- collect_text_frames(tag);
-}
-
void
set_tags(const char *name)

Return to:

Send suggestions and report system problems to the System administrator.