aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-i18n')
-rw-r--r--app-i18n/canfep/Manifest1
-rw-r--r--app-i18n/canfep/canfep-1.0-r1.ebuild38
-rw-r--r--app-i18n/canfep/files/canfep-1.0-respect-flags.patch24
-rw-r--r--app-i18n/canfep/files/canfep-1.0-utf8.patch190
-rw-r--r--app-i18n/canfep/files/canfep-posix-pty.patch67
-rw-r--r--app-i18n/canfep/files/canfep-termcap.patch266
-rw-r--r--app-i18n/canfep/metadata.xml9
7 files changed, 595 insertions, 0 deletions
diff --git a/app-i18n/canfep/Manifest b/app-i18n/canfep/Manifest
new file mode 100644
index 000000000..8b3ed0252
--- /dev/null
+++ b/app-i18n/canfep/Manifest
@@ -0,0 +1 @@
+DIST canfep-1.0.tar.gz 8067 BLAKE2B 1a6e8af357d2b7aaccf442b0f8bab577ed05a5a0fdf2fb4c189105c2c41f739c2e559e740584bf393fcc52d3f3bd0bb6216e06e2b685f62f7dded9d576e95bed SHA512 0fd7c8ca56282fa537b76fe33f46e03d4f0f4727528ccad95cd4726888372da9158fc8bed2cdc67d645defb479040cd4a4d0999f69d38fd8b4080f7ece4e67d6
diff --git a/app-i18n/canfep/canfep-1.0-r1.ebuild b/app-i18n/canfep/canfep-1.0-r1.ebuild
new file mode 100644
index 000000000..5c5fdabb8
--- /dev/null
+++ b/app-i18n/canfep/canfep-1.0-r1.ebuild
@@ -0,0 +1,38 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit toolchain-funcs
+
+DESCRIPTION="Canna Japanese kana-kanji frontend processor on console"
+HOMEPAGE="https://web.archive.org/web/20170517105759/http://www.geocities.co.jp/SiliconValley-Bay/7584/canfep/"
+SRC_URI="https://web.archive.org/web/20181106043248if_/http://www.geocities.co.jp/SiliconValley-Bay/7584/${PN}/${P}.tar.gz"
+
+LICENSE="canfep"
+SLOT="0"
+KEYWORDS="~amd64"
+
+RDEPEND="
+ app-i18n/canna
+ sys-libs/ncurses:=
+"
+DEPEND="${RDEPEND}"
+BDEPEND="virtual/pkgconfig"
+
+PATCHES=(
+ "${FILESDIR}/${P}-utf8.patch"
+ "${FILESDIR}/${PN}-posix-pty.patch"
+ "${FILESDIR}/${PN}-termcap.patch"
+ "${FILESDIR}/${P}-respect-flags.patch"
+)
+
+src_compile() {
+ tc-export CXX
+ LIBS="$($(tc-getPKG_CONFIG) --libs ncurses)" emake
+}
+
+src_install() {
+ dobin "${PN}"
+ dodoc 00{changes,readme}
+}
diff --git a/app-i18n/canfep/files/canfep-1.0-respect-flags.patch b/app-i18n/canfep/files/canfep-1.0-respect-flags.patch
new file mode 100644
index 000000000..4dbcbec77
--- /dev/null
+++ b/app-i18n/canfep/files/canfep-1.0-respect-flags.patch
@@ -0,0 +1,24 @@
+--- a/Makefile
++++ b/Makefile
+@@ -1,7 +1,5 @@
+ # Linux
+-CC=c++
+-LIBS=-lcanna -ltermcap
+-CFLAGS=-O2 -g
++LIBS += -lcanna
+
+ # Solaris 2.6J
+ #CC=c++
+@@ -19,10 +17,10 @@
+ all: $(TARGET)
+
+ $(TARGET): $(OBJS)
+- $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
++ $(CXX) $(CXXFLAGS) $(LDFLAGS) -fPIE -o $@ $(OBJS) $(LIBS)
+
+ .C.o:
+- $(CC) $(CFLAGS) -c $<
++ $(CXX) $(CXXFLAGS) -fPIC -c $<
+
+ clean:
+ rm -rf $(TARGET) $(OBJS)
diff --git a/app-i18n/canfep/files/canfep-1.0-utf8.patch b/app-i18n/canfep/files/canfep-1.0-utf8.patch
new file mode 100644
index 000000000..e798d109d
--- /dev/null
+++ b/app-i18n/canfep/files/canfep-1.0-utf8.patch
@@ -0,0 +1,190 @@
+--- a/canna.C
++++ b/canna.C
+@@ -4,10 +4,87 @@
+ #define FEP_KEY 15
+ #define ESC_KEY 27
+
++void Canna::write_utf8(int fd, char *p, int len)
++{
++ if (eucjp_to_utf8_cd == (iconv_t)-1)
++ write(fd, p, strlen(p));
++ else
++ {
++ char *putf8 = iconv_string(eucjp_to_utf8_cd, p, len);
++ write(fd, putf8, strlen(putf8));
++ free(putf8);
++ }
++}
++
++char * Canna::iconv_string(iconv_t fd, char *str, int slen)
++{
++ char *from;
++ size_t fromlen;
++ char *to;
++ size_t tolen;
++ size_t len = 0;
++ size_t done = 0;
++ char *result = NULL;
++ char *p;
++ int l;
++
++ from = (char *)str;
++ fromlen = slen;
++ for (;;)
++ {
++ if (len == 0 || errno == E2BIG)
++ {
++ /* Allocate enough room for most conversions. When re-allocating
++ * increase the buffer size. */
++ len = len + fromlen * 2 + 40;
++ p = (char*)malloc((unsigned)len);
++ if (p != NULL && done > 0)
++ memcpy(p, result, done);
++ free(result);
++ result = p;
++ if (result == NULL) /* out of memory */
++ break;
++ }
++
++ to = (char *)result + done;
++ tolen = len - done - 2;
++ /* Avoid a warning for systems with a wrong iconv() prototype by
++ * casting the second argument to void *. */
++ if (iconv(fd, &from, &fromlen, &to, &tolen) != (size_t)-1)
++ {
++ /* Finished, append a NUL. */
++ *to = 0;
++ break;
++ }
++ /* Check both ICONV_EILSEQ and EILSEQ, because the dynamically loaded
++ * iconv library may use one of them. */
++ if (errno == EILSEQ || errno == EILSEQ)
++ {
++ /* Can't convert: insert a '?' and skip a character. This assumes
++ * conversion from 'encoding' to something else. In other
++ * situations we don't know what to skip anyway. */
++ *to++ = *from++;
++ fromlen -= 1;
++ }
++ else if (errno != E2BIG)
++ {
++ /* conversion failed */
++ free(result);
++ result = NULL;
++ break;
++ }
++ /* Not enough room or skipping illegal sequence. */
++ done = to - (char *)result;
++ }
++ return result;
++}
++
+ // コンストラクタだよん
+ Canna::Canna(int ac, char** av, char* amsg, char* emsg):
+ Pty(ac, av, amsg, emsg)
+ {
++ char *p_lang = getenv("LANG");
++
+ // かんなの初期化
+ jrKanjiControl(0, KC_INITIALIZE, 0);
+ jrKanjiControl(0, KC_SETAPPNAME, "canfep");
+@@ -15,6 +92,9 @@
+ jrKanjiControl(0, KC_QUERYMODE, (char*) saveMode);
+ jrKanjiControl(0, KC_SETWIDTH, (char*) 72);
+
++ if (p_lang == NULL || strstr(p_lang, "-8"))
++ eucjp_to_utf8_cd = iconv_open("utf-8", "euc-jp");
++
+ mode(saveMode);
+ }
+
+@@ -25,6 +105,8 @@
+ jrKanjiControl(0, KC_KILL, (char*) &ksv);
+ jrKanjiControl(0, KC_FINALIZE, 0);
+
++ if (eucjp_to_utf8_cd != (iconv_t)-1)
++ iconv_close(eucjp_to_utf8_cd);
+ mode(saveMode);
+ }
+
+@@ -32,7 +114,7 @@
+ void
+ Canna::kakutei(unsigned char* p)
+ {
+- write(wfd, p, strlen((char*) p));
++ write_utf8(wfd, (char*)p, strlen((char*) p));
+ }
+
+ // 変換中(未確定)の文字列を出力する
+@@ -42,13 +124,13 @@
+ write(rfd, sc, strlen(sc));
+ write(rfd, rc, strlen(rc));
+ write(rfd, us, strlen(us));
+- write(rfd, p, pos);
++ write_utf8(rfd, (char*)p, pos);
+ write(rfd, ue, strlen(ue));
+ write(rfd, so, strlen(so));
+- write(rfd, p + pos, len);
++ write_utf8(rfd, (char*)p + pos, len);
+ write(rfd, se, strlen(se));
+ write(rfd, us, strlen(us));
+- write(rfd, p + pos + len, strlen((char*) p + pos + len));
++ write_utf8(rfd, (char*)p + pos + len, strlen((char*) p + pos + len));
+ write(rfd, ue, strlen(ue));
+ }
+
+@@ -73,7 +155,7 @@
+ write(rfd, sc, strlen(sc));
+ write(rfd, ts, strlen(ts));
+ write(rfd, ce, strlen(ce));
+- write(rfd, p, strlen((char*) p));
++ write_utf8(rfd, (char*)p, strlen((char*) p));
+ write(rfd, fs, strlen(fs));
+ }
+
+@@ -84,13 +166,13 @@
+ write(rfd, sc, strlen(sc));
+ write(rfd, ts, strlen(ts));
+ write(rfd, ce, strlen(ce));
+- write(rfd, p, strlen((char*) p));
++ write_utf8(rfd, (char*)p, strlen((char*) p));
+ write(rfd, " ", 1);
+- write(rfd, l, pos);
++ write_utf8(rfd, (char*)l, pos);
+ write(rfd, so, strlen(so));
+- write(rfd, l + pos, len);
++ write_utf8(rfd, (char*)l + pos, len);
+ write(rfd, se, strlen(se));
+- write(rfd, l + pos + len, strlen((char*) l + pos +len));
++ write_utf8(rfd, (char*)l + pos + len, strlen((char*) l + pos +len));
+ write(rfd, fs, strlen(fs));
+ }
+
+--- a/canna.H
++++ b/canna.H
+@@ -5,6 +5,8 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
++#include <errno.h>
++#include <iconv.h>
+ #include <canna/jrkanji.h>
+
+ #include "pty.H"
+@@ -17,6 +19,7 @@
+ jrKanjiStatus ks;
+ jrKanjiStatusWithValue ksv;
+ private:
++ iconv_t eucjp_to_utf8_cd;
+ unsigned char currentMode[BUFSIZ];
+ unsigned char saveMode[BUFSIZ];
+ private:
+@@ -25,6 +28,8 @@
+ void delhenkan(int len);
+ void mode(unsigned char* p);
+ void gline(unsigned char* p, unsigned char* l, int pos, int len);
++ void write_utf8(int fd, char *p, int len);
++ char* iconv_string(iconv_t fd, char *str, int slen);
+ public:
+ void loop();
+ };
diff --git a/app-i18n/canfep/files/canfep-posix-pty.patch b/app-i18n/canfep/files/canfep-posix-pty.patch
new file mode 100644
index 000000000..caa451232
--- /dev/null
+++ b/app-i18n/canfep/files/canfep-posix-pty.patch
@@ -0,0 +1,67 @@
+https://bugs.gentoo.org/show_bug.cgi?id=212709
+
+Author: OKUMURA N. Shin-ya <oku.ns@dream.com>
+
+--- a/pty.C
++++ b/pty.C
+@@ -257,6 +257,23 @@
+ }
+ }
+
++#if defined(_POSIX_C_SOURCE)
++ // BSD pty が開けないので、POSIX の方法を試す
++ if ((master = posix_openpt(O_RDWR)) >= 0) {
++ if (grantpt(master) == 0 && unlockpt(master) == 0) {
++ // マスタデバイス名は固定
++ strcpy(line, "/dev/ptmx");
++ tcgetattr(0, &tt);
++ tt.c_iflag &= ~ISTRIP;
++ ioctl(0, TIOCGWINSZ, (char*) &win);
++ return;
++ }
++ close(master);
++ } else {
++ perror("/dev/ptmx");
++ }
++#endif // _POSIX_C_SOURCE
++
+ printf("Out of pty's\n");
+ fail();
+ }
+@@ -265,12 +282,36 @@
+ void
+ Pty::getslave()
+ {
++#if defined(_POSIX_C_SOURCE)
++ // マスタデバイスが POSIX 方式の場合
++ if (strcmp(line, "/dev/ptmx") == 0) {
++ char *slave_devname = ptsname(master);
++ if (slave_devname == NULL) {
++ perror("ptsname");
++ fail();
++ }
++ slave = open(slave_devname, O_RDWR);
++ if (slave < 0) {
++ perror(slave_devname);
++ fail();
++ }
++ strcpy(line, slave_devname);
++ } else {
++ line[strlen("/dev/")] = 't';
++ slave = open(line, O_RDWR);
++ if (slave < 0) {
++ perror(line);
++ fail();
++ }
++ }
++#else // ! _POSIX_C_SOURCE
+ line[strlen("/dev/")] = 't';
+ slave = open(line, O_RDWR);
+ if (slave < 0) {
+ perror(line);
+ fail();
+ }
++#endif // _POSIX_C_SOURCE
+ tcsetattr(slave, TCSAFLUSH, &tt);
+ if (!hs)
+ win.ws_row--;
diff --git a/app-i18n/canfep/files/canfep-termcap.patch b/app-i18n/canfep/files/canfep-termcap.patch
new file mode 100644
index 000000000..afd215b07
--- /dev/null
+++ b/app-i18n/canfep/files/canfep-termcap.patch
@@ -0,0 +1,266 @@
+--- a/pty.C
++++ b/pty.C
+@@ -4,9 +4,18 @@
+ int Pty::child = 0;
+ struct termios Pty::tt;
+ int Pty::wfd = 0;
++char Pty::buf[] = "";
++char Pty::funcstr[] = "";
+ int Pty::hs = 0;
++char* Pty::so = 0;
++char* Pty::se = 0;
++char* Pty::us = 0;
++char* Pty::ue = 0;
++char* Pty::sc = 0;
++char* Pty::rc = 0;
+ char* Pty::ce = 0;
+ char* Pty::ts = 0;
++char* Pty::fs = 0;
+ char* Pty::ds = 0;
+ char Pty::endstr[] = "";
+ char Pty::endmsg[] = "";
+@@ -14,88 +23,7 @@
+ // コンストラクタだよん
+ Pty::Pty(int ac, char** av, char* amsg, char* emsg)
+ {
+- // 環境変数 TERM のエントリを取得
+- char buff[BUFSIZ];
+- char* term = getenv("TERM");
+- if (!term)
+- term = "vt100";
+- int ret = tgetent(buff, term);
+- if (ret != 1) {
+- tgetent(buff, "vt100");
+- putenv("TERM=vt100");
+- }
+-
+- // termcap から装飾用のエントリを取ってくる
+- char funcstr[BUFSIZ];
+- char* pt = funcstr;
+-
+- // スタンドアウト (反転)
+- so = tgetstr("so", &pt);
+- adjstr(so);
+- se = tgetstr("se", &pt);
+- adjstr(se);
+-
+- // アンダーライン (下線)
+- us = tgetstr("us", &pt);
+- adjstr(us);
+- ue = tgetstr("ue", &pt);
+- adjstr(ue);
+-
+- // カーソル位置の保存,保存した位置への復帰
+- sc = tgetstr("sc", &pt);
+- adjstr(sc);
+- rc = tgetstr("rc", &pt);
+- adjstr(rc);
+-
+- // カーソル位置から行の最後までを削除する
+- ce = tgetstr("ce", &pt);
+- adjstr(ce);
+-
+- // ステータスラインを持っているかどうか
+- hs = tgetflag("hs");
+-
+- // kon と jfbterm ではステータスラインを使わない
+- if (strcmp(term, "kon") == 0)
+- hs = 0;
+- if (strcmp(term, "jfbterm") == 0)
+- hs = 0;
+-
+- // ステータスラインへ移動,戻る
+- if (hs) {
+- ts = tgoto(tgetstr("ts", &pt), 0, 0);
+- adjstr(ts);
+- fs = tgetstr("fs", &pt);
+- adjstr(fs);
+- ds = tgetstr("ds", &pt);
+- adjstr(ds);
+- if (ds) {
+- strcat(endstr, ds);
+- strcat(endstr, ce);
+- }
+- }
+- else {
+- char* cs = tgoto(tgetstr("cs", &pt), tgetnum("li") - 2, 0);
+- adjstr(cs);
+- if (cs) {
+- write(1, ce, strlen(ce));
+- write(1, cs, strlen(cs));
+- }
+- char* cl = tgetstr("cl", &pt);
+- adjstr(cl);
+- if (cl) {
+- write(1, cl, strlen(cl));
+- strcat(endstr, cl);
+- }
+- ds = tgoto(tgetstr("cs", &pt), tgetnum("li") - 1, 0);
+- adjstr(ds);
+- if (ds) {
+- strcat(endstr, ds);
+- strcat(endstr, ce);
+- }
+- ts = tgoto(tgetstr("cm", &pt), 0, tgetnum("li") - 1);
+- adjstr(ts);
+- fs = rc;
+- }
++ gettermcap();
+
+ // 開始と終了のメッセージ
+ if (amsg && ac == 1)
+@@ -209,21 +137,75 @@
+ done();
+ }
+
+-// termcap エントリからパディングを削除する
+ void
+-Pty::adjstr(char* str)
++Pty::gettermcap()
+ {
+- char* sp = strdup(str);
+- char* p = sp;
+- while (*p != '\0') {
+- if (strncmp(p, "$<", 2) == 0) {
+- while (*p != '>')
+- p++;
+- *p = '\0';
++ // 環境変数 TERM のエントリを取得
++ char* term = getenv("TERM");
++ if (!term)
++ term = "vt100";
++ int ret = tgetent(buf, term);
++ if (ret != 1) {
++ tgetent(buf, "vt100");
++ putenv("TERM=vt100");
++ }
++
++ // termcap から装飾用のエントリを取ってくる
++ char* pt = funcstr;
++
++ // スタンドアウト (反転)
++ so = tgetstr("so", &pt);
++ se = tgetstr("se", &pt);
++
++ // アンダーライン (下線)
++ us = tgetstr("us", &pt);
++ ue = tgetstr("ue", &pt);
++
++ // カーソル位置の保存,保存した位置への復帰
++ sc = tgetstr("sc", &pt);
++ rc = tgetstr("rc", &pt);
++
++ // カーソル位置から行の最後までを削除する
++ ce = tgetstr("ce", &pt);
++
++ // ステータスラインを持っているかどうか
++ hs = tgetflag("hs");
++
++ // kon と jfbterm ではステータスラインを使わない
++ if (strcmp(term, "kon") == 0)
++ hs = 0;
++ if (strcmp(term, "jfbterm") == 0)
++ hs = 0;
++
++ // ステータスラインへ移動,戻る
++ if (hs) {
++ ts = tgoto(tgetstr("ts", &pt), 0, 0);
++ fs = tgetstr("fs", &pt);
++ ds = tgetstr("ds", &pt);
++ if (ds) {
++ strcat(endstr, ds);
++ strcat(endstr, ce);
+ }
+- *str++ = *p++;
+ }
+- free(sp);
++ else {
++ char* cs = tgoto(tgetstr("cs", &pt), tgetnum("li") - 2, 0);
++ if (cs) {
++ write(1, ce, strlen(ce));
++ write(1, cs, strlen(cs));
++ }
++ char* cl = tgetstr("cl", &pt);
++ if (cl) {
++ write(1, cl, strlen(cl));
++ strcat(endstr, cl);
++ }
++ ds = tgoto(tgetstr("cs", &pt), tgetnum("li") - 1, 0);
++ if (ds) {
++ strcat(endstr, ds);
++ strcat(endstr, ce);
++ }
++ ts = tgoto(tgetstr("cm", &pt), 0, tgetnum("li") - 1);
++ fs = rc;
++ }
+ }
+
+ // マスタデバイスを取る
+@@ -327,34 +309,7 @@
+ {
+ signal(SIGWINCH, SIG_IGN);
+
+- // ステータスラインが使えない場合は cs/ds/ts を取り直す
+- if (!hs) {
+- char buff[BUFSIZ];
+- char* term = getenv("TERM");
+- tgetent(buff, term);
+- char funcstr[BUFSIZ];
+- char* pt = funcstr;
+- char* cs = tgoto(tgetstr("cs", &pt), tgetnum("li") - 2, 0);
+- adjstr(cs);
+- if (cs) {
+- write(1, ce, strlen(ce));
+- write(1, cs, strlen(cs));
+- }
+- char* cl = tgetstr("cl", &pt);
+- adjstr(cl);
+- if (cl) {
+- write(1, cl, strlen(cl));
+- strcpy(endstr, cl);
+- }
+- ds = tgoto(tgetstr("cs", &pt), tgetnum("li") - 1, 0);
+- adjstr(ds);
+- if (ds) {
+- strcat(endstr, ds);
+- strcat(endstr, ce);
+- }
+- ts = tgoto(tgetstr("cm", &pt), 0, tgetnum("li") - 1);
+- adjstr(ts);
+- }
++ gettermcap();
+
+ // ウィンドウのサイズを設定し直す (stty -a の 行数/桁数 等)
+ struct winsize win;
+--- a/pty.H
++++ b/pty.H
+@@ -50,18 +50,21 @@
+ int rfd;
+ static int wfd;
+ private:
+- static void adjstr(char* str);
++ static char buf[BUFSIZ];
++ static char funcstr[BUFSIZ];
++private:
++ static void gettermcap();
+ protected:
+ static int hs;
+- char* so;
+- char* se;
+- char* us;
+- char* ue;
+- char* sc;
+- char* rc;
++ static char* so;
++ static char* se;
++ static char* us;
++ static char* ue;
++ static char* sc;
++ static char* rc;
+ static char* ce;
+ static char* ts;
+- char* fs;
++ static char* fs;
+ static char* ds;
+ private:
+ static void finish();
diff --git a/app-i18n/canfep/metadata.xml b/app-i18n/canfep/metadata.xml
new file mode 100644
index 000000000..37185a78f
--- /dev/null
+++ b/app-i18n/canfep/metadata.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+ <maintainer type="person">
+ <description>co-maintainers welcome</description>
+ <name>Alessandro Barbieri</name>
+ <email>lssndrbarbieri@gmail.com</email>
+ </maintainer>
+</pkgmetadata>