9front - general discussion about 9front
 help / color / mirror / Atom feed
From: chris@chrisfroeschl.de
To: 9front@9front.org
Subject: [9front] [PATCH] ktrans: add implicit chinese punctuation conversion
Date: Fri, 21 Jul 2023 13:10:49 +0200	[thread overview]
Message-ID: <44375B3152F8533B488D4A9F3DCF7104@chrisfroeschl.de> (raw)

Add implicit conversion to chinese ktrans mode.

This was actually done by moody, I just tested and forgot about it...

Manpage update incoming
diff bd2ef36d976db0a842e31af309f0ef1439f30a89 uncommitted
--- /dev/null
+++ b//lib/ktrans/judou.map
@@ -1,0 +1,28 @@
+ 	 
+,	,
+.	。
+<	《
+>	》
+/	/
+?	?
+;	;
+:	:
+\	、
+|	・
+`	`
+~	〜
+!	!
+@	@
+#	#
+$	¥
+&	&
+*	*
+(	(
+)	)
+-	-
++	+
+=	=
+[	「
+]	」
+{	『
+}	』
--- a/sys/src/cmd/ktrans/hash.c
+++ b/sys/src/cmd/ktrans/hash.c
@@ -34,7 +34,7 @@
 	nsz = Tagsize + size;
 	store = mallocz(sizeof(*h) + (nbuckets * nsz), 1);
 	if(store == nil)
-		return nil;
+		sysfatal("hmapalloc: out of memory");

 	h = store;
 	h->nbs = nbuckets;
@@ -82,6 +82,8 @@

 		h->cap *= 2;
 		*store = realloc(*store, sizeof(*h) + h->cap*h->nsz);
+		if(*store == nil)
+			sysfatal("hmaprepl: out of memory");
 		h = *store;
 		h->nodes = (uchar*)*store + sizeof(*h);
 		memset(h->nodes + h->len*h->nsz, 0, h->nsz);
--- a/sys/src/cmd/ktrans/main.c
+++ b/sys/src/cmd/ktrans/main.c
@@ -212,7 +212,7 @@
 Hmap *cyril;
 Hmap *greek;
 Hmap *hangul;
-Hmap *hanzi, *zidian;
+Hmap *judou, *zidian;
 Hmap *telex;

 Hmap **langtab[] = {
@@ -222,7 +222,7 @@
 	[LangRU]  &cyril,
 	[LangEL]  &greek,
 	[LangKO]  &hangul,
-	[LangZH]  &hanzi,
+	[LangZH]  &judou,
 	[LangVN]  &telex,
 };

@@ -652,7 +652,7 @@
 			switch(lang){
 			case LangZH:
 				emitutf(dictch, p, 1);
-				continue;
+				break;
 			case LangJP:
 				emitutf(dictch, p, 1);
 				if(isupper(*p))
@@ -849,7 +849,8 @@
 		zidianname = "/lib/ktrans/wubi.dict";
 	zidian = opendict(nil, zidianname);

-	natural = hanzi = nil;
+	natural = nil;
+	judou	= openmap("/lib/ktrans/judou.map");
 	hira 	= openmap("/lib/ktrans/hira.map");
 	kata 	= openmap("/lib/ktrans/kata.map");
 	greek 	= openmap("/lib/ktrans/greek.map");

                 reply	other threads:[~2023-07-21 11:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44375B3152F8533B488D4A9F3DCF7104@chrisfroeschl.de \
    --to=chris@chrisfroeschl.de \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).