--- cwebx-3.04.orig/man1/ctanglex.1
+++ cwebx-3.04/man1/ctanglex.1
@@ -0,0 +1 @@
+.so man1/cwebx.1
--- cwebx-3.04.orig/man1/cweavex.1
+++ cwebx-3.04/man1/cweavex.1
@@ -0,0 +1 @@
+.so man1/cwebx.1
--- cwebx-3.04.orig/man1/cweb.1
+++ cwebx-3.04/man1/cweb.1
@@ -1,69 +1,73 @@
-.TH WEB 1L 7/12/90
+.TH CWEBX 1 7/12/90
 .SH NAME
-ctangle, cweave \- translate CWEB to C (or C++) and/or TeX
+ctanglex, cweavex \- translate CWEB(x) to C (or C++) and/or TeX
 .SH SYNOPSIS
-.B ctangle
+.B ctanglex
 [
 .B \-bhpl
 ] [
 .B \+cs+
-] cwebfile[.w] [(changefile[.ch]|+|-) [outputfile[.c]]]
+] \fIcwebfile\fR[.w] [(\fIchangefile\fR[.ch]|+|-) [\fIoutputfile\fR[.c]]]
 .br
-.B cweave
+.B cweavex
 [
 .B \-bhpx
 ] [
 .B \+cs+dtefauwm
 ] [
 .B +isearchpath
-] cwebfile[.w] [(changefile[.ch]|+|-) [outputfile[.tex]]]
+] \fIcwebfile\fR[.w] [(\fIchangefile\fR[.ch]|+|-) [\fIoutputfile\fR[.tex]]]
 
 .SH DESCRIPTION
 The
-.I ctangle
-program converts a CWEB
+.B ctanglex
+program converts a CWEB(x)
 source document into a C program that may be compiled in the usual way.
-The output file includes #line specifications so that error reporting and
-debugging can be done in terms of the CWEB source file.
+The output file includes \fI#line\fR specifications so that error
+reporting and debugging can be done in terms of the CWEB(x) source file.
 .PP
 The
-.I cweave
-program converts the same CWEB file into a TeX file that may be
+.B cweavex
+program converts the same CWEB(x) file into a TeX file that may be
 formatted and printed in the usual way.
 It takes appropriate care of typographic details like page layout
 and the use of indentation, italics, boldface, etc., and it supplies
 extensive cross-reference information that it gathers automatically.
 .PP
-CWEB allows you to prepare a single
+CWEBx allows you to prepare a single
 document containing all the information that is needed both to produce
 a compilable C program and to produce a well-formatted document
 describing the program in as much detail as the writer may desire.  The
-user of CWEB ought to have some familiarity with TeX as well as knowledge
+user of CWEBx ought to have some familiarity with TeX as well as knowledge
 of C.
 .PP
 The command line should have one, two, or three names on it. The first is
-taken as the CWEB file (and `.w' is added if there is no extension). If that
-file cannot be opened, the extension `.web' is tried instead. If there is a
-second name, it is a change file (and `.ch' is added if there is no
-extension), otherwise the name of the CWEB file with its extension replaced
-by `.ch' is tried as change file name; if there no such file, no change file
-is used. Instead of a change file one may specify `-' or `+'; `-' means do
-not use a change file, and `+' means use a change file only if a file of the
+taken as the CWEB(x) file (and `\fI.w\fR' is added if there is no
+extension). If that file cannot be opened, the extension `\fI.web\fR'
+is tried instead. If there is a second name, it is a change file (and
+`\fI.ch\fR' is added if there is no extension), otherwise the name of
+the CWEB(x) file with its extension replaced by `\fI.ch\fR' is tried as
+change file name; if there no such file, no change file
+is used. Instead of a change file one may specify `\fB-\fR' or
+`\fB+\fR'; `\fB-\fR' means do not use a change file, and `\fB+\fR'
+means use a change file only if a file of the
 default name exists (just as if only one name was given). The change file
-overrides parts of the CWEB file, as described in the documentation. A third
-name, if present, specifies the output file name explicitly. The default
-output file name is that of the CWEB file with extension `.c' (for
-.I ctangle
-) or `.tex' (for
-.I cweave
+overrides parts of the CWEB(x) file, as described in the
+documentation. A third name, if present, specifies the output file
+name explicitly. The default output file name is that of the CWEB(x)
+file with extension `\fI.c\fR' (for
+.B ctanglex
+) or `\fI.tex\fR' (for
+.B cweavex
 ); the default extension is also applied if a third
 name is given without extension.
 .PP
