shithub: libtags

Download patch

ref: 7f72b87d6fb6e89c70bf8b280b57407dbe0d48fb
parent: e2f765c2f38c780595d97eb54e9f14c85f8f226d
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Mar 5 16:32:10 EST 2024

cp437toutf8: have the same signature as other codepage conversion funcs

--- a/437.c
+++ b/437.c
@@ -134,12 +134,12 @@
 };
 
 int
-cp437toutf8(char *o, int osz, const char *s, int sz)
+cp437toutf8(uint8_t *o, int osz, const uint8_t *s, int sz)
 {
 	int i, n;
 
 	for(i = 0; i < sz && osz > 1 && s[i] != 0; i++){
-		if((uint8_t)s[i] < 127){
+		if(s[i] < 127){
 			*o++ = s[i];
 			osz--;
 			continue;
@@ -146,7 +146,7 @@
 		}
 		if(osz < UTFmax)
 			break;
-		n = ((uint8_t)s[i] - 127) * 3;
+		n = (s[i] - 127) * 3;
 		*o++ = rh[n++];
 		*o++ = rh[n++];
 		osz -= 2;
--- a/s3m.c
+++ b/s3m.c
@@ -3,7 +3,7 @@
 int
 tags3m(Tagctx *ctx)
 {
-	char d[28+1+1], o[28*UTFmax+1], *s;
+	uint8_t d[28+1+1], o[28*UTFmax+1], *s;
 
 	if(ctx->read(ctx, d, 28+1+1) != 28+1+1 || (d[28] != 0x1a && d[28] != 0) || d[29] != 0x10)
 		return -1;
--- a/tagspriv.h
+++ b/tagspriv.h
@@ -48,7 +48,7 @@
 /*
  * Same as utf16to8, but CP437 to UTF-8.
  */
-int cp437toutf8(char *o, int osz, const char *s, int sz);
+int cp437toutf8(uint8_t *o, int osz, const uint8_t *s, int sz);
 
 /*
  * This one is common for both vorbis.c and flac.c
--- a/xm.c
+++ b/xm.c
@@ -3,9 +3,9 @@
 int
 tagxm(Tagctx *ctx)
 {
-	char d[17+20+1], o[20*UTFmax+1];
+	uint8_t d[17+20+1], o[20*UTFmax+1];
 
-	if(ctx->read(ctx, d, 17+20) != 17+20 || strncasecmp(d, "Extended Module: ", 17) != 0)
+	if(ctx->read(ctx, d, 17+20) != 17+20 || strncasecmp((char*)d, "Extended Module: ", 17) != 0)
 		return -1;
 	d[17+20] = 0;
 	if(cp437toutf8(o, sizeof(o), d+17, 20) > 0)