summaryrefslogtreecommitdiff
path: root/web/spiderweb/fixes-to-be-applied/changes
blob: aab863bc4f4ffc890a63b165b415b708d5a4292b (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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
From fubinf!thull Mon Mar 12 09:01:53 1990
Received: by cs.Princeton.EDU (5.57/1.98)
	id AA22774; Mon, 12 Mar 90 09:01:50 EST
Received: from [129.217.64.60] by Princeton.EDU (5.58+++/2.32/mailrelay)
	id AA20280; Mon, 12 Mar 90 08:59:12 EST
Received: from fubinf.uucp 
	by unido.informatik.uni-dortmund.de with uucp via EUnet (UNIDO-2.0.1.d)
	for princeton.edu
	id AO16211; Mon, 12 Mar 90 14:57:27 +0100
Received: by fubinf.uucp (4.0/SMI-4.0)
	id AA01394; Sat, 3 Nov 90 15:19:31 +0100
Date: Sat, 3 Nov 90 15:19:31 +0100
From: fubinf!thull (Klaus Thull)
Message-Id: <9011031419.AA01394@fubinf.uucp>
To: nr@Princeton.EDU
Subject: spider.fixes
Status: R

These changes made spider operational on several suns, one old
16bitter 68000 pcs cadmus, one 32bittter 68020 same,
the sony news 68030, and the sony risc.
please note that these changes refer to a version that came to me
out of its own accord one day last summer and without bearing an exact date.
please note that there is the issue of awk versions. I constantly
have to take along one awk source to be sure to compile spider.
please note that there is one extension as well: there is a symbolic
printout in weave which has, in the case of knuths pascal-web,
proven very handy.
::::::::::::::
common.ch
::::::::::::::
module 19

@d buf_size = 200 /* for \.{WEAVE} and \.{TANGLE} */
@d long_buf_size = 500 /* for \.{WEAVE} */


module 26

@d max_modules = 2000 /* number of identifiers, strings, module names;
  must be less than 10240 */


de-linting...
@x module 29
@ @<Add path name from {\tt -I} to search path@>=
	pathaddname(*argv+2);
@ @<Other...@>=
@y
@ @<Add path name from {\tt -I} to search path@>=
	pathaddname(*argv+2);
@ @<Other...@>=
extern char* getenv();
@z


de-linting...
@x module 33
@ The included file name should only contain visible ASCII characters,
@y
@ The included file name should only contain visible ASCII characters,
@z

@x
      if ((cur_file=pathopen(cur_file_name,"r"))==NULL) {
@y
      if ((cur_file=pathopen(cur_file_name))==NULL) {
@z


@d max_bytes = 90000 /* the number of bytes in identifiers,
  index entries, and module names */
@d max_names = 4000 /* number of identifiers, strings, module names;
  must be less than 10240 */

module 42

@d hash_size = 353 /* should be prime */


@x module 62
@ Some implementations may wish to pass the |history| value to the
@y
@ Some implementations may wish to pass the |history| value to the
@z

activate stats
@x
  @<Print the job |history|@>;
@y
#ifdef STAT
  print_stats();
#endif
  @<Print the job |history|@>;
@z

de-linting...
@x
fatal("! Usage: tangle webfile[.web] [changefile[.ch]] [-Ipathname ...]\n",0)@;
else
fatal("! Usage: weave webfile[.web] [changefile[.ch]] [-x] [-Ipathname ...]\n",
	0);
@y
fatal("! Usage: tangle webfile[.web] [changefile[.ch]] [-Ipathname ...]\n",
	"")@;
else
fatal("! Usage: weave webfile[.web] [changefile[.ch]] [-x] [-Ipathname ...]\n",
	"");
@z
::::::::::::::
spider.ch
::::::::::::::

escape backslash...
(and put titles right)
#x module 11
#  We write tokens out to two files: |scrapfile| for \.{WEAVE}, and
#y
#  We write tokens out to two files: |scrapfile| for \.{WEAVE}, and
#z

|ttokfile| for \.{TANGLE}.
#<Set init...#>=
	scrapfile = "scraps.web"
#x
	print "@*Scrap code generated by {\tt SPIDER}." > scrapfile
	ttokfile = "outtoks.web"
	print "@*Token code generated by {\tt SPIDER}." > scrapfile
#y
	print "@*Scrap code generated by {\\tt SPIDER}." > scrapfile
	ttokfile = "outtoks.web"
	print "@*Token code generated by {\\tt SPIDER}." > ttokfile
#z

escape backslash...
#x module 16
# We use a special file to write grammar information:
#<Set init...#>=
	grammarfile = "grammar.web"
	print "@*Grammar code generated by {\tt SPIDER}." > grammarfile
#y
# We use a special file to write grammar information:
#<Set init...#>=
	grammarfile = "grammar.web"
	print "@*Grammar code generated by {\\tt SPIDER}." > grammarfile
#z

escape backslash...
#x module 62
# This is how we write out the string or constant scrap, at the end.
#y
# This is how we write out the string or constant scrap, at the end.
#z

#x
	" and \TeX\ strings are identified." > scrapfile
#y
	" and \\TeX\\ strings are identified." > scrapfile
#z

#x module 72
# We use an ugly trick to get the token numbers different for
#y
# We use an ugly trick to get the token numbers different for
#z

#x
			temp = temp + #'37 - highesttoken ## hackety hack!
#y
			temp = temp + #'37  + 3 - highesttoken ## hackety hack!
				## +3 because three highest are already defined!
#z


#x module 126
# It's desirable to put the production in a comment, but we have to
get rid of the confusing \vert, or \.{WEAVE} will think it introduces
code.
#<Remove \vert\ from |inputline[n]| and put results in |this_string|#>=
		this_string = inputline[n]
		tempi = index(this_string,"|")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\vert " tempb
			tempi = index(this_string,"|")
			}
#y
# It's desirable to put the production in a comment, but we have to
get rid of the confusing \vert, or \.{WEAVE} will think it introduces
code. And of other things as well\dots
#<Remove \vert\ from |inputline[n]| and put results in |this_string|#>=
		tempb = inputline[n]
		tempa = ""
		tempi = index(tempb,"\\")
		while (tempi != 0) {
			tempa = tempa substr(tempb,1,tempi-1) "\\BS "
			tempb = substr(tempb,tempi+1)
			tempi = index(tempb,"\\")
			}
		this_string = tempa tempb
		tempb = this_string
		tempa = ""
		tempi = index(tempb,"##")
		while (tempi != 0) {
			tempa = tempa substr(tempb,1,tempi-1) "\\##"
			tempb = substr(tempb,tempi+1)
			tempi = index(tempb,"##")
			}
		this_string = tempa tempb
		tempb = this_string
		tempa = ""
		tempi = index(tempb,"$")
		while (tempi != 0) {
			tempa = tempa substr(tempb,1,tempi-1) "\\$"
			tempb = substr(tempb,tempi+1)
			tempi = index(tempb,"$")
			}
		this_string = tempa tempb
		tempb = this_string
		tempa = ""
		tempi = index(tempb,"%")
		while (tempi != 0) {
			tempa = tempa substr(tempb,1,tempi-1) "\\%"
			tempb = substr(tempb,tempi+1)
			tempi = index(tempb,"%")
			}
		this_string = tempa tempb
		tempb = this_string
		tempa = ""
		tempi = index(tempb,"^")
		while (tempi != 0) {
			tempa = tempa substr(tempb,1,tempi-1) "\\^"
			tempb = substr(tempb,tempi+1)
			tempi = index(tempb,"^")
			}
		this_string = tempa tempb
		tempb = this_string
		tempa = ""
		tempi = index(tempb,"@")
		while (tempi != 0) {
			tempa = tempa substr(tempb,1,tempi-1) "\\@@"
			tempb = substr(tempb,tempi+1)
			tempi = index(tempb,"@")
			}
		this_string = tempa tempb
		tempi = index(this_string,"|")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\vert " tempb
			tempi = index(this_string,"|")
			}
		tempi = index(this_string,"'")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\RQ " tempb
			tempi = index(this_string,"'")
			}
		tempi = index(this_string,"`")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\LQ " tempb
			tempi = index(this_string,"`")
			}
		tempi = index(this_string,"{")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\LB " tempb
			tempi = index(this_string,"{")
			}
		tempi = index(this_string,"}")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\RB " tempb
			tempi = index(this_string,"}")
			}
		tempi = index(this_string,"~")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\TL " tempb
			tempi = index(this_string,"~")
			}
		tempi = index(this_string,"_")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\UL " tempb
			tempi = index(this_string,"_")
			}
		tempi = index(this_string,"&")
		while (tempi != 0) {
			tempa = substr(this_string,1,tempi-1)
			tempb = substr(this_string,tempi+1)
			this_string = tempa "\\AM " tempb
			tempi = index(this_string,"&")
			}
