[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: code and testfile for version comparision (84cc2df)

Ulrike Fischer fischer at troubleshooting-tex.de
Wed Apr 10 23:56:15 CEST 2019


Repository : https://github.com/latex3/pdfresources
On branch  : testlinkstuff
Link       : https://github.com/latex3/pdfresources/commit/84cc2df0cf3c1a02e1b070d76e589996e4abad66

>---------------------------------------------------------------

commit 84cc2df0cf3c1a02e1b070d76e589996e4abad66
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Wed Apr 10 23:56:15 2019 +0200

    code and testfile for version comparision


>---------------------------------------------------------------

84cc2df0cf3c1a02e1b070d76e589996e4abad66
 pdfresources.dtx              |   62 ++++++++++++++++++++++++++++++++++++++++-
 testfiles/version-compare.lvt |   26 +++++++++++++++++
 testfiles/version-compare.tlg |   15 ++++++++++
 3 files changed, 102 insertions(+), 1 deletion(-)

diff --git a/pdfresources.dtx b/pdfresources.dtx
index fd529c2..d233094 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -230,7 +230,67 @@
 }
 %</package>
 %    \end{macrocode}
-% \section{Management code}
+% \section{Management code / pdf Module}
+%<@@=pdf>
+% \subsection{Comparing pdf versions}
+% The code assumes that the versions are two integers separated by a period.
+% \begin{macro}{\pdf_version_compare:Nn}
+%    \begin{macrocode}
+%<*package>
+\cs_new:cpn { @@_version_compare_=:w } #1 .#2 . #3\q_stop
+ {
+   \bool_if:nTF
+    {
+     \int_compare_p:n { \driver_pdf_majorversion: = #1  }
+     &&
+     \int_compare_p:n { \driver_pdf_minorversion: = #2}
+    }
+    { \prg_return_true: }
+    { \prg_return_false: }
+ }
+
+\cs_new:cpn { @@_version_compare_<:w } #1 .#2 . #3\q_stop
+ {
+   \bool_if:nTF
+    {
+     \int_compare_p:n  { \driver_pdf_majorversion: < #1}
+     ||
+     (
+      \int_compare_p:n { \driver_pdf_majorversion: = #1 }
+      &&
+      \int_compare_p:n { \driver_pdf_minorversion: < #2 }
+     )
+    }
+    { \prg_return_true: }
+    { \prg_return_false: }
+ }
+
+\cs_new:cpn { @@_version_compare_>:w } #1 .#2 . #3\q_stop
+ {
+   \bool_if:nTF
+    {
+     \int_compare_p:n  { \driver_pdf_majorversion: > #1}
+     ||
+     (
+      \int_compare_p:n { \driver_pdf_majorversion: = #1}
+      &&
+      \int_compare_p:n { \driver_pdf_minorversion: > #2 }
+     )
+    }
+    { \prg_return_true: }
+    { \prg_return_false: }
+ }
+
+\prg_new_conditional:Npnn \pdf_version_compare:Nn #1 #2
+ {
+  p,T,F,TF
+ }
+ {
+  \use:c {@@_version_compare_#1:w} #2 . . \q_stop
+ }
+%</package>
+%    \end{macrocode}
+% \end{macro}
 % \subsection{Higher-level link management}
 % \subsubsection{Startlink}
 % packages like ocgx2 and tagpdf wants to add code to links/annotation created by hyperref.
diff --git a/testfiles/version-compare.lvt b/testfiles/version-compare.lvt
new file mode 100644
index 0000000..03024aa
--- /dev/null
+++ b/testfiles/version-compare.lvt
@@ -0,0 +1,26 @@
+\input{regression-test}
+\documentclass{article}
+
+\usepackage{pdfresources}
+\begin{document}\START\showoutput
+\ExplSyntaxOn
+
+$>$  1.4:~\pdf_version_compare:NnTF > {1.4}{true}{false}
+\par
+$>$  2.0:~\pdf_version_compare:NnTF > {2.0}{true}{false}
+\par
+$=$  1.4:~\pdf_version_compare:NnTF = {1.4}{true}{false}
+\par
+$=$  1.5:~\pdf_version_compare:NnTF = {1.5}{true}{false}
+\par
+$<$  1.5:~\pdf_version_compare:NnTF < {1.5}{true}{false}
+\par
+$<$  1.6:~\pdf_version_compare:NnTF < {1.6}{true}{false}
+
+
+\par 
+\driver_pdf_majorversion:\driver_pdf_minorversion:
+
+\ExplSyntaxOff
+
+\end{document}
\ No newline at end of file
diff --git a/testfiles/version-compare.tlg b/testfiles/version-compare.tlg
new file mode 100644
index 0000000..6341bc2
--- /dev/null
+++ b/testfiles/version-compare.tlg
@@ -0,0 +1,15 @@
+This is a generated file for the l3build validation system.
+Don't change this file in any respect.
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <7> on input line ....
+LaTeX Font Info:    External font `cmex10' loaded for size
+(Font)              <5> on input line ....
+Completed box being shipped out
+! I can't write on file `version-compare.pdf'.
+(Press Enter to retry, or Control-Z to exit; default file extension is `.pdf')
+Please type another file name for output
+! Emergency stop.
+<to be read again> 
+                   \endgroup \set at typeset@protect 
+l. ...\end{document}
+*** (job aborted, file error in nonstop mode)





More information about the latex3-commits mailing list