-Options in the command line may be either turned on with `+'
-and off with `-'; several characters may follow in the same argument, which
+Options in the command line may be either turned on with `\fB+\fR' and
+off with `\fB-\fR'; several characters may follow in the same argument, which
 indicate several options that are turned on respectively off simultaneously.
 In fact, the options are processed from left to right,
-so a sequence like `-b +b' is equivalent to `+b' (which is the default).
+so a sequence like `\fB-b +b\fR' is equivalent to `\fB+b\fR' (which is
+the default).
 .PP
 The
 .B \+b
@@ -72,7 +76,8 @@
 option shows a happy message if the processing was successful. The
 .B \+p
 option shows progress reports (starred module numbers) as the processing
-takes place. If you say `-bhp', you get no terminal output but error messages.
+takes place. If you say `\fB-bhp\fR', you get no terminal output but
+error messages.
 .PP
 The
 .B \+c
@@ -80,7 +85,8 @@
 The
 .B \+s
 option prints statistics about memory usage at the end of a run
-(assuming that the programs have been compiled with the -DSTAT switch).
+(assuming that the programs have been compiled with the \fI-DSTAT\fR
+switch, as they are by default on Debian systems).
 By setting the option
 .B \++
 one can select the C++ language instead of C.
@@ -88,19 +94,19 @@
 The option
 .B \-l
 is applicable to
-.I ctangle
+.B ctanglex
 only; when selected, the C output is made more readable for humans by omitting
 .B #line
 directives and preserving layout and comments.
 .PP
 There are several other options applicable to
-.I cweave
+.B cweavex
 only. The option
 .B \-x
 means omit the index and table of contents. By setting the option
 .B \+d
 one causes
-.I cweave
+.B cweavex
 to report problems encountered in parsing the program fragments. With
 .B \+t
 the the index and module names will be written to separate files. With
@@ -144,17 +150,30 @@
 right.
 .PP
 .SH FILES
-/usr/local/lib/tex/macros/cwebxmac.tex    TeX macros used by cweave output.
+.I /usr/share/texmf/macros/litprog/cwebxmac.tex
+TeX macros used by cweavex output.
 .br
-/usr/local/lib/tex/macros/cwebcmac.tex    TeX macros used in compatibility
-mode.
+.I /usr/share/texmf/macros/litprog/cwebcmac.tex
+TeX macros used in compatibility mode.
 .br
-/usr/local/doc/cweb/manual.tex    The user manual.
+.I /usr/share/texmf/macros/litprog/cwebhmac.tex
+TeX macros which can be input after \fIcwebxmac\fR to produce
+hyperlinks in the output.
+.br
+.I /usr/doc/cwebx/manual.tex
+The user manual source.
+.br
+.I /usr/doc/cwebx/manual.tex
+The user manual in DVI format.
 .SH "SEE ALSO"
 .I Literate Programming
 by D. E. Knuth. (CSLI, Stanford, 1992)
 .br
-tex(1), cc(1), web(1)
+.BR tex (1),
+.BR cc (1),
+.BR cweb (1)
+and
+.BR web (1).
 .SH "AUTHORS"
 Don Knuth wrote WEB for TeX and Pascal. Silvio Levy designed and developed
 CWEB by adapting the WEB conventions to C and by recoding everything in CWEB.
--- cwebx-3.04.orig/Makefile
+++ cwebx-3.04/Makefile
@@ -10,20 +10,22 @@
 
 # We let CWEAVE report syntax errors by setting +d.
 # The flag +m makes the TeX output slightly more compact.
-# We use the +e flag since our printer is two-sided.
 
-CWFLAGS = +mde
+CWFLAGS = +md
 CTFLAGS =
 
 # We keep debugging info around to enable the `+d' option of cweave
-CFLAGS = -DDEBUG -DSTAT -g
-
-# RM and CP are used below in case rm and cp are aliased
-
-RM= /bin/rm
-CP= /bin/cp
-RENAME= /bin/mv
-
+CFLAGS = -DDEBUG -DSTAT -g -Wall
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+CFLAGS += -O0
+else
+CFLAGS += -O2
+endif
+
+# This is handled by debhelper's dh_strip
+# ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+# INSTALL_PROGRAM += -s
+# endif
 
 # Set CCHANGES to common-foo.ch if you need changes to common.w in another
 # file than common.ch
@@ -69,32 +71,33 @@
 manual doc: manual.dvi
 listings: common.dvi ctangle.dvi cweave.dvi
 
