View | Details | Raw Unified
Collapse All | Expand All

(-) a2ps-4.13.ORIG/Makefile.am (-1 / +1 lines)
 Lines 20-26    Link Here 
## Make sure to drop doc at the end: it causes may problems, so
## Make sure to drop doc at the end: it causes may problems, so
## let's do the maximum before it
## let's do the maximum before it
SUBDIRS = auxdir m4 etc ps ogonkify \
SUBDIRS = auxdir m4 etc ps ogonkify libjcode \
	lib src po tests sheets encoding afm fonts ppd contrib doc man
	lib src po tests sheets encoding afm fonts ppd contrib doc man
ACLOCAL_AMFLAGS = -I m4
ACLOCAL_AMFLAGS = -I m4
(-) a2ps-4.13.ORIG/Makefile.in (-1 / +1 lines)
 Lines 275-281    Link Here 
target_alias = @target_alias@
target_alias = @target_alias@
tex = @tex@
tex = @tex@
AUTOMAKE_OPTIONS = check-news 1.6.3 dist-bzip2 readme-alpha
AUTOMAKE_OPTIONS = check-news 1.6.3 dist-bzip2 readme-alpha
SUBDIRS = auxdir m4 etc ps ogonkify \
SUBDIRS = auxdir m4 etc ps ogonkify libjcode \
	lib src po tests sheets encoding afm fonts ppd contrib doc man
	lib src po tests sheets encoding afm fonts ppd contrib doc man
ACLOCAL_AMFLAGS = -I m4
ACLOCAL_AMFLAGS = -I m4
(-) a2ps-4.13.ORIG/README.jp (+89 lines)
Line 0    Link Here 
a2ps 4.12で漢字を印刷するためのパッチ
				慶應大学大学院
				古川 泰之 <yasu@on.cs.keio.ac.jp>
composite font を使って漢字を表示するためのパッチです。
composite fontには、片山 紀夫さん(はじめて日本語ghostscriptを作成した
人)のfixeucfont をベースにa2ps用に多少手をいれております。これを利用す
ることで、2バイトEUC+ASCIIの文字列のPostscriptの扱いがぐっと簡単にな
ります。
●Compositeフォントの設定方法について
最低限の設定はパッチに含まれていますので、とりあえず大丈夫だとは思いま
す。一応メモしておきます。
encodingファイル($prefix/share/a2ps/encoding/の下のファイル)には
『Composite:』および、『DefaultComposite:』が新たに指定できます。たと
えば、英語フォントに対応するEUCエンコーディングの日本語フォントを書い
て行きます。また、この際、フォント幅と半角と漢字の比も指定しなくてはな
りません。手抜きによって、漢字は固定幅フォントしか指定してはいけません。
--------------------------------------------------
#	                  日本語フォント          フォン横幅	半角と漢字の比
DefaultComposite:         Ryumin-Light-EUC-H      1             1.1	
#	    英語フォント  日本語フォント	  フォン横幅	半角と漢字の比
Composite:  Helvetica     GothicBBB-Medium-EUC-H  1		1.1
--------------------------------------------------
また、これだと斜体漢字がなく、さみしいので、SlantFontを使い、斜体の漢
字フォントも作成できます。
--------------------------------------------------
#               新規斜体日本語フォント名	ソース日本語フォント	傾き度
SlantFont:	Ryumin-Light-EUC-H-Italic	Ryumin-Light-EUC-H	0.2
--------------------------------------------------
SlantFontで生成した斜体フォントはCompositeフォント(第2引数)で利用でき
ます。
●このパッチの詳細データ
  ・残念ながら2バイトEUCコードを前提としたコーディングをしています。
    そのため、あまり漢字以外の言語を考えておりません…。
  ・倉光 君郎氏のlibjcodeを使って内部で入力ファイルの漢字エンコーディ
    ングをすべてEUCに変換して処理するようにしています。ただし、オリジ
    ナルのlibjcodeは、SJISおよびEUCの判定が甘かったので多少カスタムし
    ております。
  ・また、texのdelegate(contrib/texi2dvi4a2ps)中、TeXドライバにはpTeX
    と決めうちしています。これがいやなら、例えばNTT-jTeXを使用したい場
    合、環境変数TEXに『jtex』を、LATEXには『jlatex』を指定してください。
  ・compositefontをa2ps用に多少カスタマイズしていますが、フォントの高
    さなどの情報を完全に固定で決め打ちしている箇所があります(XXXでメモ
    しています)。そのためあまり応用性が低いと思います。
●半角を全角の1/2の大きさにしたい
パッチデフォルトでは全角文字と半角文字の大きさのバランスは、見た感じが
(個人的なセンスで)安定するようにチューニングしています。もし、テキスト
で表を作成していて、そのため、半角文字を全角のちょうど半分にそろえたい
という場合の対処方法を書いておきます。
インストール後、$prefix/share/a2ps/encoding/euc-jp中に、
--------------------------------------------------
DefaultComposite:         Ryumin-Light-EUC-H      1.0  1.1
--------------------------------------------------
というのがあると思います。最後の『1.1』を『0.8342』あたりに変更して下
さい。ノーマル固定文字に関してはこれで望みの結果が得られると思います。
他の太字フォントなども、例えば
--------------------------------------------------
Composite: Courier-Bold   GothicBBB-Medium-EUC-H  1.0  0.8342
--------------------------------------------------
のように変更すればいいと思います。なお、Courierがつかないフォント
(Helvetica等)はもともとプロポーショナルフォントなので、固定幅にはでき
ません。
●再配布について
なんだかんだいって、このパッチは、
倉光 君郎さんのlibjcode  +  片山 紀夫さんのfixeucfont 
を組み合わてできたもので私自身のコードは実はほとんどありません…。
私自身のコードは再配付/改造に関してなんら制限を設けるつもりはありませ
ん。ただし、私以外のコードの方が多いため、一応それだけは御了承お願い致
します。
(-) a2ps-4.13.ORIG/config.h.in (+3 lines)
 Lines 24-29    Link Here 
/* Define if TIOCGWINSZ requires sys/ioctl.h */
/* Define if TIOCGWINSZ requires sys/ioctl.h */
#undef GWINSZ_IN_SYS_IOCTL
#undef GWINSZ_IN_SYS_IOCTL
/* Define if you use libjcode for japanese  */
#undef USE_LIBJCODE
/* Define to 1 if you have the `alarm' function. */
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
#undef HAVE_ALARM
(-) a2ps-4.13.ORIG/configure (-2 / +46 lines)
 Lines 1587-1593    Link Here 
  --with-medium=medium    specify the default medium (A4, Letter, Legal, etc.)
  --with-medium=medium    specify the default medium (A4, Letter, Legal, etc.)
                          default=A4
                          default=A4
  --with-encoding=enc     specify the default encoding (ascii, latin1,
  --with-encoding=enc     specify the default encoding (ascii, latin1,
                          latin2... latin6, hp etc.) default=latin1
                          latin2... latin6, euc-jp, hp etc.) default=latin1
  --enable-libjcode	  Japanese code auto convert library (default: yes)
Some influential environment variables:
Some influential environment variables:
  CC          C compiler command
  CC          C compiler command
 Lines 30943-30948    Link Here 
fi;
fi;
# Check whether --enable-libjcode or --disable-libjcode was given.
if test "${enable_libjcode+set}" = set; then
  enableval="$enable_libjcode"
  COMPILE_LIBJCODE=$enableval
else
  COMPILE_LIBJCODE=yes
fi
if test "$COMPILE_LIBJCODE" = "yes"; then
	LIBJCODELIBS=\$\(top_builddir\)/libjcode/libjcode.a
	cat >> confdefs.h <<\EOF
#define USE_LIBJCODE 1
EOF
	ENCODING=euc-jp
fi
# Check whether --enable-libjcode or --disable-libjcode was given.
if test "${enable_libjcode+set}" = set; then
  enableval="$enable_libjcode"
  COMPILE_LIBJCODE=$enableval
else
  COMPILE_LIBJCODE=yes
fi
if test "$COMPILE_LIBJCODE" = "yes"; then
	LIBJCODELIBS=\$\(top_builddir\)/libjcode/libjcode.a
	cat >> confdefs.h <<\EOF
#define USE_LIBJCODE 1
EOF
	ENCODING=euc-jp
fi
########################
########################
# Nice special printers
# Nice special printers
########################
########################
 Lines 32925-32931    Link Here 
          ac_config_files="$ac_config_files contrib/psset"
          ac_config_files="$ac_config_files contrib/psset"
ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile man/Makefile tests/Makefile tests/defs lib/Makefile auxdir/Makefile m4/Makefile etc/Makefile etc/a2ps_cfg etc/a2ps-site.cfg po/Makefile.in sheets/Makefile encoding/Makefile ps/Makefile afm/Makefile contrib/Makefile contrib/sample/Makefile contrib/emacs/Makefile fonts/Makefile ppd/Makefile"
ac_config_files="$ac_config_files Makefile src/Makefile doc/Makefile man/Makefile tests/Makefile tests/defs lib/Makefile libjcode/Makefile auxdir/Makefile m4/Makefile etc/Makefile etc/a2ps_cfg etc/a2ps-site.cfg po/Makefile.in sheets/Makefile encoding/Makefile ps/Makefile afm/Makefile contrib/Makefile contrib/sample/Makefile contrib/emacs/Makefile fonts/Makefile ppd/Makefile"
cat >confcache <<\_ACEOF
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# This file is a shell script that caches the results of configure
 Lines 33546-33551    Link Here 
    "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
    "tests/Makefile") CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;;
    "tests/defs") CONFIG_FILES="$CONFIG_FILES tests/defs" ;;
    "tests/defs") CONFIG_FILES="$CONFIG_FILES tests/defs" ;;
    "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
    "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
    "libjcode/Makefile") CONFIG_FILES="$CONFIG_FILES libjcode/Makefile" ;;
    "auxdir/Makefile") CONFIG_FILES="$CONFIG_FILES auxdir/Makefile" ;;
    "auxdir/Makefile") CONFIG_FILES="$CONFIG_FILES auxdir/Makefile" ;;
    "m4/Makefile") CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;;
    "m4/Makefile") CONFIG_FILES="$CONFIG_FILES m4/Makefile" ;;
    "etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;;
    "etc/Makefile") CONFIG_FILES="$CONFIG_FILES etc/Makefile" ;;
 Lines 33804-33809    Link Here 
LPR_QUEUE_OPTION!$LPR_QUEUE_OPTION$ac_delim
LPR_QUEUE_OPTION!$LPR_QUEUE_OPTION$ac_delim
MEDIUM!$MEDIUM$ac_delim
MEDIUM!$MEDIUM$ac_delim
ENCODING!$ENCODING$ac_delim
ENCODING!$ENCODING$ac_delim
COMPILE_LIBJCODE!$COMPILE_LIBJCODE$ac_delim
LIBJCODELIBS!$LIBJCODELIBS$ac_delim
COM_gv!$COM_gv$ac_delim
COM_gv!$COM_gv$ac_delim
gv!$gv$ac_delim
gv!$gv$ac_delim
COM_ghostview!$COM_ghostview$ac_delim
COM_ghostview!$COM_ghostview$ac_delim
(-) a2ps-4.13.ORIG/configure.in (-1 / +18 lines)
 Lines 274-284    Link Here 
#
#
AC_ARG_WITH(encoding,
AC_ARG_WITH(encoding,
AC_HELP_STRING([--with-encoding=enc],
AC_HELP_STRING([--with-encoding=enc],
               [specify the default encoding (ascii, latin1, latin2... latin6, hp etc.) [default=latin1]]),
               [specify the default encoding (ascii, latin1, latin2... latin6, euc-jp, hp etc.) [default=latin1]]),
ENCODING=$with_encoding,
ENCODING=$with_encoding,
ENCODING=latin1)
ENCODING=latin1)
AC_SUBST(ENCODING)
AC_SUBST(ENCODING)
#
# use libjcode
#
AC_ARG_ENABLE(libjcode,
	[  --enable-libjcode	  Japanese code auto convert library (default: yes)],
			COMPILE_LIBJCODE=$enableval, COMPILE_LIBJCODE=yes)
if test "$COMPILE_LIBJCODE" = "yes"; then
	LIBJCODELIBS=\$\(top_builddir\)/libjcode/libjcode.a
	AC_DEFINE(USE_LIBJCODE, 1,
		  [Define if you want to use libjcode.])
	ENCODING=euc-jp
fi
AC_SUBST(COMPILE_LIBJCODE)
AC_SUBST(LIBJCODELIBS)
########################
########################
# Nice special printers
# Nice special printers
########################
########################
 Lines 386-391    Link Here 
  tests/Makefile tests/defs
  tests/Makefile tests/defs
  lib/Makefile
  lib/Makefile
  auxdir/Makefile
  auxdir/Makefile
  libjcode/Makefile
  m4/Makefile
  m4/Makefile
  etc/Makefile etc/a2ps_cfg etc/a2ps-site.cfg
  etc/Makefile etc/a2ps_cfg etc/a2ps-site.cfg
  po/Makefile.in
  po/Makefile.in
