[PATCH] Make vorbiscomment escape whitespace characters
Łukasz Stelmach <[email protected]> Sun, 5 May 2013 21:22:16 +0200
| Newsgroups | gmane.comp.multimedia.ogg.vorbis.devel |
|---|---|
| Message-ID | <[email protected]> |
Make "vorbiscomment -e" escape the space (0x20) and tab (0x09)
characters. With this patch in place it is possible to use vorbiscomment
output with the "eval" command in shellscripts like:
eval `vorbiscomment -e foo.ogg`
test -z "$ARTIST" && echo Anonymous || echo $ARTIST
Signed-off-by: Łukasz Stelmach <[email protected]>
---
vorbiscomment/vcomment.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/vorbiscomment/vcomment.c b/vorbiscomment/vcomment.c
index 3208410..2b33274 100644
--- a/vorbiscomment/vcomment.c
+++ b/vorbiscomment/vcomment.c
@@ -422,6 +422,14 @@ char *escape(const char *from, int fromsize)
char *s;
for (s = to; fromsize > 0; fromsize--, from++) {
switch (*from) {
+ case ' ':
+ *s++ = '\\';
+ *s++ = ' ';
+ break;
+ case '\t':
+ *s++ = '\\';
+ *s++ = 't';
+ break;
case '\n':
*s++ = '\\';
*s++ = 'n';
@@ -473,6 +481,12 @@ char *unescape(const char *from, int *tosize)
if (*from == '\\') {
from++;
switch (*from++) {
+ case ' ':
+ *s++ = ' ';
+ break;
+ case 't':
+ *s++ = '\t';
+ break;
case 'n':
*s++ = '\n';
break;
--
1.8.1.5
_______________________________________________
Vorbis-dev mailing list
[email protected]
http://lists.xiph.org/mailman/listinfo/vorbis-dev