From 4443aa712503e8404b2152c761c2ab5e1a98d197 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 2 Nov 2014 21:50:27 +0000
Subject: bigfoot (2nov14)

git-svn-id: svn://tug.org/texlive/trunk@35482 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/bigfoot/perpage.sty | 76 +++++++++++++++----------
 1 file changed, 47 insertions(+), 29 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/bigfoot/perpage.sty')

diff --git a/Master/texmf-dist/tex/latex/bigfoot/perpage.sty b/Master/texmf-dist/tex/latex/bigfoot/perpage.sty
index 3f4d8e216f4..6ddf546230e 100644
--- a/Master/texmf-dist/tex/latex/bigfoot/perpage.sty
+++ b/Master/texmf-dist/tex/latex/bigfoot/perpage.sty
@@ -22,12 +22,22 @@
 %% in the same archive or directory.)
 %%
 %% perpage is part of the bigfoot bundle for critical typesetting
-%% Copyright 2002, 03, 04, 05, 06  David Kastrup <dak@gnu.org>
+%% Copyright 2002--2014  David Kastrup <dak@gnu.org>
+%%
+%% The license notice and corresponding source code for this file are
+%% contained in perpage.dtx.
 %%
 \NeedsTeXFormat{LaTeX2e}
-\def\next$#1: #2 #3${#2}
-\ProvidesPackage{perpage}[\next$Date: 2006/07/15 21:43:23 $
-  \next$Revision: 1.12 $ Reset/sort counters per page]
+\ProvidesPackage{perpage}[2014/10/25 2.0 Reset/sort counters per page]
+\def\pp@cl@begin{\z@\z@ \begingroup}
+\def\pp@cl@end{\afterassignment\pp@cl@end@ii \count@}
+\def\pp@cl@end@ii{%
+  \relax
+  \expandafter\endgroup
+  \ifnum\count@<\z@
+    \expandafter\pp@cl@end@iii
+  \fi}
+\def\pp@cl@end@iii\stepcounter#1{}
 \newcommand\AddAbsoluteCounter[1]
 {\@ifundefined{c@abs#1}{%
     \expandafter\newcount\csname c@abs#1\endcsname
@@ -35,9 +45,9 @@
     \global\expandafter\let\csname cl@abs#1\endcsname\@empty
     \expandafter\xdef\csname theabs#1\endcsname{%
       \noexpand\number \csname c@abs#1\endcsname}%
-    \global\@namedef{c@pabs@#1}{\z@=\z@{%
-        \stepcounter{abs#1}%
-        \afterassignment}\count@}%
+    \global\@namedef{c@pabs@#1}{\pp@cl@begin
+      \stepcounter{abs#1}%
+      \pp@cl@end}%
     \@addtoreset{pabs@#1}{#1}}{}}
 \AddAbsoluteCounter{page}
 \def\theabspage{\ifx\thepage\relax
@@ -63,7 +73,8 @@
   \addtocounter{pp@a@#1}\m@ne
   \@addtoreset{pchk@#1}{#1}%
   \AtBeginDocument{\setcounter{pp@a@#1}\z@}%
-  \edef\next{\noexpand\AtEndDocument{\noexpand\setcounter{pp@a@#1}{%
+  \edef\next{\noexpand\AtEndDocument
+    {\noexpand\setcounter{pp@a@#1}{%
         \number\value{pp@a@#1}}}}\next}
 \@onlypreamble\pp@makeperpage
 \def\pp@chkvlist{%
@@ -84,15 +95,14 @@
   \fi}
 \def\pp@fetchctr#1{\expandafter\expandafter\expandafter\pp@fetchctrii
   \csname pp@r@#1@\number\value{pp@a@#1}\endcsname
-  \@empty\@empty}
+  {}{}}
 
 \global\let\theperpage\@empty
 
-\def\pp@fetchctrii#1#2#3{\edef\pp@label{#1}%
-  \edef\pp@page{#2}%
+\def\pp@fetchctrii#1#2#3{\def\pp@label{#1}%
+  \def\pp@page{#2}%
   \gdef\theperpage{#3}}
-\def\c@pchk@#1{\z@=\z@
-  \begingroup
+\def\c@pchk@#1{\pp@cl@begin
   \pp@fetchctr{#1}\let\next\pp@page
   \addtocounter{pp@a@#1}\@ne
   \pp@fetchctr{#1}%
@@ -107,16 +117,18 @@
   \pp@chkvlist
   \dimen@=\lastkern
   \ifdim\dimen@=\z@ \else \unkern\fi
+  \count@=\lastpenalty
   \protected@write\@auxout{}{\next}%
-  \ifdim\dimen@=\z@ \nobreak \else \kern\dimen@\fi
-  \afterassignment\endgroup\count@}
+  \ifdim\dimen@=\z@
+    \penalty \ifnum\count@<\@M \@M \else \count@ \fi
+  \else \kern\dimen@\fi
+  \pp@cl@end}
+\def\pp@labeldef#1#2#3#4#5{\@newl@bel{pp@r@#2}{#3}{{#1}{#4}{#5}}}
 \def\pp@pagectr#1#2#3#4{\@ifundefined{c@pp@a@#1}{}{%
     \addtocounter{pp@a@#1}\@ne
-    \edef\next{\noexpand
-      \@newl@bel{pp@r@#1}{#2}{{\number\value{pp@a@#1}}{#3}%
-        {#4}}}\next}}
-\def\c@schk@#1{\z@=\z@
-  \begingroup
+    \expandafter\pp@labeldef\expandafter
+      {\number\value{pp@a@#1}}{#1}{#2}{#3}{#4}}}
+\def\c@schk@#1{\pp@cl@begin
   \addtocounter{pp@a@#1}\@ne
   \ifnum\value{#1}=\@ne
     \expandafter\xdef\csname pp@g@#1\endcsname{\number\value{pp@a@#1}}%
@@ -132,11 +144,9 @@
     \count@0\csname pp@g@#1@#3\endcsname
     \advance\count@\@ne
     \expandafter\xdef\csname pp@g@#1@#3\endcsname{\number\count@}%
-    \edef\next{\noexpand
-      \@newl@bel{pp@r@#1}{#2}{{\number\count@}{#3}%
-        {#4}}}\next}}
-\def\c@spchk@#1{\z@=\z@
-  \begingroup
+    \expandafter\pp@labeldef\expandafter
+      {\number\count@}{#1}{#2}{#3}{#4}}}
+\def\c@spchk@#1{\pp@cl@begin
   \addtocounter{pp@a@#1}\@ne
   \pp@fetchctr{#1}%
   \ifx\pp@page\@empty
@@ -150,10 +160,18 @@
       \setcounter{pp@a@#1}{\value{pp@r@#1}}%
     \fi
     \global\expandafter\let\csname pp@page@#1\endcsname\next
-    \edef\next{\noexpand
-      \@newl@bel{pp@r@#1}{#2}{{\number\value{pp@a@#1}}{#3}%
-        {#4}}}\next}}
-
+    \expandafter\pp@labeldef\expandafter
+      {\number\value{pp@a@#1}}{#1}{#2}{#3}{#4}}}
+\AtBeginDocument{%
+  \begingroup
+    \@testdef{}{undefined}{}%
+    \expandafter
+  \endgroup
+  \ifx\@undefined\relax
+    \let\pp@@testdef\@testdef
+    \def\@testdef#1#2#3{{\pp@@testdef{#1}{#2}{#3}%
+        \if@tempswa\aftergroup\@tempswatrue\fi}}%
+  \fi}
 \endinput
 %%
 %% End of file `perpage.sty'.
-- 
cgit v1.2.3

