unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
blob f6a6748ce51519db1cc15a378d0da8e0b69ae1ae 3212 bytes (raw)
name: admin/charsets/eucjp-ms.awk 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
 
# eucjp-ms.awk -- Generate a translation table for eucJP-ms.
# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
#   National Institute of Advanced Industrial Science and Technology (AIST)
#   Registration Number H13PRO009

# This file is part of GNU Emacs.

# GNU Emacs is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# GNU Emacs is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.

# Commentary:

# eucJP-ms is one of eucJP-open encoding defined at this page:
#  https://web.archive.org/web/20120207064433/http://home.m05.itscom.net/numa/cde/ucs-conv/appendix.html
# This program reads the mapping file EUC-JP-MS (of glibc) and
# generates the Elisp file eucjp-ms.el that defines two translation
# tables 'eucjp-ms-decode' and 'eucjp-ms-encode'.

BEGIN {
  FS = "[ \t][ \t]*"

  # STATE: 0/ignore, 1/JISX0208, 2/JISX0208 target range
  #        3/JISX0212 4/JISX0212 target range
  state = 0;

  JISX0208_FROM1 = "/xad/xa1";
  JISX0208_TO1 = "/xad/xfc";
  JISX0208_FROM2 = "/xf5/xa1";
  JISX0212_FROM = "/x8f/xf3/xf3";

  print ";;; eucjp-ms.el -- translation table for eucJP-ms";
  print ";;; Automatically generated from /usr/share/i18n/charmaps/EUC-JP-MS.gz";
  print "(let ((map";
  print "       '(;JISEXT<->UNICODE";
}

function write_entry (unicode) {
    if (state == 1) {
	if ($2 == JISX0208_FROM1 || $2 == JISX0208_FROM2)
	    state = 2;
    } else if (state == 3) {
	if ($2 == JISX0212_FROM)
	    state = 4;
    }
    if (state == 2) {
	jis = $2
	gsub("/x", "", jis);
	printf "\n	 (#x%s . #x%s)", jis, unicode;
	if ($2 == JISX0208_TO1)
	    state = 1;
    } else if (state == 4) {
	jis = substr($2, 5, 8);
	gsub("/x", "", jis);
	printf "\n	 (#x%s #x%s)", jis, unicode;
    }
}


/^% JIS X 0208/ {
    state = 1;
    next;
}

/^% JIS X 0212/ {
    state = 3;
    next;
}

/^END CHARMAP/ {
    state = 0;
    next;
}

/^<U[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]>/ {
    if (state > 0)
	write_entry(substr($1, 3, 4));
}

/^%IRREVERSIBLE%<U[0-9A-Z][0-9A-Z][0-9A-Z][0-9A-Z]>/ {
    if (state > 0)
	write_entry(substr($1, 17, 4));
}

END {
  print ")))";
  print "  (setq map";
  print "    (mapcar";
  print "	(lambda (x)";
  print "	    (let ((code (logand (car x) #x7F7F)))";
  print "	      (if (integerp (cdr x))";
  print "		  (cons (decode-char 'japanese-jisx0208 code) (cdr x))";
  print "		(cons (decode-char 'japanese-jisx0212 code)"
  print "		      (cadr x)))))";
  print "	map))";
  print "  (define-translation-table 'eucjp-ms-decode map)";
  print "  (mapc (lambda (x)";
  print "	    (let ((tmp (car x)))";
  print "	      (setcar x (cdr x)) (setcdr x tmp)))";
  print "	map)";
  print "  (define-translation-table 'eucjp-ms-encode map))";
  print "";
  print "(provide 'eucjp-ms)";
}

debug log:

solving f6a6748ce5 ...
found f6a6748ce5 in https://git.savannah.gnu.org/cgit/emacs.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).