Skip to content

Commit

Permalink
Testcase for CTWILL.
Browse files Browse the repository at this point in the history
Trying to recreate the example from the text "Mini-Indexes for Literate
Programs," in Don E. Knuth, "Digital Typography," pp. 225--245.

gb_graph.hux and gb_save.hux were created by hand from gb_graph.aux and
gb_save.aux resulting from 'ctwill gb_graph' and 'ctwill gb_save' on the
SGB source modules.

ham.bux @i'ncludes these two files.

ham.ch adapts ham.w to the CTWILL conventions.

system.bux comes from CWEBbin and was slightly amended.

Recipe:

$> ctwill ham ham # prime the pump
$> ctwill ham ham # produce results
$> pdftex ham # requires ctwimac.tex from CTWILL/CWEBbin
$> refsort < ham.ref > ham.sref
$> pdftex ham

This should produce a 4-page PDF document for HAM.  Note that the CWEB
code presented here differs from the code in the book.
  • Loading branch information
ascherer committed Feb 5, 2019
1 parent 986e7d1 commit ce43526
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
28 changes: 28 additions & 0 deletions gb_graph.hux
@@ -0,0 +1,28 @@
@$tip {GB\_\,GRAPH}10 \&{Vertex} ${}{*}{}$@>
@$next {GB\_\,GRAPH}10 \&{Arc} ${}{*}{}$@>
@$arcs {GB\_\,GRAPH}9 \&{Arc} ${}{*}{}$@>
@$name {GB\_\,GRAPH}9 \&{char} ${}{*}{}$@>
@$n {GB\_\,GRAPH}13 \&{long}@>
@$vertices {GB\_\,GRAPH}20 \&{Vertex} ${}{*}{}$@>
@$I {GB\_\,GRAPH}8 \&{long}@>
@$m {GB\_\,GRAPH}13 \&{long}@>
@$V {GB\_\,GRAPH}8 \&{Vertex} ${}{*}{}$@>
@$A {GB\_\,GRAPH}8 \&{Arc} ${}{*}{}$@>
@$w {GB\_\,GRAPH}9 \&{util}@>

@$util {GB\_\,GRAPH}8 =\&{union}@>
@$Vertex {GB\_\,GRAPH}9 =\&{struct}@>
@$Arc {GB\_\,GRAPH}10 =\&{struct}@>
@$gb_typed_alloc {GB\_\,GRAPH}11 =macro (\,)@>
@$Graph {GB\_\,GRAPH}20 =\&{struct}@>
@$n_1 {GB\_\,GRAPH}22 =macro@>
@$arcs_per_block {GB\_\,GRAPH}29 =\T{102}@>
@$gb_new_graph {GB\_\,GRAPH}31 =macro@>
@$gb_new_arc {GB\_\,GRAPH}31 =macro@>
@$gb_new_edge {GB\_\,GRAPH}31 =macro@>
@$siz_t {GB\_\,GRAPH}34 =\&{unsigned} \&{long}@>
@$string_block_size {GB\_\,GRAPH}35 =\T{1016}@>
@$hash_link {GB\_\,GRAPH}43 =macro@>
@$hash_head {GB\_\,GRAPH}43 =macro@>
@$HASH_MULT {GB\_\,GRAPH}45 =\T{314159}@>
@$HASH_PRIME {GB\_\,GRAPH}45 =\T{516595003}@>
21 changes: 21 additions & 0 deletions gb_save.hux
@@ -0,0 +1,21 @@
@$restore_graph {GB\_\,SAVE}4 \&{Graph} ${}{*}(\,){}$@>

@$MAX_SV_STRING {GB\_\,SAVE}1 =\T{4095}@>
@$MAX_SV_ID {GB\_\,SAVE}1 =\T{154}@>
@$panic {GB\_\,SAVE}5 =macro (\,)@>
@$fillin {GB\_\,SAVE}7 =macro (\,)@>
@$buffer {GB\_\,SAVE}13 =macro@>
@$bad_type_code {GB\_\,SAVE}19 =\T{\^1}@>
@$string_too_long {GB\_\,SAVE}19 =\T{\^2}@>
@$addr_not_in_data_area {GB\_\,SAVE}19 =\T{\^4}@>
@$addr_in_mixed_block {GB\_\,SAVE}19 =\T{\^8}@>
@$bad_string_char {GB\_\,SAVE}19 =\T{\^10}@>
@$ignored_data {GB\_\,SAVE}19 =\T{\^20}@>
@$unk {GB\_\,SAVE}21 =\T{0}@>
@$ark {GB\_\,SAVE}21 =\T{1}@>
@$vrt {GB\_\,SAVE}21 =\T{2}@>
@$mxt {GB\_\,SAVE}21 =\T{3}@>
@$block_rep {GB\_\,SAVE}21 =\&{struct}@>
@$lookup {GB\_\,SAVE}25 =macro (\,)@>
@$append_comma {GB\_\,SAVE}37 =macro@>
@$trans {GB\_\,SAVE}39 =macro (\,)@>
2 changes: 2 additions & 0 deletions ham.bux
@@ -0,0 +1,2 @@
@i gb_graph.hux
@i gb_save.hux
17 changes: 17 additions & 0 deletions ham.ch
@@ -0,0 +1,17 @@
@x
\datethis
@y
\def\title{HAM}
@z

@x
I may learn my lesson.
@y
I may learn my lesson.
@-k@>
@z

@x
@*Index.
@y
@z
41 changes: 41 additions & 0 deletions system.bux
@@ -0,0 +1,41 @@
@$memcmp "<string.h>" \zip@>
@$strcat "<string.h>" \zip@>
@$strcmp "<string.h>" \zip@>
@$strcpy "<string.h>" \zip@>
@$strlen "<string.h>" \zip@>
@$strncmp "<string.h>" \zip@>
@$strncpy "<string.h>" \zip@>

@$BUFSIZ "<stdio.h>" \zip@>
@$fclose "<stdio.h>" \zip@>
@$feof "<stdio.h>" \zip@>
@$fflush "<stdio.h>" \zip@>
@$fopen "<stdio.h>" \zip@>
@$fprintf "<stdio.h>" \zip@>
@$fputs "<stdio.h>" \zip@>
@$fread "<stdio.h>" \zip@>
@$fwrite "<stdio.h>" \zip@>
@$printf "<stdio.h>" \zip@>
@$putc "<stdio.h>" \zip@>
@$putchar "<stdio.h>" \zip@>
@$puts "<stdio.h>" \zip@>
@$rename "<stdio.h>" \zip@>
@$remove "<stdio.h>" \zip@>
@$sprintf "<stdio.h>" \zip@>
@$sscanf "<stdio.h>" \zip@>
@$stdout "<stdio.h>" \zip@>
@$stderr "<stdio.h>" \zip@>

@$exit "<stdlib.h>" \zip@>

@$isalpha "<ctype.h>" \zip@>
@$isdigit "<ctype.h>" \zip@>
@$islower "<ctype.h>" \zip@>
@$isspace "<ctype.h>" \zip@>
@$isupper "<ctype.h>" \zip@>
@$isxdigit "<ctype.h>" \zip@>
@$tolower "<ctype.h>" \zip@>
@$toupper "<ctype.h>" \zip@>

@$gettext "<libintl.h>" \zip@>
@$textdomain "<libintl.h>" \zip@>

0 comments on commit ce43526

Please sign in to comment.