(-) a2ps-4.13.ORIG/contrib/texi2dvi4a2ps (-2 / +2 lines)
 Lines 374-380    Link Here 
      makeinfo= # no point in running makeinfo on latex source.
      makeinfo= # no point in running makeinfo on latex source.
      texindex=${MAKEINDEX:-makeindex}
      texindex=${MAKEINDEX:-makeindex}
      if test $oformat = dvi; then
      if test $oformat = dvi; then
        tex=${LATEX:-latex}
        tex=${LATEX:-platex}
      else
      else
        tex=${PDFLATEX:-pdflatex}
        tex=${PDFLATEX:-pdflatex}
      fi
      fi
 Lines 385-391    Link Here 
      bibtex=
      bibtex=
      texindex=${TEXINDEX:-texindex}
      texindex=${TEXINDEX:-texindex}
      if test $oformat = dvi; then
      if test $oformat = dvi; then
        tex=${TEX:-tex}
        tex=${TEX:-ptex}
      else
      else
        tex=${PDFTEX:-pdftex}
        tex=${PDFTEX:-pdftex}
      fi
      fi
(-) a2ps-4.13.ORIG/encoding/Makefile.am (-1 / +1 lines)
 Lines 16-22    Link Here 
minor_encodings = \
minor_encodings = \
ms-cp1250.edf hp.edf mac.edf ibm-cp437.edf ibm-cp850.edf iso2.edf	\
ms-cp1250.edf hp.edf mac.edf ibm-cp437.edf ibm-cp850.edf iso2.edf	\
iso3.edf iso4.edf iso5.edf iso7.edf iso9.edf iso10.edf iso13.edf	\
iso3.edf iso4.edf iso5.edf iso7.edf iso9.edf iso10.edf iso13.edf	\
iso15.edf koi8.edf ms-cp1251.edf
iso15.edf koi8.edf ms-cp1251.edf euc-jp.edf
if EXTENSIONS
if EXTENSIONS
encodings_DATA = encoding.map $(major_encodings) $(minor_encodings)
encodings_DATA = encoding.map $(major_encodings) $(minor_encodings)
(-) a2ps-4.13.ORIG/encoding/Makefile.in (-1 / +1 lines)
 Lines 270-276    Link Here 
minor_encodings = \
minor_encodings = \
ms-cp1250.edf hp.edf mac.edf ibm-cp437.edf ibm-cp850.edf iso2.edf	\
ms-cp1250.edf hp.edf mac.edf ibm-cp437.edf ibm-cp850.edf iso2.edf	\
iso3.edf iso4.edf iso5.edf iso7.edf iso9.edf iso10.edf iso13.edf	\
iso3.edf iso4.edf iso5.edf iso7.edf iso9.edf iso10.edf iso13.edf	\
iso15.edf koi8.edf ms-cp1251.edf
iso15.edf koi8.edf ms-cp1251.edf euc-jp.edf
@EXTENSIONS_FALSE@encodings_DATA = encoding.map $(major_encodings)
@EXTENSIONS_FALSE@encodings_DATA = encoding.map $(major_encodings)
@EXTENSIONS_TRUE@encodings_DATA = encoding.map $(major_encodings) $(minor_encodings)
@EXTENSIONS_TRUE@encodings_DATA = encoding.map $(major_encodings) $(minor_encodings)
(-) a2ps-4.13.ORIG/encoding/encoding.map (+6 lines)
 Lines 93-98    Link Here 
koi8			koi8
koi8			koi8
koi			koi8
koi			koi8
euc-jp			euc-jp
eucjp			euc-jp
japanese		euc-jp
ja			euc-jp
jp			euc-jp
########################################################################
########################################################################
# Some architectures specific char sets
# Some architectures specific char sets
########################################################################
########################################################################
(-) a2ps-4.13.ORIG/encoding/euc-jp.edf (+109 lines)
Line 0    Link Here 
# Description of the EUC-JP encoding
# Copyright (c) 1988, 89, 90, 91, 92, 93 Miguel Santana
# Copyright (c) 1995, 96, 97, 98 Akim Demaille, Miguel Santana
#
#
# This file is part of a2ps.
# 
# This program 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 2, or (at your option)
# any later version.
#
# This program 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 this program; see the file COPYING.  If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
Name: EUC-JP
# This text is reproduced by a courtesy of Roman Czyborra
# http://czyborra.com/charsets/iso8859.html
Documentation
The EUC-JP character set, often simply referred to as Latin 1,
covers most West European languages, such as French, Spanish, Catalan,
Basque, Portuguese, Italian, Albanian, Rhaeto-Romanic, Dutch, German,
Danish, Swedish, Norwegian, Finnish, Faroese, Icelandic, Irish,
Scottish, and English, incidentally also Afrikaans and Swahili, thus
in effect also the entire American continent, Australia and the
southern two-thirds of Africa. The lack of the ligatures Dutch IJ,
French OE and ,,German`` quotation marks is considered tolerable.
The lack of the new C=-resembling Euro currency symbol U+20AC has
opened the discussion of a new Latin0.
EndDocumentation
# If there is an unknown font requested, use Courier
Default: Courier
# Automatic spell checking :)
Substitute: 	Times			Times-Roman
Substitute: 	Helvetica-Italic	Helvetica-Oblique
Substitute: 	Helvetica-BoldItalic	Helvetica-BoldOblique
# SlantFont for Japanese Italic Kanji font
#		new font			source font		value
SlantFont:	Ryumin-Light-EUC-H-Italic	Ryumin-Light-EUC-H	0.2
SlantFont:	GothicBBB-Medium-EUC-H-Italic	GothicBBB-Medium-EUC-H	0.2
# Compose font for japanese EUC code
#		target font		additional font			width	size rate
DefaultComposite:			Ryumin-Light-EUC-H		1.0	1.1
# 1:2 fixed
#DefaultComposite:			Ryumin-Light-EUC-H		1.0	0.8333
# 1:1 fixed
#DefaultComposite:			Ryumin-Light-EUC-H		1.0	1.6666
Composite:	Helvetica		GothicBBB-Medium-EUC-H		1.0	1.1
Composite:	Helvetica-Oblique	GothicBBB-Medium-EUC-H-Italic	1.0 	1.1
Composite:	Helvetica-Bold		GothicBBB-Medium-EUC-H  	1.0 	1.1
Composite:	Helvetica-BoldOblique	GothicBBB-Medium-EUC-H-Italic	1.0	1.1
Composite:	Courier-Oblique		Ryumin-Light-EUC-H-Italic	1.0	1.1
Composite:	Courier-Bold		GothicBBB-Medium-EUC-H		1.0	1.1
Composite:	Courier-BoldOblique	GothicBBB-Medium-EUC-H-Italic	1.0	1.1
Composite:	Times-Bold		GothicBBB-Medium-EUC-H		1.0	1.1
Vector:
.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
space exclam quotedbl numbersign dollar percent ampersand quoteright
parenleft parenright asterisk plus comma minus period slash
zero one two three four five six seven
eight nine colon semicolon less equal greater question
at A B C D E F G
H I J K L M N O
P Q R S T U V W
X Y Z bracketleft backslash bracketright asciicircum underscore
quoteleft a b c d e f g
h i j k l m n o
p q r s t u v w
x y z braceleft bar braceright asciitilde .notdef
.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
.notdef .notdef .notdef .notdef .notdef .notdef .notdef .notdef
space exclamdown cent sterling currency yen brokenbar section
dieresis copyright ordfeminine guillemotleft logicalnot hyphen registered macron
degree plusminus twosuperior threesuperior acute mu paragraph bullet
cedilla onesuperior ordmasculine guillemotright onequarter onehalf threequarters questiondown
Agrave Aacute Acircumflex Atilde Adieresis Aring AE Ccedilla
Egrave Eacute Ecircumflex Edieresis Igrave Iacute Icircumflex Idieresis
Eth Ntilde Ograve Oacute Ocircumflex Otilde Odieresis multiply
Oslash Ugrave Uacute Ucircumflex Udieresis Yacute Thorn germandbls
agrave aacute acircumflex atilde adieresis aring ae ccedilla
egrave eacute ecircumflex edieresis igrave iacute icircumflex idieresis
eth ntilde ograve oacute ocircumflex otilde odieresis divide
oslash ugrave uacute ucircumflex udieresis yacute thorn ydieresis
(-) a2ps-4.13.ORIG/lib/encoding.c (-1 / +250 lines)
 Lines 37-42    Link Here 
#include "document.h"
#include "document.h"
#include "quotearg.h"
#include "quotearg.h"
#include "strverscmp.h"
#include "strverscmp.h"
#ifdef USE_LIBJCODE
int use_libjcode = false;
#endif
/* Suffix of the Encoding Description Files */
/* Suffix of the Encoding Description Files */
#define EDF_SUFFIX ".edf"
#define EDF_SUFFIX ".edf"
 Lines 389-403    Link Here 
 * Association of suffixes rules, and corresponding style sheet
 * Association of suffixes rules, and corresponding style sheet
 * (The hashing is upon `alias')
 * (The hashing is upon `alias')
 */
 */
struct slantfont_info {
  char * name;
  char * src;
  float raito;
};
struct encoding {
struct encoding {
  char * key;			/* e.g. latin1			*/
  char * key;			/* e.g. latin1			*/
  char * name;			/* e.g. ISO Latin 1		*/
  char * name;			/* e.g. ISO Latin 1		*/
  int    composite_flag;		/* flag for composite font	*/
  uchar * documentation;		/* Useful pieces of text	*/
  uchar * documentation;		/* Useful pieces of text	*/
  char * default_font;		/* When a font can't be used
  char * default_font;		/* When a font can't be used
				   define the font to use	*/
				   define the font to use	*/
  struct pair_htable * substitutes;	/* e.g. in latin2, don't use
  struct pair_htable * substitutes;	/* e.g. in latin2, don't use
					 * Courier, but Courier-Ogonki	*/
					 * Courier, but Courier-Ogonki	*/
  struct pair_htable * composite;
  struct slantfont_info     slantfont[NB_FACES];
  char * vector[256];	/* Define the char set			*/
  char * vector[256];	/* Define the char set			*/
  struct darray * font_names_used;
  struct darray * font_names_used;
 Lines 407-412    Link Here 
  struct hash_table_s * fonts;	/* Contains cells that are
  struct hash_table_s * fonts;	/* Contains cells that are
				 * 1. name of font, 2. int wx[256] 	*/
				 * 1. name of font, 2. int wx[256] 	*/
  unsigned int * faces_wx[NB_FACES];
  unsigned int * faces_wx[NB_FACES];
  unsigned int   composite_wx[NB_FACES];     /* fixed length font width*/
  float          composite_raito[NB_FACES];  /* size raito of additonal and orinal font */
};
};
/*
/*
 Lines 423-431    Link Here 
  res->name = NULL;
  res->name = NULL;
  res->default_font = NULL;
  res->default_font = NULL;
  res->documentation = NULL;
  res->documentation = NULL;
  res->composite_flag = false;
  /* Vector will be set by setup */
  /* Vector will be set by setup */
  res->substitutes = pair_table_new ();
  res->substitutes = pair_table_new ();
  res->composite = pair_table_new ();
  res->slantfont[0].name = NULL;
  res->font_names_used = da_new ("List of font names", 10,
  res->font_names_used = da_new ("List of font names", 10,
				 da_linear, 10,
				 da_linear, 10,
				 (da_print_func_t) da_str_print,
				 (da_print_func_t) da_str_print,
 Lines 471-476    Link Here 
}
}
/*
/*
 * Add a composite font in the current encoding
 */
static void
encoding_add_composite_font (struct encoding * encoding,
			      const char * orig, const char * subs,
			      int wx, float raito)
{
  encoding->composite_flag = true;
  pair_add2 (encoding->composite, orig, subs, wx, raito);
}
/*
 * Add a composite font in the current encoding
 */
static void
encoding_add_slant_font (struct encoding * encoding,
			 const char * new, const char * src,
			 float raito)
{
  static num =  0;
  encoding->slantfont[num].name = strdup(new);
  encoding->slantfont[num].src  = strdup(src);
  encoding->slantfont[num].raito = raito;
  encoding->slantfont[num+1].name = NULL;
  num++;
}
/*
 * When FONT_NAME is used with ENCODING, return the
 * When FONT_NAME is used with ENCODING, return the
 * real font name to use (e.g., in latin2, Courier-Ogonki
 * real font name to use (e.g., in latin2, Courier-Ogonki
 * should be returned when asked for Courier).
 * should be returned when asked for Courier).
 Lines 514-519    Link Here 
    }
    }
  message (msg_enc,
  message (msg_enc,
	   (stderr, "In encoding %s, composite font for %s is resolved as %s\n",
	    encoding->key, font_name, res));
  return res;
}
/*
 * Get composite font size and raito
 */
static int
composite_font_info_get_wx(struct a2ps_job * job,
			   struct encoding * encoding,
			   const char * font_list)
{
  int wx= -1;
  char * font_list_copy;
  char * font_name;
  astrcpy (font_list_copy, font_list);
  font_name = strtok (font_list_copy, ",<>;");
  wx = pair_get_wx (encoding->composite, font_name);
  if (wx<0)
      wx = pair_get_wx (encoding->composite, "default_composite__");
  return wx;
}
static float
composite_font_info_get_raito(struct a2ps_job * job,
			      struct encoding * encoding,
			      const char * font_list)
{
  float raito= -1;
  char * font_list_copy;
  char * font_name;
  astrcpy (font_list_copy, font_list);
  font_name = strtok (font_list_copy, ",<>;");
  raito = pair_get_raito (encoding->composite, font_name);
  if (raito<0)
      raito = pair_get_raito (encoding->composite, "default_composite__");
  return raito;
}
const char *
encoding_resolve_composite_font (struct a2ps_job * job,
				  struct encoding * encoding,
				  const char * font_list)
{
  const char * res = NULL;
  char * font_list_copy;
  char * font_name;
  astrcpy (font_list_copy, font_list);
  font_name = strtok (font_list_copy, ",<>;");
  /* Find if there is a substitute for that font */
  res = pair_get (encoding->composite, font_name);
  /* We've found nothing interesting.  Last chance is the default
   * font */
  if (!res)
    {
      res = pair_get (encoding->composite, "default_composite__");
      if (!res)
	error (1, 0, "Cannot find font %s, nor any composite font",
	       font_name);
    }
  
  message (msg_enc,
	   (stderr, "In encoding %s, font %s is resolved as %s\n",
	   (stderr, "In encoding %s, font %s is resolved as %s\n",
	    encoding->key, font_name, res));
	    encoding->key, font_name, res));
  return res;
  return res;
 Lines 585-590    Link Here 
	{
	{
	  token2 = GET_TOKEN (NULL);
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  CHECK_TOKEN ();
#ifdef USE_LIBJCODE
	  if( strcmp(token2, "EUC-JP")== 0)
	    use_libjcode = true;
	  else 
	    use_libjcode = false;
#endif
	  encoding->name = xstrdup (token2);
	  encoding->name = xstrdup (token2);
	}
	}
      else if (strequ (token, "Default:"))
      else if (strequ (token, "Default:"))
 Lines 633-638    Link Here 
	  subs = token2;
	  subs = token2;
	  encoding_add_font_substitute (encoding, orig, subs);
	  encoding_add_font_substitute (encoding, orig, subs);
	}
	}
      else if (strequ (token, "DefaultComposite:"))
	{
	  char * orig, * subs;
	  int wx;
	  float raito;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  subs = token2;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  wx = (int)atof(token2)*1000;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  raito = atof(token2);
	  encoding_add_composite_font(encoding, "default_composite__",
				      subs, wx, raito);
	}
      else if (strequ (token, "Composite:"))
	{
	  char * orig, * subs;
	  int wx;
	  float raito;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  orig = token2;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  subs = token2;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  wx = (int)atof(token2)*1000;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  raito = atof(token2);
	  encoding_add_composite_font(encoding, orig, subs, wx, raito);
	}
      else if (strequ (token, "SlantFont:"))
	{
	  char * new, * src;
	  float raito;
	  unsigned int num;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  new = token2;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  src = token2;
	  token2 = GET_TOKEN (NULL);
	  CHECK_TOKEN ();
	  raito = atof(token2);
	  for (num = 0 ; encoding->slantfont[num].name ; num ++ );
	  if (num > sizeof encoding->slantfont - 1){
	      error_at_line (1, 0, fname, firstline,
			   _("too many slant font: `%s'"), new);
	  }
	  encoding_add_slant_font(encoding, new, src, raito);
	}
      else
      else
        error_at_line (1, 0, fname, firstline,
        error_at_line (1, 0, fname, firstline,
                       _("invalid option `%s'"), quotearg (token));
                       _("invalid option `%s'"), quotearg (token));
 Lines 754-759    Link Here 
}
}
/*
/*
 * Return the flag of composite flag
 */
