Skip to content

Commit

Permalink
Tuneup for CWEB 4.9.
Browse files Browse the repository at this point in the history
Fix issues #61, #62, and #64; clarify issue #63.

Use iftex.sty to test for TeX engine.
Revert a few occurrences of '\ifacro', synonymous for '\ifpdf'.

'$' is permitted in C identifiers (CTANGLE).
Add option '+u' for CTANGLE (poor man's UTF-8 transliteration).

Improve PDF validation, following advice from 3-Height PDF Validator.
NOS has 'count \I' subentries.
  • Loading branch information
ascherer committed May 15, 2023
1 parent d0ca712 commit e067b8d
Show file tree
Hide file tree
Showing 37 changed files with 434 additions and 251 deletions.
6 changes: 3 additions & 3 deletions Makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Copyright (C) 1987,1990,1993,2000 Silvio Levy and Donald E. Knuth
#
# Modified for GCC under Linux by Andreas Scherer, June 8, 1996.
# Last updated by Andreas Scherer, February 2022.
# Last updated by Andreas Scherer, August 2022.

# The following copyright notice extends to the changes in this Makefile
# only, not to any part of the original CWEB distribution.
Expand Down Expand Up @@ -182,7 +182,7 @@ COMMPATCH = comm-extensions.ch comm-extensions.hch \
comm-output.ch comm-output.hch \
comm-patch.ch comm-texlive.ch comm-texlive.hch
CTANGPATCH = ctang-i18n.ch ctang-newpage.ch ctang-output.ch \
ctang-patch.ch ctang-texlive.ch
ctang-patch.ch ctang-texlive.ch ctang+u.ch
CWEAVPATCH = cweav-extensions.ch prod-cweave.ch cweav-i18n.ch cweav-newpage.ch \
cweav-output.ch cweav-patch.ch cweav-texlive.ch cwtw-texlive.ch
CTWILLPATCH = cweav-twill.ch prod-twill.ch ctwill-texlive.ch ctwill-man.ch
Expand Down Expand Up @@ -400,7 +400,7 @@ $(CCHANGES): common.w comm-patch.ch comm-extensions.ch \
$(HCHANGES): common.h comm-extensions.hch \
comm-output.hch comm-i18n.hch # comm-texlive.hch
$(TIE) -m $@ $^
$(TCHANGES): ctangle.w ctang-patch.ch \
$(TCHANGES): ctangle.w ctang-patch.ch ctang+u.ch \
ctang-output.ch ctang-i18n.ch # ctang-texlive.ch
$(TIE) -c $@ $^; $(SUBVER)
$(WCHANGES): cweave.w cweav-patch.ch cweav-extensions.ch \
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[cweb system](http://www-cs-faculty.stanford.edu/~uno/cweb.html)
and donald e. knuth's [ctwill program](http://ftp.cs.stanford.edu/pub/ctwill).
it requires the contents of [the original *cweb* source
drop](https://github.com/ascherer/cweb/releases/download/cweb-4.8/cweb-4.8.tar.gz)
drop](https://github.com/ascherer/cweb/releases/download/cweb-4.9/cweb-4.9.tar.gz)
and [the secondary *ctwill* source
drop](http://ftp.cs.stanford.edu/pub/ctwill/ctwill.tar.gz), to which it applies
a set of change files to introduce advanced features. see the extensive
Expand All @@ -23,11 +23,11 @@ a set of change files to introduce advanced features. see the extensive

## manual compilation

extract `ctwill.tar.gz` and add the contents of `cweb-4.8.tar.gz` (overwriting
extract `ctwill.tar.gz` and add the contents of `cweb-4.9.tar.gz` (overwriting
outdated source files `Makefile`, `common.h`, `common.w`, and `prod.w`) and
`cwebbin-2022.2.tar.gz` for the full set of source files.
`cwebbin-2023.tar.gz` for the full set of source files.
replace `@@VERSION@@` in line 129 of the `Makefile.unix` with something like
`Version 4.8 [CWEBbin 2022.2]`.
`Version 4.9 [CWEBbin 2023]`.
`touch *.cxx`.
unix/linux users should work with [`make -f Makefile.unix`](Makefile.unix)
exclusively (targets `boot`, `cautiously`, and `all`).
Expand All @@ -47,8 +47,8 @@ clone
[cweb](https://github.com/ascherer/cweb) and
[cwebbin](https://github.com/ascherer/cwebbin), create the source drops with
```
git archive -o cweb-4.8.tar.gz cweb-4.8
git archive -o cwebbin-2022.2.tar.gz cwebbin-2022.2
git archive -o cweb-4.9.tar.gz cweb-4.9
git archive -o cwebbin-2023.tar.gz cwebbin-2023
```
respectively, put these two tarballs and the original `ctwill.tar.gz` in the
*SOURCES* directory, add the patch files
Expand Down Expand Up @@ -95,5 +95,5 @@ macros, and cweb include files.
updated versions of **cweb** are added to the texlive source tree with
```
cd /path/to/texlive-source/texk/web2c/cwebdir
pax -rzf /path/to/cweb-4.8.tar.gz
pax -rzf /path/to/cweb-4.9.tar.gz
```
42 changes: 22 additions & 20 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-*-Text-*-
%%% LEGALESE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% This file is part of CWEBbin (Version 4.8 [2022]).
% This file is part of CWEBbin (Version 4.9 [2023]).
% (Set TAB to 8 spaces to get the spacing right.)
% The CWEB programs by Silvio Levy are based on programs by D. E. Knuth.
% They are distributed WITHOUT ANY WARRANTY, express or implied.

% This README file was last updated June 5, 2022 by Andreas Scherer.
% This README file was last updated May 15, 2023 by Andreas Scherer.

% The following copyright notices extend to the respective parts of the
% changed or added source code introduced in this patch only, not to the
Expand All @@ -16,7 +16,7 @@
% Copyright (C) 1991-1993 Hans-Hermann Bode
% Copyright (C) 1992 Klaus Guntermann
% Copyright (C) 1991,1993 Carsten Steger
% Copyright (C) 1993-2000,2005,2011,2018–2022 Andreas Scherer
% Copyright (C) 1993-2000,2005,2011,2018–2023 Andreas Scherer

% Permission is granted to make and distribute verbatim copies of this
% document provided that the copyright notice and this permission notice
Expand Down Expand Up @@ -55,11 +55,11 @@ CWEB 4.0 (and higher) can be retrieved from

https://github.com/ascherer/cweb

To apply this patched version of CWEB, extract the patch archive (yielding a
new subdirectory) and add the original distribution. Care has been taken to
avoid collisions with any files from the original distribution and the
Makefiles provide a target to cleanly remove the patch leaving only the files
of the original distribution (and vice versa).
To apply this patched version of CWEB, extract the patch archive and add the
contents of the original distribution. Care has been taken to avoid
collisions with any files from the original distribution and the Makefiles
provide a target to cleanly remove the patch leaving only the files of the
original distribution (and vice versa).

Intermediate files with extensions .tex and .cxx are reproducable from the
general sources by means of an executable ctangle, cweave, and an ANSI-C/C++
Expand All @@ -68,9 +68,12 @@ available at

CTAN: https://ctan.org/pkg/tie

TIE should be available on all systems with a recent TeX installation.
Alternatively, you can also try to use Julian Gilbey's CTIE processor, but
intermediate results are different.
To produce the CWEB source code of the CTWILL program from the original CWEAVE
source, you need Julian Gilbey's CTIE processor, which is available at

CTAN: https://ctan.org/pkg/ctie

C/TIE should be available on all systems with a recent TeX installation.

%%% TABLE OF CONTENTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Expand All @@ -81,6 +84,7 @@ GENERAL CONTRIBUTION:
├── 0001-Support-extended-syntax-for-numeric-literals.patch for CTWILL
├── 0002-Purge-redundant-TeX-macro.patch for CTWILL
├── 0003-Adapt-to-CWEB-4.5.patch for CTWILL
├── 0004-Add-silent-datecontentspage-macro.patch for CTWILL
├── comm-extensions.ch change file for common.w
├── comm-extensions.hch change file for common.h
├── comm-i18n.ch change file for common.w
Expand Down Expand Up @@ -251,10 +255,13 @@ GENERAL CONTRIBUTION:
itself. (Otherwise the source files common.w and ctangle.w won't
actually have been used.)

5. After all is set, you should become `superuser' and run `make -f
Makefile.unix install'; this will install the binaries, the TeX macros
and CWEB @include files, and some documentation in places specified in
Makefile.unix.
5. <Obsolete>After all is set, you should become `superuser' and run
`make -f Makefile.unix install'; this will install the binaries, the
TeX macros and CWEB @include files, and some documentation in places
specified in Makefile.unix.</Obsolete>
Please follow the instructions in README.md for 'advanced packaging'.
deb- and rpm-packages not only can be installed, but also cleanly
uninstalled from all system paths.

6. If you want a full documentation of the tangle and weave programs,
type `make -f Makefile.unix docs' or preferably `make -f Makefile.unix
Expand Down Expand Up @@ -392,11 +399,6 @@ I want to express my deep gratitude to Silvio Levy and Donald Knuth for the
marvelous tool they provided us with. Also I am indepted to my various pre-
and co-workers on whose initial ideas and contributions this package is based.


Happy CWEBbin'!

June 5, 2022

Andreas Scherer

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 changes: 2 additions & 2 deletions comm-mini.ch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Limbo.

@x
\def\title{Common code for CTANGLE and CWEAVE (Version 4.8 [CWEBbin 2022])}
\def\title{Common code for CTANGLE and CWEAVE (Version 4.9 [CWEBbin 2023])}
@y
\def\title{COMMON (Version 4.8 [CWEBbin 2022])}
\def\title{COMMON (Version 4.9 [CWEBbin 2023])}
\def\contentspagenumber{0}
@z

Expand Down
8 changes: 5 additions & 3 deletions comm-patch.ch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-*-Web-*-
This file, COMM-FOO.CH, is part of CWEBBIN (@VERSION@).
It is a changefile for COMMON.W, Version 4.8.
It is a changefile for COMMON.W, Version 4.3.

Technically, COMM-FOO.CH is constructed from a multitude of separate change
files by applying Klaus Guntermann's TIE processor. Any comments (like this
Expand Down Expand Up @@ -182,17 +182,19 @@ p21 29 October 2005 AS ANSI C++ patches to patch level [p21].

2022 05 February 2022 AS Tuneup for CWEB 4.7 [2022].
05 June 2022 AS Tuneup for CWEB 4.8 [2022].

2023 15 May 2023 AS Tuneup for CWEB 4.9 [2023].
------------------------------------------------------------------------------
Material in limbo.

@x l.25
\def\title{Common code for CTANGLE and CWEAVE (Version 4.8)}
\def\title{Common code for CTANGLE and CWEAVE (Version 4.9)}
@y
\def\title{Common code for CTANGLE and CWEAVE (@VERSION@)}
@z

@x l.30
\centerline{(Version 4.8)}
\centerline{(Version 4.9)}
@y
\centerline{(@VERSION@)}
@z
Expand Down
4 changes: 2 additions & 2 deletions comm-texlive.ch
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ Material in limbo.
\def\title{Common code for CTANGLE and CWEAVE (@VERSION@)}
@y
\def\Kpathsea/{{\mc KPATHSEA\spacefactor1000}} \ifacro\sanitizecommand\Kpathsea{KPATHSEA}\fi
\def\title{Common code for CTANGLE and CWEAVE (4.8 [\TeX~Live])}
\def\title{Common code for CTANGLE and CWEAVE (4.9 [\TeX~Live])}
@z

@x l.30 and l.191 of COMM-PATCH.CH
\centerline{(@VERSION@)}
@y
\centerline{(Version 4.8 [\TeX~Live])}
\centerline{(Version 4.9 [\TeX~Live])}
@z

@x l.32
Expand Down
6 changes: 3 additions & 3 deletions common.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,8 @@ fatal(_("! Cannot open output file "),tex_file_name);
static boolean input_ln(
FILE*fp)
{
register int c= EOF;
register char*k;
int c= EOF;
char*k;
if(feof(fp))return false;
limit= k= buffer;
while(k<=buffer_end&&(c= getc(fp))!=EOF&&c!='\n')
Expand Down Expand Up @@ -1370,7 +1370,7 @@ scan_args(void)
{
char*dot_pos;
char*name_pos;
register char*s;
char*s;
boolean found_web= false,found_change= false,found_out= false;


Expand Down
56 changes: 56 additions & 0 deletions ctang+u.ch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
Changes for CTANGLE.W by Andreas Scherer.

This set of changes extends CTANGLE's transliteration mechanism to ``poor man's
UTF-8'' by stripping all but the last of a sequence of high-bit bytes
representing a multi-byte character.

Section 59.

@x l.712
@ @<Case of an identifier@>=@t\1\quad@>
@y
@ Nowadays, most computer files are encoded in some form of ``Unicode''. A very
convenient special case is ``UTF-8'', a variable-length multi-byte encoding. In
order to avoid major surgery for the transliteration feature---as tempting as
the extended notation \.{@@l c3bc ue} might be---, \.{CTANGLE}
accepts the \.{+u} option to activate a ``poor man's UTF-8'' mechanism. The
first in a sequence of up to four high-bit bytes (amounting to more than
$2^{20}$~possible character representations) determines the number of bytes
used to represent the next character. Instead of extending the |translit| table
to this multi-byte scenario, we simply strip all but the last byte and use this
as the transliteration index.

% Exercise 11.6 from the TeXbook:
\def\frac#1/#2{\leavevmode\kern.1em\raise.5ex\hbox{\the\scriptfont0 #1}
\kern-.1em/\kern-.15em\lower.25ex\hbox{\the\scriptfont0 #2}}

\&{Example:} While in ``classic ASCII'' the German word {\it gr\"un\/} could be
treated with transliteration \.{@@l fc ue} (from codepage ISO/IEC~8859-1) to
get \.{gruen} as suggested above, in UTF-8 you'd be advised to use \.{@@l bc
ue} instead, because character {\it \"u\/} (latin small letter u with
diaeresis) is encoded as the two-byte sequence \.{c3 bc}, indicated by the
initial three bits of byte \.{c3} (\.{1100 0011}). Note that this simple
approach leads to the collision with character $\frac1/4$ (vulgar fraction one
quarter) with its two-byte encoding \.{c2 bc}.

@d transliterate_utf_eight flags['u']

@<Case of an identifier@>=@t\1\quad@>
@z

@x l.717
if ((eight_bits)(*j)<0200) C_putc(*j);
@^high-bit character handling@>
else C_printf("%s",translit[(eight_bits)(*j)-0200]);
@y
if (ishigh(*j)) {
@^high-bit character handling@>
if (transliterate_utf_eight) {
if ((eight_bits)(*j)>=0360) j+=3;
else if ((eight_bits)(*j)>=0340) j+=2;
else if ((eight_bits)(*j)>=0300) j+=1;
}
C_printf("%s",translit[(eight_bits)(*j)-0200]);
}
else C_putc(*j);
@z
8 changes: 5 additions & 3 deletions ctang-patch.ch
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,19 @@ p21 29 October 2005 AS ANSI C++ patches for patch level [p21].

2022 05 February 2022 AS tuneup for CWEB 4.7 [2022].
05 June 2022 AS tuneup for CWEB 4.8 [2022].

2023 15 May 2023 AS tuneup for CWEB 4.9 [2023].
------------------------------------------------------------------------------
Material in limbo.

@x l.30
\def\title{CTANGLE (Version 4.8)}
\def\title{CTANGLE (Version 4.9)}
@y
\def\title{CTANGLE (@VERSION@)}
@z

@x l.34
\centerline{(Version 4.8)}
\centerline{(Version 4.9)}
@y
\centerline{(@VERSION@)}
@z
Expand All @@ -192,7 +194,7 @@ z
Section 1.

@x l.64
@d banner "This is CTANGLE (Version 4.8)"
@d banner "This is CTANGLE (Version 4.9)"
@y
@d banner "This is CTANGLE (@VERSION@)"
@z
Expand Down
6 changes: 3 additions & 3 deletions ctang-texlive.ch
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Material in limbo.
@x l.30 and l.169 of CTANG-PATCH.CH
\def\title{CTANGLE (@VERSION@)}
@y
\def\title{CTANGLE (Version 4.8 [\TeX~Live])}
\def\title{CTANGLE (Version 4.9 [\TeX~Live])}
@z

@x l.34 and l.175 of CTANG-PATCH.CH
\centerline{(@VERSION@)}
@y
\centerline{(Version 4.8 [\TeX~Live])}
\centerline{(Version 4.9 [\TeX~Live])}
@z

@x l.36
Expand All @@ -38,7 +38,7 @@ Section 1.
@x l.64 and l.188 of CTANG-PATCH.CH and l.17 of CTANG-I18N.CH
@d banner _("This is CTANGLE (@VERSION@)")
@y
@d banner "This is CTANGLE, Version 4.8"
@d banner "This is CTANGLE, Version 4.9"
/* will be extended by the \TeX~Live |versionstring| */
@z

Expand Down
2 changes: 1 addition & 1 deletion ctangle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/*:4*/
#line 67 "ctangle.w"

#define banner _("This is CTANGLE (Version 4.8 [CWEBbin 2022.2])") \
#define banner _("This is CTANGLE (Version 4.9 [CWEBbin 2023])") \

#define _(s) gettext(s) \

Expand Down
Loading

0 comments on commit e067b8d

Please sign in to comment.