shithub: riscv

Download patch

ref: 5e81cc48bdb00a3e7ae3334728659b8f014248da
parent: b66bffe91c2b0fac63a5124b968e807d5e73729e
author: Sigrid <[email protected]>
date: Mon May 3 17:04:39 EDT 2021

libtags: upstream updates

--- a/sys/src/cmd/audio/libtags/it.c
+++ b/sys/src/cmd/audio/libtags/it.c
@@ -3,12 +3,12 @@
 int
 tagit(Tagctx *ctx)
 {
-	char d[4+26+1], o[26*UTFmax+1];
+	uchar d[4+26+1], o[26*2+1];
 
 	if(ctx->read(ctx, d, 4+26) != 4+26 || memcmp(d, "IMPM", 4) != 0)
 		return -1;
 	d[4+26] = 0;
-	if(cp437toutf8(o, sizeof(o), d+4, 26) > 0)
+	if(iso88591toutf8(o, sizeof(o), d+4, 26) > 0)
 		txtcb(ctx, Ttitle, "", o);
 
 	return 0;
--- a/sys/src/cmd/audio/libtags/mod.c
+++ b/sys/src/cmd/audio/libtags/mod.c
@@ -16,6 +16,7 @@
 	"CD81",
 	"OCTA",
 	"OKTA",
+	"10CH",
 	"16CN",
 	"32CN",
 	nil,
@@ -24,7 +25,7 @@
 int
 tagmod(Tagctx *ctx)
 {
-	char d[20], o[20*UTFmax+1];
+	uchar d[20], o[20*2+1];
 	int i;
 
 	if(ctx->seek(ctx, 1080, 0) != 1080)
@@ -41,7 +42,7 @@
 		return -1;
 	if(ctx->read(ctx, d, 20) != 20)
 		return -1;
-	if(cp437toutf8(o, sizeof(o), d, 20) > 0)
+	if(iso88591toutf8(o, sizeof(o), d, 20) > 0)
 		txtcb(ctx, Ttitle, "", o);
 
 	return 0;
--- a/sys/src/cmd/audio/libtags/tags.c
+++ b/sys/src/cmd/audio/libtags/tags.c
@@ -41,19 +41,20 @@
 	char *e;
 
 	if(f == nil && size == 0){
-		while(*s <= ' ' && *s)
+		while((uchar)*s <= ' ' && *s)
 			s++;
 		e = s + strlen(s);
-		while(e != s && e[-1] <= ' ')
+		while(e != s && (uchar)e[-1] <= ' ')
 			e--;
 		*e = 0;
 	}
-	if(type != Tunknown){
-		ctx->found |= 1<<type;
-		ctx->num++;
-	}
-	if(*s)
+	if(*s){
 		ctx->tag(ctx, type, k, s, offset, size, f);
+		if(type != Tunknown){
+			ctx->found |= 1<<type;
+			ctx->num++;
+		}
+	}
 }
 
 int
--- a/sys/src/cmd/audio/libtags/tagspriv.h
+++ b/sys/src/cmd/audio/libtags/tagspriv.h
@@ -41,4 +41,4 @@
 
 void tagscallcb(Tagctx *ctx, int type, const char *k, char *s, int offset, int size, Tagread f);
 
-#define txtcb(ctx, type, k, s) tagscallcb(ctx, type, k, (const char*)s, 0, 0, nil)
+#define txtcb(ctx, type, k, s) tagscallcb(ctx, type, k, (char*)s, 0, 0, nil)
--- a/sys/src/cmd/audio/libtags/xm.c
+++ b/sys/src/cmd/audio/libtags/xm.c
@@ -3,12 +3,11 @@
 int
 tagxm(Tagctx *ctx)
 {
-	char d[17+20+1], o[20*UTFmax+1], *s;
+	char d[17+20+1], o[20*UTFmax+1];
 
-	if(ctx->read(ctx, d, 17+20) != 17+20 || memcmp(d, "Extended Module: ", 17) != 0)
+	if(ctx->read(ctx, d, 17+20) != 17+20 || cistrncmp(d, "Extended Module: ", 17) != 0)
 		return -1;
 	d[17+20] = 0;
-	for(s = d+17; *s == ' '; s++);
 	if(cp437toutf8(o, sizeof(o), d+17, 20) > 0)
 		txtcb(ctx, Ttitle, "", o);