diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/frametab.gperf | 7 | ||||
-rw-r--r-- | src/idest.h | 3 | ||||
-rw-r--r-- | src/idop.c | 59 |
3 files changed, 44 insertions, 25 deletions
diff --git a/src/frametab.gperf b/src/frametab.gperf index 7863d08..c02b771 100644 --- a/src/frametab.gperf +++ b/src/frametab.gperf | |||
@@ -44,3 +44,3 @@ decode_qv(struct ed_item *item, struct id3_frame const *frame, | |||
44 | break; | 44 | break; |
45 | item->qv[i] = field_to_string(field, 0); | 45 | item->qv[i] = field_to_string(field, frame); |
46 | } | 46 | } |
@@ -348,3 +348,2 @@ text_decode(struct ed_item *item, struct id3_frame const *frame) | |||
348 | { | 348 | { |
349 | int isgenre = strcmp(frame->id, ID3_FRAME_GENRE) == 0; | ||
350 | union id3_field *field; | 349 | union id3_field *field; |
@@ -352,3 +351,3 @@ text_decode(struct ed_item *item, struct id3_frame const *frame) | |||
352 | int rc; | 351 | int rc; |
353 | 352 | ||
354 | field = id3_frame_field(frame, 1); | 353 | field = id3_frame_field(frame, 1); |
@@ -356,3 +355,3 @@ text_decode(struct ed_item *item, struct id3_frame const *frame) | |||
356 | return IDEST_ERR_NOFIELD; | 355 | return IDEST_ERR_NOFIELD; |
357 | str = field_to_string(field, isgenre); | 356 | str = field_to_string(field, frame); |
358 | rc = utf8_convert(idest_conv_decode, str, &item->value); | 357 | rc = utf8_convert(idest_conv_decode, str, &item->value); |
diff --git a/src/idest.h b/src/idest.h index 2c10077..787cdad 100644 --- a/src/idest.h +++ b/src/idest.h | |||
@@ -94,3 +94,2 @@ void set_tags(const char *name); | |||
94 | void del_tags(const char *name); | 94 | void del_tags(const char *name); |
95 | char *idest_ucs4_cvt(id3_ucs4_t const *ucs4); | ||
96 | void query_tags(const char *name); | 95 | void query_tags(const char *name); |
@@ -98,3 +97,3 @@ void info_id3(const char *name); | |||
98 | 97 | ||
99 | char *field_to_string(union id3_field *field, int isgenre); | 98 | char *field_to_string(union id3_field *field, struct id3_frame const *frame); |
100 | int field_binary_from_string(union id3_field *field, const char *str); | 99 | int field_binary_from_string(union id3_field *field, const char *str); |
@@ -190,6 +190,27 @@ safe_id3_file_update_and_close(struct id3_file *file) | |||
190 | 190 | ||
191 | static int | ||
192 | frame_encoding_is_8bit(struct id3_frame const *frame) | ||
193 | { | ||
194 | union id3_field const *field; | ||
195 | |||
196 | if (!frame) | ||
197 | return 0; | ||
198 | field = id3_frame_field(frame, 0); | ||
199 | if (!field) | ||
200 | return 0; | ||
201 | return id3_field_gettextencoding(field) == ID3_FIELD_TEXTENCODING_ISO_8859_1; | ||
202 | } | ||
203 | |||
204 | static int | ||
205 | frame_is_genre(struct id3_frame const *frame) | ||
206 | { | ||
207 | if (!frame) | ||
208 | return 0; | ||
209 | return strcmp(frame->id, ID3_FRAME_GENRE) == 0; | ||
210 | } | ||
211 | |||
191 | char * | 212 | char * |
192 | idest_ucs4_cvt(id3_ucs4_t const *ucs4) | 213 | idest_ucs4_cvt(id3_ucs4_t const *ucs4, struct id3_frame const *frame) |
193 | { | 214 | { |
194 | if (broken_8bit_charset) { | 215 | if (broken_8bit_charset && frame_encoding_is_8bit(frame)) { |
195 | char *tempval = (char*)id3_ucs4_latin1duplicate(ucs4); | 216 | char *tempval = (char*)id3_ucs4_latin1duplicate(ucs4); |
@@ -207,3 +228,4 @@ idest_ucs4_cvt(id3_ucs4_t const *ucs4) | |||
207 | static void | 228 | static void |
208 | add_stringlist(gl_list_t list, union id3_field *field, int isgenre, | 229 | add_stringlist(gl_list_t list, union id3_field *field, |
230 | struct id3_frame const *frame, | ||
209 | size_t *psize) | 231 | size_t *psize) |
@@ -220,5 +242,5 @@ add_stringlist(gl_list_t list, union id3_field *field, int isgenre, | |||
220 | continue; | 242 | continue; |
221 | if (isgenre) | 243 | if (frame_is_genre(frame)) |
222 | ucs4 = id3_genre_name(ucs4); | 244 | ucs4 = id3_genre_name(ucs4); |
223 | str = idest_ucs4_cvt(ucs4); | 245 | str = idest_ucs4_cvt(ucs4, frame); |
224 | size += strlen(str); | 246 | size += strlen(str); |
@@ -286,3 +308,3 @@ field_binary_from_string(union id3_field *field, const char *str) | |||
286 | char * | 308 | char * |
287 | field_to_string(union id3_field *field, int isgenre) | 309 | field_to_string(union id3_field *field, struct id3_frame const *frame) |
288 | { | 310 | { |
@@ -314,4 +336,4 @@ field_to_string(union id3_field *field, int isgenre) | |||
314 | ucs4 = id3_field_getstring(field);; | 336 | ucs4 = id3_field_getstring(field);; |
315 | if (ucs4) | 337 | if (ucs4) |
316 | ret = idest_ucs4_cvt(ucs4); | 338 | ret = idest_ucs4_cvt(ucs4, frame); |
317 | break; | 339 | break; |
@@ -320,3 +342,3 @@ field_to_string(union id3_field *field, int isgenre) | |||
320 | ucs4 = id3_field_getfullstring(field); | 342 | ucs4 = id3_field_getfullstring(field); |
321 | ret = idest_ucs4_cvt(ucs4); | 343 | ret = idest_ucs4_cvt(ucs4, frame); |
322 | break; | 344 | break; |
@@ -330,3 +352,3 @@ field_to_string(union id3_field *field, int isgenre) | |||
330 | list = new_string_list(true); | 352 | list = new_string_list(true); |
331 | add_stringlist(list, field, isgenre, &sz); | 353 | add_stringlist(list, field, frame, &sz); |
332 | ret = xmalloc(sz + 1); | 354 | ret = xmalloc(sz + 1); |
@@ -530,3 +552,3 @@ update_frames(struct id3_tag *tag) | |||
530 | static void | 552 | static void |
531 | collect_text_frames(struct id3_tag *tag) | 553 | fixup_charset(struct id3_tag *tag) |
532 | { | 554 | { |
@@ -535,2 +557,5 @@ collect_text_frames(struct id3_tag *tag) | |||
535 | 557 | ||
558 | if (!broken_8bit_charset) | ||
559 | return; | ||
560 | |||
536 | for (i = 0; (frame = id3_tag_findframe(tag, NULL, i)); i++) { | 561 | for (i = 0; (frame = id3_tag_findframe(tag, NULL, i)); i++) { |
@@ -539,2 +564,3 @@ collect_text_frames(struct id3_tag *tag) | |||
539 | idest_frame_lookup(frame->id); | 564 | idest_frame_lookup(frame->id); |
565 | |||
540 | if (!ft) { | 566 | if (!ft) { |
@@ -547,2 +573,5 @@ collect_text_frames(struct id3_tag *tag) | |||
547 | 573 | ||
574 | if (!frame_encoding_is_8bit(frame)) | ||
575 | continue; | ||
576 | |||
548 | ed_item_zero(&itm); | 577 | ed_item_zero(&itm); |
@@ -562,10 +591,2 @@ collect_text_frames(struct id3_tag *tag) | |||
562 | 591 | ||
563 | static void | ||
564 | fixup_charset(struct id3_tag *tag) | ||
565 | { | ||
566 | if (!broken_8bit_charset) | ||
567 | return; | ||
568 | collect_text_frames(tag); | ||
569 | } | ||
570 | |||
571 | void | 592 | void |