Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2002 03:23:07 +0900 (JST)
From:      TATEISHI Katsuyuki <katsu@iec.hiroshima-u.ac.jp>
To:        FreeBSD-gnats-submit@freebsd.org
Cc:        futatuki@bsdclub.org
Subject:   ports/33954: Update port: japanese/gqmpeg
Message-ID:  <200201161823.g0GIN7L36918@adam.iec.hiroshima-u.ac.jp>

next in thread | raw e-mail | index | archive | help

>Number:         33954
>Category:       ports
>Synopsis:       Update port: japanese/gqmpeg
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 16 10:30:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     TATEISHI Katsuyuki
>Release:        FreeBSD 4.5-RC i386
>Organization:
>Environment:
System: FreeBSD adam.iec.hiroshima-u.ac.jp 4.5-RC FreeBSD 4.5-RC #23: Sun Jan 13 07:28:36 JST 2002 root@adam.iec.hiroshima-u.ac.jp:/usr/obj/usr/src/sys/ADAM i386

>Description:

Enable a new feature which can save ID3 tags as SJIS.

Submitted by:	Yasuhito FUTATSUKI <futatuki@bsdclub.org>
	
Added files:	files/
		files/extra-patch-src::japanese_tag.c
		files/extra-patch-src::japanese_tag.h
		files/extra-patch-src::mpg_tagutil.c

>How-To-Repeat:
>Fix:

Index: gqmpeg/Makefile
===================================================================
RCS file: /home/ncvs/ports/japanese/gqmpeg/Makefile,v
retrieving revision 1.1
diff -u -r1.1 Makefile
--- gqmpeg/Makefile	22 Oct 2001 06:21:17 -0000	1.1
+++ gqmpeg/Makefile	16 Jan 2002 16:39:14 -0000
@@ -12,6 +12,10 @@
 PATCH_SITES=	http://linuxlovers.yi.org/softarc/
 PATCHFILES=	gqmpeg-0.9.0-jp_title.patch
 
+.if defined(WITH_SJIS_TAG)
+EXTRA_PATCHES=	${.CURDIR}/files/extra-patch-*
+.endif
+
 MASTERDIR=	${.CURDIR}/../../audio/gqmpeg
 MD5_FILE=	${.CURDIR}/distinfo
 COMMENT=	${.CURDIR}/pkg-comment
@@ -20,5 +24,13 @@
 CONFIGURE_ARGS=	--enable-japanese
 
 NOMAN=		yes
+
+.if !defined(WITH_SJIS_TAG)
+pre-everything::
+	@${ECHO_MSG}
+	@${ECHO_MSG} "If you want to save ID3 tags as SJIS(default: EUC),"
+	@${ECHO_MSG} "hit Ctrl-C right now and execute \"make WITH_SJIS_TAG=yes\""
+	@${ECHO_MSG}
+.endif
 
 .include "${MASTERDIR}/Makefile"
