summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-01-09 22:53:50 +0000
committerKarl Berry <karl@freefriends.org>2015-01-09 22:53:50 +0000
commit68d94357af9f1ad97052ca3e416f8f2e0c8c060f (patch)
tree2dbf75a95b2c4e66440859c427cad98b93dbc997 /Master/texmf-dist/tex
parente50577c5f3a68dbf81c75d8166d6088679a6622b (diff)
qrcode (9jan15)
git-svn-id: svn://tug.org/texlive/trunk@36007 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/qrcode/qrcode.sty746
1 files changed, 387 insertions, 359 deletions
diff --git a/Master/texmf-dist/tex/latex/qrcode/qrcode.sty b/Master/texmf-dist/tex/latex/qrcode/qrcode.sty
index 71504c64504..7caa94bec7e 100644
--- a/Master/texmf-dist/tex/latex/qrcode/qrcode.sty
+++ b/Master/texmf-dist/tex/latex/qrcode/qrcode.sty
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% Copyright (C) 2014 by Anders Hendrickson <ahendric@cord.edu>
+%% Copyright (C) 2015 by Anders Hendrickson <ahendric@cord.edu>
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -20,7 +20,7 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{qrcode}
- [2014/09/26 v1.0 QR code generation]
+ [2015/01/08 v1.5 QR code generation]
%%PACKAGE LOADING
\RequirePackage{xcolor}%
\RequirePackage{xkeyval}%
@@ -33,10 +33,17 @@
\define@boolkey{qr}[qr@]{draft}[true]{\ifqr@draft\qr@draft@modetrue\else\qr@draft@modefalse\fi}%
\define@boolkey{qr}[qr@]{final}[true]{\ifqr@final\qr@draft@modefalse\else\qr@draft@modetrue\fi}%
\define@boolkey{qr}[qr@]{forget}[true]{\ifqr@forget\qr@forget@modetrue\else\qr@forget@modefalse\fi}%
+\define@boolkey{qr}[qr@]{hyperlink}[true]{}% %This creates \ifqr@hyperlink.
+\define@boolkey{qr}[qr@]{hyperlinks}[true]{\ifqr@hyperlinks\qr@hyperlinktrue\else\qr@hyperlinkfalse\fi}%
+\define@boolkey{qr}[qr@]{link}[true]{\ifqr@link\qr@hyperlinktrue\else\qr@hyperlinkfalse\fi}%
+\define@boolkey{qr}[qr@]{nolink}[true]{\ifqr@nolink\qr@hyperlinkfalse\else\qr@hyperlinktrue\fi}% %Make nolink an antonym.
+\define@boolkey{qr}[qr@]{links}[true]{\ifqr@links\qr@hyperlinktrue\else\qr@hyperlinkfalse\fi}%
+\define@boolkey{qr}[qr@]{nolinks}[true]{\ifqr@nolinks\qr@hyperlinkfalse\else\qr@hyperlinktrue\fi}% %Make nolinks an antonym.
%%EXECUTION OF OPTIONS
\qr@draft@modefalse
\qr@forget@modefalse
+\qr@hyperlinktrue
\ProcessOptionsX<qr>
@@ -50,34 +57,34 @@
\newlinechar=`\^^J
-\def\@relax{\relax}%
+\def\qr@relax{\relax}%
-\def\preface@macro#1#2{%
+\def\qr@preface@macro#1#2{%
% #1 = macro name
% #2 = text to add to front of macro
- \def\tempb{#2}%
- \xa\xa\xa\def\xa\xa\xa#1\xa\xa\xa{\xa\tempb #1}%
+ \def\qr@tempb{#2}%
+ \xa\xa\xa\def\xa\xa\xa#1\xa\xa\xa{\xa\qr@tempb #1}%
}%
-\def\g@preface@macro#1#2{%
+\def\qr@g@preface@macro#1#2{%
% #1 = macro to be appended to
% #2 = code to add
- \edef\codeA{#2}%
- \xa\xa\xa\gdef\xa\xa\xa#1\xa\xa\xa{\xa\codeA#1}%
+ \edef\qr@tempb{#2}%
+ \xa\xa\xa\gdef\xa\xa\xa#1\xa\xa\xa{\xa\qr@tempb#1}%
}
\def\qr@getstringlength#1{%
\bgroup
\qr@a=0%
- \xdef\thestring{#1}%
- \xa\qr@stringlength@recursive\xa(\thestring\relax\relax)%
+ \xdef\qr@thestring{#1}%
+ \xa\qr@stringlength@recursive\xa(\qr@thestring\relax\relax)%
\xdef\qr@stringlength{\the\qr@a}%
\egroup
}%
\def\qr@stringlength@recursive(#1#2){%
- \def\testi{#1}%
- \ifx\testi\@relax
+ \def\qr@testi{#1}%
+ \ifx\qr@testi\qr@relax
%we are done.
\let\qr@next=\relax%
\else
@@ -187,7 +194,7 @@
\qr@a=\qr@stringlength\relax%
\advance\qr@a by 1\relax%
\qr@for \i = \qr@a to #2 by 1\relax%
- {\g@preface@macro{#1}{0}}%
+ {\qr@g@preface@macro{#1}{0}}%
}
\qr@a=-1\relax%
@@ -224,12 +231,12 @@
\advance\qr@b by \qr@a\relax%
\divide\qr@a by \qr@newbase\relax%
\ifnum\qr@b<10\relax
- \edef\newdigit{\the\qr@b}%
+ \edef\qr@newdigit{\the\qr@b}%
\else
- \edef\newdigit{\csname qr@hexchar@\the\qr@b\endcsname}%
+ \edef\qr@newdigit{\csname qr@hexchar@\the\qr@b\endcsname}%
\fi
- \edef\qr@argument{{\noexpand\qr@base@result}{\newdigit}}%
- \xa\g@preface@macro\qr@argument%
+ \edef\qr@argument{{\noexpand\qr@base@result}{\qr@newdigit}}%
+ \xa\qr@g@preface@macro\qr@argument%
\ifnum\qr@a=0\relax
\relax
\else
@@ -265,8 +272,8 @@
% #1 (optional) = # digits desired
% #2 = macro to save to
% #3 = binary string (must be multiple of 4 bits)
- \def\test@i{#1}%
- \ifx\test@i\@relax%
+ \def\qr@test@i{#1}%
+ \ifx\qr@test@i\qr@relax%
%No argument specified
\def\qr@desireddigits{0}%
\else
@@ -281,8 +288,8 @@
\def\qr@binarytohex@int(#1#2#3#4#5){%
% #1#2#3#4 = 4 bits
% #5 = remainder, including \relax\relax\relax\relax\relax terminator
- \def\test@i{#1}%
- \ifx\test@i\@relax%
+ \def\qr@test@i{#1}%
+ \ifx\qr@test@i\qr@relax%
%Done.
\def\qr@next{\relax}%
\else%
@@ -297,8 +304,8 @@
% #2 = macro to save to
% #3 = hexadecimal string
\bgroup
- \def\test@i{#1}%
- \ifx\test@i\@relax%
+ \def\qr@test@i{#1}%
+ \ifx\qr@test@i\qr@relax%
%No argument specified
\def\qr@desireddigits{0}%
\else
@@ -314,8 +321,8 @@
\def\qr@hextobinary@int(#1#2){%
% #1 = hexadecimal character
% #2 = remainder, including \relax\relax terminator
- \def\test@@i{#1}%
- \ifx\test@@i\@relax%
+ \def\qr@test@@i{#1}%
+ \ifx\qr@test@@i\qr@relax%
%Done.
\def\qr@next{\relax}%
\else%
@@ -345,8 +352,8 @@
% #1 = first hex char
% #2 = remainder
\advance \qr@a by \csname qr@hextodecimal@#1\endcsname\relax%
- \edef\testii{#2}%
- \ifx\testii\@relax%
+ \edef\qr@testii{#2}%
+ \ifx\qr@testii\qr@relax%
%Done.
\let\qr@next=\relax%
\else
@@ -360,6 +367,7 @@
{\catcode`\%=12\relax\gdef\qr@otherpercent{%}}%
{\catcode`\#=12\relax\gdef\qr@otherpound{#}}%
{\catcode`\|=0\relax|catcode`|\=12|relax|gdef|qr@otherbackslash{\}}%
+{\catcode`\^^J=12\relax\gdef\qr@otherlf{^^J}}%
\bgroup
\catcode`\<=1\relax
\catcode`\>=2\relax
@@ -372,6 +380,7 @@
{\catcode`\_=12\relax\gdef\qr@otherunderscore{_}}%
{\catcode`\$=12\relax\gdef\qr@otherdollar{$}}%
+{\catcode`\^^M=13\relax\gdef\qr@verbatimlinefeeds{\let^^M=\qr@otherlf}}
\def\qr@verbatimcatcodes{%
\catcode`\#=12\relax
\catcode`\$=12\relax
@@ -380,7 +389,8 @@
\catcode`\_=12\relax
\catcode`\~=12\relax
\catcode`\%=12\relax
- \catcode`\ =12\relax}%
+ \catcode`\ =12\relax
+ \catcode`\^^M=13\relax\qr@verbatimlinefeeds}%
\def\qr@setescapedspecials{%
\let\ =\qr@otherspace%
@@ -394,6 +404,7 @@
\let\\=\qr@otherbackslash%
\let\{=\qr@otherleftbrace%
\let\}=\qr@otherrightbrace%
+ \let\?=\qr@otherlf%
}%
\def\qr@creatematrix#1{%
\xa\gdef\csname #1\endcsname##1##2{%
@@ -431,7 +442,7 @@
\xa\gdef\csname #1@numcols\endcsname{#2}%
\qr@for \i = 1 to #2 by 1%
{\qr@for \j = 1 to #2 by 1%
- {\qr@storetomatrix{#1}{\the\i}{\the\j}{\@blank}}}%
+ {\qr@storetomatrix{#1}{\the\i}{\the\j}{\qr@blank}}}%
}%
\def\qr@numberofrowsinmatrix#1{%
@@ -457,7 +468,7 @@
\def\qr@printmatrix#1{%
\def\qr@black{\rule{\qr@modulesize}{\qr@modulesize}}%
- \def\@white{\rule{\qr@modulesize}{0pt}}%
+ \def\qr@white{\rule{\qr@modulesize}{0pt}}%
\def\qr@black@fixed{\rule{\qr@modulesize}{\qr@modulesize}}%
\def\qr@white@fixed{\rule{\qr@modulesize}{0pt}}%
\def\qr@black@format{\rule{\qr@modulesize}{\qr@modulesize}}%
@@ -502,8 +513,8 @@
\qr@for \i = 1 to \qr@size by 1%
{\ifqr@tight\else\rule{4\qr@modulesize}{0pt}\fi% %Blank space at left.
\qr@for \j = 1 to \qr@size by 1%
- {\edef\theargument{(\qr@binarystring)}%
- \xa\qr@printsavedbinarymatrix@int\theargument
+ {\edef\qr@theargument{(\qr@binarystring)}%
+ \xa\qr@printsavedbinarymatrix@int\qr@theargument
}%
\par}%
\ifqr@tight\else\rule{0pt}{4\qr@modulesize}\par\fi%
@@ -611,11 +622,11 @@
}%
\def\qr@placetimingpatterns#1{%
- %Set \endingcol to n-8.
+ %Set \qr@endingcol to n-8.
\qr@a=\qr@size\relax%
\advance\qr@a by -8\relax%
- \edef\endingcol{\the\qr@a}%
- \qr@for \j = 9 to \endingcol by 1%
+ \edef\qr@endingcol{\the\qr@a}%
+ \qr@for \j = 9 to \qr@endingcol by 1%
{\ifodd\j\relax%
\qr@storetomatrix{#1}{7}{\the\j}{\qr@black@fixed}%
\qr@storetomatrix{#1}{\the\j}{7}{\qr@black@fixed}%
@@ -770,7 +781,7 @@
\ifnum#1=1
\qr@storetomatrix{#3}{\theqr@i}{\theqr@j}{\qr@black}%
\else
- \qr@storetomatrix{#3}{\theqr@i}{\theqr@j}{\@white}%
+ \qr@storetomatrix{#3}{\theqr@i}{\theqr@j}{\qr@white}%
\fi
}%
@@ -793,8 +804,8 @@
% (qr@i,qr@j) = position to write in LaTeX counters
% #2#3#4 contains the hex codes of the bytes to be written, plus \relax\relax\relax
% as an end-of-file marker
- \edef\testii{#2}%
- \ifx\testii\@relax%
+ \edef\qr@testii{#2}%
+ \ifx\qr@testii\qr@relax%
% #2 is \relax, so there is nothing more to write.
\relax
\let\go=\relax
@@ -804,9 +815,9 @@
\xdef\qr@datatowrite{\bytetowrite\relax}% %Add terminating "\relax"
\qr@writedata@recursive{#1}% %This function actually writes the 8 bits.
\edef\qr@argument{{#1}(#4)}%
- \xa\def\xa\go\xa{\xa\qr@writedata@hex@recursive\qr@argument}% %Call self to write the next bit.
+ \xa\def\xa\qr@next\xa{\xa\qr@writedata@hex@recursive\qr@argument}% %Call self to write the next bit.
\fi
- \go
+ \qr@next
}%
\def\qr@writedata#1#2{%
@@ -820,14 +831,14 @@
\qr@writedata@recursive{#1}%
}%
-\def\@@blank{\@blank}%
+\def\qr@@blank{\qr@blank}%
\def\qr@writedata@recursive#1{%
% #1 = matrix name
% (qr@i,qr@j) = position to write in (LaTeX counters)
% \qr@datatowrite contains the bits to be written, plus '\relax' as an end-of-file marker
\xa\let\xa\squarevalue\csname #1@\theqr@i @\theqr@j\endcsname%
- \ifx\squarevalue\@@blank
+ \ifx\squarevalue\qr@@blank
%Square is blank, so write data in it.
\xa\qr@writebit\xa(\qr@datatowrite){#1}%
%The \qr@writebit macro not only writes the first bit of \qr@datatowrite into the matrix,
@@ -879,15 +890,15 @@
\fi
\fi
%Now check whether there are any more bits to write.
- \ifx\qr@datatowrite\@relax
+ \ifx\qr@datatowrite\qr@relax
% \qr@datatowrite is just `\relax', so we're done.
- \let\nexttoken=\relax
+ \let\qr@next=\relax
\relax
\else
% Write some more!
- \def\nexttoken{\qr@writedata@recursive{#1}}%
+ \def\qr@next{\qr@writedata@recursive{#1}}%
\fi
- \nexttoken
+ \qr@next
}%
\def\qr@writeremainderbits#1{%
@@ -907,8 +918,8 @@
\def\qr@setmaskingfunction#1{%
% #1 = 1 decimal digit for the mask. (I see no reason to use the 3-bit binary code.)
% The current position is (\themaski,\themaskj), with indexing starting at 0.
- \edef\maskselection{#1}%
- \xa\ifcase\maskselection\relax
+ \edef\qr@maskselection{#1}%
+ \xa\ifcase\qr@maskselection\relax
%Case 0: checkerboard
\def\qr@parsemaskingfunction{%
% Compute mod(\themaski+\themaskj,2)%
@@ -1075,28 +1086,28 @@
\newif\ifqr@currentcellcontainsdata
\qr@currentcellcontainsdatafalse
-\def\@@white{\@white}%
-\def\@@black{\qr@black}%
+\def\qr@@white{\qr@white}%
+\def\qr@@black{\qr@black}%
\def\qr@checkifcurrentcellcontainsdata#1{%
% #1 = name of matrix
\qr@currentcellcontainsdatafalse
- \xa\ifx\csname #1@\the\i @\the\j\endcsname\@@white
+ \xa\ifx\csname #1@\the\i @\the\j\endcsname\qr@@white
\qr@currentcellcontainsdatatrue
\fi
- \xa\ifx\csname #1@\the\i @\the\j\endcsname\@@black
+ \xa\ifx\csname #1@\the\i @\the\j\endcsname\qr@@black
\qr@currentcellcontainsdatatrue
\fi
}%
\def\qr@flipped@black{\qr@black}%
-\def\qr@flipped@white{\@white}%
+\def\qr@flipped@white{\qr@white}%
\def\qr@flipcurrentcell#1{%
% #1 = name of matrix
% (\i, \j) = current position, in TeX counts.
% This assumes the cell contains data, either black or white!
- \xa\ifx\csname #1@\the\i @\the\j\endcsname\@@white
+ \xa\ifx\csname #1@\the\i @\the\j\endcsname\qr@@white
\qr@storetomatrix{#1}{\the\i}{\the\j}{\qr@flipped@black}%
\else
\qr@storetomatrix{#1}{\the\i}{\the\j}{\qr@flipped@white}%
@@ -1114,23 +1125,23 @@
\qr@applymask{originalmatrix}{#1}{0}%
\message{done. Calculating penalty...}%
\qr@evaluatemaskpenalty{#1}%
- \xdef\currentbestpenalty{\qr@penalty}%
+ \xdef\qr@currentbestpenalty{\qr@penalty}%
\message{penalty is \qr@penalty>^^J}%
- \gdef\currentbestmask{0}%
+ \gdef\qr@currentbestmask{0}%
\qr@for \i = 1 to 7 by 1%
{\message{<Applying Mask \the\i...}%
\qr@applymask{originalmatrix}{currentmasked}{\the\i}%
\message{done. Calculating penalty...}%
\qr@evaluatemaskpenalty{currentmasked}%
\message{penalty is \qr@penalty>^^J}%
- \xa\xa\xa\ifnum\xa\qr@penalty\xa<\currentbestpenalty\relax
+ \xa\xa\xa\ifnum\xa\qr@penalty\xa<\qr@currentbestpenalty\relax
%We found a better mask.
- \xdef\currentbestmask{\the\i}%
+ \xdef\qr@currentbestmask{\the\i}%
\qr@createduplicatematrix{#1}{currentmasked}%
- \xdef\currentbestpenalty{\qr@penalty}%
+ \xdef\qr@currentbestpenalty{\qr@penalty}%
\fi
}%
- \xdef\qr@mask@selected{\currentbestmask}%
+ \xdef\qr@mask@selected{\qr@currentbestmask}%
\message{<Selected Mask \qr@mask@selected>^^J}%
}%
@@ -1138,18 +1149,18 @@
\def\qr@Nii{3}%
\def\qr@Niii{40}%
\def\qr@Niv{10}%
-\def\@fiveones{11111}%
-\def\@fivezeros{11111}%
-\def\@twoones{11}%
-\def\@twozeros{00}%
-\def\@finderA{00001011101}%
-\def\@finderB{10111010000}%
-\def\@finderB@three{1011101000}%
-\def\@finderB@two{101110100}%
-\def\@finderB@one{10111010}%
-\def\@finderB@zero{1011101}%
-\newif\ifstringoffive
-\def\addpenaltyiii{%
+\def\qr@fiveones{11111}%
+\def\qr@fivezeros{11111}%
+\def\qr@twoones{11}%
+\def\qr@twozeros{00}%
+\def\qr@finderA{00001011101}%
+\def\qr@finderB{10111010000}%
+\def\qr@finderB@three{1011101000}%
+\def\qr@finderB@two{101110100}%
+\def\qr@finderB@one{10111010}%
+\def\qr@finderB@zero{1011101}%
+\newif\ifqr@stringoffive
+\def\qr@addpenaltyiii{%
\addtocounter{penaltyiii}{\qr@Niii}%
}%
\newcounter{totalones}%
@@ -1165,55 +1176,55 @@
\setcounter{penaltyiii}{0}%
\setcounter{penaltyiv}{0}%
\bgroup%localize the meanings we give to the symbols
- \def\qr@black{1}\def\@white{0}%
+ \def\qr@black{1}\def\qr@white{0}%
\def\qr@black@fixed{1}\def\qr@white@fixed{0}%
\def\qr@format@square{0}% This is not stated in the specs, but seems
% to be the standard implementation.
- \def\@blank{0}% These would be any bits at the end.
+ \def\qr@blank{0}% These would be any bits at the end.
%
\setcounter{totalones}{0}%
\qr@for \i=1 to \qr@size by 1%
- {\def\lastfive{z}% %The z is a dummy, that will be removed before any testing.
- \stringoffivefalse
- \def\lasttwo@thisrow{z}% %The z is a dummy.
- \def\lasttwo@nextrow{z}% %The z is a dummy.
- \def\lastnine{z0000}% %The 0000 stands for the white space to the left. The z is a dummy.
- \def\ignore@finderB@at{0}%
+ {\def\qr@lastfive{z}% %The z is a dummy, that will be removed before any testing.
+ \qr@stringoffivefalse
+ \def\qr@lasttwo@thisrow{z}% %The z is a dummy.
+ \def\qr@lasttwo@nextrow{z}% %The z is a dummy.
+ \def\qr@lastnine{z0000}% %The 0000 stands for the white space to the left. The z is a dummy.
+ \def\qr@ignore@finderB@at{0}%
\qr@for \j=1 to \qr@size by 1%
- {\edef\newbit{\qr@matrixentry{#1}{\the\i}{\the\j}}%
+ {\edef\qr@newbit{\qr@matrixentry{#1}{\the\i}{\the\j}}%
%
% LASTFIVE CODE FOR PENALTY 1
% First, add the new bit to the end.
- \xa\g@addto@macro\xa\lastfive\xa{\newbit}%
+ \xa\g@addto@macro\xa\qr@lastfive\xa{\qr@newbit}%
\ifnum\j<5\relax%
%Not yet on the 5th entry.
%Don't do any testing.
\else
% 5th entry or later.
% Remove the old one, and then test.
- \removefirsttoken\lastfive%
- \ifx\lastfive\@fiveones%
- \ifstringoffive%
+ \qr@removefirsttoken\qr@lastfive%
+ \ifx\qr@lastfive\qr@fiveones%
+ \ifqr@stringoffive%
%This is a continuation of a previous block of five or more 1's.
\stepcounter{penaltyi}%
\else
%This is a new string of five 1's.
\addtocounter{penaltyi}{\qr@Ni}%
- \global\stringoffivetrue
+ \global\qr@stringoffivetrue
\fi
\else
- \ifx\lastfive\@fivezeros%
- \ifstringoffive
+ \ifx\qr@lastfive\qr@fivezeros%
+ \ifqr@stringoffive
%This is a continuation of a previous block of five or more 0's.
\stepcounter{penaltyi}%
\else
%This is a new string of five 0's.
\addtocounter{penaltyi}{\qr@Ni}%
- \global\stringoffivetrue
+ \global\qr@stringoffivetrue
\fi
\else
%This is not a string of five 1's or five 0's.
- \global\stringoffivefalse
+ \global\qr@stringoffivefalse
\fi
\fi
\fi
@@ -1222,27 +1233,27 @@
% Every 2x2 block of all 1's counts for \qr@Nii penalty points.
% We do not need to run this test in the last row.
\xa\ifnum\xa\i\xa<\qr@size\relax
- \xa\g@addto@macro\xa\lasttwo@thisrow\xa{\newbit}%
- %Compute \iplusone
+ \xa\g@addto@macro\xa\qr@lasttwo@thisrow\xa{\qr@newbit}%
+ %Compute \qr@iplusone
\qr@a=\i\relax%
\advance\qr@a by 1%
- \edef\iplusone{\the\qr@a}%
+ \edef\qr@iplusone{\the\qr@a}%
%
- \edef\nextrowbit{\qr@matrixentry{#1}{\iplusone}{\the\j}}%
- \xa\g@addto@macro\xa\lasttwo@nextrow\xa{\nextrowbit}%
+ \edef\qr@nextrowbit{\qr@matrixentry{#1}{\qr@iplusone}{\the\j}}%
+ \xa\g@addto@macro\xa\qr@lasttwo@nextrow\xa{\qr@nextrowbit}%
\ifnum\j<2\relax%
%Still in the first column; no check.
\else
%Second column or later. Remove the old bits, and then test.
- \removefirsttoken\lasttwo@thisrow
- \removefirsttoken\lasttwo@nextrow
- \ifx\lasttwo@thisrow\@twoones
- \ifx\lasttwo@nextrow\@twoones
+ \qr@removefirsttoken\qr@lasttwo@thisrow
+ \qr@removefirsttoken\qr@lasttwo@nextrow
+ \ifx\qr@lasttwo@thisrow\qr@twoones
+ \ifx\qr@lasttwo@nextrow\qr@twoones
\addtocounter{penaltyii}{\qr@Nii}%
\fi
\else
- \ifx\lasttwo@thisrow\@twozeros
- \ifx\lasttwo@nextrow\@twozeros
+ \ifx\qr@lasttwo@thisrow\qr@twozeros
+ \ifx\qr@lasttwo@nextrow\qr@twozeros
\addtocounter{penaltyii}{\qr@Nii}%
\fi
\fi
@@ -1252,59 +1263,59 @@
%
% LASTNINE CODE FOR PENALTY 3
% First, add the new bit to the end.
- \xa\g@addto@macro\xa\lastnine\xa{\newbit}%
+ \xa\g@addto@macro\xa\qr@lastnine\xa{\qr@newbit}%
\ifnum\j<7\relax%
%Not yet on the 7th entry.
%Don't do any testing.
\else
% 7th entry or later.
% Remove the old one, and then test.
- \removefirsttoken\lastnine
+ \qr@removefirsttoken\qr@lastnine
\xa\ifnum\qr@size=\j\relax%
% Last column. Any of the following should count:
- % 1011101 (\@finderB@zero)
- % 10111010 (\@finderB@one)
- % 101110100 (\@finderB@two)
- % 1011101000 (\@finderB@three)
- % 10111010000 (\@finderB)
- \ifx\lastnine\@finderB
- \addpenaltyiii
+ % 1011101 (\qr@finderB@zero)
+ % 10111010 (\qr@finderB@one)
+ % 101110100 (\qr@finderB@two)
+ % 1011101000 (\qr@finderB@three)
+ % 10111010000 (\qr@finderB)
+ \ifx\qr@lastnine\qr@finderB
+ \qr@addpenaltyiii
\else
- \removefirsttoken\lastnine
- \ifx\lastnine\@finderB@three
- \addpenaltyiii
+ \qr@removefirsttoken\qr@lastnine
+ \ifx\qr@lastnine\qr@finderB@three
+ \qr@addpenaltyiii
\else
- \removefirsttoken\lastnine
- \ifx\lastnine\@finderB@two
- \addpenaltyiii
+ \qr@removefirsttoken\qr@lastnine
+ \ifx\qr@lastnine\qr@finderB@two
+ \qr@addpenaltyiii
\else
- \removefirsttoken\lastnine
- \ifx\lastnine\@finderB@one
- \addpenaltyiii
+ \qr@removefirsttoken\qr@lastnine
+ \ifx\qr@lastnine\qr@finderB@one
+ \qr@addpenaltyiii
\else
- \removefirsttoken\lastnine
- \ifx\lastnine\@finderB@zero
- \addpenaltyiii
+ \qr@removefirsttoken\qr@lastnine
+ \ifx\qr@lastnine\qr@finderB@zero
+ \qr@addpenaltyiii
\fi
\fi
\fi
\fi
\fi
\else
- \ifx\lastnine\@finderA% %Matches 0000 1011101
- \addpenaltyiii
+ \ifx\qr@lastnine\qr@finderA% %Matches 0000 1011101
+ \qr@addpenaltyiii
%Also, we record our discovery, so that we can't count this pattern again
%if it shows up four columns later as 1011101 0000.
%
- %Set \ignore@finderB@at to \j+4.
+ %Set \qr@ignore@finderB@at to \j+4.
\qr@a=\j\relax%
\advance\qr@a by 4%
- \xdef\ignore@finderB@at{\the\qr@a}%
+ \xdef\qr@ignore@finderB@at{\the\qr@a}%
\else
- \ifx\lastfive\@finderB% %Matches 1011101 0000.
- \xa\ifnum\ignore@finderB@at=\j\relax
+ \ifx\qr@lastfive\qr@finderB% %Matches 1011101 0000.
+ \xa\ifnum\qr@ignore@finderB@at=\j\relax
%This pattern was *not* counted already earlier.
- \addpenaltyiii
+ \qr@addpenaltyiii
\fi
\fi
\fi
@@ -1312,7 +1323,7 @@
\fi
%
%COUNT 1's FOR PENALTY 4
- \xa\ifnum\newbit=1\relax%
+ \xa\ifnum\qr@newbit=1\relax%
\stepcounter{totalones}%
\fi
}% end of j-loop
@@ -1320,45 +1331,45 @@
%
%NOW WE ALSO NEED TO RUN DOWN THE COLUMNS TO FINISH CALCULATING PENALTIES 1 AND 3.
\qr@for \j=1 to \qr@size by 1%
- {\def\lastfive{z}% %The z is a dummy, that will be removed before any testing.
- \stringoffivefalse
- \def\lastnine{z0000}% %The 0000 stands for the white space to the left. The z is a dummy.
- \def\ignore@finderB@at{0}%
+ {\def\qr@lastfive{z}% %The z is a dummy, that will be removed before any testing.
+ \qr@stringoffivefalse
+ \def\qr@lastnine{z0000}% %The 0000 stands for the white space to the left. The z is a dummy.
+ \def\qr@ignore@finderB@at{0}%
\qr@for \i=1 to \qr@size by 1%
- {\edef\newbit{\qr@matrixentry{#1}{\the\i}{\the\j}}%
+ {\edef\qr@newbit{\qr@matrixentry{#1}{\the\i}{\the\j}}%
%
% LASTFIVE CODE FOR PENALTY 1
% First, add the new bit to the end.
- \xa\g@addto@macro\xa\lastfive\xa{\newbit}%
+ \xa\g@addto@macro\xa\qr@lastfive\xa{\qr@newbit}%
\ifnum\i<5\relax%
%Not yet on the 5th entry.
%Don't do any testing.
\else
% 5th entry or later.
% Remove the old one, and then test.
- \removefirsttoken\lastfive%
- \ifx\lastfive\@fiveones%
- \ifstringoffive%
+ \qr@removefirsttoken\qr@lastfive%
+ \ifx\qr@lastfive\qr@fiveones%
+ \ifqr@stringoffive%
%This is a continuation of a previous block of five or more 1's.
\stepcounter{penaltyi}%
\else
%This is a new string of five 1's.
\addtocounter{penaltyi}{\qr@Ni}%
- \global\stringoffivetrue
+ \global\qr@stringoffivetrue
\fi
\else
- \ifx\lastfive\@fivezeros%
- \ifstringoffive
+ \ifx\qr@lastfive\qr@fivezeros%
+ \ifqr@stringoffive
%This is a continuation of a previous block of five or more 0's.
\stepcounter{penaltyi}%
\else
%This is a new string of five 0's.
\addtocounter{penaltyi}{\qr@Ni}%
- \global\stringoffivetrue
+ \global\qr@stringoffivetrue
\fi
\else
%This is not a string of five 1's or five 0's.
- \global\stringoffivefalse
+ \global\qr@stringoffivefalse
\fi
\fi
\fi
@@ -1367,59 +1378,59 @@
%
% LASTNINE CODE FOR PENALTY 3
% First, add the new bit to the end.
- \xa\g@addto@macro\xa\lastnine\xa{\newbit}%
+ \xa\g@addto@macro\xa\qr@lastnine\xa{\qr@newbit}%
\ifnum\i<7\relax%
%Not yet on the 7th entry.
%Don't do any testing.
\else
% 7th entry or later.
% Remove the old one, and then test.
- \removefirsttoken\lastnine
+ \qr@removefirsttoken\qr@lastnine
\xa\ifnum\qr@size=\i\relax%
% Last column. Any of the following should count:
- % 1011101 (\@finderB@zero)
- % 10111010 (\@finderB@one)
- % 101110100 (\@finderB@two)
- % 1011101000 (\@finderB@three)
- % 10111010000 (\@finderB)
- \ifx\lastnine\@finderB
- \addpenaltyiii
+ % 1011101 (\qr@finderB@zero)
+ % 10111010 (\qr@finderB@one)
+ % 101110100 (\qr@finderB@two)
+ % 1011101000 (\qr@finderB@three)
+ % 10111010000 (\qr@finderB)
+ \ifx\qr@lastnine\qr@finderB
+ \qr@addpenaltyiii
\else
- \removefirsttoken\lastnine
- \ifx\lastnine\@finderB@three
- \addpenaltyiii
+ \qr@removefirsttoken\qr@lastnine
+ \ifx\qr@lastnine\qr@finderB@three
+ \qr@addpenaltyiii
\else
- \removefirsttoken\lastnine
- \ifx\lastnine\@finderB@two
- \addpenaltyiii
+ \qr@removefirsttoken\qr@lastnine
+ \ifx\qr@lastnine\qr@finderB@two
+ \qr@addpenaltyiii
\else
- \removefirsttoken\lastnine
- \ifx\lastnine\@finderB@one
- \addpenaltyiii
+ \qr@removefirsttoken\qr@lastnine
+ \ifx\qr@lastnine\qr@finderB@one
+ \qr@addpenaltyiii
\else
- \removefirsttoken\lastnine
- \ifx\lastnine\@finderB@zero
- \addpenaltyiii
+ \qr@removefirsttoken\qr@lastnine
+ \ifx\qr@lastnine\qr@finderB@zero
+ \qr@addpenaltyiii
\fi
\fi
\fi
\fi
\fi
\else
- \ifx\lastnine\@finderA% %Matches 0000 1011101
- \addpenaltyiii
+ \ifx\qr@lastnine\qr@finderA% %Matches 0000 1011101
+ \qr@addpenaltyiii
%Also, we record our discovery, so that we can't count this pattern again
%if it shows up four columns later as 1011101 0000.
%
- %Set \ignore@finderB@at to \i+4.
+ %Set \qr@ignore@finderB@at to \i+4.
\qr@a=\i\relax%
\advance\qr@a by 4%
- \xdef\ignore@finderB@at{\the\qr@a}%
+ \xdef\qr@ignore@finderB@at{\the\qr@a}%
\else
- \ifx\lastfive\@finderB% %Matches 1011101 0000.
- \xa\ifnum\ignore@finderB@at=\i\relax
+ \ifx\qr@lastfive\qr@finderB% %Matches 1011101 0000.
+ \xa\ifnum\qr@ignore@finderB@at=\i\relax
%This pattern was *not* counted already earlier.
- \addpenaltyiii
+ \qr@addpenaltyiii
\fi
\fi
\fi
@@ -1457,14 +1468,14 @@
\edef\qr@penalty{\the\qr@a}%
}%
-\def\removefirsttoken#1{%
+\def\qr@removefirsttoken#1{%
%Removes the first token from the macro named in #1.
\edef\qr@argument{(#1)}%
- \xa\removefirsttoken@int\qr@argument%
- \xdef#1{\removefirsttoken@result}%
+ \xa\qr@removefirsttoken@int\qr@argument%
+ \xdef#1{\qr@removefirsttoken@result}%
}%
-\def\removefirsttoken@int(#1#2){%
- \def\removefirsttoken@result{#2}%
+\def\qr@removefirsttoken@int(#1#2){%
+ \def\qr@removefirsttoken@result{#2}%
}%
\def\qr@writeformatstring#1#2{%
@@ -1485,7 +1496,6 @@
% #2 = first bit of string
% #3 = rest of bitstream
% (qr@i,qr@j) = current (valid) position to write (in LaTeX counters)
- \def\formattowrite{#3}%
\ifnum#2=1\relax
\qr@storetomatrix{#1}{\theqr@i}{\theqr@j}{\qr@black@format}%
\else
@@ -1510,11 +1520,11 @@
%N.B. that at the end of time, this will leave us at invalid position (0,9).
%That makes for an easy test to know when we are done.
\ifnum\c@qr@i<1
- \let\nexttoken=\relax
+ \let\qr@next=\relax
\else
- \def\nexttoken{\qr@writeformatA@recursive{#1}(#3)}%
+ \def\qr@next{\qr@writeformatA@recursive{#1}(#3)}%
\fi
- \nexttoken
+ \qr@next
}%
\def\qr@writeformatB@recursive#1(#2#3){%
@@ -1522,7 +1532,6 @@
% #2 = first bit of string
% #3 = rest of bitstream
% (qr@i,qr@j) = current (valid) position to write (in LaTeX counters)
- \def\formattowrite{#3}%
\ifnum#2=1\relax
\qr@storetomatrix{#1}{\theqr@i}{\theqr@j}{\qr@black@format}%
\else
@@ -1550,11 +1559,11 @@
%N.B. that at the end of time, this will leave us at invalid position (9,n+1).
%That makes for an easy test to know when we are done.
\xa\ifnum\qr@size<\c@qr@j\relax
- \let\nexttoken=\relax
+ \let\qr@next=\relax
\else
- \def\nexttoken{\qr@writeformatB@recursive{#1}(#3)}%
+ \def\qr@next{\qr@writeformatB@recursive{#1}(#3)}%
\fi
- \nexttoken
+ \qr@next
}%
\def\qr@writeversionstring#1#2{%
@@ -1584,12 +1593,10 @@
% In the comments, we describe what happens in the lower-left region,
% not the upper-right.
%
- \def\versiontowrite{#3}%
- %
- %Set \topline equal to n-10.
+ %Set \qr@topline equal to n-10.
\qr@a=\qr@size\relax%
\advance\qr@a by -10\relax%
- \edef\topline{\the\qr@a}%
+ \edef\qr@topline{\the\qr@a}%
%
\ifnum#2=1\relax
\qr@storetomatrix{#1}{\theqr@i}{\theqr@j}{\qr@black@format}%
@@ -1600,7 +1607,7 @@
\fi
% Now the tricky part--moving counters i and j to their next positions.
\addtocounter{qr@i}{-1}%
- \xa\ifnum\topline>\c@qr@i\relax
+ \xa\ifnum\qr@topline>\c@qr@i\relax
%We've overshot the top of the region.
%We need to move left one column and down three.
\addtocounter{qr@j}{-1}%
@@ -1609,11 +1616,11 @@
%N.B. that at the end of time, this will leave us at invalid position (n-8,0).
%That makes for an easy test to know when we are done.
\ifnum\c@qr@j<1\relax
- \let\nexttoken=\relax
+ \let\qr@next=\relax
\else
- \def\nexttoken{\qr@writeversion@recursive{#1}(#3)}%
+ \def\qr@next{\qr@writeversion@recursive{#1}(#3)}%
\fi
- \nexttoken
+ \qr@next
}%
\newcounter{qr@hexchars}%
@@ -1625,22 +1632,22 @@
% #1 = string of ascii characters, to be converted into bitstream
%
% We do this one entirely in hex, rather than binary, because we can.
- \edef\plaintext{#1}%
+ \edef\qr@plaintext{#1}%
%
%First, the mode indicator.
\def\qr@codetext{4}% %This means `binary'
%
%Next, the character count.
- \qr@getstringlength{\plaintext}%
- %Set \charactercountlengthinhex to \qr@charactercountbits@byte/4%
+ \qr@getstringlength{\qr@plaintext}%
+ %Set \qr@charactercountlengthinhex to \qr@charactercountbits@byte/4%
\qr@a=\qr@charactercountbits@byte\relax%
\divide \qr@a by 4\relax%
- \edef\charactercountlengthinhex{\the\qr@a}%
- \qr@decimaltohex[\charactercountlengthinhex]{\charactercount}{\qr@stringlength}%
- \xa\g@addto@macro\xa\qr@codetext\xa{\charactercount}%
+ \edef\qr@charactercountlengthinhex{\the\qr@a}%
+ \qr@decimaltohex[\qr@charactercountlengthinhex]{\qr@charactercount}{\qr@stringlength}%
+ \xa\g@addto@macro\xa\qr@codetext\xa{\qr@charactercount}%
%
%Now comes the actual data.
- \edef\qr@argument{(,\plaintext\relax\relax\relax)}%
+ \edef\qr@argument{(,\qr@plaintext\relax\relax\relax)}%
\xa\qr@encode@ascii@recursive\qr@argument%
%
%Now the terminator.
@@ -1653,7 +1660,7 @@
\setcounter{qr@hexchars}{0}%
\qr@getstringlength{\qr@codetext}%
\setcounter{qr@hexchars}{\qr@stringlength}%
- %Set \qr@numpaddingcodewords equal to \qr@totaldatacodewords - hexchars/2.
+ %Set \qr@numpaddingcodewords equal to \qr@totaldatacodewords - qr@hexchars/2.
\qr@a=-\c@qr@hexchars\relax
\divide\qr@a by 2\relax
\advance\qr@a by \qr@totaldatacodewords\relax
@@ -1675,15 +1682,15 @@
% #1 = hex codes translated so far
% #2 = next plaintext character to translate
% #3 = remainder of plaintext
- \edef\testii{#2}%
- \ifx\testii\@relax%
+ \edef\qr@testii{#2}%
+ \ifx\qr@testii\qr@relax%
% All done!
\g@addto@macro\qr@codetext{#1}%
\else%
% Another character to translate.
- \edef\asciicode{\number`#2}%
- \qr@decimaltohex[2]{\newhexcodes}{\asciicode}%
- \edef\qr@argument{(#1\newhexcodes,#3)}%
+ \edef\qr@asciicode{\number`#2}%
+ \qr@decimaltohex[2]{\qr@newhexcodes}{\qr@asciicode}%
+ \edef\qr@argument{(#1\qr@newhexcodes,#3)}%
%\show\qr@argument
\xa\qr@encode@ascii@recursive\qr@argument%
\fi%
@@ -1785,11 +1792,11 @@
\let\xa=\expandafter
\makeatletter
-\def\preface@macro#1#2{%
+\def\qr@preface@macro#1#2{%
% #1 = macro name
% #2 = text to add to front of macro
- \def\tempb{#2}%
- \xa\xa\xa\gdef\xa\xa\xa#1\xa\xa\xa{\xa\tempb #1}%
+ \def\qr@tempb{#2}%
+ \xa\xa\xa\gdef\xa\xa\xa#1\xa\xa\xa{\xa\qr@tempb #1}%
}%
\newif\ifqr@leadingcoeff
@@ -1825,16 +1832,16 @@
\ifqr@xorfailed
%If xor failed, that means our #1 was already the remainder!
\qr@divisiondonetrue
- \edef\theremainder{#1}%
+ \edef\qr@theremainder{#1}%
\else
%xor succeeded. We need to recurse.
- \xa\xa\xa\edef\xa\xa\xa\qr@numerator\xa\xa\xa{\xa\qr@stripleadingzero\xa(\xorresult)}%
+ \xa\xa\xa\edef\xa\xa\xa\qr@numerator\xa\xa\xa{\xa\qr@stripleadingzero\xa(\qr@xorresult)}%
\fi
\else
\xa\def\xa\qr@numerator\xa{\qr@stripleadingzero(#1)}%
\ifx\qr@numerator\@qr@empty
\qr@divisiondonetrue
- \def\theremainder{0}%
+ \def\qr@theremainder{0}%
\fi
\fi
\ifqr@divisiondone
@@ -1860,24 +1867,24 @@
\def\qr@xorbitstrings@recursive(#1,#2#3)(#4#5){%
% #1#2#3 is the first bitstring, xor'ed up through #1.
% #4#5 is the remaining portion of the second bitstring.
- \def\testii{#2}%
- \def\testiv{#4}%
- \ifx\testii\@relax
+ \def\qr@testii{#2}%
+ \def\qr@testiv{#4}%
+ \ifx\qr@testii\qr@relax
% #1 contains the whole string.
% Now if #4 is also \relax, that means the two strings started off with equal lengths.
% If, however, #4 is not \relax, that means the second string was longer than the first, a problem.
- \ifx\testiv\@relax
+ \ifx\qr@testiv\qr@relax
%No problem. We are done.
\qr@xorbit@saveresult(#1#2#3)%
\else
%Problem! The second string was longer than the first.
\qr@xorfailedtrue
- \def\xorresult{}%
+ \def\qr@xorresult{}%
\fi
\else
% There is still a bit to manipulate in #2.
% Check whether #4 contains anything.
- \ifx\testiv\@relax
+ \ifx\qr@testiv\qr@relax
% No, #4 is empty. We are done. "#2#3" contains the remainder of the first string,
% which we append untouched and then strip off the two \relax-es.
\qr@xorbit@saveresult(#1#2#3)%
@@ -1896,39 +1903,35 @@
\def\qr@xorbit@saveresult(#1\relax\relax){%
%Strips off the extra '\relax'es at the end.
- \def\xorresult{#1}%
+ \def\qr@xorresult{#1}%
}%
\newif\ifqr@divisiondone
-\def\dodivision#1#2{%
- \qr@divisiondonefalse
- \dodivision@recursive{#1}{#2}%
-}%
-\def\BCHcode#1{%
- \edef\formatinfo{#1}%
- \def\formatinfopadded{\formatinfo 0000000000}%
+\def\qr@BCHcode#1{%
+ \edef\qr@formatinfo{#1}%
+ \def\qr@formatinfopadded{\qr@formatinfo 0000000000}%
\def\qr@divisor{10100110111}%
\qr@divisiondonefalse
- \qr@polynomialdivide{\formatinfopadded}{\qr@divisor}%
+ \qr@polynomialdivide{\qr@formatinfopadded}{\qr@divisor}%
%
- \qr@getstringlength{\theremainder}%
+ \qr@getstringlength{\qr@theremainder}%
%Run loop from stringlength+1 to 10.
\qr@a=\qr@stringlength\relax%
\advance\qr@a by 1\relax%
\qr@for \i = \qr@a to 10 by 1%
- {\preface@macro{\theremainder}{0}%
- \xdef\theremainder{\theremainder}%
+ {\qr@preface@macro{\qr@theremainder}{0}%
+ \xdef\qr@theremainder{\qr@theremainder}%
}%
- \edef\BCHresult{\formatinfo\theremainder}%
+ \edef\qr@BCHresult{\qr@formatinfo\qr@theremainder}%
}%
\def\qr@formatmask{101010000010010}%
\def\qr@encodeandmaskformat#1{%
- \BCHcode{#1}%
- \qr@xorbitstrings{\BCHresult}{\qr@formatmask}%
- \edef\qr@format@bitstring{\xorresult}%
+ \qr@BCHcode{#1}%
+ \qr@xorbitstrings{\qr@BCHresult}{\qr@formatmask}%
+ \edef\qr@format@bitstring{\qr@xorresult}%
}%
\def\qr@Golaycode#1{%
@@ -1939,15 +1942,15 @@
\qr@divisiondonefalse
\qr@polynomialdivide{\qr@versioninfopadded}{\qr@divisor}%
%
- \qr@getstringlength{\theremainder}%
+ \qr@getstringlength{\qr@theremainder}%
%Run loop from stringlength+1 to 12.
\qr@a=\qr@stringlength\relax%
\advance\qr@a by 1\relax%
\qr@for \i = \qr@a to 12 by 1%
- {\preface@macro{\theremainder}{0}%
- \xdef\theremainder{\theremainder}%
+ {\qr@preface@macro{\qr@theremainder}{0}%
+ \xdef\qr@theremainder{\qr@theremainder}%
}%
- \edef\Golayresult{\qr@versioninfo\theremainder}%
+ \edef\qr@Golayresult{\qr@versioninfo\qr@theremainder}%
}%
\def\F@result{}%
@@ -1960,8 +1963,8 @@
\edef#1{\qr@xor@result}%
}%
\def\qr@xorbitstring@recursive(#1#2)(#3#4){%
- \edef\testi{#1}%
- \ifx\testi\@relax%
+ \edef\qr@testi{#1}%
+ \ifx\qr@testi\qr@relax%
%Done.
\let\qr@next=\relax%
\else
@@ -1977,38 +1980,38 @@
\def\F@addchar@raw#1#2{%
%Add two hexadecimal digits using bitwise xor
- \qr@hextobinary[4]{\summandA}{#1}%
- \qr@hextobinary[4]{\summandB}{#2}%
- \qr@xorbitstring{\F@result}{\summandA}{\summandB}%
+ \qr@hextobinary[4]{\qr@summandA}{#1}%
+ \qr@hextobinary[4]{\qr@summandB}{#2}%
+ \qr@xorbitstring{\F@result}{\qr@summandA}{\qr@summandB}%
\qr@binarytohex[1]{\F@result}{\F@result}%
}%
-\def\canceltwos#1{%
+\def\qr@canceltwos#1{%
\edef\qr@argument{(#1\relax\relax)}%
- \xa\canceltwos@int\qr@argument%
+ \xa\qr@canceltwos@int\qr@argument%
}%
-\def\canceltwos@int(#1#2){%
- \xa\canceltwos@recursion(,#1#2)%
+\def\qr@canceltwos@int(#1#2){%
+ \xa\qr@canceltwos@recursion(,#1#2)%
}%
-\def\canceltwos@recursion(#1,#2#3){%
- \def\testii{#2}%
- \ifx\testii\@relax
+\def\qr@canceltwos@recursion(#1,#2#3){%
+ \def\qr@testii{#2}%
+ \ifx\qr@testii\qr@relax
%Cancelling complete.
- \striptworelaxes(#1#2#3)%
+ \qr@striptworelaxes(#1#2#3)%
%Now \F@result contains the answer.
\else
\relax
\ifnum#2=2\relax
- \canceltwos@recursion(#10,#3)%
+ \qr@canceltwos@recursion(#10,#3)%
\else
- \canceltwos@recursion(#1#2,#3)%
+ \qr@canceltwos@recursion(#1#2,#3)%
\fi
\fi
}%
-\def\striptworelaxes(#1\relax\relax){%
+\def\qr@striptworelaxes(#1\relax\relax){%
\gdef\F@result{#1}%
}%
@@ -2033,15 +2036,15 @@
\def\F@addstrings@recursion(#1,#2#3)(#4#5){%
%Adds two hexadecimal strings, bitwise, from left to right.
%The second string is allowed to be shorter than the first.
- \def\testii{#2}%
- \def\testiv{#4}%
- \ifx\testii\@relax
+ \def\qr@testii{#2}%
+ \def\qr@testiv{#4}%
+ \ifx\qr@testii\qr@relax
%The entire string has been processed.
\gdef\F@result{#1}%
\else
- \ifx\testiv\@relax
+ \ifx\qr@testiv\qr@relax
%The second string is over.
- \striptworelaxes(#1#2#3)%
+ \qr@striptworelaxes(#1#2#3)%
%Now \F@result contains the answer.
\else
%We continue to add.
@@ -2054,24 +2057,24 @@
\gdef\F@stripleadingzero(0#1){\edef\F@result{#1}}%
\setcounter{qr@i}{0}%
-\def\poweroftwo{1}%
+\def\qr@poweroftwo{1}%
\qr@for \i = 1 to 254 by 1%
{\stepcounter{qr@i}%
- \qr@a=\poweroftwo\relax
+ \qr@a=\qr@poweroftwo\relax
\multiply\qr@a by 2\relax
- \edef\poweroftwo{\the\qr@a}%
- %\show\poweroftwo
- \qr@decimaltohex[2]{\poweroftwo@hex}{\poweroftwo}%
- \xa\ifnum\poweroftwo>255\relax
+ \edef\qr@poweroftwo{\the\qr@a}%
+ %\show\qr@poweroftwo
+ \qr@decimaltohex[2]{\qr@poweroftwo@hex}{\qr@poweroftwo}%
+ \xa\ifnum\qr@poweroftwo>255\relax
%We need to bitwise add the polynomial represented by 100011101, i.e. 0x11d.
- \F@addstrings{\poweroftwo@hex}{11d}% %Now it should start with 0.
+ \F@addstrings{\qr@poweroftwo@hex}{11d}% %Now it should start with 0.
\xa\F@stripleadingzero\xa(\F@result)% %Now it should be two hex digits.
- \edef\poweroftwo@hex{\F@result}% %Save the hex version.
- \qr@hextodecimal{\poweroftwo}{\F@result}%
+ \edef\qr@poweroftwo@hex{\F@result}% %Save the hex version.
+ \qr@hextodecimal{\qr@poweroftwo}{\F@result}%
\fi
- \xdef\poweroftwo{\poweroftwo}%
- \xa\xdef\csname F@twotothe@\theqr@i\endcsname{\poweroftwo@hex}%
- \xa\xdef\csname F@logtwo@\poweroftwo@hex\endcsname{\theqr@i}%
+ \xdef\qr@poweroftwo{\qr@poweroftwo}%
+ \xa\xdef\csname F@twotothe@\theqr@i\endcsname{\qr@poweroftwo@hex}%
+ \xa\xdef\csname F@logtwo@\qr@poweroftwo@hex\endcsname{\theqr@i}%
}%
\xa\xdef\csname F@twotothe@0\endcsname{01}%
\xa\xdef\csname F@logtwo@01\endcsname{0}%
@@ -2083,26 +2086,26 @@
\xa\xdef\xa\F@result\xa{\csname F@logtwo@#1\endcsname}%
}%
-\def\@zerozero{00}%
+\def\qr@zerozero{00}%
\def\F@multiply#1#2{%
% #1 and #2 are two elements of F_256,
% given as two-character hexadecimal strings.
% Multiply them within F_256, and place the answer in \F@result
- \edef\argA{#1}%
- \edef\argB{#2}%
- \ifx\argA\@zerozero
+ \edef\qr@argA{#1}%
+ \edef\qr@argB{#2}%
+ \ifx\qr@argA\qr@zerozero
\def\F@result{00}%
\else
- \ifx\argB\@zerozero
+ \ifx\qr@argB\qr@zerozero
\def\F@result{00}%
\else
- \xa\F@logtwo\xa{\argA}%
- \edef\logA{\F@result}%
- \xa\F@logtwo\xa{\argB}%
- \edef\logB{\F@result}%
- \xa\qr@a\xa=\logA\relax% \qr@a = \logA
- \xa\advance\xa\qr@a\logB\relax% \advance \qr@a by \logB
+ \xa\F@logtwo\xa{\qr@argA}%
+ \edef\qr@logA{\F@result}%
+ \xa\F@logtwo\xa{\qr@argB}%
+ \edef\qr@logB{\F@result}%
+ \xa\qr@a\xa=\qr@logA\relax% \qr@a = \qr@logA
+ \xa\advance\xa\qr@a\qr@logB\relax% \advance \qr@a by \qr@logB
\ifnum\qr@a>254\relax%
\advance\qr@a by -255\relax%
\fi%
@@ -2116,20 +2119,20 @@
% #1 and #2 are two elements of F_256,
% given as two-character hexadecimal strings.
% Multiply them within F_256, and place the answer in \F@result
- \edef\argA{#1}%
- \edef\argB{#2}%
- \ifx\argA\@zerozero
+ \edef\qr@argA{#1}%
+ \edef\qr@argB{#2}%
+ \ifx\qr@argA\qr@zerozero
\def\F@result{00}%
\else
- \ifx\argB\@zerozero
+ \ifx\qr@argB\qr@zerozero
\def\F@result{00}%
\else
- \xa\F@logtwo\xa{\argA}%
- \edef\logA{\F@result}%
- \xa\F@logtwo\xa{\argB}%
- \edef\logB{\F@result}%
- \xa\qr@a\xa=\logA\relax% \qr@a = \logA
- \xa\advance\xa\qr@a\logB\relax% \advance \qr@a by \logB
+ \xa\F@logtwo\xa{\qr@argA}%
+ \edef\qr@logA{\F@result}%
+ \xa\F@logtwo\xa{\qr@argB}%
+ \edef\qr@logB{\F@result}%
+ \xa\qr@a\xa=\qr@logA\relax% \qr@a = \qr@logA
+ \xa\advance\xa\qr@a\qr@logB\relax% \advance \qr@a by \qr@logB
\ifnum\qr@a>254\relax%
\advance\qr@a by -255\relax%
\fi%
@@ -2148,8 +2151,8 @@
}%
\def\FX@stringlength@recursive(#1#2#3){%
- \def\testi{#1}%
- \ifx\testi\@relax
+ \def\qr@testi{#1}%
+ \ifx\qr@testi\qr@relax
%we are done.
\else
\stepcounter{qr@i}%
@@ -2163,7 +2166,7 @@
% Tests whether the leading coefficient of the hex-string #1#2#3 is '00'.
\edef\FX@leadingcoefficient{#1#2}%
\FX@leadingcoeff@zerofalse
- \ifx\FX@leadingcoefficient\@zerozero
+ \ifx\FX@leadingcoefficient\qr@zerozero
\FX@leadingcoeff@zerotrue
\fi
}%
@@ -2173,15 +2176,15 @@
\newcounter{qr@divisionsremaining} %Keep track of how many divisions to go!
\def\FX@polynomialdivide#1#2{%
\edef\FX@numerator{#1}%
- \edef\denominator{#2}%
+ \edef\FX@denominator{#2}%
\qr@getstringlength\FX@numerator%
\setcounter{qr@divisionsremaining}{\qr@stringlength}%
- \qr@getstringlength\denominator%
+ \qr@getstringlength\FX@denominator%
\addtocounter{qr@divisionsremaining}{-\qr@stringlength}%
\addtocounter{qr@divisionsremaining}{2}%
\divide\c@qr@divisionsremaining by 2\relax% %2 hex chars per number
\FX@divisiondonefalse%
- \xa\xa\xa\FX@polynomialdivide@recursive\xa\xa\xa{\xa\FX@numerator\xa}\xa{\denominator}%
+ \xa\xa\xa\FX@polynomialdivide@recursive\xa\xa\xa{\xa\FX@numerator\xa}\xa{\FX@denominator}%
}%
\def\FX@polynomialdivide@recursive#1#2{%
@@ -2204,7 +2207,7 @@
\ifFX@subtract@failed%
%If subtraction failed, that means our #1 was already the remainder!
\FX@divisiondonetrue%
- \edef\theremainder{#1}%
+ \edef\qr@theremainder{#1}%
\else%
%xor succeeded. We need to recurse.
\xa\xa\xa\edef\xa\xa\xa\FX@numerator\xa\xa\xa{\xa\FX@stripleadingzero\xa(\FX@subtraction@result)}%
@@ -2214,7 +2217,7 @@
\ifnum\c@qr@divisionsremaining=0\relax
%Division is done!
\FX@divisiondonetrue%
- \edef\theremainder{\FX@numerator}%
+ \edef\qr@theremainder{\FX@numerator}%
\relax%
\else%
\xa\FX@polynomialdivide@recursive\xa{\FX@numerator}{#2}%
@@ -2241,13 +2244,13 @@
% #5#6#7 is the remaining portion of the second bitstring.
% Thus #5#6 constitutes the next two-character coefficient
% #8 is the element a of F_256. It should contain two characters.
- \def\testii{#2}%
- \def\testv{#5}%
- \ifx\testii\@relax
+ \def\qr@testii{#2}%
+ \def\qr@testv{#5}%
+ \ifx\qr@testii\qr@relax
% #1 contains the whole string.
% Now if #5 is also \relax, that means the two strings started off with equal lengths.
% If, however, #5 is not \relax, that means the second string was longer than the first, a problem.
- \ifx\testv\@relax
+ \ifx\qr@testv\qr@relax
%No problem. We are done.
\FX@subtract@saveresult(#1#2#3#4)% %We keep the #2#3#4 to be sure we have all three relax-es to strip off.
\else
@@ -2259,7 +2262,7 @@
\else
% There is still a coefficient to manipulate in #2#3.
% Check whether #5 contains anything.
- \ifx\testv\@relax
+ \ifx\qr@testv\qr@relax
% No, #5 is empty. We are done. "#2#3#4" contains the remainder of the first string,
% which we append untouched and then strip off the three \relax-es.
\FX@subtract@saveresult(#1#2#3#4)%
@@ -2296,12 +2299,12 @@
% (If i=0, then \FX@generatorpolynomial should be 01.)
% This recursion step should multiply the existing polynomial by (x-2^i),
% increment i by 1, and check whether we're done or not.
- \edef\summandA{\FX@generatorpolynomial 00}% This is f(x) * x
- \edef\summandB{00\FX@generatorpolynomial}% This is f(x), with a 0x^{i+1} in front.
+ \edef\qr@summandA{\FX@generatorpolynomial 00}% This is f(x) * x
+ \edef\qr@summandB{00\FX@generatorpolynomial}% This is f(x), with a 0x^{i+1} in front.
\F@twotothe{\theqr@i}%
- \edef\theconstant{\F@result}%
- \FX@subtractphase{\summandA}{\summandB}{\theconstant}%
- %This calculates \summandA + \theconstant * \summandB
+ \edef\qr@theconstant{\F@result}%
+ \FX@subtractphase{\qr@summandA}{\qr@summandB}{\qr@theconstant}%
+ %This calculates \qr@summandA + \qr@theconstant * \qr@summandB
%and stores the result in \FX@subtraction@result
\edef\FX@generatorpolynomial{\FX@subtraction@result}%
\stepcounter{qr@i}%
@@ -2318,13 +2321,13 @@
\def\FX@generate@errorbytes#1#2{%
% #1 = datastream in hex
% #2 = number of error correction bytes requested
- \edef\numerrorbytes{#2}%
- \xa\FX@creategeneratorpolynomial\xa{\numerrorbytes}%
+ \edef\qr@numerrorbytes{#2}%
+ \xa\FX@creategeneratorpolynomial\xa{\qr@numerrorbytes}%
\edef\FX@numerator{#1}%
- \qr@for \i = 1 to \numerrorbytes by 1%
+ \qr@for \i = 1 to \qr@numerrorbytes by 1%
{\g@addto@macro\FX@numerator{00}}% %One error byte means two hex codes.
\FX@polynomialdivide{\FX@numerator}{\FX@generatorpolynomial}%
- \edef\FX@errorbytes{\theremainder}%
+ \edef\FX@errorbytes{\qr@theremainder}%
}%
\newif\ifqr@versionmodules
@@ -2501,7 +2504,7 @@
% 3 = 11 = Q
% This macro calculates and sets a variety of global macros and/or counters
% storing version information that is used later in construction the QR code.
- % Thus \setversion should be called every time!
+ % Thus \qr@setversion should be called every time!
%
\edef\qr@version{#1}%
\edef\qr@level{#2}%
@@ -2583,7 +2586,7 @@
\def\qr@settableix{%
\xa\ifcase\qr@level\relax
%00: Level 'M', medium error correction
- \edef\tempdata{(%
+ \edef\qr@tempdata{(%
\ifcase\qr@version\relax
\relax %There is no version 0.
\or1,10%
@@ -2629,7 +2632,7 @@
\fi)}%
\or
%01: Level 'L', low error correction
- \edef\tempdata{%
+ \edef\qr@tempdata{%
(\ifcase\qr@version\relax
\relax %There is no version 0.
\or 1,7%
@@ -2675,7 +2678,7 @@
\fi)}%
\or
%10: Level 'H', high error correction
- \edef\tempdata{(%
+ \edef\qr@tempdata{(%
\ifcase\qr@version\relax
\relax %There is no version 0.
\or1,17%
@@ -2721,7 +2724,7 @@
\fi)}%
\or
%11: Level 'Q', quality error correction
- \edef\tempdata{(%
+ \edef\qr@tempdata{(%
\ifcase\qr@version\relax
\relax %There is no version 0.
\or1,13%
@@ -2766,12 +2769,12 @@
\or68,30%
\fi)}%
\fi
-\xa\qr@settableix@int\tempdata
+\xa\qr@settableix@int\qr@tempdata
}%
\define@key{qr}{version}{\edef\qr@desiredversion{#1}}%
\define@key{qr}{level}{\qr@setlevel{#1}}%
\define@key{qr}{height}{\qr@setheight{#1}}%
-\define@boolkey{qr}[qr@]{tight}[true]{}% %This creates \ifqr@tight and initializes it to false.
+\define@boolkey{qr}[qr@]{tight}[true]{}% %This creates \ifqr@tight and initializes it to true.
\define@boolkey{qr}[qr@]{padding}[true]{\ifqr@padding\qr@tightfalse\else\qr@tighttrue\fi}% %Define 'padding' as antonym to 'tight'
\def\@qr@M{M}\def\@qr@z{0}%
@@ -2815,12 +2818,29 @@
}
\qrset{version=0, level=0, tight}
-\newcommand\qrcode[1][]{%
+\newif\ifqr@starinvoked%
+\def\qrcode{\@ifstar\qrcode@star\qrcode@nostar}%
+\def\qrcode@star{\qr@starinvokedtrue\qrcode@i}%
+\def\qrcode@nostar{\qr@starinvokedfalse\qrcode@i}%
+
+\newcommand\qrcode@i[1][]{%
\begingroup%
+ \ifqr@starinvoked%
+ \qr@hyperlinkfalse%
+ \fi%
\setkeys{qr}{#1}%
- \bgroup\qr@verbatimcatcodes\qr@setescapedspecials\qrcode@i}%
+ \bgroup\qr@verbatimcatcodes\qr@setescapedspecials\qrcode@in}%
+
+\def\qrcode@in#1{\xdef\qr@texttoencode{#1}\egroup\qrcode@int\endgroup}%
-\def\qrcode@i#1{\xdef\qr@texttoencode{#1}\egroup\qrcode@int\endgroup}%
+\def\qrcode@hyperwrapper@hyperref{\href{\qr@texttoencode}}%
+\def\qrcode@hyperwrapper@nohyperref{\relax}%
+
+\AtBeginDocument{%
+ \@ifpackageloaded{hyperref}%
+ {\global\let\qrcode@hyperwrapper=\qrcode@hyperwrapper@hyperref}%
+ {\global\let\qrcode@hyperwrapper=\qrcode@hyperwrapper@nohyperref}%
+}%
\def\qrcode@int{%
\message{^^J^^J<QR code requested for "\qr@texttoencode" in version
@@ -2830,21 +2850,29 @@
\xa\qr@choose@best@version\xa{\qr@texttoencode}%
\qr@setversion{\qr@version}{\qr@level}%
%
+ \ifqr@hyperlink%
+ \let\qrcode@wrapper=\qrcode@hyperwrapper%
+ \else%
+ \let\qrcode@wrapper=\relax%
+ \fi%
+ %
%Next, check whether we have already encoded this text at this version
%and level.
- \xa\ifx\csname qr@savedbinarymatrix@\qr@texttoencode @\qr@version @\qr@level\endcsname
- \relax%
- %This text has not yet been encoded.
- \qrcode@int@new%
- \else
- %This text has already been encoded!
- \ifqr@forget@mode
- %In 'forget' mode, we deliberately recalculate anyway.
+ \qrcode@wrapper{%
+ \xa\ifx\csname qr@savedbinarymatrix@\qr@texttoencode @\qr@version @\qr@level\endcsname
+ \relax%
+ %This text has not yet been encoded.
\qrcode@int@new%
\else
- \qrcode@int@remember%
- \fi
- \fi%
+ %This text has already been encoded!
+ \ifqr@forget@mode
+ %In 'forget' mode, we deliberately recalculate anyway.
+ \qrcode@int@new%
+ \else
+ \qrcode@int@remember%
+ \fi
+ \fi%
+ }%
}%
\def\qrcode@int@new{%
@@ -2859,7 +2887,7 @@
version \qr@version-\qr@level@char{\qr@level}.>^^J}%
\relax% Draft mode---don't load any data or do any work. Also don't save!
\def\qr@format@square{\qr@black}%
- \def\@blank{\@white}%
+ \def\qr@blank{\qr@white}%
\fboxsep=-\fboxrule%
\fbox{\qr@printmatrix{newqr}}%
\else
@@ -2874,17 +2902,17 @@
\message{done.>^^J}%
\qr@writeremainderbits{newqr}%
\qr@chooseandapplybestmask{newqr}%
- \qr@decimaltobinary[2]{\level@binary}{\qr@level}%
- \qr@decimaltobinary[3]{\mask@binary}{\qr@mask@selected}%
- \edef\formatstring{\level@binary\mask@binary}%
+ \qr@decimaltobinary[2]{\qr@level@binary}{\qr@level}%
+ \qr@decimaltobinary[3]{\qr@mask@binary}{\qr@mask@selected}%
+ \edef\qr@formatstring{\qr@level@binary\qr@mask@binary}%
\message{<Encoding and writing format string...}%
- \xa\qr@encodeandmaskformat\xa{\formatstring}%
+ \xa\qr@encodeandmaskformat\xa{\qr@formatstring}%
\qr@writeformatstring{newqr}{\qr@format@bitstring}%
\message{done.>^^J}%
\message{<Encoding and writing version information...}%
- \qr@decimaltobinary[6]{\version@binary}{\qr@version}%
- \qr@Golaycode{\version@binary}%
- \qr@writeversionstring{newqr}{\Golayresult}%
+ \qr@decimaltobinary[6]{\qr@version@binary}{\qr@version}%
+ \qr@Golaycode{\qr@version@binary}%
+ \qr@writeversionstring{newqr}{\qr@Golayresult}%
\message{done.>^^J}%
\message{<Saving QR code to memory...}%
\qr@matrixtobinary{newqr}%
@@ -2927,8 +2955,8 @@
\def\qr@binarymatrix@result{}%
\bgroup
\def\qr@black{1}%
- \def\@white{0}%
- \def\@blank{0}%
+ \def\qr@white{0}%
+ \def\qr@blank{0}%
\def\qr@black@fixed{1}%
\def\qr@white@fixed{0}%
\def\qr@black@format{1}%
@@ -2936,8 +2964,8 @@
%
\qr@for \i = 1 to \qr@size by 1%
{\qr@for \j = 1 to \qr@size by 1%
- {\edef\theentry{\qr@matrixentry{#1}{\the\i}{\the\j}}%
- \xa\g@addto@macro\xa\qr@binarymatrix@result\xa{\theentry}%
+ {\edef\qr@theentry{\qr@matrixentry{#1}{\the\i}{\the\j}}%
+ \xa\g@addto@macro\xa\qr@binarymatrix@result\xa{\qr@theentry}%
}%
}%
\egroup%
@@ -2953,16 +2981,16 @@
\def\qr@sanitize@output@int(#1#2){%
% #1 = first character
% #2 = rest of output, including terminator
- \edef\testi{#1}%
- \ifx\testi\@relax
+ \edef\qr@testi{#1}%
+ \ifx\qr@testi\qr@relax
% Done.
\let\qr@next=\relax
\else
- \ifx\testi\qr@otherrightbrace
+ \ifx\qr@testi\qr@otherrightbrace
\edef\qr@sanitized@result{\qr@sanitized@result\qr@otherbackslash}%
- \else\ifx\testi\qr@otherleftbrace
+ \else\ifx\qr@testi\qr@otherleftbrace
\edef\qr@sanitized@result{\qr@sanitized@result\qr@otherbackslash}%
- \else\ifx\testi\qr@otherbackslash
+ \else\ifx\qr@testi\qr@otherbackslash
\edef\qr@sanitized@result{\qr@sanitized@result\qr@otherbackslash}%
\fi
\fi
@@ -2976,14 +3004,14 @@
\def\@qr@TRUE{TRUE}%
\def\qr@writebinarymatrixtoauxfile#1{%
\qr@sanitize@output{\qr@texttoencode}%
- \edef\theargument{{\qr@sanitized@result}{\qr@version}{\qr@level}{#1}}%
- \xa\write\xa\@auxout\xa{\xa\string\xa\qr@savematrix\theargument}%
+ \edef\qr@theargument{{\qr@sanitized@result}{\qr@version}{\qr@level}{#1}}%
+ \xa\write\xa\@auxout\xa{\xa\string\xa\qr@savematrix\qr@theargument}%
%
% Now set a flag, so we don't write this again.
\xa\gdef\csname qr@savedflag@\qr@texttoencode @\qr@version @\qr@level\endcsname{TRUE}%
}%
-\gdef\dummyqrsavedefinition{}%
+\gdef\qr@dummyqrsavedefinition{}%
\begingroup
\catcode`\#=12\relax
\catcode`\<=1\relax
@@ -2992,7 +3020,7 @@
\catcode`\}=12\relax
\catcode`\|=0\relax
\catcode`\\=12|relax
- |gdef|dummyqrsavedefinition<%
+ |gdef|qr@dummyqrsavedefinition<%
\ifx\qr@savematrix\@undefined%
\def\qr@savematrix{\begingroup\let\do\@makeother\dospecials\catcode`\{=1\catcode`\}=2\relax
\qr@savematrix@int}%
@@ -3001,8 +3029,8 @@
>
|endgroup
-\edef\qr@argument{(\dummyqrsavedefinition)}%
-\xa\write\xa\@auxout\xa{\dummyqrsavedefinition}%
+\edef\qr@argument{(\qr@dummyqrsavedefinition)}%
+\xa\write\xa\@auxout\xa{\qr@dummyqrsavedefinition}%
\def\qr@savematrix{\bgroup\qr@verbatimcatcodes\qr@setescapedspecials\qr@savematrix@int}%