#z


activate this if year is field no 8

 x module 151
#*1Tracking the generation date.
 y
#*1Tracking the generation date.
 z

 x
	year = $7
 y
	year = $8
 z

::::::::::::::
tangle.ch
::::::::::::::

@ The following parameters were sufficient in the original \.{TANGLE} to
handle \TeX, so they should be sufficient for most applications of \.{TANGLE}.

If you change |max_bytes|, |max_names| or |hash_size| you should also
change them in the file |"common.web"|.

@d max_bytes = 90000 /* the number of bytes in identifiers,
  index entries, and module names; used in |"common.web"| */
@d max_toks = 150000 /* number of bytes in compressed \cee\ code */
@d max_names = 4000 /* number of identifiers, strings, module names;
  must be less than 10240; used in |"common.web"| */
@d max_texts = 2000 /* number of replacement texts, must be less than 10240 */
@d hash_size = 353 /* should be prime; used in |"common.web"| */
@d longest_name = 400 /* module names shouldn't be longer than this */
@d stack_size = 50 /* number of simultaneous levels of macro expansion */
@d buf_size = 100 /* for \.{WEAVE} and \.{TANGLE} */

de-linting...
@x
@ Here's the procedure that decides whether a name of length |l|
starting at position |first| equals the identifier pointed to by |p|:

