diff options
author | sf <sf@FreeBSD.org> | 2002-01-16 20:41:41 +0000 |
---|---|---|
committer | sf <sf@FreeBSD.org> | 2002-01-16 20:41:41 +0000 |
commit | 49049404d2b56d1f55c086686da5d811c0bef5bf (patch) | |
tree | 060c3d3f2b8990e48dd4b59339fc9be2db619251 /japanese | |
parent | f56b290dece2ac0f9fa0655d41314b0a926f7428 (diff) | |
download | FreeBSD-ports-49049404d2b56d1f55c086686da5d811c0bef5bf.zip FreeBSD-ports-49049404d2b56d1f55c086686da5d811c0bef5bf.tar.gz |
add a new feature which can save ID3 tags as SJIS. (disabled by default)
Submitted by: Yasuhito FUTATSUKI <futatuki@bsdclub.org>
PR: 33954
Submitted by: maintainer
Diffstat (limited to 'japanese')
-rw-r--r-- | japanese/gqmpeg/Makefile | 12 | ||||
-rw-r--r-- | japanese/gqmpeg/files/extra-patch-src::japanese_tag.c | 79 | ||||
-rw-r--r-- | japanese/gqmpeg/files/extra-patch-src::japanese_tag.h | 10 | ||||
-rw-r--r-- | japanese/gqmpeg/files/extra-patch-src::mpg_tagutil.c | 83 |
4 files changed, 184 insertions, 0 deletions
diff --git a/japanese/gqmpeg/Makefile b/japanese/gqmpeg/Makefile index a555981..6d551b9 100644 --- a/japanese/gqmpeg/Makefile +++ b/japanese/gqmpeg/Makefile @@ -12,6 +12,10 @@ MAINTAINER= katsu@iec.hiroshima-u.ac.jp 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 @@ -21,4 +25,12 @@ 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" diff --git a/japanese/gqmpeg/files/extra-patch-src::japanese_tag.c b/japanese/gqmpeg/files/extra-patch-src::japanese_tag.c new file mode 100644 index 0000000..cf46e48 --- /dev/null +++ b/japanese/gqmpeg/files/extra-patch-src::japanese_tag.c @@ -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; + } + diff --git a/japanese/gqmpeg/files/extra-patch-src::japanese_tag.h b/japanese/gqmpeg/files/extra-patch-src::japanese_tag.h new file mode 100644 index 0000000..c495dec --- /dev/null +++ b/japanese/gqmpeg/files/extra-patch-src::japanese_tag.h @@ -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 */ + diff --git a/japanese/gqmpeg/files/extra-patch-src::mpg_tagutil.c b/japanese/gqmpeg/files/extra-patch-src::mpg_tagutil.c new file mode 100644 index 0000000..bf6afa1 --- /dev/null +++ b/japanese/gqmpeg/files/extra-patch-src::mpg_tagutil.c @@ -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++) + { |