From b0c666dbd315af330424f5d34739d7d4134d0c17 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 2 Jun 2024 20:26:39 +0000
Subject: latex2e (2jun24)

git-svn-id: svn://tug.org/texlive/trunk@71408 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/tools/xr.sty | 62 ++++++++++++++++++++++++--------
 1 file changed, 48 insertions(+), 14 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/tools/xr.sty')

diff --git a/Master/texmf-dist/tex/latex/tools/xr.sty b/Master/texmf-dist/tex/latex/tools/xr.sty
index ece5e0df2d0..9e3f16cd92b 100644
--- a/Master/texmf-dist/tex/latex/tools/xr.sty
+++ b/Master/texmf-dist/tex/latex/tools/xr.sty
@@ -13,7 +13,7 @@
 %% (but please observe conditions on bug reports sent to that address!)
 %% 
 %% 
-%% Copyright (C) 1993-2023
+%% Copyright (C) 1993-2024
 %% The LaTeX Project and any individual authors listed elsewhere
 %% in this file.
 %% 
@@ -35,17 +35,40 @@
 %% The list of all files belonging to the LaTeX `Tools Bundle' is
 %% given in the file `manifest.txt'.
 %% 
-%% File: xr.dtx Copyright (C) 1993-2019 David Carlisle
+%% File: xr.dtx Copyright (C) 1993-2024 David Carlisle
 \NeedsTeXFormat{LaTeX2e}
+\DeclareRelease{v5}{2023-07-04}{xr-2023-07-04.sty}
+\DeclareCurrentRelease{}{2024-04-10}
 \ProvidesPackage{xr}
-         [2023-07-04 v5.06 eXternal References (DPC)]
-\def\externaldocument{\@ifnextchar[\XR@{\XR@[]}}
+         [2024-04-10 v6.00 eXternal References (DPC)]
+\def\externaldocument{\@testopt\XR@cite{}}
 \let\externalcitedocument\externaldocument
-\def\XR@[#1]#2{{%
+\def\XR@cite[#1]{\@testopt{\XR@[#1]}{}}
+\def\XR@[#1][#2]#3{\@testopt{\XR@@{#1}{#2}{#3}}{#3.\XR@ext}}
+\def\XR@@nocite{nocite}
+\long\def\@gobblefour  #1#2#3#4{}
+\long\def\@firstoffour #1#2#3#4{#1}
+\long\def\@secondoffour#1#2#3#4{#2}
+\long\def\@thirdoffour #1#2#3#4{#3}
+\long\def\@fourthoffour #1#2#3#4{#4}
+\def\XR@addURL#1{\XR@@dURL#1{}{}{}{}\\}
+\def\XR@@dURL#1#2#3#4#5\\{%
+     \unexpanded{{#1}{#2}{#3}{#4}}{\XR@URL}%
+  }%
+\providecommand\XR@ext{pdf}
+\def\XR@@#1#2#3[#4]{{%
   \makeatletter
   \def\XR@prefix{#1}%
-  \set@curr@file{#2}%
-  \expandafter\XR@next\@curr@file.aux\relax\\}}
+   \def\XR@nocite{#2}%
+   \ifx\XR@nocite\XR@@nocite
+     \let\XR@bibcite\vadjust
+   \else
+     \let\XR@bibcite\bibcite
+   \fi
+  \def\XR@URL{#4}%
+  \set@curr@file{#3}%
+  \filename@parse\@curr@file
+  \XR@next\@curr@file.aux\relax\\}}
 \def\XR@next#1\relax#2\\{%
   \edef\XR@list{#2}%
   \XR@loop{#1}}
@@ -64,15 +87,26 @@
   \read\@inputcheck to\XR@line
   \expandafter\XR@test\XR@line...\XR@}
 \long\def\XR@test#1#2#3#4\XR@{%
-  \let\XR@tempa\@gobbletwo
+  \let\XR@tempa\@gobblefour
   \ifx#1\newlabel
-    \let\XR@tempa\@firstoftwo
-  \else\ifx#1\bibcite
-    \let\XR@tempa\@firstoftwo
+    \let\XR@tempa\@firstoffour
+  \else\ifx#1\XR@bibcite
+    \let\XR@tempa\@secondoffour
   \else\ifx#1\@input
-     \let\XR@tempa\@secondoftwo
-  \fi\fi\fi
-   \XR@tempa{#1{\XR@prefix#2}{#3}}{\edef\XR@list{\XR@list#2\relax}}%
+     \let\XR@tempa\@thirdoffour
+  \else\ifx#1\new@label@record
+     \let\XR@tempa\@fourthoffour
+  \fi\fi\fi\fi
+   \XR@tempa
+    {%
+     \expandafter\protected@xdef\csname r@\XR@prefix#2\endcsname{\XR@addURL{#3}}%
+    }%
+    {\expandafter\bibcite\expandafter{\XR@prefix#2}{#3}}%
+    {\edef\XR@list{\XR@list\filename@area#2\relax}}%
+    {%
+      \edef\next{\noexpand\new@label@record{\XR@prefix#2}{\unexpanded{#3}{xr-url}{\XR@URL}}}%
+      \next
+    }
   \ifeof\@inputcheck\expandafter\XR@aux
   \else\expandafter\XR@read\fi}
 \endinput
-- 
cgit v1.2.3