@u
names_match(p,first,l)
name_pointer p; /* points to the proposed match */
ASCII *first; /* position of first character of string */
int l; /* length of identifier */
@y
@ Here's the procedure that decides whether a name of length |l|
starting at position |first| equals the identifier pointed to by |p|:

@u
names_match(p,first,l,t)
name_pointer p; /* points to the proposed match */
ASCII *first; /* position of first character of string */
int l; /* length of identifier */
eight_bits t; /* which is a dummy but lint complains */
  /* it will still complain \dots */
@z



12-char significance
@x module 110
@ We use macros with zero or more parameters, and we give the parameters names.
@y
@ We use macros with zero or more parameters, and we give the parameters names.
@z

@x
@d max_param_name_texts = 256
@y

Identifier conflict with PCS C\dots

@d param_name_texts_end = p_nm_txts_end
@d next_param_name_text = next_p_nm_txt
@#
@d max_param_name_texts = 256
@z

de-linting
@x
@ This function prints out a decimal constant using |app_repl|.
@u
app_decimal(c)
	int c; /* on entry require |c>=0| */
{int power;
@y
@ This function prints out a decimal constant using |app_repl|.
This casting trick is due to Tim Morgan's WEB-C.

@d app_decimal(x) = zapp_decimal((long)(x))

@u
zapp_decimal(c)
	long c; /* on entry require |c>=0| */
{long power;
@z
::::::::::::::
weave.ch
::::::::::::::

@x module 1
#ifdef STAT
  @<Print statistics about memory usage@>;
#endif STAT
@y
@z

module 2
@ The following parameters were sufficient in the original \.{WEAVE} to
handle \TeX, so they should be sufficient for most applications of \.{CWEAVE}.

@d max_bytes = 90000 /* the number of bytes in identifiers,
  index entries, and module names */
@d max_names = 4000 /* number of identifiers, strings, module names;
  must be less than 10240 */
@d max_modules = 2000 /* greater than the total number of modules */
@d hash_size = 353 /* should be prime */
@d buf_size = 100 /* maximum length of input line, plus one */
@d longest_name = 400 /* module names and strings shouldn't be longer than this */
@d long_buf_size = 500 /* |buf_size+longest_name| */
@d line_length = 80 /* lines of \TeX\ output have at most this many characters;
  should be less than 256 */
@d max_refs = 20000 /* number of cross-references; must be less than 65536 */
@d max_toks = 20000 /* number of symbols in \cee\ texts being parsed;
  must be less than 65536 */
@x
@d max_texts = 2000 /* number of phrases in \cee\ texts being parsed;
  must be less than 10240 */
@d max_scraps = 1000 /* number of tokens in \cee\ texts being parsed */
@y
@d max_texts = 4000 /* number of phrases in \cee\ texts being parsed;
  must be less than 10240 */
@d max_scraps = 4000 /* number of tokens in \cee\ texts being parsed */
@z
@d stack_size = 400 /* number of simultaneous output levels */

@x
/* identifier =200 or octal @'310 */
@y
/* identifier =200 or octal |@'310| */
@z

@x module 57
@ In the \TeX\ part of a module, cross-reference entries are made only for
@y
@ In the \TeX\ part of a module, cross-reference entries are made only for
@z

@x doesn't belong here
#ifdef DEBUG
    case trace: tracing=next_control-'0'; continue;
#endif DEBUG
@y
@z


Print symbolically the entire tree

@x module 87
@ Token lists in |@!tok_mem| are composed of the following kinds of
@y
@ Token lists in |@!tok_mem| are composed of the following kinds of
@z


@u
#ifdef DEBUG
@x
print_text(p) /* prints a token list */
text_pointer p;
@y
print_text(p,ind) /* prints a token list */
text_pointer p;
int ind;
@z
{
  token_pointer j; /* index into |tok_mem| */
  sixteen_bits r; /* remainder of token after the flag has been stripped off */
  if (p>=text_ptr) printf("BAD");
  if (p>=text_ptr) printf("BAD");
  else for (j=*p; j<*(p+1); j++) {
    r=*j%id_flag;
    r=*j%id_flag;
    switch (*j/id_flag) {
      case 1: printf("\\{"); print_id((name_dir+r)); printf("}"); break;
 /* |id_flag| */
      case 2: printf("\&{"); print_id((name_dir+r)); printf("}"); break;
 /* |res_flag| */
      case 3: printf("<"); print_id((name_dir+r)); printf(">"); break;
        /* |mod_flag| */
@x
      case 4: printf("[[%d]]",r); break; /* |tok_flag| */
      case 5: printf("|[[%d]]|",r); break; /* |inner_tok_flag| */
@y
      case 4:  /* we make this a recursive prettyprinting here */
		printf("@@/\n");
		{ int i; for (i=0; i<ind; i++) printf(" "); }
		printf("[[%d:",r);
		print_text(r+tok_start,ind+1);
		printf("]]");
		break; /* |tok_flag| */
      case 5:
		printf("@@/\n");
		{ int i; for (i=0; i<ind; i++) printf(" "); }
		printf("|[[%d:",r);
		print_text(r+tok_start,ind+1);
		printf("]]|");
		break; /* |inner_tok_flag| */
@z
      default: @<Print token |r| in symbolic form@>;
    }
  }
}
#endif DEBUG

@x module 106
@ @<If semi-tracing, show the irreducible scraps@>=
#ifdef DEBUG
@y
@ @<If semi-tracing, show the irreducible scraps@>=
#ifdef DEBUG
  if (tracing==2)
  {
    scrap_pointer k;
    printf("\nafter...\n");
    for (k=scrap_base; k<=lo_ptr; k++)
    { print_cat(k->cat); printf(", %ld:<",(long)(k->trans-tok_start)); 
      print_text(k->trans,0); printf(">");
    }
    new_line;
  }
@z
if (lo_ptr>scrap_base && tracing==1) {
  printf("\nIrreducible scrap sequence in section %d:",module_count);
  mark_harmless;
  for (j=scrap_base; j<=lo_ptr; j++) {
    printf(" "); print_cat(j->cat);
  }
}
#endif DEBUG

@x module 107
@ @<If tracing,...@>=
#ifdef DEBUG
if (tracing==2) {
  printf("\nTracing after l. %d:\n",cur_line); mark_harmless;
  if (loc>buffer+50) {
    printf("...");
    ASCII_write(loc-51,51);
  }
  else ASCII_write(buffer+1,loc-buffer);
}
#endif DEBUG
@y
@ @<If tracing,...@>=
#ifdef DEBUG
if (tracing==2) {
  scrap_pointer k;
  printf("\nTracing after l. %d:\n",cur_line); mark_harmless;
  if (loc>buffer+50) {
    printf("...");
    ASCII_write(loc-51,51);
  }
  else ASCII_write(buffer,loc-buffer);
  printf("\nbefore...\n");
  for (k=scrap_base; k<scrap_ptr; k++)
  { print_cat(k->cat); printf(", %ld:<",(long)(k->trans-tok_start)); 
    print_text(k->trans,0); printf(">\n");
  }
  new_line;
}
#endif DEBUG
@z

@x module 144
@ In the \TeX\ part of a module, we simply copy the source text, except that
@y
@ In the \TeX\ part of a module, we simply copy the source text, except that
@z

@x
    case vertical_bar: /* surround vertical bar with \.{\\CD...\\DC} */
@y
#ifdef DEBUG
    case trace: tracing=*(loc-1)-'0'; continue;
#endif DEBUG
    case vertical_bar: /* surround vertical bar with \.{\\CD...\\DC} */
@z



@x module 262
@ @<Print statistics about memory usage@>=
printf(
"\nMemory usage statistics: %d of %d names, %d of %d cross-references,\n",
  name_ptr-name_dir, name_dir_end-name_dir,
  xref_ptr-xmem, xmem_end-xmem);
printf("\t %d of %d bytes;",byte_ptr-byte_mem,byte_mem_end-byte_mem);
printf("\nParsing required %d of %d(%d) scraps, %d of %d(%d) texts,\n",
  max_scr_ptr-scrap_info, max_scraps, max_scraps-SCRAP_SLACK,
  max_text_ptr-tok_start, max_texts, max_texts-TEXT_SLACK
  );
printf("\t %d of %d(%d) tokens, %d of %d levels;\n",
  max_tok_ptr-tok_mem, max_toks, max_toks-TOK_SLACK,
  max_stack_ptr-stack, stack_end-stack
  );
printf("\nSorting required %d levels\n", max_sort_ptr-scrap_info);
@y
@ @u print_stats() {
#ifdef STAT
printf(
"\nMemory usage statistics: %d of %d names, %d of %d cross-references,\n",
  name_ptr-name_dir, name_dir_end-name_dir,
  xref_ptr-xmem, xmem_end-xmem);
printf("\t %d of %d bytes;",byte_ptr-byte_mem,byte_mem_end-byte_mem);
printf("\nParsing required %d of %d(%d) scraps, %d of %d(%d) texts,\n",
  max_scr_ptr-scrap_info, max_scraps, max_scraps-SCRAP_SLACK,
  max_text_ptr-tok_start, max_texts, max_texts-TEXT_SLACK
  );
printf("\t %d of %d(%d) tokens, %d of %d levels;\n",
  max_tok_ptr-tok_mem, max_toks, max_toks-TOK_SLACK,
  max_stack_ptr-stack, stack_end-stack
  );
printf("\nSorting required %d levels\n", max_sort_ptr-scrap_info);
#endif
}
@z

@x
#ifdef STAT
  @<Print statistics about memory usage@>;
#endif STAT
@y
@z