int
encoding_get_composite_flag (struct encoding * enc)
{
  return enc->composite_flag;
}
/*
 * Prepare the environment (a dictionary) for the support
 * Prepare the environment (a dictionary) for the support
 * of ENCODING, dump it into STREAM.
 * of ENCODING, dump it into STREAM.
 *
 *
 Lines 766-774    Link Here 
		     struct encoding * encoding)
		     struct encoding * encoding)
{
{
  size_t i, nb;
  size_t i, nb;
  size_t ns;
  const char * real_font_name;		/* After subsitution	*/
  const char * real_font_name;		/* After subsitution	*/
  char ** font_names = (char **) encoding->font_names_used->content;
  char ** font_names = (char **) encoding->font_names_used->content;
  /* How many fonts are there? */
  /* How many fonts are there? */
  da_qsort (encoding->font_names_used);
  da_qsort (encoding->font_names_used);
  da_unique (encoding->font_names_used, (da_map_func_t) free);
  da_unique (encoding->font_names_used, (da_map_func_t) free);
 Lines 787-801    Link Here 
   * in the current ENCODING	*/
   * in the current ENCODING	*/
  nb = encoding->font_names_used->len;
  nb = encoding->font_names_used->len;
  /* The number of slant fonts */
  for (i= 0, ns=0 ; encoding->slantfont[i].name ; i++ )
      ns++;
  /* Create the dictionary and fill it */
  /* Create the dictionary and fill it */
  fprintf (stream, "%% Dictionary for %s support\n",
  fprintf (stream, "%% Dictionary for %s support\n",
	  encoding->name);
	  encoding->name);
  fprintf (stream, "/%sdict %d dict begin\n", encoding->key, nb);
  fprintf (stream, "/%sdict %d dict begin\n", encoding->key,
	   (encoding->composite_flag == true)? nb+nb+ns:nb+ns);
  for (i = 0 ; i < nb ; i++)
  for (i = 0 ; i < nb ; i++)
    fprintf (stream, "  /f%s %sEncoding /%s reencode_font\n",
    fprintf (stream, "  /f%s %sEncoding /%s reencode_font\n",
	     font_names [i],
	     font_names [i],
	     encoding->name,
	     encoding->name,
	     encoding_resolve_font_substitute (job, encoding, font_names [i]));
	     encoding_resolve_font_substitute (job, encoding, font_names [i]));
  /* Slant font setting */
  for (i = 0 ; encoding->slantfont[i].name ; i++ )
    fprintf (stream, "  /%s /%s %f slantfont  definefont pop\n",
	     encoding->slantfont[i].name,
	     encoding->slantfont[i].src,
	     encoding->slantfont[i].raito);
  /*
   * Composite font setting.
   * If kanji font size is larger than alphabet character, 
   * set base font size to kanji charactor size.
   */
  if (encoding->composite_flag == true) {
    for (i = 0 ; i < nb ; i++)
      fprintf (stream, "  /f%s /f%s /%s %f %f false  compositefont "
	               "%f scalefont def\n",
	       font_names [i],
	       font_names [i],
	       encoding_resolve_composite_font (job, encoding, font_names [i]),
	       encoding->composite_raito[i],
	       (encoding->composite_raito[i] > 1.0)?
	       0: (1-encoding->composite_raito[i])/2.0,
	       (encoding->composite_raito[i] > 1.0)?
	       1.0/encoding->composite_raito[i]: 1.0 );
  }
  fputs ("currentdict end def\n", stream);
  fputs ("currentdict end def\n", stream);
}
}


 Lines 939-944    Link Here 
				   true_font_name,
				   true_font_name,
				   encoding->vector,
				   encoding->vector,
				   encoding->faces_wx [face]);
				   encoding->faces_wx [face]);
      if (encoding->composite_flag)
	{
	  encoding->composite_raito[i] =
	    composite_font_info_get_raito(job, encoding, 
					  job->face_eo_font [face]);
	  encoding->composite_wx[i] =
	    composite_font_info_get_wx(job, encoding, 
				       job->face_eo_font [face]);
	  /* If kanji font size is larger than alphabet character, 
	     fit kanji charactor size to base font size */
	  if (encoding->composite_raito[i] < 1.0)
	      encoding->composite_wx[i] *= encoding->composite_raito[i]; 
	}
    }
    }
}
}
 Lines 1073-1078    Link Here 
  return 0;	/* For -Wall */
  return 0;	/* For -Wall */
}
}
unsigned int
char_composite_WX (a2ps_job * job, uchar c)
{
  return (job->encoding->composite_wx[job->status->face]/
	  job->encoding->composite_raito[job->status->face]);
}
/*
/*
 *	Returns the WX of a string (including M- and ^)
 *	Returns the WX of a string (including M- and ^)
 */
 */
(-) a2ps-4.13.ORIG/lib/encoding.h (+8 lines)
 Lines 43-48    Link Here 
 */
 */
unsigned int char_WX PARAMS ((struct a2ps_job * job, uchar c));
unsigned int char_WX PARAMS ((struct a2ps_job * job, uchar c));
unsigned int string_WX PARAMS ((struct a2ps_job * job, uchar * string));
unsigned int string_WX PARAMS ((struct a2ps_job * job, uchar * string));
unsigned int char_composite_WX PARAMS ((struct a2ps_job * job, uchar c));
/************************************************************************/
/************************************************************************/
 Lines 56-61    Link Here 
					FILE * stream));
					FILE * stream));
int encoding_char_exists PARAMS ((struct encoding * enc,
int encoding_char_exists PARAMS ((struct encoding * enc,
					enum face_e face, uchar c));
					enum face_e face, uchar c));
int encoding_get_composite_flag (struct encoding * enc);
struct encoding *
struct encoding *
get_encoding_by_alias PARAMS ((struct a2ps_job * job, 
get_encoding_by_alias PARAMS ((struct a2ps_job * job, 
			       char *string));
			       char *string));
 Lines 71-76    Link Here 
		 struct encoding * encoding,
		 struct encoding * encoding,
		 const char * font_name));
		 const char * font_name));
const char * encoding_resolve_composite_font
	PARAMS ((struct a2ps_job * job,
		 struct encoding * encoding,
		 const char * font_name));
/*
/*
 * Have a struct encoding determine the faces_wx
 * Have a struct encoding determine the faces_wx
 */
 */
(-) a2ps-4.13.ORIG/lib/pair_ht.c (+61 lines)
 Lines 49-54    Link Here 
{
{
  char * key;
  char * key;
  char * value;
  char * value;
  float  raito;
  int    wx;
};
};
/*
/*
 Lines 165-170    Link Here 
}
}
/*
/*
 *  Add a pair, with your own allocation for them.
 * It KEY is yet used, override its value with VALUE
 */
void
pair_add2 (struct hash_table_s * table,
	  const char * key, const char * value, int wx, float raito)
{
  struct pair * item, token;
  
  token.key = (char *) key;
  item = (struct pair *) hash_find_item (table, &token);
  if (item) {
    if (item->value)
      free (item->value);
  } else {
    item = XMALLOC (struct pair, 1);
    item->key = xstrdup(key);
    item->wx    = wx;
    item->raito = raito;
  }
  
  if (value)
    item->value = xstrdup (value);
  else
    item->value = NULL;
  hash_insert (table, item);
}
/*
 * Remove a pair and free it.
 * Remove a pair and free it.
 * It KEY is yet used, override its value with VALUE
 * It KEY is yet used, override its value with VALUE
 */
 */
 Lines 201-206    Link Here 
    return NULL;
    return NULL;
}
}
int
pair_get_wx (struct hash_table_s * table, const char * key)
{
  struct pair * item, token;
  
  token.key = (char *) key;
  item = (struct pair *) hash_find_item (table, &token);
  if (item)
    return item->wx;
  else
    return -1;
}
float
pair_get_raito (struct hash_table_s * table, const char * key)
{
  struct pair * item, token;
  
  token.key = (char *) key;
  item = (struct pair *) hash_find_item (table, &token);
  if (item)
    return item->raito;
  else
    return -1;
}
/*
/*
 * Return the content of the hash table, ordered
 * Return the content of the hash table, ordered
 */
 */
(-) a2ps-4.13.ORIG/lib/pair_ht.h (+8 lines)
 Lines 56-61    Link Here 
void pair_add PARAMS ((struct pair_htable * table, 
void pair_add PARAMS ((struct pair_htable * table, 
		       const char * key, const char * value));
		       const char * key, const char * value));
void pair_add2 PARAMS ((struct pair_htable * table, 
		       const char * key, const char * value,
			int wx, float raito));
/*
/*
 * The key and value of the matching item  will be free'd
 * The key and value of the matching item  will be free'd
 * (No problem if KEY matches nothing)
 * (No problem if KEY matches nothing)
 Lines 68-73    Link Here 
 */
 */
char * pair_get PARAMS ((struct pair_htable * table,
char * pair_get PARAMS ((struct pair_htable * table,
			 const char * key));
			 const char * key));
int    pair_get_wx PARAMS ((struct pair_htable * table,
			    const char * key));
float  pair_get_raito PARAMS ((struct pair_htable * table,
			       const char * key));
void pair_table_list_short PARAMS ((struct pair_htable * table,
void pair_table_list_short PARAMS ((struct pair_htable * table,
				    FILE * stream));
				    FILE * stream));
