1CWEB(1) General Commands Manual CWEB(1)
2
3
4
6 ctangle, cweave - translate CWEB to C/C++ and/or TeX
7
9 ctangle [options] webfile[.w] [{changefile[.ch]|-} [outfile[.c]]]
10 cweave [options] webfile[.w] [{changefile[.ch]|-} [outfile[.tex]]]
11
13 The ctangle program converts a CWEB source document into a C/C++ pro‐
14 gram that may be compiled in the usual way. The output file includes
15 #line specifications so that debugging can be done in terms of the CWEB
16 source file.
17
18 The cweave program converts the same CWEB file into a TeX file that may
19 be formatted and printed in the usual way. It takes appropriate care
20 of typographic details like page layout and the use of indentation,
21 italics, boldface, etc., and it supplies extensive cross-index informa‐
22 tion that it gathers automatically.
23
24 CWEB allows you to prepare a single document containing all the infor‐
25 mation that is needed both to produce a compilable C/C++ program and to
26 produce a well-formatted document describing the program in as much de‐
27 tail as the writer may desire. The user of CWEB ought to be familiar
28 with TeX as well as C/C++.
29
31 The command line should have one, two, or three names on it. The first
32 is taken as the CWEB input file (and .w is added if there is no exten‐
33 sion). If there is a second name, it is a change file (and .ch is
34 added if there is no extension). The change file overrides parts of
35 the CWEB file, as described in the documentation. If there is a third
36 name, it overrides the default name of the output file, which is ordi‐
37 narily the same as the name of the input file (but on the current di‐
38 rectory) with the extension .tex. If you just want to change the out‐
39 put file name, but don’t have a change file to apply, you can use `-'
40 as the second argument.
41
43 CWEBbin tries hard to be a drop-in replacement for CWEB, so in general
44 you should not notice any differences in invoking the programs nor in
45 the resulting output. There are, however, a few differences worth not‐
46 ing:
47
48 • Options --help, --quiet, --verbose, --version, and flags +c, -i, -o,
49 and +lX are new in CWEBbin and TeX Live.
50
51 • Option +lX is accompanied by several wrapper files for cwebmac.tex
52 with translated captions for German (+ld), French (+lf), and Italian
53 (+li).
54
55 • CWEB in TeX Live operates silently by default (as of 2019); use the
56 --verbose option to get the original behavior.
57
58 • File lookup with the environment variable CWEBINPUTS is extended to
59 permit several, colon-separated, paths; see ENVIRONMENT below.
60
61 • If properly configured, the main programs ctangle and cweave are lo‐
62 calized with the “GNU gettext utilities”.
63
65 Options on the command line may be either turned off with `-' (if they
66 are on by default) or turned on with `+' (if they are off by default).
67 In fact, the options are processed from left to right, so a sequence
68 like --verbose -h will only show the banner line (+b) and the progress
69 report (+p), but leave out the happy message (-h).
70
71 The first batch of options are common to both ctangle and cweave:
72
73 • +b: print banner line on terminal
74
75 • +h: print success message on completion
76
77 • +p: print progress report messages
78
79 • +q/-q: shortcut for -bhp; also --quiet (default)
80
81 • +v/-v: shortcut for +bhp; also --verbose
82
83 • +c: check temporary output for changes
84
85 • +s: print usage statistics
86
87 • --help: display help message and exit
88
89 • --version: output version information and exit
90
91 There is one other option applicable to ctangle only:
92
93 • +k: keep separators in numeric literals in the output
94
95 There are seven other options applicable to cweave only:
96
97 • -e: do not enclose C/C++ material in \PB{...}
98
99 • -f: do not force a newline after every C/C++ statement in output
100
101 • -i: suppress indentation of parameter declarations
102
103 • -o: suppress separation of declarations and statements
104
105 • -x: omit indices, section names, table of contents
106
107 • +lX/-lX: use macros for language X as of Xcwebmac.tex
108
109 • +t: treat typename in a template like typedef
110
112 The environment variable CWEBINPUTS is used to search for the input
113 files, or the system default if CWEBINPUTS is not set. See tex(1) for
114 the details of the searching. To avoid conflicts with other programs
115 that also use the CWEBINPUTS environment, you can be more specific and
116 use CWEBINPUTS_cweb for special requirements in CWEB.
117
118 If prepared for NLS support, ctangle and cweave use the environment
119 variable TEXMFLOCALEDIR to configure the parent directory where the
120 “GNU gettext utilities” search for translation catalogs.
121
122 These variables are preconfigured in TeX Live’s texmf.cnf.
123
125 The location of the files mentioned below varies from system to system.
126 Use the kpsewhich utility to find their locations.
127
128 • cwebmac.tex: The default TeX macros \input in the first line of the
129 cweave output file.
130
131 • cwebman.tex: The CWEB user manual, available in PDF from CTAN
132 (https://ctan.org/pkg/cweb).
133
135 • The CWEB System of Structured Documentation: by Donald E. Knuth and
136 Silvio Levy (hardcopy version of cwebman.tex and the source code
137 listings of common.w, ctangle.w, and cweave.w).
138
139 • Literate Programming: by D. E. Knuth.
140
141 • Weaving a Program: by Wayne Sewell.
142
143 cweb(1), tex(1), cc(1)
144
146 Don Knuth wrote WEB for TeX and Pascal.
147 Silvio Levy designed and developed CWEB by adapting the WEB conventions
148 to C and by recoding everything in CWEB. Knuth began using CWEB and
149 made further refinements.
150 Many other helpers are acknowledged in the CWEB manual.
151 Contemporary development on https://github.com/ascherer/cweb.
152
153
154
155Web2c 2022 July 27, 2021 CWEB(1)