-cautiously:
+cautiously: ctangle
 	make common.c ctangle.c cweave.c
-	$(RENAME) ctangle SAVEctangle # save version in case things mess up
+	mv ctangle SAVEctangle # save version in case things mess up
 	make ctangle
-	$(RENAME) common.c SAVEcommon.c
+	mv common.c SAVEcommon.c
 	./ctangle common $(CCHANGES)
 	diff common.c SAVEcommon.c
-	$(RENAME) SAVEcommon.c common.c # restore date
-	$(RENAME) ctangle.c SAVEctangle.c
+	mv SAVEcommon.c common.c # restore date
+	mv ctangle.c SAVEctangle.c
 	./ctangle ctangle $(TCHANGES)
 	diff ctangle.c SAVEctangle.c
-	$(RENAME) SAVEctangle.c ctangle.c # restore date
-	$(RENAME) cweave.c SAVEcweave.c
+	mv SAVEctangle.c ctangle.c # restore date
+	mv cweave.c SAVEcweave.c
 	./ctangle cweave $(WCHANGES)
 	diff cweave.c SAVEcweave.c
-	$(RENAME) SAVEcweave.c cweave.c # restore date
-	$(RM) SAVEctangle # succeeded, use new binary from now on
+	mv SAVEcweave.c cweave.c # restore date
+	rm SAVEctangle # succeeded, use new binary from now on
 
 SAVEctangle.c:
-	$(CP) ctangle.c SAVEctangle.c
+	cp ctangle.c SAVEctangle.c
 
 SAVEcommon.c:
-	$(CP) common.c SAVEcommon.c
+	cp common.c SAVEcommon.c
 
 common.c: common.w $(CCHANGES) common.inc
 	$(CTANGLE) common $(CCHANGES)
+
 common.h: common.w $(CCHANGES)
 	$(CTANGLE) common $(CCHANGES)
 
@@ -120,3 +123,21 @@
 	$(CWEAVE) cweave $(WCHANGES)
 
 manual.dvi: compare.tex
+
+# Debian additions: we need a clean and install target of course!!
+
+# Are we going to suffix an `x' on the end of filenames to distinguish
+# CWEBx from K&L CWEB?
+DESTPREF=x
+
+INSTALLROOT=debian/cwebx
+BINDIR=$(INSTALLROOT)/usr/bin
+MACRODIR=$(INSTALLROOT)/usr/share/texmf/tex/plain/litprog
+
+clean:
+	-rm -f *.dvi *.log *.o ctangle cweave cweave.c manual.toc
+
+install:
+	cp cweave $(BINDIR)/cweave$(DESTPREF)
+	cp ctangle $(BINDIR)/ctangle$(DESTPREF)
+	cp cweb?mac.tex $(MACRODIR)
--- cwebx-3.04.orig/common.c
+++ cwebx-3.04/common.c
@@ -846,7 +846,9 @@
 break;default:/*105:*/
 #line 1688 "common.w"
 fatal("! Usage:\n"
-"c%se [(+|-)options] cwebfile[.w] [(changefile[.ch]|+|-) [outputfile[.%s]]]"
+#line 14 "common.ch"
+"c%sex [(+|-)options] cwebfile[.w] [(changefile[.ch]|+|-) [outputfile[.%s]]]"
+#line 1690 "common.w"
 ,program==ctangle?"tangl":"weav"
 ,program==ctangle?"c":"tex");/*:105*/
 #line 1581 "common.w"
@@ -855,7 +857,9 @@
 if(files_found==0)/*105:*/
 #line 1688 "common.w"
 fatal("! Usage:\n"
-"c%se [(+|-)options] cwebfile[.w] [(changefile[.ch]|+|-) [outputfile[.%s]]]"
+#line 14 "common.ch"
+"c%sex [(+|-)options] cwebfile[.w] [(changefile[.ch]|+|-) [outputfile[.%s]]]"
+#line 1690 "common.w"
 ,program==ctangle?"tangl":"weav"
 ,program==ctangle?"c":"tex");/*:105*/
 #line 1584 "common.w"
