Created
September 9, 2018 13:47
-
-
Save jfbu/ff1fe5ddad072c59e940b321edc25353 to your computer and use it in GitHub Desktop.
CheckWhetherNull.tex
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
% Time-stamp: <09-09-2018 15:45:05 CEST> | |
% cf https://tex.stackexchange.com/questions/449869/trying-to-get-zapspace-and-lowercase-to-work-on-string-comparison/449979 | |
\catcode`@ 11 | |
\long\def\@gobble#1{} | |
%\long\def\JFB@stop@firstoftwo#1#2{\z@#1} | |
\long\def\JFB@stop@secondoftwo#1#2{\z@#2} | |
\long\def\JFB@stop@thirdoffour#1#2#3#4{\z@#3} | |
% first variant | |
\long\def\JFB@CheckWhetherNull#1{% | |
\romannumeral | |
\expandafter\expandafter\expandafter\@gobble | |
\expandafter\expandafter\expandafter{% | |
\expandafter\string\expandafter{% | |
\expandafter{\string#1}\expandafter\@gobble\string}% | |
\iffalse}\JFB@stop@thirdoffour\fi | |
\JFB@stop@secondoftwo | |
}% | |
\JFB@CheckWhetherNull{}{OK}{WRONG} | |
\JFB@CheckWhetherNull{{}}{WRONG}{OK} | |
\JFB@CheckWhetherNull{ }{WRONG}{OK} | |
\JFB@CheckWhetherNull{ {}}{WRONG}{OK} | |
\JFB@CheckWhetherNull{a}{WRONG}{OK} | |
\JFB@CheckWhetherNull{\error}{WRONG}{OK} | |
% second variant with less \expandafter's | |
\long\def\@gobbletwo#1#2{} | |
\long\def\JFB@CheckWhetherNull#1{% | |
\romannumeral | |
\expandafter\expandafter\expandafter\@gobbletwo | |
\expandafter\string\expandafter{\expandafter{% | |
\expandafter{\string#1}\expandafter\@gobble\string}% | |
\iffalse}\JFB@stop@thirdoffour\fi | |
\JFB@stop@secondoftwo | |
}% | |
\JFB@CheckWhetherNull{}{OK}{WRONG} | |
\JFB@CheckWhetherNull{{}}{WRONG}{OK} | |
\JFB@CheckWhetherNull{ }{WRONG}{OK} | |
\JFB@CheckWhetherNull{ {}}{WRONG}{OK} | |
\JFB@CheckWhetherNull{a}{WRONG}{OK} | |
\JFB@CheckWhetherNull{\error}{WRONG}{OK} | |
\bye |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment