diff options
-rw-r--r-- | Master/texmf-dist/doc/latex/qrcode/README | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/qrcode/qrcode.pdf | bin | 250696 -> 265315 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/qrcode/qrcode.dtx | 809 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/qrcode/qrcode.ins | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/qrcode/qrcode.sty | 746 |
5 files changed, 834 insertions, 730 deletions
diff --git a/Master/texmf-dist/doc/latex/qrcode/README b/Master/texmf-dist/doc/latex/qrcode/README index 3d1185885dc..5b0c65f6b3d 100644 --- a/Master/texmf-dist/doc/latex/qrcode/README +++ b/Master/texmf-dist/doc/latex/qrcode/README @@ -1,7 +1,7 @@ ============================================================================== -The `qrcode' package v1.0 -Copyright (C) 2014 Anders Hendrickson (anders.hendrickson@snc.edu) +The `qrcode' package v1.5 +Copyright (C) 2015 Anders Hendrickson (anders.hendrickson@snc.edu) This package generates Quick Response (QR) codes in LaTeX without the need for pstricks or any other graphics @@ -9,6 +9,7 @@ packages. Changes: - 2014/09/26 Initial version +- 2015/01/08 Added support for new lines and hyperlinks ============================================================================== diff --git a/Master/texmf-dist/doc/latex/qrcode/qrcode.pdf b/Master/texmf-dist/doc/latex/qrcode/qrcode.pdf Binary files differindex c366b880e46..ad7f658cf05 100644 --- a/Master/texmf-dist/doc/latex/qrcode/qrcode.pdf +++ b/Master/texmf-dist/doc/latex/qrcode/qrcode.pdf diff --git a/Master/texmf-dist/source/latex/qrcode/qrcode.dtx b/Master/texmf-dist/source/latex/qrcode/qrcode.dtx index b7a8afa4f79..3f4c18f47cb 100644 --- a/Master/texmf-dist/source/latex/qrcode/qrcode.dtx +++ b/Master/texmf-dist/source/latex/qrcode/qrcode.dtx @@ -27,12 +27,13 @@ %<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01] %<package>\ProvidesPackage{qrcode} %<*package> - [2014/09/26 v1.0 QR code generation] + [2015/01/08 v1.5 QR code generation] %</package> % %<*driver> \documentclass{ltxdoc} -\usepackage{qrcode} +\usepackage{hyperref} +\usepackage[nolinks]{qrcode} \EnableCrossrefs \CodelineIndex \OnlyDescription @@ -65,6 +66,7 @@ % % % \changes{v1.0}{2014/09/26}{Initial version} +% \changes{v1.5}{2015/01/08}{Added support for new lines and hyperlinks.} % % \GetFileInfo{qrcode.sty} % @@ -73,18 +75,17 @@ % \def\F{F} % % \title{The \textsf{qrcode} package: \\ -% \makebox[0pt][r]{\raisebox{-0.3\height}[0pt][0pt]{\qrcode[tight]{http://ctan.org/pkg/qrcode}}\rule{0.75in}{0pt}}Quick Response code \\ +% \makebox[0pt][r]{\raisebox{-0.3\height}[0pt][0pt]{\qrcode[hyperlink,tight]{http://ctan.org/pkg/qrcode}}\rule{0.75in}{0pt}}Quick Response code \\ % generation in \LaTeX\thanks{This document % corresponds to \textsf{qrcode}~\fileversion, dated \filedate.}} % \author{Anders Hendrickson\\ St.~Norbert College, De~Pere, WI, USA \\ \texttt{anders.hendrickson@snc.edu}} -% \date{September 26, 2014} +% \date{January 8, 2015} % % \maketitle % % % \section{Introduction} % -% % The proliferation of smartphones and tablets has led to the widespread % use of Quick Response (QR) codes, which encode numeric, alphanumeric, kanji, % or binary information into a square matrix of black and white pixels called modules. @@ -130,9 +131,9 @@ % \begin{center} % |\qrcode|\oarg{options}\marg{text to be encoded} % \end{center} -% For example, |\qrcode[height=0.5in]{http://www.ctan.org}| produces +% For example, |\qrcode[hyperlink,height=0.5in]{http://www.ctan.org}| produces % \begin{center} -% \qrcode[height=0.5in]{http://www.ctan.org} +% \qrcode[hyperlink,height=0.5in]{http://www.ctan.org} % \end{center} % Although the most common use of QR codes is as URLs, % the \meta{text to be encoded} can be almost any typed text. @@ -140,6 +141,16 @@ % % \subsection{Package Options} % +% \DescribeMacro{nolinks} +% When the |hyperref| package is loaded, +% by default |\qrcode| assumes its argument is a URL +% and makes the QR code produced a hyperlink to that URL. +% This default behavior may be changed by invoking the |nolinks| package option. +% For example, most of the QR codes in this document are not in fact URLs, +% so this documentation was typeset with |\usepackage[nolinks]{qrcode}|. +% The |hyperlinks| option is an antonym to |nolinks| and is the default. +% These options have no effect if hyperref is not loaded. +% % \DescribeMacro{draft} % \DescribeMacro{final} % Creating QR codes for short URLs takes relatively little time.\footnote{On @@ -278,6 +289,33 @@ % specified, however, the QR code will automatically be surrounded with 4 modules' % worth of white\-space. The key |tight| is an antonym of |padding|; the default is |tight|. % +% \DescribeMacro{link} +% \DescribeMacro{nolink} +% \DescribeMacro{\qrcode*} +% As described above, if the |hyperref| package is loaded, +% then the QR codes produced in a PDF document can be made +% into hyperlinks to their text. The default behavior +% can be controlled with the options |nolinks| and |hyperlinks|, +% but this default can be overridden for individual QR codes by invoking +% the options |link| or |nolink|. +% Moreover, the starred version of the macro, |\qrcode*|, is a shorthand +% equivalent to |\qrcode[nolink]|. +% \begin{quote} +% \begin{tabular}{p{5.2cm}p{3in}} +% \raggedright +% \qrset{link, height=1.5cm} +% \qrcode{http://www.ctan.org} +% \qrcode[nolink]{This is not a URL.} +% \qrcode*{Neither is this.} +% & +% \begin{minipage}{3in} +% |\qrset{link, height=1.5cm}| \\ +% |\qrcode{http://www.ctan.org}| \\ +% |\qrcode[nolink]{This is not a URL.}| \\ +% |\qrcode*{Neither is this.}| +% \end{minipage} +% \end{tabular} +% \end{quote} % % \subsection{Special characters}\label{sect:specialcharacters} % Many URLs can be processed by \TeX\ with no hiccups, @@ -292,11 +330,14 @@ % \begin{center} % |#| |$| |&| |^| |_| |~| |%| {\tt\char32} % \end{center} +% and line breaks as well.\footnote{Technically, when the input character +% {\tt\char`\^\char`\^M} (CR, charcode 13) is encountered, +% the character {\tt\char`\^\char`\^J} (LF, charcode 10) is placed into the QR code.} % Conspicuously absent from this list are |\|, |{|, and |}|. % This is intentional, so that macros may be used within |\qrcode| % to generate the \meta{text to be encoded} automatically. % If these characters are desired, they may be obtained by ``escaping'' them -% with an extra backslash: +% with an extra backslash. % \begin{quote} % \begin{tabular}{p{2in}p{3in}} % \qrset{height=1.5cm}% @@ -325,10 +366,11 @@ % by escaping them with an extra backslash; % so long as they eventually pass unexpanded to |\qrcode|, % they will produce the correct QR code. +% A line break may be obtained with |\?|. % \begin{quote} % \begin{tabular}{p{1.5cm}p{2in}} -% \fbox{\qrcode[height=1cm]{\#\$\&\^\_\~\%\ \\\{\}}} -% & |\fbox{qrcode[height=1cm]{\#\$\&\^\_\~\%\ \\\{\}}}| +% \fbox{\qrcode[height=1cm]{\#\$\&\^\_\~\?\%\ \\\{\}}} +% & |\fbox{qrcode[height=1cm]{\#\$\&\^\_\~\?\%\ \\\{\}}}| % \end{tabular} % \end{quote} % @@ -359,10 +401,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> @@ -384,36 +433,36 @@ %Tests -\def\@relax{\relax}% +\def\qr@relax{\relax}% %Manipulating macros -\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 @@ -544,7 +593,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}}% } @@ -583,12 +632,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 @@ -627,8 +676,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 @@ -643,8 +692,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% @@ -659,8 +708,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 @@ -676,8 +725,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% @@ -707,8 +756,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 @@ -727,6 +776,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 @@ -739,6 +789,12 @@ {\catcode`\_=12\relax\gdef\qr@otherunderscore{_}}% {\catcode`\$=12\relax\gdef\qr@otherdollar{$}}% +%Line feeds require some special handling. \TeX\ reads a line feed in the input +%as |^^M| (carriage return, character code 13), but it should be encoded in a +%QR code as |^^J| (line feed, character code 10). +%To do this, we make |^^M| an active character and a synonym for a |^^J| with catcode 12. +%Note that the macro |\qr@verbatimlinefeeds| must itself be processed with |^^M| active. +{\catcode`\^^M=13\relax\gdef\qr@verbatimlinefeeds{\let^^M=\qr@otherlf}} \def\qr@verbatimcatcodes{% \catcode`\#=12\relax \catcode`\$=12\relax @@ -747,7 +803,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% @@ -761,6 +818,7 @@ \let\\=\qr@otherbackslash% \let\{=\qr@otherleftbrace% \let\}=\qr@otherrightbrace% + \let\?=\qr@otherlf% }% % \end{macrocode} % \subsection{Plotting} @@ -804,7 +862,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{% @@ -830,7 +888,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}}% @@ -875,8 +933,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% @@ -988,11 +1046,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}% @@ -1147,7 +1205,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 }% @@ -1170,8 +1228,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 @@ -1181,9 +1239,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{% @@ -1197,14 +1255,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, @@ -1256,15 +1314,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{% @@ -1284,8 +1342,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)% @@ -1453,28 +1511,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}% @@ -1492,23 +1550,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}% }% @@ -1517,18 +1575,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}% @@ -1544,55 +1602,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 @@ -1601,27 +1659,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 @@ -1631,59 +1689,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 @@ -1691,7 +1749,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 @@ -1699,45 +1757,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 @@ -1746,59 +1804,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 @@ -1836,14 +1894,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{% @@ -1864,7 +1922,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 @@ -1889,11 +1946,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){% @@ -1901,7 +1958,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 @@ -1929,11 +1985,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{% @@ -1963,12 +2019,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}% @@ -1979,7 +2033,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}% @@ -1988,11 +2042,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 }% % \end{macrocode} % @@ -2008,22 +2062,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. @@ -2036,7 +2090,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 @@ -2058,15 +2112,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% @@ -2172,11 +2226,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 @@ -2212,16 +2266,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 @@ -2247,24 +2301,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)% @@ -2283,39 +2337,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{% @@ -2326,15 +2376,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}% }% % \end{macrocode} % @@ -2363,8 +2413,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 @@ -2380,38 +2430,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}% }% @@ -2436,15 +2486,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. @@ -2464,24 +2514,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}% @@ -2493,26 +2543,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% @@ -2527,20 +2577,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% @@ -2573,8 +2623,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}% @@ -2588,7 +2638,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 }% @@ -2598,15 +2648,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{% @@ -2629,7 +2679,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)}% @@ -2639,7 +2689,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}% @@ -2666,13 +2716,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 @@ -2684,7 +2734,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)% @@ -2721,12 +2771,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}% @@ -2743,13 +2793,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}% }% % \end{macrocode} % @@ -2931,7 +2981,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}% @@ -3013,7 +3063,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% @@ -3059,7 +3109,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% @@ -3105,7 +3155,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% @@ -3151,7 +3201,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% @@ -3196,7 +3246,7 @@ \or68,30% \fi)}% \fi -\xa\qr@settableix@int\tempdata +\xa\qr@settableix@int\qr@tempdata }% % \end{macrocode} % \subsection{More key handling} @@ -3204,7 +3254,7 @@ \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}% @@ -3257,12 +3307,29 @@ % and that any escaped special characters are converted to the intended % characters with category code 12 (other). % \begin{macrocode} -\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 @@ -3272,21 +3339,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{% @@ -3301,7 +3376,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 @@ -3316,17 +3391,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}% @@ -3369,8 +3444,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}% @@ -3378,8 +3453,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% @@ -3395,16 +3470,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 @@ -3418,14 +3493,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 @@ -3434,7 +3509,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}% @@ -3443,8 +3518,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}% diff --git a/Master/texmf-dist/source/latex/qrcode/qrcode.ins b/Master/texmf-dist/source/latex/qrcode/qrcode.ins index b50f77ae891..6e5eadecbd4 100644 --- a/Master/texmf-dist/source/latex/qrcode/qrcode.ins +++ b/Master/texmf-dist/source/latex/qrcode/qrcode.ins @@ -1,5 +1,5 @@ %% qrcode.ins -%% Copyright 2014 by Anders O.F. Hendrickson +%% Copyright 2015 by Anders O.F. Hendrickson %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -25,7 +25,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 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}% |