--- cwebx-3.04.orig/common.ch
+++ cwebx-3.04/common.ch
@@ -0,0 +1,15 @@
+% Change file for common.w, written by jdg@debian.org, original
+% version on 15/5/97
+%
+% This change reflects the fact that these two programs will be
+% installed as cweavex and ctanglex, instead of the normal cweave and
+% ctangle, so the error messages should reflect this.  I don't care
+% that the banner line says `This is CTANGLE (Version x3.04)' or
+% whatever, as that already makes it clear that this is CWEBx and not
+% K&L CWEB.
+%
+@x
+"c%se [(+|-)options] cwebfile[.w] [(changefile[.ch]|+|-) [outputfile[.%s]]]"
+@y
+"c%sex [(+|-)options] cwebfile[.w] [(changefile[.ch]|+|-) [outputfile[.%s]]]"
+@z
--- cwebx-3.04.orig/manual.tex
+++ cwebx-3.04/manual.tex
@@ -99,6 +99,15 @@
 
 \bigskip\bigskip
 
+\noindent
+{\bf WARNING: \sl On Debian systems, \kern0.3pt \CWEBx. is installed
+as a suite of two programs:\/ \.{cweavex} and\/ \.{ctanglex}, to
+distinguish them from\/ \.{cweave} and\/ \.{ctangle}, which are the
+original Levy/Knuth versions.  Therefore, please be careful to
+call the programs by these names rather than\/ \.{cweave} and\/
+\.{ctangle} as used in the remainder of this manual.}
+
+\bigskip
 
 \beginsection Overview
 
--- cwebx-3.04.orig/parser.w
+++ cwebx-3.04/parser.w
@@ -178,7 +178,7 @@
 { unop = 1, /* a unary operator like `|!|' */
   binop, /* a binary operator like `|<|' */
   unorbinop, /* an operator that can be either, like `|-|' */
-  select, /* structure selection: `|.|' or `|->|' */
+  selectx, /* structure selection: `|.|' or `|->|' */
   question, /* a question mark operator */
   lbrace, rbrace, lpar, rpar, lbrack, rbrack,
     /* `|{|', \ `|}|', `(', \ `)', `[', \ `]' */
@@ -231,7 +231,7 @@
 { '/', binop,	yes_math, "/" }, @/
 { '<', binop,	yes_math, "<" }, @/
 { '>', binop,	yes_math, ">" }, @/
-{ '.', select,	yes_math, "." }, @/
+{ '.', selectx,	yes_math, "." }, @/
 { '=', binop,	yes_math, "\\K" }, @/ @.\\K@>
 { '|', binop,	yes_math, "\\OR" }, @.\\OR@>
    { or, binop,	yes_math, "\\OR" }, @/
@@ -264,7 +264,7 @@
 { or_or,	binop,	yes_math, "\\V" }, @/ @.\\V@>
 { plus_plus,	unop,	yes_math, "\\PP" }, @/ @.\\PP@>
 { minus_minus,	unop, 	yes_math, "\\MM" }, @/ @.\\MM@>
-{ minus_gt,	select,	yes_math, "\\MG" }, @/ @.\\MG@>
+{ minus_gt,	selectx,	yes_math, "\\MG" }, @/ @.\\MG@>
 { gt_gt,	binop,	yes_math, "\\GG" }, @/ @.\\GG@>
 { lt_lt,	binop,	yes_math, "\\LL" }, @/ @.\\LL@>
 { mul_assign,	binop,	yes_math, "\\KK*" }, @/ @.\\KK@>
@@ -322,7 +322,7 @@
 #ifdef DEBUG
 void print_cat (int c) /* symbolic printout of a category */
 { static char* cat_name[]=
-  { "unop", "binop", "op", "select"
+  { "unop", "binop", "op", "selectx"
   , "?", "{", "}", "(", ")", "[", "]", ",", ";", ":", "::", "@@;"
   , "subscr", "struct_head", "short_{", "short_struct_head"
   , "cmp_stmt", "stmt"
--- cwebx-3.04.orig/rules.w
+++ cwebx-3.04/rules.w
@@ -62,8 +62,8 @@
 { 1, {{expression, unop}},			{expression, NULL}},	@/
 { 2, {{expression, binop, expression}},		{expression, NULL}},	@/
 { 3, {{expression, unorbinop, expression}},	{expression, NULL}},	@/
-{ 4, {{expression, select, expression}},	{expression, NULL}},	@/
-{ 5, {{expression, select, int_like}},		{expression, "__$_"}},	@/
+{ 4, {{expression, selectx, expression}},	{expression, NULL}},	@/
+{ 5, {{expression, selectx, int_like}},		{expression, "__$_"}},	@/
 { 6, {{expression, comma, expression}},		{expression, "__p1_"}},	@/
 { 7, {{expression, expression}},		{expression, NULL}},	@/
 { 8, {{expression, lpar, rpar}},		{expression, "__,_"}},	@/
