Bug#601274: vorbis-tools: vorbiscomment should allow for delimiter other than newline

2010-12-01 Thread Rafael Cunha de Almeida
I've forwarded this patch upstream:

https://trac.xiph.org/ticket/1755



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#601274: vorbis-tools: vorbiscomment should allow for delimiter other than newline

2010-10-24 Thread Rafael Cunha de Almeida
Package: vorbis-tools
Version: 1.2.0-5rafael1
Severity: wishlist
Tags: patch

When vorbiscomment reads from a file, it would be nice if it could use a
delimiter other than newline. That way a metadata field value could have
a newline (which is the case for lyrics, for instance).

I wrote a patch that does just that. I tested it on version 1.2, but it
seems that version 1.4 of vorbiscommand doesn't change anything
significant. Feel free to send it upstream, apply to debian package or
just ignore it :P.

-- System Information:
Debian Release: 5.0.6
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-2-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages vorbis-tools depends on:
ii  libao2 0.8.8-4   Cross Platform Audio Output Librar
ii  libc6  2.7-18lenny4  GNU C Library: Shared libraries
ii  libcurl3-gnutls7.18.2-8lenny4Multi-protocol file transfer libra
ii  libflac8   1.2.1-1.2 Free Lossless Audio Codec - runtim
ii  libogg01.1.3-4   Ogg Bitstream Library
ii  libspeex1  1.2~rc1-1 The Speex codec runtime library
ii  libvorbis0a1.2.0.dfsg-3.1+lenny1 The Vorbis General Audio Compressi
ii  libvorbisenc2  1.2.0.dfsg-3.1+lenny1 The Vorbis General Audio Compressi
ii  libvorbisfile3 1.2.0.dfsg-3.1+lenny1 The Vorbis General Audio Compressi

vorbis-tools recommends no packages.

vorbis-tools suggests no packages.

-- no debconf information
diff -ur vorbis-tools-1.2.0.old/vorbiscomment/vcomment.c new/vorbis-tools-1.2.0/vorbiscomment/vcomment.c
--- vorbis-tools-1.2.0.old/vorbiscomment/vcomment.c	2008-03-03 02:37:25.0 -0300
+++ vorbis-tools-1.2.0.new/vorbiscomment/vcomment.c	2010-10-24 16:15:37.0 -0200
@@ -49,6 +49,7 @@
 	/* mode and flags */
 	int	mode;
 	int	raw;
+	char	delimiter;
 
 	/* file names and handles */
 	char	*infilename, *outfilename;
@@ -69,7 +70,7 @@
 /* prototypes */
 void usage(void);
 void print_comments(FILE *out, vorbis_comment *vc, int raw);
-int  add_comment(char *line, vorbis_comment *vc, int raw);
+int  add_comment(char *line, vorbis_comment *vc, char delim, int raw);
 
 param_t	*new_param(void);
 void free_param(param_t *param);
@@ -78,7 +79,7 @@
 void close_files(param_t *p, int output_written);
 
 char *
-read_line (FILE *input)
+read_line (FILE *input, char delim)
 {
 /* Construct a list of buffers. Each buffer will hold 1024 bytes. If
  * more is required, it is easier to extend the list than to extend
@@ -94,7 +95,7 @@
 
 while (1)
 {
-char *retval;
+int retval;
 
 /* Increase the max buffer count in increments of 10 */
 if (buffer_count == max_buffer_count)
@@ -103,15 +104,27 @@
 buffers = realloc (buffers, sizeof (char *) * max_buffer_count);
 }
 
-buffer = malloc (sizeof (char) * (buffer_size + 1));
-retval = fgets (buffer, (buffer_size + 1), input);
+buffer = calloc (sizeof (char), buffer_size + 1);
+{
+int i;
+for (i = 0; i  buffer_size-1; ++i) {
+retval = fgetc(input);
+if (retval == EOF) {
+break;
+} else if (retval == delim) {
+buffer[i] = delim;
+break;
+}
+buffer[i] = retval;
+}
+}
 
-if (retval)
+if (retval != EOF)
 {
 buffers[buffer_count] = buffer;
 buffer_count++;
 
-if (retval[strlen (retval) - 1] == '\n')
+if (buffer[strlen(buffer) - 1] == delim)
 {
 /* End of the line */
 break;
@@ -231,7 +244,7 @@
 
 		for(i=0; i  param-commentcount; i++)
 		{
-			if(add_comment(param-comments[i], vc, param-raw)  0)
+			if(add_comment(param-comments[i], vc, param-delimiter, param-raw)  0)
 fprintf(stderr, _(Bad comment: \%s\\n), param-comments[i]);
 		}
 
@@ -240,9 +253,9 @@
 		{
 			char *comment;
 
-			while ((comment = read_line (param-com)))
+			while ((comment = read_line (param-com, param-delimiter)))
 {
-if (add_comment (comment, vc, param-raw)  0)
+if (add_comment (comment, vc, param-delimiter, param-raw)  0)
 {
 fprintf (stderr, _(bad comment: