summaryrefslogtreecommitdiff
path: root/Build/source/extra/bibtex/bibtex.vms-changes
blob: 6fb4a808d2767f9c171709ac19e7ff1de45fb7d0 (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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
BIBTeX change file for Vax/VMS
Modified, 12-Feb-88 by Jerry Leichter for Version .99b
Modified, 15-Apr-88 by Jerry Leichter for Version .99c
Modified, 27-May-88 by Nelson Beebe.  Fixed some spelling errors and typos
        that showed up when the code was woven.  Added support for specifying
        the file name on the command line.
@x
\def\title{\BibTeX\ }
@y
\pageno=\contentspagenumber \advance\pageno by 1
\let\maybe=\iffalse
\def\title{\BibTeX changes for Vax/VMS}
@z

@x
@d banner=='This is BibTeX, Version 0.99c' {printed when the program starts}
@y
@d banner=='This is BibTeX, Vax/VMS Version 0.99c'
@z

@x
@d term_out == tty
@d term_in == tty
@y
@d term_out == output
@d term_in == input
@z

@x
@d print(#) == begin write(log_file,#); write(term_out,#); end
@d print_ln(#) == begin write_ln(log_file,#); write_ln(term_out,#); end
@d print_newline == print_a_newline
                                {making this a procedure saves a little space}
@#
@d trace_pr(#) == begin write(log_file,#); end
@d trace_pr_ln(#) == begin write_ln(log_file,#); end
@d trace_pr_newline == begin write_ln(log_file); end

@<Procedures and functions for all file I/O, error messages, and such@>=
procedure print_a_newline;
begin
write_ln(log_file);
write_ln(term_out);
end;
@y
@d print(#) == begin write(log_file,#); write(term_out,#); end
@d print_ln(#) == begin write_ln(log_file,#,chr(13),chr(10));
 write_ln(term_out,#,chr(13),chr(10)); end
@d print_newline == print_a_newline
                                {making this a procedure saves a little space}
@#
@d trace_pr(#) == begin write(log_file,#); end
@d trace_pr_ln(#) == begin write_ln(log_file,#,chr(13),chr(10)); end
@d trace_pr_newline == begin write_ln(log_file,chr(13),chr(10)); end

@<Procedures and functions for all file I/O, error messages, and such@>=
procedure print_a_newline;
begin
write_ln(log_file,chr(13),chr(10));
write_ln(term_out,chr(13),chr(10));
end;
@z

@x
@d othercases == others: {default for cases not listed explicitly}
@y
@d othercases == otherwise {Vax/VMS default for cases not listed
 explicitly}
@z

@x
program BibTEX;                 {all files are opened dynamically}
@y
program BibTEX(input,output);
                        {all files are opened dynamically}
@z

@x
@<Compiler directives@>=
@{@&$C-,A+,D-@}  {no range check, catch arithmetic overflow, no debug overhead}
@!debug @{@&$C+,D+@}@+ gubed            {but turn everything on when debugging}
@y
On Vax/VMS, there are no compiler directives that can be introduced in this
way, but we take this opportunity to include a few system-dependent goodies.

@d VAX_text==@= text @>
@d VAX_new==@= new @>
@d VAX_none==@= none @>
@d VAX_word==@= word @>
@d VAX_error==@= error @>
@d VAX_length==@= length @>
@d VAX_syi_sid==@= syi$_sid @>
@d VAX_continue==@= continue @>
@d VAX_external==@= external @>
@d VAX_readonly==@= readonly @>
@d VAX_volatile==@= volatile @>
@d VAX_aligned==@= aligned @>
@d VAX_unsigned==@= unsigned @>
@d VAX_carriage_control==@= carriage_control @>
@d VAX_io_setmode==@= io$_setmode @>
@d VAX_iom_ctrlcast==@= io$m_ctrlcast @>
@d VAX_immed==@= %immed @>
@d VAX_stdescr==@= %stdescr @>
@d VAX_ref==@= %ref @>
@d VAX_qiow==@= $qiow @>
@d VAX_assign==@= $assign @>
@d VAX_numtim==@= $numtim @>
@d VAX_getsyi==@= $getsyi @>
@d VAX_lib_get_foreign==@= lib$get_foreign @>
@d VAX_disposition==@= disposition @>
@d VAX_delete==@= delete @>
@d VAX_save==@= save @>
@d VAX_varying==@= varying @>
@d VAX_substr==@= substr @>
@d VAX_trnlog==@= $trnlog @>
@d VAX_ss_normal==@= ss$_normal @>

@<Compiler directives@>=
@=[check(none)]@> {no debug overhead, but...}
debug @=[check(all)]@> gubed {turn everything on when debugging}
@z

@x Define the compile-time constant |max_rescan| for command-line processing
@!lit_stk_size=100; {maximum number of literal functions on the stack}
@y
@!lit_stk_size=100; {maximum number of literal functions on the stack}
@!max_cmdline=500; {maximum length of the rescan buffer}
@z

@x
@<Types in the outer block@>=
@y
@<Types in the outer block@>=
@!word_type = [word]-32768..32767;      {16-bit integers}
@z

@x
@!alpha_file=packed file of text_char; {files that contain textual data}
@y
@!alpha_file=text; {files that contain textual data}
@z

@x
@d reset_OK(#)==erstat(#)=0
@d rewrite_OK(#)==erstat(#)=0

@<Procedures and functions for file-system interacting@>=
function erstat(var f:file):integer; extern;    {in the runtime library}
@#@t\2@>
function a_open_in(var f:alpha_file):boolean;   {open a text file for input}
begin reset(f,name_of_file,'/O'); a_open_in:=reset_OK(f);
end;
@#
function a_open_out(var f:alpha_file):boolean;  {open a text file for output}
begin rewrite(f,name_of_file,'/O'); a_open_out:=rewrite_OK(f);
end;
@y
@<Procedures and functions for file-system interacting@>=
function a_open_in(var f:alpha_file):boolean;   {open a text file for input}
begin
open(f,name_of_file,VAX_readonly,VAX_error:=VAX_continue);
if status(f)>0 then a_open_in:=false
else begin
 reset(f,VAX_error:=VAX_continue);
 a_open_in:=status(f)<=0;
 end;
end;
@#
function a_open_out(var f:alpha_file):boolean;  {open a text file for output}
begin
open(f,name_of_file,VAX_new,16383,{VAX\_disposition:=VAX\_delete,}
        VAX_error:=VAX_continue);
if status(f)>0 then a_open_out:=false
else begin
 rewrite(f,VAX_error:=VAX_continue);
 a_open_out:=status(f)<=0;
 end;
end;
@z

@x
pre_define('texinputs:  ',10,file_area_ilk);
s_bst_area := hash_text[pre_def_loc];
pre_define('texbib:     ',7,file_area_ilk);
s_bib_area := hash_text[pre_def_loc];
@y
pre_define('tex$inputs: ',11,file_area_ilk);
s_bst_area := hash_text[pre_def_loc];
pre_define('tex$bib:    ',8,file_area_ilk);
s_bib_area := hash_text[pre_def_loc];
@z

@x
check_cmnd_line := false;                       {many systems will change this}
@y
check_cmnd_line := true;                        {many systems will change this}
@z

@x And finally, here's the code that handles the command line argument.
@<Process a possible command line@>=
begin
do_nothing;             {the ``default system'' doesn't use the command line}
end
@y
On VAX/VMS, we can make a program runnable by name by defining a foreign
command symbol for it; the command line is then accessible via a call to
\.{lib\$get\_foreign()}.  Since all we need is a single word off the
command line, and since prompting for the input of that word is both a
nuisance, and precludes use of nice utilities like \.{Make}, it seems
simplest to pick up the name from the command line.

The Kellerman and Smith VMS \TeX{} implementation takes this notion a
step further, and adds code to support running the program in native
mode, complete with command line switches and fancy parsing; they have
more ambition than I do just now.

@<Process a possible command line@>=
begin
  get_cmdline;
  if (aux_name_length = file_name_size) then
    sam_you_made_the_file_name_too_long
  else if (aux_name_length = 0) then
    goto aux_not_found
end
@
@<Procedures and functions for all file I/O, error messages, and such@>=
function VAX_lib_get_foreign(VAX_stdescr s :
                packed array [a..b : integer] of char;
        %immed p2 : integer;
        var p3 : word_type) : integer;
        fortran;
@#
procedure get_cmdline;
label exit;
var
        cmdline : packed array [1..max_cmdline] of char;
        cmdlength : word_type;
        i : integer;
@#
begin
        aux_name_length := 0;
        if not odd (VAX_lib_get_foreign(cmdline,0,cmdlength)) then
        begin
                print_ln('Cannot get command line; use "bibtex file"');
                return
        end;
@#
        i:=1;
        while (i<=cmdlength) and (cmdline[i]=' ') do incr(i); {skip spaces}@/
        if i>cmdlength then return; {there was no argument}
@#
        while (cmdline[i]>' ') do       {copy the argument into |name_of_file|}
        begin
            if (aux_name_length = file_name_size) then
                return;
            incr(aux_name_length);
            name_of_file[aux_name_length] := cmdline[i];
            incr(i)
        end;
exit:
end;
@
@z

@x
This section should be replaced, if necessary, by changes to the program
that are necessary to make \BibTeX\ work at a particular installation.
It is usually best to design your change file so that all changes to
previous sections preserve the section numbering; then everybody's version
will be consistent with the printed program. More extensive changes,
which introduce new sections, can be inserted here; then only the index
itself will get a new section number.
@y
Here are the remaining changes to the program
that are necessary to make \.{TeX} work on Vax/VMS.

@z