summaryrefslogtreecommitdiffabout
path: root/libid3tag
authorSergey Poznyakoff <gray@gnu.org.ua>2011-07-24 21:11:46 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-07-24 21:11:46 (GMT)
commit6db300c686c28f05562930b5ff58487f625e4a01 (patch) (side-by-side diff)
treee79ca14f3bf56769919df7a7aa2ad343f7bf46c9 /libid3tag
parent10424c8227706ee06981dd8ecaaef905b8fd61bf (diff)
downloadidest-6db300c686c28f05562930b5ff58487f625e4a01.tar.gz
idest-6db300c686c28f05562930b5ff58487f625e4a01.tar.bz2
Minor change
* libid3tag/compat.gperf: Reformat
Diffstat (limited to 'libid3tag') (more/less context) (ignore whitespace changes)
-rw-r--r--libid3tag/compat.gperf282
1 files changed, 142 insertions, 140 deletions
diff --git a/libid3tag/compat.gperf b/libid3tag/compat.gperf
index 4e24613..6fa1d4e 100644
--- a/libid3tag/compat.gperf
+++ b/libid3tag/compat.gperf
@@ -133,165 +133,167 @@ WPB, EQ(WPUB) /* Publishers official webpage */
WXX, EQ(WXXX) /* User defined URL link frame */
%%
-static
-int translate_TCON(struct id3_frame *frame, char const *oldid,
- id3_byte_t const *data, id3_length_t length)
+static int
+translate_TCON(struct id3_frame *frame, char const *oldid,
+ id3_byte_t const *data, id3_length_t length)
{
- id3_byte_t const *end;
- enum id3_field_textencoding encoding;
- id3_ucs4_t *string = 0, *ptr, *endptr;
- int result = 0;
+ id3_byte_t const *end;
+ enum id3_field_textencoding encoding;
+ id3_ucs4_t *string = 0, *ptr, *endptr;
+ int result = 0;
- /* translate old TCON syntax into multiple strings */
+ /* translate old TCON syntax into multiple strings */
- assert(frame->nfields == 2);
+ assert(frame->nfields == 2);
- encoding = ID3_FIELD_TEXTENCODING_ISO_8859_1;
+ encoding = ID3_FIELD_TEXTENCODING_ISO_8859_1;
- end = data + length;
+ end = data + length;
- if (id3_field_parse(&frame->fields[0], &data, end - data, &encoding) == -1)
- goto fail;
+ if (id3_field_parse(&frame->fields[0], &data,
+ end - data, &encoding) == -1)
+ goto fail;
- string = id3_parse_string(&data, end - data, encoding, 0);
- if (string == 0)
- goto fail;
+ string = id3_parse_string(&data, end - data, encoding, 0);
+ if (string == 0)
+ goto fail;
- ptr = string;
- while (*ptr == '(') {
- if (*++ptr == '(')
- break;
+ ptr = string;
+ while (*ptr == '(') {
+ if (*++ptr == '(')
+ break;
+
+ endptr = ptr;
+ while (*endptr && *endptr != ')')
+ ++endptr;
- endptr = ptr;
- while (*endptr && *endptr != ')')
- ++endptr;
+ if (*endptr)
+ *endptr++ = 0;
- if (*endptr)
- *endptr++ = 0;
+ if (id3_field_addstring(&frame->fields[1], ptr) == -1)
+ goto fail;
+
+ ptr = endptr;
+ }
+
+ if (*ptr && id3_field_addstring(&frame->fields[1], ptr) == -1)
+ goto fail;
- if (id3_field_addstring(&frame->fields[1], ptr) == -1)
- goto fail;
+ if (0) {
+ fail:
+ result = -1;
+ }
- ptr = endptr;
- }
+ if (string)
+ free(string);
- if (*ptr && id3_field_addstring(&frame->fields[1], ptr) == -1)
- goto fail;
-
- if (0) {
- fail:
- result = -1;
- }
-
- if (string)
- free(string);
-
- return result;
+ return result;
}
/*
* NAME: compat->fixup()
* DESCRIPTION: finish compatibility translations
*/
-int id3_compat_fixup(struct id3_tag *tag)
+int
+id3_compat_fixup(struct id3_tag *tag)
{
- struct id3_frame *frame;
- unsigned int index;
- id3_ucs4_t timestamp[17] = { 0 };
- int result = 0;
-
- /* create a TDRC frame from obsolete TYER/TDAT/TIME frames */
-
- /*
- * TYE/TYER: YYYY
- * TDA/TDAT: DDMM
- * TIM/TIME: HHMM
- *
- * TDRC: yyyy-MM-ddTHH:mm
- */
-
- index = 0;
- while ((frame = id3_tag_findframe(tag, ID3_FRAME_OBSOLETE, index++))) {
- char const *id;
- id3_byte_t const *data, *end;
- id3_length_t length;
- enum id3_field_textencoding encoding;
- id3_ucs4_t *string;
-
- id = id3_field_getframeid(&frame->fields[0]);
- assert(id);
-
- if (strcmp(id, "TYER") != 0 && strcmp(id, "YTYE") != 0 &&
- strcmp(id, "TDAT") != 0 && strcmp(id, "YTDA") != 0 &&
- strcmp(id, "TIME") != 0 && strcmp(id, "YTIM") != 0)
- continue;
-
- data = id3_field_getbinarydata(&frame->fields[1], &length);
- assert(data);
-
- if (length < 1)
- continue;
-
- end = data + length;
-
- encoding = id3_parse_uint(&data, 1);
- string = id3_parse_string(&data, end - data, encoding, 0);
-
- if (id3_ucs4_length(string) < 4) {
- free(string);
- continue;
- }
-
- if (strcmp(id, "TYER") == 0 ||
- strcmp(id, "YTYE") == 0) {
- timestamp[0] = string[0];
- timestamp[1] = string[1];
- timestamp[2] = string[2];
- timestamp[3] = string[3];
- }
- else if (strcmp(id, "TDAT") == 0 ||
- strcmp(id, "YTDA") == 0) {
- timestamp[4] = '-';
- timestamp[5] = string[2];
- timestamp[6] = string[3];
- timestamp[7] = '-';
- timestamp[8] = string[0];
- timestamp[9] = string[1];
- }
- else { /* TIME or YTIM */
- timestamp[10] = 'T';
- timestamp[11] = string[0];
- timestamp[12] = string[1];
- timestamp[13] = ':';
- timestamp[14] = string[2];
- timestamp[15] = string[3];
- }
-
- free(string);
- }
-
- if (timestamp[0]) {
- id3_ucs4_t *strings;
-
- frame = id3_frame_new("TDRC");
- if (frame == 0)
- goto fail;
-
- strings = timestamp;
-
- if (id3_field_settextencoding(&frame->fields[0],
+ struct id3_frame *frame;
+ unsigned int index;
+ id3_ucs4_t timestamp[17] = { 0 };
+ int result = 0;
+
+ /* create a TDRC frame from obsolete TYER/TDAT/TIME frames */
+
+ /*
+ * TYE/TYER: YYYY
+ * TDA/TDAT: DDMM
+ * TIM/TIME: HHMM
+ *
+ * TDRC: yyyy-MM-ddTHH:mm
+ */
+
+ index = 0;
+ while ((frame = id3_tag_findframe(tag, ID3_FRAME_OBSOLETE,
+ index++))) {
+ char const *id;
+ id3_byte_t const *data, *end;
+ id3_length_t length;
+ enum id3_field_textencoding encoding;
+ id3_ucs4_t *string;
+
+ id = id3_field_getframeid(&frame->fields[0]);
+ assert(id);
+
+ if (strcmp(id, "TYER") != 0 && strcmp(id, "YTYE") != 0 &&
+ strcmp(id, "TDAT") != 0 && strcmp(id, "YTDA") != 0 &&
+ strcmp(id, "TIME") != 0 && strcmp(id, "YTIM") != 0)
+ continue;
+
+ data = id3_field_getbinarydata(&frame->fields[1], &length);
+ assert(data);
+
+ if (length < 1)
+ continue;
+
+ end = data + length;
+
+ encoding = id3_parse_uint(&data, 1);
+ string = id3_parse_string(&data, end - data, encoding, 0);
+
+ if (id3_ucs4_length(string) < 4) {
+ free(string);
+ continue;
+ }
+
+ if (strcmp(id, "TYER") == 0 ||
+ strcmp(id, "YTYE") == 0) {
+ timestamp[0] = string[0];
+ timestamp[1] = string[1];
+ timestamp[2] = string[2];
+ timestamp[3] = string[3];
+ } else if (strcmp(id, "TDAT") == 0 ||
+ strcmp(id, "YTDA") == 0) {
+ timestamp[4] = '-';
+ timestamp[5] = string[2];
+ timestamp[6] = string[3];
+ timestamp[7] = '-';
+ timestamp[8] = string[0];
+ timestamp[9] = string[1];
+ } else { /* TIME or YTIM */
+ timestamp[10] = 'T';
+ timestamp[11] = string[0];
+ timestamp[12] = string[1];
+ timestamp[13] = ':';
+ timestamp[14] = string[2];
+ timestamp[15] = string[3];
+ }
+
+ free(string);
+ }
+
+ if (timestamp[0]) {
+ id3_ucs4_t *strings;
+
+ frame = id3_frame_new("TDRC");
+ if (frame == 0)
+ goto fail;
+
+ strings = timestamp;
+
+ if (id3_field_settextencoding(&frame->fields[0],
ID3_FIELD_TEXTENCODING_ISO_8859_1) == -1 ||
- id3_field_setstrings(&frame->fields[1], 1, &strings) == -1 ||
- id3_tag_attachframe(tag, frame) == -1) {
- id3_frame_delete(frame);
- goto fail;
- }
- }
-
- if (0) {
- fail:
- result = -1;
- }
-
- return result;
+ id3_field_setstrings(&frame->fields[1], 1,
+ &strings) == -1 ||
+ id3_tag_attachframe(tag, frame) == -1) {
+ id3_frame_delete(frame);
+ goto fail;
+ }
+ }
+
+ if (0) {
+ fail:
+ result = -1;
+ }
+
+ return result;
}

Return to:

Send suggestions and report system problems to the System administrator.