(-) a2ps-4.13.ORIG/lib/psgen.c (-1 / +26 lines)
 Lines 875-880    Link Here 
  print:
  print:
  default:
  default:
    {
    {
      static mb_flag= 0;
      uchar buf[256];
      uchar buf[256];
      int nchars;
      int nchars;
      *buf = '\0';
      *buf = '\0';
 Lines 889-894    Link Here 
    job->status->face_declared = false;
    job->status->face_declared = false;
  }
  }
  if (c > 127 && encoding_get_composite_flag (job->encoding) &&
      job->status->face != Symbol) {
    if (mb_flag) {
        nchars = ps_escape_char (job, mb_flag, buf) + 
	         ps_escape_char (job, c, buf);
	job->status->wx += char_composite_WX(job, c);
	job->status->column += nchars;
	if (line_full) {
	    if (job->folding) {
	        fold_line (job, new_face);
		job->status->column = nchars*2;
		job->status->wx = char_composite_WX(job, c);
	    } else {
	      job->status->is_in_cut = true;
	      return;
	    }
	}
	mb_flag = 0;
    } else {
        mb_flag = c;
	return;
    }
  } else {
      nchars = ps_escape_char (job, c, buf);
      nchars = ps_escape_char (job, c, buf);
      job->status->wx += char_WX (job, c);
      job->status->wx += char_WX (job, c);
      job->status->column += nchars;
      job->status->column += nchars;
 Lines 902-909    Link Here 
	  return;
	  return;
	}
	}
      }
      }
  }
      output (jdiv, "%s", buf);
      output (jdiv, "%s", buf);
      job->status->chars++;
      job->status->chars+=nchars;
    }
    }
    break;
    break;
  }
  }
(-) a2ps-4.13.ORIG/libjcode/Doc/rfc1468.txt (+339 lines)
Line 0    Link Here 
Network Working Group                                           J. Murai
Request for Comments: 1468                               Keio University
                                                              M. Crispin
                                                       Panda Programming
                                                         E. van der Poel
                                                               June 1993
           Japanese Character Encoding for Internet Messages
Status of this Memo
   This memo provides information for the Internet community.  It does
   not specify an Internet standard.  Distribution of this memo is
   unlimited.
Introduction
   This document describes the encoding used in electronic mail [RFC822]
   and network news [RFC1036] messages in several Japanese networks. It
   was first specified by and used in JUNET [JUNET]. The encoding is now
   also widely used in Japanese IP communities.
   The name given to this encoding is "ISO-2022-JP", which is intended
   to be used in the "charset" parameter field of MIME headers (see
   [MIME1] and [MIME2]).
