summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/dialogl/grabhedr.sty
blob: a0af96b97748a9148bcc1464283e610adc3593b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
%% 
%% This is file `grabhedr.sty',
%% generated with the docstrip utility.
%% 
%% The original source files were:
%% 
%% grabhedr.dtx  (with options: `2e')

%%% ====================================================================
%%%  @LaTeX-style-file{
%%%     filename        = "grabhedr.sty",
%%%     version         = "0.9j",
%%%     date            = "1994/11/08",
%%%     time            = "16:15:00 EST",
%%%     author          = "Michael Downes",
%%%     email           = "mjd@math.ams.org (Internet)",
%%%     keywords        = "TeX, file header,
%%%     supported       = "yes",
%%%     abstract        = "This file defines a function \inputfwh
%%%       to be used instead of \input, to allow TeX to grab
%%%       information from standardized file headers in the form
%%%       proposed by Nelson Beebe during his term as president of the
%%%       TeX Users Group. Of which all this here is an example.",
%%%     checksum        = "60397 519 2589 19482",
%%%     docstring       = "The checksum field above contains a CRC-16
%%%       checksum as the first value, followed by the equivalent of
%%%       the standard UNIX wc (word count) utility output of lines,
%%%       words, and characters.  This is produced by Robert Solovay's
%%%       checksum utility.",
%%%  }
%%% ====================================================================
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{grabhedr}[1994/11/08 v0.9j]
\begingroup
\catcode96 12 % left quote
\catcode`\= 12
\catcode`\{=1 \catcode`\}=2 \catcode`\#=6
\catcode`\$=3 \catcode`\~=13 \catcode`\^=7
\catcode`\_=8 \catcode`\^^M=5 \catcode`\"=12
\catcode`\@=11
\gdef\@empty{}
\long\gdef\@gobble#1{}
\long\gdef\@gobbletwo#1#2{}
\long\gdef\@gobblethree#1#2#3{}
\long\gdef\@car#1#2\@nil{#1}
\ifx\UndEFiNed\@@input % LaTeX not loaded.
  \edef\0{\meaning\input}\edef\1{\string\input}%
  \ifx\0\1%
    \global\let\@@input\input
  \else
    \errhelp{%
Grabhedr.sty needs to know the name of the
\input primitive in order to define \inputfwh
properly. Consult a TeXnician for help.}
    \errmessage{%
      Non-primitive \noexpand\input detected}%
  \fi
\fi
\global\toksdef\toks@=0
\long\gdef\afterfi#1\fi{\fi#1}
\global\let\nx@\noexpand
\global\let\xp@\expandafter
\begingroup \lccode`\.=`\%%
\lowercase{\gdef\@percentchar{.}}%
\endgroup
\gdef\fileversiondate#1#2#3{%
  \xp@\xdef\csname#1\endcsname{#2 (#3)}%
  \def\filename{#1}\def\fileversion{#2}%
  \def\filedate{#3}%
  \message{#1 \csname#1\endcsname}%
}
\xdef\@filehdrstart{%
  \@percentchar\@percentchar\@percentchar\space
  ==================================%
  ==================================}
\gdef\@scanfileheader#1@#2#{\@xscanfileheader}
\long\gdef\@xscanfileheader#1{%
  \@yscanfileheader#1{} version = "??",
  date = "??",\@yscanfileheader}
\long\gdef\@yscanfileheader
  #1 filename = "#2",#3 version = "#4",%
  #5 date = "#6",#7\@yscanfileheader{%
  \endgroup
  \csname fileversiondate\endcsname{#2}{#4}{#6}%
}
\begingroup
\lccode`\$=`\^^M
\lowercase{\gdef\@readfirstheaderline#1$}{%
  \toks@{#1}%
  \edef\@tempa{\@percentchar\the\toks@}%
  \ifx\@tempa\@filehdrstart
    \endgroup \begingroup
    \catcode`\%=9 \catcode`\^^M=5 \catcode`\@=11
    \catcode`\ =10 \catcode`\==12 \catcode`\"=12
  \xp@\@scanfileheader
  \else
    \message{(* Missing file header? *)}%
    \afterfi\endgroup
  \fi}
\endgroup
\gdef\@xinputfwh{%
  \ifx\next\@readfirstheaderline
    \catcode`\%=12 \catcode`\{=12 \catcode`\}=12
    \catcode`\\=12 \catcode`\^^L=12
    \catcode`\^=12
    \catcode`\^^M=3\relax
  \else \endgroup\fi
}
\gdef\@inputfwh{\futurelet\next\@xinputfwh}
\gdef\inputfwh#1{%
  \begingroup\catcode`\%=\active
  \endlinechar`\^^M\relax
  \lccode`\~=`\%\relax
  \lowercase{\let~}\@readfirstheaderline
  \xp@\@inputfwh\@@input #1\relax
}
\gdef\localcatcodes#1{%
  \ifx\@empty\@catcodestack
    \gdef\@catcodestack{{}}%
  \fi
  \def\do##1##2{%
    \ifnum##2>\z@
      \catcode\number`##1 \space
      \number\catcode`##1\relax
    \expandafter\do\fi}%
  \xdef\@catcodestack{{\do#1\relax\m@ne}%
    \@catcodestack}%
  \def\do##1##2{\catcode`##1 ##2\relax\do}%
  \do#1\ {\catcode32\let\do}%
}
\gdef\@catcodestack{{}}
\gdef\restorecatcodes{%
  \begingroup
  \ifx\@empty\@catcodestack
    \errmessage{Can't pop catcodes;
      \nx@\@catcodestack = empty}%
    \endgroup
  \else
    \def\do##1##2\do{%
      \gdef\@catcodestack{##2}%
      \endgroup##1}%
    \xp@\do\@catcodestack\do
  \fi
}
\expandafter\gdef\csname trap.input\endcsname
  \input#1 \relax{%
    \expandafter\ifx\csname#1\endcsname\relax
      \afterfi\inputfwh{#1}\relax
    \fi}
\endgroup
\endinput
%% 
%% End of file `grabhedr.sty'.