%#!euptex pdfprimitive-test.tex
\catcode`\{=1\catcode`\}=2
\scrollmode
\catcode`\Q=14
\ifdefined\pdfprimitive\else\catcode`\Q=11 \fi

Q\let\pdfprimitive\primitive\let\ifpdfprimitive\ifprimitive
\catcode`\Q=11 

\def\relax{\message{RELAX}}
\def\fuga{\message{FUGA}}
\let\input=\halign

\relax                   % ==> RELAX
\pdfprimitive\relax      % ==> (no output)
\message{\meaning\relax} % ==> macro:->\message {RELAX}

\fuga              % ==> FUGA
\pdfprimitive\fuga % ==> ``! Missing primitive name.'' error

\ifpdfprimitive\relax\message{T}\else\message{F}\fi % ==> F (macro)
\ifpdfprimitive\par\message{T}\else\message{F}\fi   % ==> T
\ifpdfprimitive\input\message{T}\else\message{F}\fi % ==> F
 % (This \input is not ``primitive \input''.)
\ifpdfprimitive\hoge\message{T}\else\message{F}\fi  % ==> F (undefined)
\ifpdfprimitive\fuga\message{T}\else\message{F}\fi  % ==> F (macro)

\show\pdfstrcmp % ==> \pdfstrcmp

% fix for overwriting entries (170924)
\ifpdfprimitive\ \message{T}\else\message{F}\fi     % ==> T
\ifpdfprimitive\vrule\message{T}\else\message{F}\fi % ==> T

% fix for back_input in vertical mode (170924)
\setbox0=\vbox{\pdfprimitive\ \undefined}
% ==> ``! Undefined control sequence.'' error
\setbox0=\vbox{\pdfprimitive\vrule\undefined}
% ==> ``! Undefined control sequence.'' error

\setbox0=\hbox{%
  \def\A{\message{<\the\count42>}\ignorespaces}
  \count42=\pdfprimitive\X 1\A
  \count42=\pdfprimitive\- 2\A
  \count42=\pdfprimitive\vrule 3\A
}

\end