Index: gqmpeg/files/extra-patch-src::japanese_tag.c
===================================================================
RCS file: gqmpeg/files/extra-patch-src::japanese_tag.c
diff -N gqmpeg/files/extra-patch-src::japanese_tag.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gqmpeg/files/extra-patch-src::japanese_tag.c	16 Jan 2002 01:42:34 -0000
@@ -0,0 +1,79 @@
+--- ./src/japanese_tag.c.orig	Fri Jan  5 00:35:31 2001
++++ ./src/japanese_tag.c	Fri Jan  4 05:58:49 2002
+@@ -64,6 +64,16 @@
+ 	*p2 -= cellOffset;
+ }
+ 
++static void _sjis_rev_shift(int *p1, int *p2)
++{
++	unsigned char c1 = *p1;
++	unsigned char c2 = *p2;
++	int rowOffset = c1 < 95 ? 112 : 176;
++	int cellOffset = c1 % 2 ? (c2 > 95 ? 32 : 31) : 126;
++	*p1 = ((c1 + 1) >> 1) + rowOffset;
++	*p2 += cellOffset;
++}
++
+ static unsigned char *_skip_esc(unsigned char *str, int *esc_in)
+ {
+ 	int c;
+@@ -139,6 +149,36 @@
+ 	*str2 = '\0';
+ }
+ 
++static void _euc2shift(unsigned char const *str, unsigned char *str2)
++{
++	int p1,p2;
++  
++	while ((p1 = (int)*str) != '\0') {
++                /* SB-SJIS with SS2 */
++		if (p1 == 0x8e) {
++			if((p2 = (int)*(++str)) == '\0') break;
++			CHAROUT(p1);
++			str++;
++			continue;
++		}
++
++		if ( (p1 >= 161) && ( p1 <= 254) ) {
++			if ((p2 = (int)*(++str)) == '\0') break;
++			if ( (p2 >= 161) && ( p2 <= 254) ) {
++				p1 -= 128, p2 -= 128;
++				_sjis_rev_shift(&p1,&p2);
++			}
++			CHAROUT(p1);
++			CHAROUT(p2);
++			str++;
++			continue;
++		}
++		CHAROUT(p1);
++		str++;
++	}
++	*str2='\0';
++}
++
+ static int _detect(unsigned char *str, int expected)
+ {
+ 	register int c;
+@@ -313,6 +353,22 @@
+ 
+ 	ret = g_strdup(buf);
+ 	g_free(buf);
++	return ret;
++}
++
++char *to_string_sjis_from_euc(char const *str)
++{
++	char *buf, *ret;
++
++	if(!str) return (NULL);
++
++	buf = (char*)g_malloc(strlen(str)*2 + 1);
++	if (!buf) return NULL;
++
++	_euc2shift((unsigned char *)str, (unsigned char *)buf);
++
++	ret = strdup(buf);
++	free(buf);
+ 	return ret;
+ }
+ 
Index: gqmpeg/files/extra-patch-src::japanese_tag.h
===================================================================
RCS file: gqmpeg/files/extra-patch-src::japanese_tag.h
diff -N gqmpeg/files/extra-patch-src::japanese_tag.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gqmpeg/files/extra-patch-src::japanese_tag.h	16 Jan 2002 01:44:23 -0000
@@ -0,0 +1,10 @@
+--- ./src/japanese_tag.h.orig	Fri Jan  5 00:43:02 2001
++++ ./src/japanese_tag.h	Fri Jan  4 04:24:21 2002
+@@ -16,6 +16,7 @@
+ #ifdef ENABLE_JAPANESE_TAGS
+ 
+ char *to_string_euc(char *str);
++char *to_string_sjis_from_euc(char const *str);
+ 
+ #endif /* ENABLE_JAPANESE_TAGS */
+ 
Index: gqmpeg/files/extra-patch-src::mpg_tagutil.c
===================================================================
RCS file: gqmpeg/files/extra-patch-src::mpg_tagutil.c
diff -N gqmpeg/files/extra-patch-src::mpg_tagutil.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gqmpeg/files/extra-patch-src::mpg_tagutil.c	16 Jan 2002 01:45:34 -0000
@@ -0,0 +1,83 @@
+--- ./src/mpg_tagutil.c.orig	Thu Oct 25 10:56:57 2001
++++ ./src/mpg_tagutil.c	Fri Jan  4 05:58:35 2002
+@@ -149,6 +149,12 @@
+ 	FILE *f;
+ 	gchar buf[130];
+ 	gint i;
++#ifdef ENABLE_JAPANESE_TAGS
++	gchar tmpbuf[31];
++	gchar *ctp;
++
++	tmpbuf[30] = '\0';
++#endif
+ 
+ 	f = fopen(path,"r+");
+         if (!f)
+@@ -209,11 +215,67 @@
+ 		}
+ 
+ 	strncpy(buf, "TAG", 3);
++#ifdef ENABLE_JAPANESE_TAGS
++	if (title && *title) {
++		strncpy(tmpbuf, title, 30);
++		ctp = to_string_sjis_from_euc(tmpbuf);
++		if (ctp) {
++			strncpy(buf + 3, ctp, 30);
++			free(ctp);
++		}
++		else {
++        	        printf("fail to convert title tag encoding\n");
++			fclose(f);
++			return FALSE;
++		}
++	}
++	if (artist && *artist) {
++		strncpy(tmpbuf, artist, 30);
++		ctp = to_string_sjis_from_euc(tmpbuf);
++		if (ctp) {
++			strncpy(buf + 33, ctp, 30);
++			free(ctp);
++		}
++		else {
++        	        printf("fail to convert artist tag encoding\n");
++			fclose(f);
++			return FALSE;
++		}
++	}
++	if (album && *album) {
++		strncpy(tmpbuf, album, 30);
++		ctp = to_string_sjis_from_euc(tmpbuf);
++		if (ctp) {
++			strncpy(buf + 63, ctp, 30);
++			free(ctp);
++		}
++		else {
++        	        printf("fail to convert album tag encoding\n");
++			fclose(f);
++			return FALSE;
++		}
++	}
++	if (year) strncpy(buf + 93, year, 4);
++	if (comment && *comment) {
++		strncpy(tmpbuf, comment, 30);
++		ctp = to_string_sjis_from_euc(tmpbuf);
++		if (ctp) {
++			strncpy(buf + 97, ctp, 30);
++			free(ctp);
++		}
++		else {
++        	        printf("fail to convert comment tag encoding\n");
++			fclose(f);
++			return FALSE;
++		}
++	}
++#else
+ 	if (title) strncpy(buf + 3, title, 30);
+ 	if (artist) strncpy(buf + 33, artist, 30);
+ 	if (album) strncpy(buf + 63, album, 30);
+ 	if (year) strncpy(buf + 93, year, 4);
+ 	if (comment) strncpy(buf + 97, comment, 30);
++#endif
+ 
+ 	for (i=0; i<128; i++)
+ 		{
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200201161823.g0GIN7L36918>