Created
June 30, 2016 12:38
-
-
Save zr-tex8r/58fc33678f7a86ab548c8d20c93cb403 to your computer and use it in GitHub Desktop.
TeX: pLaTeX のコードに潜在するバグを一気に消し去る話
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% tcsafepltx.sty | |
% | |
%--------------------------------------- prologue | |
% | |
%% If \documentclass is done, then exit. | |
\global\let\next\relax% | |
\begingroup\catcode61\catcode48\catcode32=10\relax% | |
\catcode123=1 \catcode125=2 \endlinechar=13 \catcode13=5 % | |
\ifx\documentclass\@twoclasseserror | |
\PackageError{tcsafepltx}% | |
{This package cannot be loaded here}\@ehc | |
\global\let\next\endinput | |
\fi | |
\endgroup\next\relax% | |
% | |
%% reset some catcodes | |
\catcode61\catcode48\catcode32=10\endlinechar=13 \catcode13=5 % | |
\catcode96=12 \catcode`\"=12 \catcode`\'=12 \catcode`\-=12 | |
\catcode`\+=12 \catcode`\/=12 \catcode`\.=12 | |
\catcode`\{=1 \catcode`\}=2 \catcode`\#=6 | |
\chardef\tcspAtcc=\catcode`\@ | |
\catcode`\@=11 \escapechar=`\\ | |
%% check if it is a format-making job | |
\newif\iftcsp@fmt@job | |
\begingroup \escapechar\m@ne | |
\edef\tcsp@job{\jobname} | |
\edef\tcsp@x{\string\platex} | |
\ifx\tcsp@x\tcsp@job \global\tcsp@fmt@jobtrue \fi | |
\edef\tcsp@x{\string\uplatex} | |
\ifx\tcsp@x\tcsp@job \global\tcsp@fmt@jobtrue \fi | |
\endgroup | |
%--------------------------------------- declaration | |
\iftcsp@fmt@job | |
\def\next#1#2#3#4[#5]{\immediate\write16{Loading: #4 [#5]}} | |
\else \let\next\relax | |
\fi | |
%% package declaration | |
\next | |
\NeedsTeXFormat{LaTeX2e} | |
\ProvidesPackage{tcsafepltx}[2016/06/30 v0.2] | |
%--------------------------------------- output box | |
%% \tcsp@outbox@platex | |
\def\tcsp@outbox@platex{% | |
\font\tcsp@font@IpxmA=ipxm-r-u26 at 240pt | |
\font\tcsp@font@IpxgA=ipxg-r-u30 at 80pt | |
\hbox to\hsize{\tcsp@font@IpxgA | |
\hfil\hfil | |
\raise20pt\hbox{\char"86}\hfil | |
\raise30pt\hbox{\char"4D}\hfil | |
\raise36pt\hbox{\char"60}\hfil | |
\raise30pt\hbox{\char"8B}\hfil | |
\raise20pt\hbox{\char"7E}\hfil\hfil}% | |
\vskip20pt | |
\hbox to\hsize{\tcsp@font@IpxmA\hfil\char"03\hfil}} | |
%% \tcsp@outbox@uplatex | |
\def\tcsp@outbox@uplatex{% | |
\font\tcsp@font@Ipxm=upjisr-h at 240pt | |
\font\tcsp@font@Ipxg=upjisg-h at 60pt | |
\hbox to\hsize{\tcsp@font@Ipxg | |
\hfil\hfil | |
\raise20pt\hbox{\char"3086}\hfil | |
\raise30pt\hbox{\char"304D}\hfil | |
\raise36pt\hbox{\char"3060}\hfil | |
\raise30pt\hbox{\char"308B}\hfil | |
\raise20pt\hbox{\char"307E}\hfil\hfil}% | |
\vskip20pt | |
\hbox to\hsize{\tcsp@font@Ipxm\hfil\char"2603\hfil}} | |
%--------------------------------------- main procedure | |
%% variables | |
\newbox\tcsp@out | |
%% \tcsp@mainproc | |
\def\tcsp@mainproc{% | |
\global\let\tcsp@mainproc\relax | |
% suppress normal output | |
\output{\setbox\z@\box\@cclv \deadcycles\z@}% | |
% shipout the special box | |
\setbox\tcsp@out\vbox{% | |
\moveleft1in\vbox{\hsize=210mm | |
\kern-1in \kern40mm | |
\ifnum\ifx\ucs\@undefined\z@\else\ucs"3000\fi="3000 | |
\tcsp@outbox@uplatex | |
\else | |
\tcsp@outbox@platex | |
\fi}}% | |
\shipout\box\tcsp@out | |
% quit now | |
\nonstopmode\@@end} | |
%--------------------------------------- trigger (package) | |
\iftcsp@fmt@job\else | |
%% add a hook | |
\g@addto@macro\@reset@ptions{% | |
\tcsp@mainproc} | |
\fi | |
%--------------------------------------- trigger (format) | |
\iftcsp@fmt@job | |
%% add a hook | |
\everyjob\expandafter{\the\everyjob | |
\tcsp@get@ready} | |
%% \tcsp@get@ready | |
\def\tcsp@get@ready{% | |
\count@\z@ \loop\ifnum\count@<\@cclvi | |
\catcode\count@=12 | |
\advance\count@\@ne | |
\repeat | |
\everypar{\everypar{}\tcsp@mainproc}% | |
\ifx\everyeof\@undefined\else | |
\everyeof{\everyeof{}\tcsp@mainproc}% | |
\fi | |
\parindent\z@} | |
\fi | |
%--------------------------------------- all done | |
\iftcsp@fmt@job | |
\catcode`\@=\tcspAtcc | |
\fi | |
\endinput | |
%% EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ネタの本文はこちら。