Description
   The text starts in ASCII [ASCII], and switches to Japanese characters
   through an escape sequence. For example, the escape sequence ESC $ B
   (three bytes, hexadecimal values: 1B 24 42) indicates that the bytes
   following this escape sequence are Japanese characters, which are
   encoded in two bytes each.  To switch back to ASCII, the escape
   sequence ESC ( B is used.
   The following table gives the escape sequences and the character sets
   used in ISO-2022-JP messages. The ISOREG number is the registration
   number in ISO's registry [ISOREG].
       Esc Seq    Character Set                  ISOREG
       ESC ( B    ASCII                             6
       ESC ( J    JIS X 0201-1976 ("Roman" set)    14
       ESC $ @    JIS X 0208-1978                  42
       ESC $ B    JIS X 0208-1983                  87
   Note that JIS X 0208 was called JIS C 6226 until the name was changed
Murai, Crispin & van der Poel                                   [Page 1]

RFC 1468   Japanese Character Encoding for Internet Messages   June 1993
   on March 1st, 1987. Likewise, JIS C 6220 was renamed JIS X 0201.
   The "Roman" character set of JIS X 0201 [JISX0201] is identical to
   ASCII except for backslash () and tilde (~). The backslash is
   replaced by the Yen sign, and the tilde is replaced by overline. This
   set is Japan's national variant of ISO 646 [ISO646].
   The JIS X 0208 [JISX0208] character sets consist of Kanji, Hiragana,
   Katakana and some other symbols and characters. Each character takes
   up two bytes.
   For further details about the JIS Japanese national character set
   standards, refer to [JISX0201] and [JISX0208].  For further
   information about the escape sequences, see [ISO2022] and [ISOREG].
   If there are JIS X 0208 characters on a line, there must be a switch
   to ASCII or to the "Roman" set of JIS X 0201 before the end of the
   line (i.e., before the CRLF). This means that the next line starts in
   the character set that was switched to before the end of the previous
   line.
   Also, the text must end in ASCII.
   Other restrictions are given in the Formal Syntax below.
Formal Syntax
   The notational conventions used here are identical to those used in
   RFC 822 [RFC822].
   The * (asterisk) convention is as follows:
       l*m something
   meaning at least l and at most m somethings, with l and m taking
   default values of 0 and infinity, respectively.
   message             = headers 1*( CRLF *single-byte-char *segment
                         single-byte-seq *single-byte-char )
                                           ; see also [MIME1] "body-part"
                                           ; note: must end in ASCII
   headers             = <see [RFC822] "fields" and [MIME1] "body-part">
   segment             = single-byte-segment / double-byte-segment
   single-byte-segment = single-byte-seq 1*single-byte-char
Murai, Crispin & van der Poel                                   [Page 2]

RFC 1468   Japanese Character Encoding for Internet Messages   June 1993
   double-byte-segment = double-byte-seq 1*( one-of-94 one-of-94 )
   single-byte-seq     = ESC "(" ( "B" / "J" )
   double-byte-seq     = ESC "$" ( "@" / "B" )
   CRLF                = CR LF
                                                    ; ( Octal, Decimal.)
   ESC                 = <ISO 2022 ESC, escape>     ; (    33,      27.)
   SI                  = <ISO 2022 SI, shift-in>    ; (    17,      15.)
   SO                  = <ISO 2022 SO, shift-out>   ; (    16,      14.)
   CR                  = <ASCII CR, carriage return>; (    15,      13.)
   LF                  = <ASCII LF, linefeed>       ; (    12,      10.)
   one-of-94           = <any one of 94 values>     ; (41-176, 33.-126.)
   7BIT                = <any 7-bit value>          ; ( 0-177,  0.-127.)
   single-byte-char    = <any 7BIT, including bare CR & bare LF, but NOT
                          including CRLF, and not including ESC, SI, SO>
MIME Considerations
   The name given to the JUNET character encoding is "ISO-2022-JP". This
   name is intended to be used in MIME messages as follows:
       Content-Type: text/plain; charset=iso-2022-jp
   The ISO-2022-JP encoding is already in 7-bit form, so it is not
   necessary to use a Content-Transfer-Encoding header. It should be
   noted that applying the Base64 or Quoted-Printable encoding will
   render the message unreadable in current JUNET software.
   ISO-2022-JP may also be used in MIME Part 2 headers.  The "B"
   encoding should be used with ISO-2022-JP text.
Background Information
   The JUNET encoding was described in the JUNET User's Guide [JUNET]
   (JUNET Riyou No Tebiki Dai Ippan).
   The encoding is based on the particular usage of ISO 2022 announced
Murai, Crispin & van der Poel                                   [Page 3]

RFC 1468   Japanese Character Encoding for Internet Messages   June 1993
   by 4/1 (see [ISO2022] for details). However, the escape sequence
   normally used for this announcement is not included in ISO-2022-JP
   messages.
   The Kana set of JIS X 0201 is not used in ISO-2022-JP messages.
   In the past, some systems erroneously used the escape sequence ESC (
   H in JUNET messages. This escape sequence is officially registered
   for a Swedish character set [ISOREG], and should not be used in ISO-
   2022-JP messages.
   Some systems do not distinguish between ESC ( B and ESC ( J or
   between ESC $ @ and ESC $ B for display. However, when relaying a
   message to another system, the escape sequences must not be altered
   in any way.
   The human user (not implementor) should try to keep lines within 80
   display columns, or, preferably, within 75 (or so) columns, to allow
   insertion of ">" at the beginning of each line in excerpts. Each JIS
   X 0208 character takes up two columns, and the escape sequences do
   not take up any columns. The implementor is reminded that JIS X 0208
   characters take up two bytes and should not be split in the middle to
   break lines for displaying, etc.
   The JIS X 0208 standard was revised in 1990, to add two characters at
   the end of the table. Although ISO 2022 specifies special additional
   escape sequences to indicate the use of revised character sets, it is
   suggested here not to make use of this special escape sequence in
   ISO-2022-JP text, even if the two characters added to JIS X 0208 in
   1990 are used.
   For further information about Japanese character encodings such as PC
   codes, FTP locations of implementations, etc, see "Electronic
   Handling of Japanese Text" [JPN.INF].
References
   [ASCII] American National Standards Institute, "Coded character set
   -- 7-bit American national standard code for information
   interchange", ANSI X3.4-1986.
   [ISO646] International Organization for Standardization (ISO),
   "Information technology -- ISO 7-bit coded character set for
   information interchange", International Standard, Ref. No. ISO/IEC
   646:1991.
   [ISO2022] International Organization for Standardization (ISO),
   "Information processing -- ISO 7-bit and 8-bit coded character sets
Murai, Crispin & van der Poel                                   [Page 4]

RFC 1468   Japanese Character Encoding for Internet Messages   June 1993
   -- Code extension techniques", International Standard, Ref. No. ISO
   2022-1986 (E).
   [ISOREG] International Organization for Standardization (ISO),
   "International Register of Coded Character Sets To Be Used With
   Escape Sequences".
   [JISX0201] Japanese Standards Association, "Code for Information
   Interchange", JIS X 0201-1976.
   [JISX0208] Japanese Standards Association, "Code of the Japanese
   graphic character set for information interchange", JIS X 0208-1978,
   -1983 and -1990.
   [JPN.INF] Ken R. Lunde <lunde@adobe.com>, "Electronic Handling of
   Japanese Text", March 1992,
   msi.umn.edu(128.101.24.1):pub/lunde/japan[123].inf
   [JUNET] JUNET Riyou No Tebiki Sakusei Iin Kai (JUNET User's Guide
   Drafting Committee), "JUNET Riyou No Tebiki (Dai Ippan)" ("JUNET
   User's Guide (First Edition)"), February 1988.
   [MIME1] Borenstein N., and N. Freed, "MIME (Multipurpose
   Internet Mail Extensions): Mechanisms for Specifying and
   Describing the Format of Internet Message Bodies", RFC 1341,
   Bellcore, Innosoft, June 1992.
   [MIME2] Moore, K., "Representation of Non-ASCII Text in Internet
   Message Headers", RFC 1342, University of Tennessee, June 1992.
   [RFC822] Crocker, D., "Standard for the Format of ARPA Internet
   Text Messages", STD 11, RFC 822, UDEL, August 1982.
   [RFC1036] Horton M., and R. Adams, "Standard for Interchange of USENET
   Messages", RFC 1036, AT&T Bell Laboratories, Center for Seismic
   Studies, December 1987.
Acknowledgements
   Many people assisted in drafting this document. The authors wish to
   thank in particular Akira Kato, Masahiro Sekiguchi and Ken'ichi
   Handa.
Security Considerations
   Security issues are not discussed in this memo.
Murai, Crispin & van der Poel                                   [Page 5]

RFC 1468   Japanese Character Encoding for Internet Messages   June 1993
Authors' Addresses
   Jun Murai
   Keio University
   5322 Endo, Fujisawa
   Kanagawa 252 Japan
   Fax: +81 466 49 1101
   EMail: jun@wide.ad.jp
   Mark Crispin
   Panda Programming
   6158 Lariat Loop NE
   Bainbridge Island, WA 98110-2098
   USA
   Phone: +1 206 842 2385
   EMail: MRC@PANDA.COM
   Erik M. van der Poel
   A-105 Park Avenue
   4-4-10 Ohta, Kisarazu
   Chiba 292 Japan
   Phone: +81 438 22 5836
   Fax:   +81 438 22 5837
   EMail: erik@poel.juice.or.jp
Murai, Crispin & van der Poel                                   [Page 6]

(-) a2ps-4.13.ORIG/libjcode/Doc/rfc1554.txt (+339 lines)
Line 0    Link Here 
Network Working Group                                            M. Ohta
Request for Comments: 1554                 Tokyo Institute of Technology
Category: Informational                                         K. Handa
                                                                     ETL
                                                           December 1993
          ISO-2022-JP-2: Multilingual Extension of ISO-2022-JP
Status of this Memo
   This memo provides information for the Internet community.  This memo
   does not specify an Internet standard of any kind.  Distribution of
   this memo is unlimited.
Introduction
   This memo describes a text encoding scheme: "ISO-2022-JP-2", which is
   used experimentally for electronic mail [RFC822] and network news
   [RFC1036] messages in several Japanese networks.  The encoding is a
   multilingual extension of "ISO-2022-JP", the existing encoding for
   Japanese [2022JP].  The encoding is supported by an Emacs based
   multilingual text editor: MULE [MULE].
   The name, "ISO-2022-JP-2", is intended to be used in the "charset"
   parameter field of MIME headers (see [MIME1] and [MIME2]).
Description
   The text with "ISO-2022-JP-2" starts in ASCII [ASCII], and switches
   to other character sets of ISO 2022 [ISO2022] through limited
   combinations of escape sequences.  All the characters are encoded
   with 7 bits only.
   At the beginning of text, the existence of an announcer sequence:
   "ESC 2/0 4/1 ESC 2/0 4/6 ESC 2/0 5/10" is (though omitted) assumed.
   Thus, characters of 94 character sets are designated to G0 and
   invoked as GL.  C1 control characters are represented with 7 bits.
   Characters of 96 character sets are designated to G2 and invoked with
   SS2 (single shift two, "ESC 4/14" or "ESC N").
   For example, the escape sequence "ESC 2/4 2/8 4/3" or "ESC $ ( C"
   indicates that the bytes following the escape sequence are Korean KSC
   characters, which are encoded in two bytes each.  The escape sequence
   "ESC 2/14 4/1" or "ESC . A" indicates that ISO 8859-1 is designated
   to G2. After the designation, the single shifted sequence "ESC 4/14
   4/1" or "ESC N A" is interpreted to represent a character "A with
   acute".
Ohta & Handa                                                    [Page 1]

RFC 1554         Multilingual Extension of ISO-2022-JP     December 1993
   The following table gives the escape sequences and the character sets
   used in "ISO-2022-JP-2" messages. The reg# is the registration number
   in ISO's registry [ISOREG].
                              94 character sets
      reg#  character set      ESC sequence                designated to
      ------------------------------------------------------------------
      6     ASCII              ESC 2/8 4/2      ESC ( B    G0
      42    JIS X 0208-1978    ESC 2/4 4/0      ESC $ @    G0
      87    JIS X 0208-1983    ESC 2/4 4/2      ESC $ B    G0
      14    JIS X 0201-Roman   ESC 2/8 4/10     ESC ( J    G0
      58    GB2312-1980        ESC 2/4 4/1      ESC $ A    G0
      149   KSC5601-1987       ESC 2/4 2/8 4/3  ESC $ ( C  G0
      159   JIS X 0212-1990    ESC 2/4 2/8 4/4  ESC $ ( D  G0
                              96 character sets
      reg#  character set      ESC sequence                designated to
      ------------------------------------------------------------------
      100   ISO8859-1          ESC 2/14 4/1     ESC . A    G2
      126   ISO8859-7(Greek)   ESC 2/14 4/6     ESC . F    G2
   For further information about the character sets and the escape
   sequences, see [ISO2022] and [ISOREG].
   If there is any G0 designation in text, there must be a switch to
   ASCII or to JIS X 0201-Roman before a space character (but not
   necessarily before "ESC 4/14 2/0" or "ESC N ' '") or control
   characters such as tab or CRLF.  This means that the next line starts
   in the character set that was switched to before the end of the
   previous line.  Though the designation to JIS X 0201-Roman is allowed
   for backward compatibility to "ISO-2022-JP", its use is discouraged.
   Applications such as pagers and editors which randomly seek within a
   text file encoded with "ISO-2022-JP-2" may assume that all the lines
   begin with ASCII, not with JIS X 0201-Roman.
   At the beginning of a line, information on G2 designation of the
   previous line is cleared.  New designation must be given before a
   character in 96 character sets is used in the line.
   The text must end in ASCII designated to G0.
   As the "ISO-2022-JP", and thus, "ISO-2022-JP-2", is designed to
   represent English and modern Japanese, left-to-right directionality
   is assumed if the text is displayed horizontally.
   Users of "ISO-2022-JP-2" must be aware that some common transport
   such as old Bnews can not relay a 7-bit value 7/15 (decimal 127),
   which is used to encode, say, "y with diaeresis" of ISO 8859-1.
Ohta & Handa                                                    [Page 2]

RFC 1554         Multilingual Extension of ISO-2022-JP     December 1993
   Other restrictions are given in the Formal Syntax section below.
Formal Syntax
   The notational conventions used here are identical to those used in
   STD 11, RFC 822 [RFC822].
   The * (asterisk) convention is as follows:
      l*m something
   meaning at least l and at most m somethings, with l and m taking
   default values of 0 and infinity, respectively.
   message             = headers 1*(CRLF text)
                                          ; see also [MIME1] "body-part"
                                          ; note: must end in ASCII
   text                = *(single-byte-char /
                           g2-desig-seq /
                           single-shift-char)
                          [*segment
                           reset-seq
                           *(single-byte-char /
                             g2-desig-seq /
                             single-shift-char ) ]
                                          ; note: g2-desig-seq must
                                          ; precede single-shift-char
   headers             = <see [RFC822] "fields" and [MIME1] "body-part">
   segment             = single-byte-segment / double-byte-segment
   single-byte-segment = single-byte-seq
                         *(single-byte-char /
                           g2-desig-seq /
                           single-shift-char )
   double-byte-segment = double-byte-seq
                         *((one-of-94 one-of-94) /
                           g2-desig-seq /
                           single-shift-char )
   reset-seq           = ESC "(" ( "B" / "J" )
   single-byte-seq     = ESC "(" ( "B" / "J" )
   double-byte-seq     = (ESC "$" ( "@" / "A" / "B" )) /
Ohta & Handa                                                    [Page 3]

RFC 1554         Multilingual Extension of ISO-2022-JP     December 1993
                         (ESC "$" "(" ( "C" / "D" ))
   g2-desig-seq        = ESC "." ( "A" / "F" )
   single-shift-seq    = ESC "N"
   single-shift-char   = single-shift-seq one-of-96
   CRLF                = CR LF
                                                    ; ( Octal, Decimal.)
   ESC                 = <ISO 2022 ESC, escape>     ; (    33,      27.)
   SI                  = <ISO 2022 SI, shift-in>    ; (    17,      15.)
   SO                  = <ISO 2022 SO, shift-out>   ; (    16,      14.)
   CR                  = <ASCII CR, carriage return>; (    15,      13.)
   LF                  = <ASCII LF, linefeed>       ; (    12,      10.)
   one-of-94           = <any one of 94 values>     ; (41-176, 33.-126.)
   one-of-96           = <any one of 96 values>     ; (40-177, 32.-127.)
   7BIT                = <any 7-bit value>          ; ( 0-177,  0.-127.)
   single-byte-char    = <any 7BIT, including bare CR & bare LF, but NOT
                          including CRLF, and not including ESC, SI, SO>
MIME Considerations
   The name given to the character encoding is "ISO-2022-JP-2". This
   name is intended to be used in MIME messages as follows:
      Content-Type: text/plain; charset=iso-2022-jp-2
   The "ISO-2022-JP-2" encoding is already in 7-bit form, so it is not
   necessary to use a Content-Transfer-Encoding header. It should be
   noted that applying the Base64 or Quoted-Printable encoding will
   render the message unreadable in non-MIME-compliant software.
   "ISO-2022-JP-2" may also be used in MIME headers.  Both "B" and "Q"
   encoding could be useful with "ISO-2022-JP-2" text.
Ohta & Handa                                                    [Page 4]

RFC 1554         Multilingual Extension of ISO-2022-JP     December 1993
References
   [ASCII] American National Standards Institute, "Coded character set
           -- 7-bit American national standard code for information
           interchange", ANSI X3.4-1986.
   [ISO2022] International Organization for Standardization (ISO),
             "Information processing -- ISO 7-bit and 8-bit coded
             character sets -- Code extension techniques",
             International Standard, Ref. No. ISO 2022-1986 (E).
   [ISOREG] International Organization for Standardization (ISO),
            "International Register of Coded Character Sets To Be Used
            With Escape Sequences".
   [MIME1] Borenstein, N., and N. Freed, "MIME  (Multipurpose Internet
           Mail Extensions) Part One: Mechanisms for Specifying and
           Describing the Format of Internet Message Bodies", RFC 1521,
           September 1993.
   [MIME2] Moore, K., "MIME (Multipurpose Internet Mail Extensions) Part
           Two: Message Header Extensions for Non-ASCII Text", RFC 1522,
           September 1993.
   [RFC822] Crocker, D., "Standard for the Format of ARPA Internet Text
            Messages", STD 11, RFC 1522, UDEL, August 1982.
   [RFC1036] Horton M., and R. Adams, "Standard for Interchange of
             USENET Messages", RFC 1036, AT&T Bell Laboratories, Center
             for Seismic Studies, December 1987.
   [2022JP] Murai, J., Crispin, M., and E. van der Poel, "Japanese
            Character Encoding for Internet Messages", RFC 1468, June
            1993.
   [MULE] Nishikimi, M., Handa, K., and S. Tomura, "Mule: MULtilingual
          Enhancement to GNU Emacs", Proc. of INET'93, August, 1993.
Acknowledgements
   This memo is the result of discussion between various people in a
   news group: fj.kanji and is reviewed by a mailing list: jp-msg
   @iij.ad.jp.  The Authors wish to thank in particular Prof. Eiichi
   Wada for his suggestions based on profound knowledge in ISO 2022 and
   related standards.
Ohta & Handa                                                    [Page 5]

RFC 1554         Multilingual Extension of ISO-2022-JP     December 1993
Security Considerations
   Security issues are not discussed in this memo.
Authors' Addresses
   Masataka Ohta
   Tokyo Institute of Technology
   2-12-1, O-okayama, Meguro-ku,
   Tokyo 152, JAPAN
   Phone: +81-3-5499-7084
   Fax: +81-3-3729-1940
   EMail: mohta@cc.titech.ac.jp
   Ken'ichi Handa
   Electrotechnical Laboratory
   Umezono 1-1-4, Tsukuba,
   Ibaraki 305, JAPAN
   Phone: +81-298-58-5916
   Fax: +81-298-58-5918
   EMail: handa@etl.go.jp
Ohta & Handa                                                    [Page 6]

(-) a2ps-4.13.ORIG/libjcode/Makefile.in (+100 lines)
Line 0    Link Here 
# Makefile for directory with library jcode
# by Kuramitsu Kimio
PACKAGE = @PACKAGE@
VERSION = @VERSION@
SHELL = /bin/sh
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = ..
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
transform = @program_transform_name@
libdir = $(exec_prefix)/lib
includedir = $(prefix)/include
datadir = $(prefix)/@DATADIRNAME@
subdir = libjcode
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
MKINSTALLDIRS = @MKINSTALLDIRS@
AR = ar
CC = @CC@
LIBTOOL = @LIBTOOL@
RANLIB = @RANLIB@
DEFS = -DLOCALEDIR=\"$(localedir)\" -DGNULOCALEDIR=\"$(gnulocaledir)\" \
-DLOCALE_ALIAS_PATH=\"$(aliaspath)\" @DEFS@
CPPFLAGS = @CPPFLAGS@
CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@
COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) $(XCFLAGS)
HEADERS = $(COMHDRS)
COMHDRS = jlib.h
SOURCES = $(COMSRCS)
COMSRCS = detect.c libjcode.c
OBJECTS = detect.$lo libjcode.$lo
DISTFILES.common = README
DISTFILES.normal = VERSION
.SUFFIXES:
.SUFFIXES: .c .o .lo
.c.o:
	$(COMPILE) $<
.c.lo:
	$(LIBTOOL) --mode=compile $(COMPILE) $<
INCLUDES = -I. -I$(top_srcdir)/
all: all-@COMPILE_LIBJCODE@
all-yes: libjcode.$la
all-no:
libjcode.a: $(OBJECTS)
	rm -f $@
	$(AR) cru $@ $(OBJECTS)
	$(RANLIB) $@
libjcode.la: $(OBJECTS)
	$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $(OBJECTS) \
		   -version-info 1:0 -rpath $(libdir)
check: all
install: install-exec install-data
install-exec: all
install-data: all
# Define this as empty until I found a useful application.
installcheck:
uninstall:
info dvi:
$(OBJECTS): jlibconfig.h jlib.h
mostlyclean:
	rm -f *.a *.o *.lo core core.*
clean: mostlyclean
distclean: clean
	rm -f Makefile ID TAGS po2msg.sed po2tbl.sed
maintainer-clean: distclean
	@echo "This command is intended for maintainers to use;"
	@echo "it deletes files that may require special tools to rebuild."
Makefile: Makefile.in ../config.status
	cd .. \
	  && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
(-) a2ps-4.13.ORIG/libjcode/README (+158 lines)
Line 0    Link Here 
libjcode ライブラリパッケージ	1.00 版/ 1996
ご存知の通り、日本語を表すための文字コードは、JIS(ISO-2022)、EUC、SJIS  の
3種類がよく使われています。これは、パソコン間でSJISの文章をやり取りする時
は、何にも問題のない話でした。しかし、WWW のようなインターネット時代になる
と、様々な文字コードが混在してしまい、大きな混乱を招く結果になります。
そんな中で多くのプログラマーが日本語コード処理の煩雑さの罠に陥らなくて済む
ようにまとめたのが、この C言語用の libjcode ライブラリです。
-- libjcode パッケージの特徴 ------------------------------------------------
 1. インターネットでの利用を前提とした日本語コード変換ライブラリ
 2. SJIS 半角カナを全角に変換可能
-- パッケージの中身 ---------------------------------------------------------
	/
	README		このファイル
	Makefile	Unix 版 Makefile
	config.h	設定用 #include ファイル
	libjcode.c	JIS、SJIS、EUCの変換
	detect.c	コード判定用
	sample.c	簡単なサンプルプログラム
	jlib.h		ライブラリ用 #include ファイル
	Doc/
	rfc1468.txt	RFC1468
			"Japanese Character Encoding for Internet Messages."
	rfc1554.txt	RFC1554	
			"ISO-2022-JP-2: Multilingual Extension of ISO-2022-JP"
-- 利用上の注意 -------------------------------------------------------------
libjcode は、完全にフリーなライブラリです。インターネットにおける日本語環境
の改善を最終目標にしております。日本語コードの変換を行いたい方なら誰でも、
自由に改良して、自分のプログラムに合わせて組み込むことができます。
ただし、利用にする場合は次の条件を守ってください。
 1. libjcode を利用したために如何なる損害が生じても作者には一切の責任を
    取りません。
 2. 国立大学のコンピュータ資源を使っているので、著作権表示、
	(C) Kuramitsu Kimio, Tokyo Univ. 1996-97
    を念のために残しておいてください。
ライブラリ利用中にバグを発見し直された方、より効率のよりアルゴリズムを実装
なさった方は、それを作者に送って頂けると、libjcode としてもより信頼性の高い
ライブラリへと成長できます。よろしくお願いします。
また、libjcodeを組み込んだソフトウエアの名前も教えていただけると、実際の実
装例として、紹介したいと思います。
-- 使い方 -------------------------------------------------------------------
1. まず、make によって、libjcode.a ライブラリを作ります。
   config.h を直すことで、多少機能を変えることができますが、ソースコード
   を読んだ方が早いでしょう。
2. サンプルプログラム sample.c と Makefile を見ると、このライブラリをどの
   ように組み込むか参考にしてください。
-- 動作確認環境 -------------------------------------------------------------
ANSI C コンパイラを使っていれば、普通にコンパイルできるはずです。
	Solaris 2.5 (Sparc) with gcc 2.7.2
	Linux 2.0 with gcc 2.7.2
-- ライブラリの一覧 ---------------------------------------------------------
普通に使えるライブラリ関数は、jlib.h ヘッダファイルに書かれています。最初
に #include "jlib.h" を追加します。
#define ディレクティブの内容
#define ASCII	ASCII コード
#define JIS	iso-2022-jp コード
#define EUC	x-euc-jp コード
#define SJIS	x-sjis コード
関数:
extern int detectKanjiCode(char *str);
	文字列 str のコードを判定します。
	返り値は、ASCII, JIS, EUC, SJIS のどれかです。
extern char *toStringJIS(char *str);
	文字列 str をJIS コードに変換します。
extern char *toStringEUC(char *str);
	文字列 str をEUC コードに変換します。
extern char *toStringSJIS(char *str);
	文字列 str をSJIS コードに変換します。
-- 知られている問題点 -------------------------------------------------------
半角SJISが含まれたテキストを想定しているので、EUC と SJIS の自動判定が
かなり弱い。
-- 今後の予定 ---------------------------------------------------------------
確実にやろうと思っていること。
	JIS X 0212-1990 (俗称 補助漢字)の変換に対応
	MIME ヘッダのエンコード/デコード
できたらやりたいこと(CGI 向けライブラリ)
	全角 --> 半角 
		(例 foo@mail.com --> foo@mail.com)
	平仮名 <--> カタカナ 
	ROMAN 字 --> かな
		(Kuramitsu --> くらみつ)
挑戦したいこと。
	SJIS と ISO-8859-1(laten) の自動識別
道義的に悩むところ
	Unicode への対応
-- 歴史 ---------------------------------------------------------------------
libjcode を作る直接のきっかけとなったのは、Thomus Boutell 著の
"CGI Programming with C and Perl"(Addison-Wesley)に付属するサンプルCGIプロ
グラムを日本語の入力を受け付けるようにするために、漢字コード変換に触れる必
要性がありました。ところが、Perl用には優れた漢字変換のライブラリが存在しま
したが、残念ながらC版には、優れたライブラリが手に入れることができませんで
した。
そこで、Ken Lunde 著の「日本語情報処理」(O'Reilly)を参考にライブラリ作成を
始めることにしました。
1996/12/10	ホームページ上で公開開始。
		http://www.lib.m.u-tokyo.ac.jp/~kiki/libjcode/
1996/12/19	"CGI Programming with C and Perl5"の日本語版付録CD-ROM付録
		として、libjcode-1.00 配布開始
-- 謝辞 ---------------------------------------------------------------------
坂村研究室の先輩である川幡 太一(kawabata@is.s.u-tokyo.ac.jp)さんには、日本
語処理という狭い観点にとらわれず、広く多国語環境や処理について様々な助言や
アドバイスをして頂きました。また、本ライブラリ実現のためのバグ取りも手伝っ
て頂きました。
---
本ライブラリを活用して多くのCGIプログラムやWindows/Macintosh 用のフリーウ
エア、また商用アプリケーションの日本語版が正しく漢字コードを扱えるように
なって頂けれれば、幸いです。
					 		      1996年 12月
					      倉光 君郎 / Kuramitsu Kimio
						  kiki@is.s.u-tokyo.ac.jp
(-) a2ps-4.13.ORIG/libjcode/detect.c (+204 lines)
Line 0    Link Here 
/*
 * detect.c - libjcode コード自動判定ルーチン
 *                (C) Kuramitsu Kimio, Tokyo Univ. 1996-97 
 *
 * Ken Lunde 著 「日本語情報処理」 と jconv.c を参考に作り 
 * ました。
 * CGI プログラムでの利用を考えて、ひらがな、かたかなの並び
 * によるSJIS, EUC の推定アルゴリズム等を加えてあります。
 *
 * 更新履歴
 *       - jcode.plのSJIS/EUC判定にコードを用いた
 *                Yasuyuki Furukawa (yasu@on.cs.keio.ac.jp)
 */
#include <stdio.h>
#include "config.h"
#include "jlibconfig.h"
static int _detect(unsigned char *str, int expected);
static int _detect_euc_or_sjis(unsigned char *str);
void printDetectCode(int detected);
int detectKanjiCode(char *str);
/* ------------------------------------------------------ 漢字コードの識別 --*/
static int _detect(unsigned char *str, int expected)
{
  register int c;
  while((c = (int)*str)!= '\0') {
    /* JIS コードの判定 */
    if(c == ESC) {
      if((c = (int)*(++str)) == '\0') return expected; 
      if (c == '$') {
	if((c = (int)*(++str)) == '\0') return expected; 
	/* ESC $ B --> 新JIS 
	   ESC $ @ --> 旧JIS */
	if (c == 'B' || c == '@') return JIS;
      }
#ifdef NECKANJI
      if (c == 'K')
	return NEC;    /* ESC K --> NEC JIS */
#endif
      str++;
      continue;
    }
    
    /* SJIS に一意に決定 */
    if ((c >= 129 && c <= 141) || (c >= 143 && c <= 159))
        return SJIS;
    /* SS2 */
    if (c == SS2) {
      if((c = (int)*(++str)) == '\0') return expected; 
      if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160) || 
	  (c >= 224 && c <= 252)) return SJIS;
      if (c >= 161 && c <= 223) expected = EUCORSJIS;
      str++;
      continue;
    }
    if (c >= 161 && c <= 223) {
      if((c = (int)*(++str)) == '\0') return expected; 
      
      if (c >= 240 && c <= 254)
	return EUC;
      if (c >= 161 && c <= 223) {
	expected = EUCORSJIS;
	str++;
	continue;
      }
      if (c <= 159) return SJIS;
      if (c >= 240 && c <= 254) return EUC;
     
      if (c >= 224 && c <= 239) {
	expected = EUCORSJIS;
	while (c >= 64) {
	  if (c >= 129) {
	    if (c <= 141 || (c >= 143 && c <= 159))
	      return SJIS;
	    else if (c >= 253 && c <= 254) {
	      return EUC;
	    }
	  }
	  if((c = (int)*(++str)) == '\0') return EUCORSJIS; 
	}
	str++;
	continue;
      }
      
      if (c >= 224 && c <= 239) {
        if((c = (int)*(++str)) == '\0') return expected; 
        if ((c >= 64 && c <= 126) || (c >= 128 && c <= 160))
          return SJIS;
        if (c >= 253 && c <= 254) return EUC;
        if (c >= 161 && c <= 252)
          expected = EUCORSJIS;
      }
    }
    str++;
  }
  return expected;
}
/* ---------------------------------------------------SJIS か EUC の判定 -- */
/* 日本語の特徴(ひらがな、カタカナ)から判定するため、
   判定ミスが発生する場合もあります。 */
static int _detect_euc_or_sjis(unsigned char *str) {
  int c1, c2;
  int euc_c = 0, sjis_c = 0;
  unsigned char *ptr;
  static int expected = EUCORSJIS;
#ifdef USE_CACHE_KANA_NARABI
  if (expected != EUCORSJIS)
      return expected;
#endif
  ptr = str, c2 = 0;
  while ((c1 = (int)*ptr++) != '\0') {
      if ((c2 >  0x80 && c2 < 0xa0) && (c2 >= 0xe0 && c2 < 0xfd) &&
	  (c1 >= 0x40 && c1 < 0x7f) && (c1 >= 0x80 && c1 < 0xfd))
	  sjis_c++, c1 = *ptr++;
      c2 = c1;
  }
  if (sjis_c == 0)
      expected = EUC;
  else {
      ptr = str, c2 = 0;
      while ((c1 = (int)*ptr++) != '\0') {
	  if ((c2 > 0xa0  && c2 < 0xff) &&
	      (c1 > 0xa0  && c1 < 0xff))
	    euc_c++, c1 = *ptr++;
	  c2 = c1;
      }
      if (sjis_c > euc_c)
	  expected = SJIS;
      else
	  expected = EUC;
  }
  return expected;
}
/* ---------------------------------------------------------- Public 関数 -- */
#ifdef DEBUG
void printDetectCode(int detected) {
  switch(detected) {
  case ASCII:
    fprintf(stderr, "ASCII/JIS-Roman characters(94 printable)\n");
    break;
  case JIS:
    fprintf(stderr, "JIS(iso-2022-jp)\n");
    break;
  case EUC:
    fprintf(stderr, "EUC(x-euc-jp)\n");
    break;
  case SJIS:
    fprintf(stderr, "SJIS(x-sjis)\n");
    break;
  case NEW:
    fprintf(stderr, "JIS X 0208-1990\n");
    break;
  case OLD:
    fprintf(stderr, "JIS X 0208-1978\n");
    break;
  case EUCORSJIS:
    fprintf(stderr, "EUC or SJIS\n");
    break;
  default:
    printf("Another Codes!!\n");
  }
}
#endif
int detectKanjiCode(char *str)
{
  static int detected = ASCII;
  if(!str) return (0);
  /* JIS, EUC, SJIS, EUCORSJIS の判定 */
  detected = _detect((unsigned char *)str, ASCII);
  /* 新JIS, 旧JIS, NEC JIS の場合、JIS に変更する */
  if(detected == NEW || detected == OLD || detected == NEC)
    return JIS;
  /* SJIS か EUC の区別をカナの並びから推定する */
  if(detected == EUCORSJIS)
#ifdef KANA_NARABI
    detected = _detect_euc_or_sjis((unsigned char *)str);
#else
    detected = EUC;  /* デフォルト EUC */
#endif
#ifdef DEBUG
    printDetectCode(detected);
#endif
  return detected;
}
(-) a2ps-4.13.ORIG/libjcode/jlib.h (+17 lines)
Line 0    Link Here 
/*
 *  jlib.h -- jlib.c 用のヘッダファイル  by. 倉光 君郎
 *
 *  jlib.c を利用する場合は、include してください。
 *
 */
#define ASCII         0
#define JIS           1
#define EUC           2
#define SJIS          3
extern int detectKanjiCode(char *str);
extern char *toStringJIS(char *str);
extern char *toStringEUC(char *str);
extern char *toStringSJIS(char *str);
extern char *toStringAuto(char *str);
(-) a2ps-4.13.ORIG/libjcode/jlibconfig.h (+42 lines)
Line 0    Link Here 
/*
 * config.h
 */
#define ASCII         0
#define JIS           1
#define EUC           2
#define SJIS          3
#define NEW           4
#define OLD           5
#define NEC           6
#define EUCORSJIS     7
#define NUL           0
#define LF            10
#define FF            12
#define CR            13
#define ESC           27
#define SS2           142
#define TRUE          1
#define FALSE         0
/* 半角カナ(SJIS) を強制的に全角カナに変更する */
#undef NO_HANKAKU_SJIS
/* ひらがな、カタカナの並びから EUC , SJIS を推定する */
#define KANA_NARABI
/* EUC , SJIS を推定を始めの一度しか行なわない */
/* (ファイルを一つしかひらかないなら有効でいい) */
#undef USE_CACHE_KANA_NARABI
/* strdup関数がシステムにあればdefine */
#define HAVE_STRDUP     1
/* デバック用の関数を有効にする */
#undef DEBUG
/* ロケール名(大文字、小文字は区別されない) */
#define SJIS_LOCALE_NAME  "ja_JP.SJIS", "ja_JP.PCK"
#define JIS_LOCALE_NAME   "ja_JP.JIS", "ja_JP.jis7"
#define EUC_LOCALE_NAME   "ja_JP.ujis", "ja_JP.EUC",\
                          "ja_JP.eucJP","japanese", "ja"
(-) a2ps-4.13.ORIG/libjcode/libjcode.c (+554 lines)
Line 0    Link Here 
/* 
 *  libjcode.c -- 漢字変換ライブラリ    1.0 版
 *                (C) Kuramitsu Kimio, Tokyo Univ. 1996-97
 *
 *  このライブラリは、CGI Programming with C and Perl のために
 *  Ken Lunde 著 「日本語情報処理」 (O'llery) を参考にして、
 *  ストリーム用だったjconv.c を、ストリング対応にしてライブラリ化
 *  しました。 
 *  ただし、CGI (INTERNET)での利用を考えて、変更してあります。
 */
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <locale.h>
#include "jlib.h"
#include "config.h"
#include "jlibconfig.h"
 
extern int detectKanjiCode(char *str);
static unsigned char *_to_jis(unsigned char *str);
static unsigned char *_to_ascii(unsigned char *str);
static void _jis_shift(int *p1, int *p2);
static void _sjis_shift(int *p1, int *p2);
static unsigned char *_sjis_han2zen(unsigned char *str, int *p1, int *p2);
static void _shift2seven(unsigned char *str, unsigned char *str2);
static void _shift2euc(unsigned char *str, unsigned char *str2);
static void _shift_self(unsigned char *str, unsigned char *str2);
static void _euc2seven(unsigned char *str, unsigned char *str2);
static void _euc2shift(unsigned char *str, unsigned char *str2);
static unsigned char *_skip_esc(unsigned char *str, int *esc_in);
static void _seven2shift(unsigned char *str, unsigned char *str2);
static void _seven2euc(unsigned char *str, unsigned char *str2);
#define CHAROUT(ch) *str2 = (unsigned char)(ch); str2++;
#ifndef HAVE_STRDUP
#define strdup(str)  _strdup(str)
static char *_str_dup(unsigned char *buf) {
  unsigned char *p, *str;
  if((str = (char *)malloc(strlen(buf) + 1)) == NULL) {
    fprintf(stderr, "Can't malloc string buffer\n");
    exit(2);
  }
  p = (unsigned char *)str;
   
  while(*buf)
    *p++ = *buf++;
  *p = '\0';
  return str;
}
#endif
/* --------------------------------------- JIS(ISO-2022) コードへ切り替え -- */
static unsigned char *_to_jis(unsigned char *str) {
  *str = (unsigned char)ESC; str++;
  *str = (unsigned char)'$'; str++;
  *str = (unsigned char)'B'; str++;
  return str;
}
/* ----------------------------------------------- ASCII コードへ切り替え -- */
/* ESC ( B と ESC ( J の違い。
   本来は、 ESC ( J が正しいJIS-Roman 体系であるが、
   インターネットの上では、英数字はASCII の方が自然かと思われる。
   \ 記号と ~記号が違うだけである。 */
static unsigned char *_to_ascii(unsigned char *str) {
  *str = (unsigned char)ESC; str++;
  *str = (unsigned char)'('; str++;
  *str = (unsigned char)'B'; str++;
  return str;
}
/* -------------------------------------- JIS コード を SJISとしてシフト -- */
static void _jis_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;
}
/* --------------------------------- SJIS コードをJIS コードとしてシフト -- */
static void _sjis_shift(int *p1, int *p2)
{
  unsigned char c1 = *p1;
  unsigned char c2 = *p2;
  int adjust = c2 < 159;
  int rowOffset = c1 < 160 ? 112 : 176;
  int cellOffset = adjust ? (c2 > 127 ? 32 : 31) : 126;
  *p1 = ((c1 - rowOffset) << 1) - adjust;
  *p2 -= cellOffset;
}
/* ---------------------------------------------- SJIS 半角を全角に変換 -- */
#define HANKATA(a)  (a >= 161 && a <= 223)
#define ISMARU(a)   (a >= 202 && a <= 206)
#define ISNIGORI(a) ((a >= 182 && a <= 196) || (a >= 202 && a <= 206) || (a == 179))
static int stable[][2] = {
    {129,66},{129,117},{129,118},{129,65},{129,69},{131,146},{131,64},
    {131,66},{131,68},{131,70},{131,72},{131,131},{131,133},{131,135},
    {131,98},{129,91},{131,65},{131,67},{131,69},{131,71},{131,73},
    {131,74},{131,76},{131,78},{131,80},{131,82},{131,84},{131,86},
    {131,88},{131,90},{131,92},{131,94},{131,96},{131,99},{131,101},
    {131,103},{131,105},{131,106},{131,107},{131,108},{131,109},
    {131,110},{131,113},{131,116},{131,119},{131,122},{131,125},
    {131,126},{131,128},{131,129},{131,130},{131,132},{131,134},
    {131,136},{131,137},{131,138},{131,139},{131,140},{131,141},
    {131,143},{131,147},{129,74},{129,75}};
static unsigned char *_sjis_han2zen(unsigned char *str, int *p1, int *p2)
{
  register int c1, c2;
  c1 = (int)*str; str++;
  *p1 = stable[c1 - 161][0];
  *p2 = stable[c1 - 161][1];
  /* 濁音、半濁音の処理 */
  c2 = (int)*str;
  if (c2 == 222 && ISNIGORI(c1)) {
    if ((*p2 >= 74 && *p2 <= 103) || (*p2 >= 110 && *p2 <= 122))
      (*p2)++;
    else if (*p1 == 131 && *p2 == 69)
      *p2 = 148;
    str++;
  }
  if (c2 == 223 && ISMARU(c1) && (*p2 >= 110 && *p2 <= 122) ) {
    *p2 += 2;
    str++;
  }
  return str++;
}
/* -------------------------------------------------- SJIS コードを変換 -- */
#define SJIS1(A)    ((A >= 129 && A <= 159) || (A >= 224 && A <= 239))
#define SJIS2(A)    (A >= 64 && A <= 252)
static void _shift2seven(unsigned char *str, unsigned char *str2)
{
  int p1,p2,esc_in = FALSE;
  while ((p1 = (int)*str) != '\0') {
    if (SJIS1(p1)) {
      if((p2 = (int)*(++str)) == '\0') break;
      if (SJIS2(p2)) {
        _sjis_shift(&p1,&p2);
        if (!esc_in) {
          esc_in = TRUE;
          str2 = _to_jis(str2);
        }
      }
      CHAROUT(p1);
      CHAROUT(p2);
      str++;
      continue;
    }
#ifdef NO_HANKAKU_SJIS
    /* 半角 SJIS は、強制的に全角に変える */
    if (HANKATA(p1)) {
      str = _sjis_han2zen(str, &p1, &p2);
      _sjis_shift(&p1,&p2);
      if (!esc_in) {
        esc_in = TRUE;
        str2 = _to_jis(str2);
      }
      CHAROUT(p1);
      CHAROUT(p2);
      continue;
    }
#endif
    if (esc_in) {
      /* LF / CR の場合は、正常にエスケープアウトされる */
      esc_in = FALSE;
      str2 = _to_ascii(str2);
    }
    CHAROUT(p1);
    str++;
  }
  if (esc_in)
    str2 = _to_ascii(str2);
  *str2='\0';
}
/* --------------------------------------------- SJIS を EUC に変換する -- */
static void _shift2euc(unsigned char *str, unsigned char *str2)
{
  int p1,p2;
  
  while ((p1 = (int)*str) != '\0') {
    if (SJIS1(p1)) {
      if((p2 = (int)*(++str)) == '\0') break;
      if (SJIS2(p2)) {
        _sjis_shift(&p1,&p2);
        p1 += 128;
        p2 += 128;
      }
      CHAROUT(p1);
      CHAROUT(p2);
      str++;
      continue;
    }
#ifdef NO_HANKAKU_SJIS
    /* 半角 SJIS は、強制的に全角に変える */
    if (HANKATA(p1)) {
      str = _sjis_han2zen(str,&p1,&p2);
      _sjis_shift(&p1,&p2);
      p1 += 128;
      p2 += 128;
      CHAROUT(p1);
      CHAROUT(p2);
      continue;
    }
#endif
    CHAROUT(p1);
    str++;
  }
  *str2='\0';
}
/* ------------------------------------------------- 半角 SJIS を取り除く -- */
static void _shift_self(unsigned char *str, unsigned char *str2)
{
  int p1,p2;
  
  while ((p1 = (int)*str) != '\0') {
#ifdef NO_HANKAKU_SJIS
    /* 半角 SJIS は、強制的に全角に変える */
    if (HANKATA(p1)) {
      str = _sjis_han2zen(str, &p1, &p2);
      CHAROUT(p1);
      CHAROUT(p2);
      continue;
    }
#endif
    CHAROUT(p1);
    str++;
  }
  *str2='\0';
}
/* ------------------------------------------------------EUC から JIS へ -- */
#define ISEUC(A)    (A >= 161 && A <= 254)
static void _euc2seven(unsigned char *str, unsigned char *str2)
{
  int p1, p2, esc_in = FALSE;
  while ((p1 = (int)*str) != '\0') {
    if (p1 == LF || p1 == CR) {
      if (esc_in) {
        esc_in = FALSE;
        str2 = _to_ascii(str2);
      }
      CHAROUT(p1);
      str++;
      continue;
    }
    if (ISEUC(p1)) {
      if((p2 = (int)*(++str)) == '\0') break;
      if (ISEUC(p2)) {
	if (!esc_in) {
	  esc_in = TRUE;
	  str2 =_to_jis(str2);
	}
	CHAROUT(p1-128);
	CHAROUT(p2-128);
	str++;
	continue;
      }
    }
    if (esc_in) {
      esc_in = FALSE;
      str2 = _to_ascii(str2);
    }
    CHAROUT(p1);
    str++;
  }
  *str2='\0';
}
/* ------------------------------------------------ EUC から SJIS に変換 -- */
 
static void _euc2shift(unsigned char *str, unsigned char *str2)
{
  int p1,p2;
  while ((p1 = (int)*str) != '\0') {
    if (ISEUC(p1)) {
      if((p2 = (int)*(++str)) == '\0') break;
      if (ISEUC(p2)) {
	p1 -= 128;
        p2 -= 128;
        _jis_shift(&p1,&p2);
      }
      CHAROUT(p1);
      CHAROUT(p2);
      str++;
      continue;
    }
    CHAROUT(p1);
    str++;
  }
  *str2='\0';
}
/* -------------------------------------- ESC シーケンスをスキップする ----- */
static unsigned char *_skip_esc(unsigned char *str, int *esc_in) {
  int c;
  
  c = (int)*(++str);
  if ((c == '$') || (c == '(')) str++;
  if ((c == 'K') || (c == '$')) *esc_in = TRUE;
  else *esc_in = FALSE;
  if(*str != '\0') str++;
  return str;
}
/* ----------------------------------------------- JIS を SJIS に変換する -- */
static void _seven2shift(unsigned char *str, unsigned char *str2)
{
  int p1, p2, esc_in = FALSE;
  while ((p1 = (int)*str) != '\0') {
    /* ESCシーケンスをスキップする */
    if (p1 == ESC) {
      str = _skip_esc(str, &esc_in);
      continue;
    }
    if (p1 == LF || p1 == CR) {
      if (esc_in) esc_in = FALSE;
    }
    if(esc_in) { /* ISO-2022-JP コード */
      if((p2 = (int)*(++str)) == '\0') break;
      _jis_shift(&p1, &p2);
      CHAROUT(p1);
      CHAROUT(p2);
    }else{       /* ASCII コード */
      CHAROUT(p1);
    }
    str++;
  }
  *str2 = '\0';
}
/* ------------------------------------------------ JIS を EUC に変換する -- */
static void _seven2euc(unsigned char *str, unsigned char *str2)
{
  int p1, esc_in = FALSE;
  while ((p1 = (int)*str) != '\0') {
    /* ESCシーケンスをスキップする */
    if (p1 == ESC) {
      str = _skip_esc(str, &esc_in);
      continue;
    }
    if (p1 == LF || p1 == CR) {
      if (esc_in) esc_in = FALSE;
    }
    if(esc_in) { /* ISO-2022-JP コード */
      CHAROUT(p1 + 128); 
      
      if((p1 = (int)*(++str)) == '\0') break;
      CHAROUT(p1 + 128);
    }else{       /* ASCII コード */
      CHAROUT(p1);
    }
    str++;
  }
  *str2 = '\0';
}
/* ------------------------------------------------------------------------ */
/* --------------------------------------------------------- Public 関数 -- */
char *toStringJIS(char *str) {
  int detected;
  unsigned char *buf, *ret;
  if(!str) return (NULL);
  detected = detectKanjiCode(str);
  if(detected == ASCII || detected == JIS)
    return strdup(str);
  buf = (unsigned char*)malloc(strlen(str)*2);
  if (!buf) return NULL;
  switch(detected) {
  case SJIS :
    _shift2seven((unsigned char *)str, buf);
    break;
  case EUC :
    _euc2seven((unsigned char *)str, buf);
    break;
  default:
    free(buf);
    return strdup(str);
    break;
  }
  ret = strdup(buf);
  free(buf);
  return ret;
}
char *toStringEUC(char *str) {
  int detected;
  unsigned char *buf, *ret;
  if(!str) return (NULL);
  detected = detectKanjiCode(str);
  if(detected == ASCII || detected == EUC) return strdup(str);
  buf = (unsigned char*)malloc(strlen(str)*2);
  if (!buf) return NULL;
  switch(detected) {
  case SJIS :
    _shift2euc((unsigned char *)str, buf);
    break;
  case JIS :
  case NEW : case OLD : case NEC :
     _seven2euc((unsigned char *)str, buf);
    break;
  default:
    free(buf);
    return strdup(str);
    break;
  }
  ret = strdup(buf);
  free(buf);
  return ret;
}
char *toStringSJIS(char *str) {
  int detected;
  unsigned char *buf, *ret;
  if (!str) return NULL;
  detected = detectKanjiCode(str);
  if(detected == ASCII) return strdup(str);
  
  buf = (unsigned char*)malloc(strlen(str)*2);
  if (!buf) return NULL;
  switch(detected) {
  case NEW : case OLD : case NEC :
  case JIS :
    _seven2shift((unsigned char *)str, buf);
    break;
  case EUC :
    _euc2shift((unsigned char *)str, buf);
    break;
  case SJIS :  
  default:
    _shift_self((unsigned char *)str, buf);
  }
  ret = strdup(buf);
  free(buf);
  return ret;
}
char *toStringAuto(char *str) {
  static int  jpcode = -1;
  static char *sjis_locale_name[] = {SJIS_LOCALE_NAME, NULL};
  static char *jis_locale_name[]  = {JIS_LOCALE_NAME, NULL};
  static char *euc_locale_name[]  = {EUC_LOCALE_NAME, NULL};
  static struct LOCALETABLE {
    int code;
    char **name_list;
  } locale_table[] = { {SJIS, sjis_locale_name},
		     {EUC, euc_locale_name},
		     {JIS, jis_locale_name}};
  if(!str) return (NULL);
  if (jpcode == -1) {
    char *ctype = setlocale(LC_CTYPE, "");
    int i, j;
    for( j=0; jpcode == -1 && 
	      j < sizeof(locale_table)/sizeof(struct LOCALETABLE); j++ ) {
      char **name = locale_table[j].name_list;
      for( i=0; name[i]; i++ )
	if (strcasecmp(ctype, name[i]) == 0) {
	  jpcode = locale_table[j].code;
	  break;
	}
    }
    if(jpcode == -1)
        jpcode = ASCII;
  }
  switch (jpcode) {
    case SJIS:
      return (toStringSJIS(str));
    break;
    case JIS:
    case NEW : case OLD : case NEC :
      return (toStringJIS(str));
    break;
    case EUC:
      return (toStringEUC(str));
    break;
    default:
      return (strdup(str));
    break;
  }
}
(-) a2ps-4.13.ORIG/libjcode/sample.c (+41 lines)
Line 0    Link Here 
/*
  sample.c -- サンプルプログラム   by. 倉光 君郎, 1996
  このプログラムは、サンプルプログラムです。
  標準入力から読み込んだテキストをオプションにあわせて、
  コード変換します。
*/
#include <stdio.h>
#include <string.h>
#include "jlib.h"
extern void printDetectCode(int code);
void main(int ac, char *av[]) {
  char buffer[BUFSIZ];
  int mode=JIS;
  if(ac == 2) {
    if(!strcmp(av[1], "-e")) mode = EUC;
    if(!strcmp(av[1], "-s")) mode =SJIS;
  }
  while(fgets(buffer,BUFSIZ,stdin) != NULL) {
    switch(mode) {
    case EUC:
      printf("%s", toStringEUC(buffer));
      break;
    case SJIS:
      printf("%s", toStringSJIS(buffer));
      break;
    default:
      printf("%s", toStringJIS(buffer));
      break;
    }
  }
  exit(0);
}
(-) a2ps-4.13.ORIG/ps/base.ps (-1 / +143 lines)
 Lines 153-159    Link Here 
% Return the y size of the current font
% Return the y size of the current font
% - => fontsize
% - => fontsize
/currentfontsize {
/currentfontsize {
  currentfont /FontMatrix get 3 get 1000 mul
  currentfont /FontType get 0 eq {
    currentfont /FontMatrix get 3 get
  }{
    currentfont /FontMatrix get 3 get 1000 mul
  } ifelse
} bind def
} bind def
% reencode the font
% reencode the font
 Lines 200-205    Link Here 
  end 
  end 
} bind def
} bind def
% composite fonts for ASCII-EUC mixed string
% Version 1.2 1/31/1990
% Orignal Ken'ichi HANDA (handa@etl.go.jp)
% Modified Norio Katayama (katayama@rd.nacsis.ac.jp),1998
% Extend & Fix Koji Nakamaru (maru@on.cs.keio.ac.jp), 1999
% Anyone can freely copy, modify, distribute this program.
/copyfont {	% font-dic extra-entry-count  copyfont  font-dic
	1 index maxlength add dict begin
	{	1 index /FID ne 2 index /UniqueID ne and
		{def} {pop pop} ifelse
	} forall
	currentdict
	end
} bind def
/compositefont { % ASCIIFontName EUCFontName RomanScale RomanOffset Rot(T/F) compositefont font
    /RomanRotation exch def
    /RomanOffset exch def
    /RomanScale exch def
    userdict /fixeucfont_dict known not {
	userdict begin
	    /fixeucfont_dict 2 dict begin
		/UpperByteEncoding [
		    16#00 1 16#20 { pop 0 } for
		    16#21 1 16#28 { 16#20 sub } for
		    16#29 1 16#2F { pop 0 } for
		    16#30 1 16#74 { 16#27 sub } for
		    16#75 1 16#FF { pop 0 } for
		] def
	        /LowerByteEncoding [
		    16#00 1 16#A0 { pop /.notdef } for
		    16#A1 1 16#FE { 16#80 sub 16 2 string cvrs
				    (cXX) dup 1 4 -1 roll
				    putinterval cvn } for
		    /.notdef
		] def
		currentdict
	    end def
	end
    } if
    findfont dup /FontType get 0 eq {
	14 dict begin
	    %
	    % 7+8 bit EUC font
	    %
	    12 dict begin
		/EUCFont exch def
		/FontInfo (7+8 bit EUC font) readonly def
		/PaintType 0 def
		/FontType 0 def
		/FontMatrix matrix def
		% /FontName
		/Encoding fixeucfont_dict /UpperByteEncoding get def
		/FMapType 2 def
		EUCFont /WMode known
		{ EUCFont /WMode get /WMode exch def }
		{ /WMode 0 def } ifelse
		/FDepVector [
		    EUCFont /FDepVector get 0 get
		    [ 16#21 1 16#28 {} for 16#30 1 16#74 {} for ]
		    {
			13 dict begin
			    /EUCFont EUCFont def
			    /UpperByte exch 16#80 add def	
			    % /FontName
			    /FontInfo (EUC lower byte font) readonly def
			    /PaintType 0 def
			    /FontType 3 def
			    /FontMatrix matrix def
			    /FontBBox {0 0 0 0} def
			    /Encoding
				fixeucfont_dict /LowerByteEncoding get def
			    % /UniqueID
			    % /WMode
			    /BuildChar {
				gsave
				exch dup /EUCFont get setfont
				/UpperByte get
				2 string
				dup 0 4 -1 roll put
				dup 1 4 -1 roll put
				dup stringwidth setcharwidth
				0 0 moveto show
				grestore
			    } bind def
			    currentdict
			end
			/lowerbytefont exch definefont
		    } forall
		] def
		currentdict
	    end
	    /eucfont exch definefont
	    exch
	    findfont 1 copyfont dup begin
		RomanRotation {
			/FontMatrix FontMatrix
			[ 0 RomanScale neg RomanScale 0 RomanOffset neg 0 ]
			matrix concatmatrix def
		}{
			/FontMatrix FontMatrix
			[ RomanScale 0 0 RomanScale 0 RomanOffset ] matrix concatmatrix
			def
			/CDevProc
			    {pop pop pop pop 0 exch -1000 exch 2 div 880} def
		} ifelse
	    end
	    /asciifont exch definefont
	    exch
	    /FDepVector [ 4 2 roll ] def
	    /FontType 0 def
	    /WMode 0 def
	    /FMapType 4 def
	    /FontMatrix matrix def
	    /Encoding [0 1] def
	    /FontBBox {0 0 0 0} def
%	    /FontHeight 1.0 def % XXXX
	    /FontHeight RomanScale 1.0 ge { RomanScale }{ 1.0 } ifelse def
	    /Descent -0.3 def   % XXXX
	    currentdict
	end
	/tmpfont exch definefont
	pop
	/tmpfont findfont
    }{
	pop findfont 0 copyfont
    } ifelse
} def	
/slantfont {	% FontName slant-degree  slantfont  font'
    exch findfont 1 copyfont begin
    [ 1 0 4 -1 roll 1 0 0 ] FontMatrix exch matrix concatmatrix
    /FontMatrix exch def
    currentdict
    end
} def
% Function print line number (<string> # -)
% Function print line number (<string> # -)
/# {
/# {
  gsave
  gsave
(-) a2ps-4.13.ORIG/src/Makefile.am (-2 / +2 lines)
 Lines 49-56    Link Here 
# I don't really understand why I have to put srcdir here, but
# I don't really understand why I have to put srcdir here, but
# it is needed for yacc and lex files (seems related to #line, but
# it is needed for yacc and lex files (seems related to #line, but
# I really don't understand why)...
# I really don't understand why)...
INCLUDES = -I.. -I$(srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/intl
INCLUDES = -I.. -I$(srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/intl -I$(top_builddir)/libjcode
a2ps_LDADD = $(top_builddir)/lib/liba2ps.la @LIBINTL@ -lm
a2ps_LDADD = $(top_builddir)/lib/liba2ps.la @LIBINTL@ @LEXLIB@ @LIBJCODELIBS@ -lm
EXTRA_DIST = $(BUILT_SOURCES)
EXTRA_DIST = $(BUILT_SOURCES)
(-) a2ps-4.13.ORIG/src/Makefile.in (-2 / +2 lines)
 Lines 304-311    Link Here 
# I don't really understand why I have to put srcdir here, but
# I don't really understand why I have to put srcdir here, but
# it is needed for yacc and lex files (seems related to #line, but
# it is needed for yacc and lex files (seems related to #line, but
# I really don't understand why)...
# I really don't understand why)...
INCLUDES = -I.. -I$(srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/intl
INCLUDES = -I.. -I$(srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/intl -I$(top_builddir)/libjcode
a2ps_LDADD = $(top_builddir)/lib/liba2ps.la @LIBINTL@ -lm
a2ps_LDADD = $(top_builddir)/lib/liba2ps.la @LIBINTL@ @LEXLIB@ @LIBJCODELIBS@ -lm
EXTRA_DIST = $(BUILT_SOURCES)
EXTRA_DIST = $(BUILT_SOURCES)
all: $(BUILT_SOURCES)
all: $(BUILT_SOURCES)
	$(MAKE) $(AM_MAKEFLAGS) all-am
	$(MAKE) $(AM_MAKEFLAGS) all-am
(-) a2ps-4.13.ORIG/src/buffer.c (+16 lines)
 Lines 41-46    Link Here 
#include "argmatch.h"
#include "argmatch.h"
#include "buffer.h"
#include "buffer.h"
#include <assert.h>
#include <assert.h>
#ifdef USE_LIBJCODE
#include "jlib.h"
extern use_libjcode;
#endif


/****************************************************************/
/****************************************************************/
/*		 	Handling of the various eol styles	*/
/*		 	Handling of the various eol styles	*/
 Lines 418-426    Link Here 
     match_keyword, which looks one char after the current char.  With
     match_keyword, which looks one char after the current char.  With
     this sentinel, which is probably not in the alphabet, we save a
     this sentinel, which is probably not in the alphabet, we save a
     test on the length of the buffer. */
     test on the length of the buffer. */
#ifdef USE_LIBJCODE
  obstack_1grow (&buffer->obstack, '\0');
  if (use_libjcode == true)
    {
      if(buffer->content) free(buffer->content);
      buffer->content = toStringEUC(obstack_finish (&buffer->obstack));
    }
  else
      buffer->content = (uchar *) obstack_finish (&buffer->obstack);
  buffer->len = strlen(buffer->content);
#else
  buffer->len = obstack_object_size (&buffer->obstack);
  buffer->len = obstack_object_size (&buffer->obstack);
  obstack_1grow (&buffer->obstack, '\0');
  obstack_1grow (&buffer->obstack, '\0');
  buffer->content = (uchar *) obstack_finish (&buffer->obstack);
  buffer->content = (uchar *) obstack_finish (&buffer->obstack);
#endif
  /* One more line read */
  /* One more line read */
  buffer->line++;
  buffer->line++;