home *** CD-ROM | disk | FTP | other *** search
- -*-Web-*-
- This file, CTANGLE-P.CH, is part of CWEB-p.
- It is a changefile for CTANGLE.W, Version 3.0.
-
- Authors and Contributors:
- (H2B) Hans-Hermann Bode, Universität Osnabrück,
- (hhbode@@dosuni1.rz.uni-osnabrueck.de or HHBODE@@DOSUNI1.BITNET).
-
- (KG) Klaus Guntermann, TH Darmstadt,
- (guntermann@@iti.informatik.th-darmstadt.de).
-
- (AS) Andreas Scherer,
- Abt-Wolf-Straße 17, 96215 Lichtenfels, Germany.
-
- (CS) Carsten Steger, Universität München,
- carsten.steger@informatik.tu-muenchen.de
-
- Caveat utilitor: Some of the source code introduced by this change file is
- made conditional to the use of specific compilers on specific systems.
- This applies to places marked with `#ifdef __TURBOC__' and `#ifdef _AMIGA'.
-
- This program is distributed WITHOUT ANY WARRANTY, express or implied.
-
- The following copyright notice extends to this changefile only, not to
- the masterfile CTANGLE.W.
-
- Copyright (C) 1993 Andreas Scherer
- Copyright (C) 1991, 1993 Carsten Steger
- Copyright (C) 1991, 1992 Hans-Hermann Bode
-
- Permission is granted to make and distribute verbatim copies of this
- document provided that the copyright notice and this permission notice
- are preserved on all copies.
-
- Permission is granted to copy and distribute modified versions of this
- document under the conditions for verbatim copying, provided that the
- entire resulting derived work is distributed under the terms of a
- permission notice identical to this one.
-
- Version history:
-
- Version Date Author Comment
- a1/t1 10 Oct 1991 H2B First attempt for CTANGLE.W 2.0.
- p2 13 Feb 1992 H2B Updated for CTANGLE.W 2.2, ANSI and Turbo
- changefiles merged together.
- p3 16 Apr 1992 H2B Updated for CTANGLE.W 2.4.
- p4 21 Jun 1992 H2B Nothing changed.
- p5 18 Jul 1992 H2B Extensions for C++ implemented.
- p5a 24 Jul 1992 KG adaptions for other ANSI C compiler
- p5b 28 Jul 1992 H2B Remaining headers converted to ANSI style.
- p6 06 Sep 1992 H2B Updated for CTANGLE.W 2.7, |dot_dot_dot|
- added, parsing of @@'\'' fixed (due to KG),
- @@<Copy an ASCII constant@@> extended,
- (nonfatal) confusion in processing short
- comments fixed.
- p6a 15 Mar 1993 AS Re-changing some of the TC stuff to SAS/C
- p6b 27 Jul 1993 AS new patch level in accordance with CWeave
- p6c 04 Sep 1993 AS new patch level in accordance with Common
- p6d 09 Oct 1993 AS Updated for CTANGLE.W 2.8. (This was p7)
- p7 13 Nov 1992 H2B Converted to master change file, updated for
- ctangle.w 2.8. [Not released.]
- p7.5 29 Nov 1992 H2B Updated for ctangle.w 2.9beta. [Not released.]
- p8 08 Dec 1992 H2B Updated for ctangle.w 2.9++ (stuff went into
- the source file), ANSI bug in <Get a constant>
- fixed. [Not released.]
- p8a 10 Mar 1993 H2B Restructured for public release.
- [Not released.]
- p8b 14 Apr 1993 H2B Updated for ctangle.w 3.0beta. [Not released.]
- p8c 21 Jun 1993 H2B Updated for final ctangle.w 3.0.
- p8d 25 Oct 1993 AS Incorporated into Amiga version 2.8 [p7] and
- updated to version 3.0.
- ------------------------------------------------------------------------------
- @x l.1
- % This file is part of CWEB.
- % This program by Silvio Levy and Donald E. Knuth
- % is based on a program by Knuth.
- % It is distributed WITHOUT ANY WARRANTY, express or implied.
- % Version 3.0 --- June 1993
-
- % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
- @y
- % This file, CTANGLE.W, is part of CWEB-p.
- % This program by Silvio Levy and Donald E. Knuth
- % is based on a program by Knuth.
- % It is distributed WITHOUT ANY WARRANTY, express or implied.
- % Version 2.4 --- Don Knuth, April 1992
- % Version 2.4 [p5] --- Hans-Hermann Bode, July 1992
- % Version 2.4 [p5a] --- Klaus Guntermann, July 1992
- % Version 2.4 [p5b] --- Hans-Hermann Bode, July 1992
- % Version 2.7 --- Don Knuth, July 1992
- % Version 2.7 [p6] --- Hans-Hermann Bode, September 1992
- % Version 2.7 [p6a] --- Andreas Scherer, March 1993
- % Version 2.7 [p6b] --- Andreas Scherer, July 1993
- % Version 2.7 [p6c] --- Andreas Scherer, September 1993
- % Version 2.8 --- Don Knuth, September 1992
- % Version 2.8 [p7] --- Andreas Scherer, October 1993
- % Version 3.0 --- Don Knuth, June 1993
- % Version 3.0 [p8c] --- Hans-Hermann Bode, June 1993
- % Version 3.0 [p8d] --- Andreas Scherer, October 1993
-
- % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
- % Copyright (C) 1991,1992,1993 Hans-Hermann Bode
- % Copyright (C) 1993 Andreas Scherer
- @z
- ------------------------------------------------------------------------------
- @x l.25
- \def\title{CTANGLE (Version 3.0)}
- @y
- \def\title{CTANGLE (Version 3.0 [p8d])}
- @z
- ------------------------------------------------------------------------------
- @x l.29
- \centerline{(Version 3.0)}
- @y
- \centerline{(Version 3.0 [p8d])}
- @z
- ------------------------------------------------------------------------------
- @x l.33
- Copyright \copyright\ 1987, 1990, 1993 Silvio Levy and Donald E. Knuth
- @y
- Copyright \copyright\ 1987, 1990, 1993 Silvio Levy and Donald E. Knuth
- \smallskip\noindent
- Copyright \copyright\ 1991, 1992, 1993 Hans-Hermann Bode
- \smallskip\noindent
- Copyright \copyright\ 1993 Andreas Scherer
- @z
- ------------------------------------------------------------------------------
- Activate this, if only the changed modules should be printed.
- x l.46
- \let\maybe=\iftrue
- y
- \let\maybe=\iffalse
- z
- ------------------------------------------------------------------------------
- @x l.49
- This is the \.{CTANGLE} program by Silvio Levy and Donald E. Knuth,
- based on \.{TANGLE} by Knuth.
- @y
- This is the \.{CTANGLE} program by Silvio Levy and Donald E. Knuth,
- based on \.{TANGLE} by Knuth, with {\mc ANSI-C} conforming changes
- and {\mc TURBO}-\CPLUSPLUS/ implementation made by Hans-Hermann Bode.
- {\mc SAS/C~6.0} implementation made by Andreas Scherer.
- @z
- ------------------------------------------------------------------------------
- @x l.59
- @d banner "This is CTANGLE (Version 3.0)\n"
- @y
- @d banner "This is CTANGLE (Version 3.0 [p8d])\n"
- @z
- ------------------------------------------------------------------------------
- @x l.74
- @<Predecl...@>=
- extern int strlen(); /* length of string */
- extern int strcmp(); /* compare strings lexicographically */
- extern char* strcpy(); /* copy one string to another */
- extern int strncmp(); /* compare up to $n$ string characters */
- extern char* strncpy(); /* copy up to $n$ string characters */
- @y
- @<Include files@>=
- #include <string.h>
- @z
- ------------------------------------------------------------------------------
- @x l.89
- int main (ac, av)
- int ac;
- char **av;
- @y
- int main (int ac, char **av)
- @z
- ------------------------------------------------------------------------------
- Blow the fuck out of {\mc MULTIPLE SCLEROSIS};
- any decent system is capable of using the defaults.
- x l.103
- @ The following parameters were sufficient in the original \.{TANGLE} to
- handle \TEX/,
- so they should be sufficient for most applications of \.{CTANGLE}.
- y
- @ In the following, due to memory limitations of {\mc MS-DOS} systems, the
- value of |max_toks| is reduced to~$1\over2$ of its value in the original
- \.{CTANGLE}, the remaining parameters were sufficient in the original
- \.{CTANGLE} to handle \TEX/; nevertheless, even |max_toks| should be sufficient
- for most applications of \.{CTANGLE}.
- @^system dependencies@>
- z
- ------------------------------------------------------------------------------
- x l.111
- @d max_toks 270000 /* number of bytes in compressed \Cee\ code */
- y
- @d max_toks 135000 /* number of bytes in compressed \Cee\ code */
- z
- ------------------------------------------------------------------------------
- @x l.124
- @i common.h
- @y
- @i common-p.h
- @z
- ------------------------------------------------------------------------------
- @x l.151
- eight_bits *tok_start; /* pointer into |tok_mem| */
- @y
- eight_bits HUGE *tok_start; /* pointer into |tok_mem| */
- @z
- ------------------------------------------------------------------------------
- @x l.160
- eight_bits tok_mem[max_toks];
- eight_bits *tok_mem_end=tok_mem+max_toks-1;
- eight_bits *tok_ptr; /* first unused position in |tok_mem| */
- @y
- #ifdef __TURBOC__
- eight_bits HUGE *tok_mem;
- eight_bits HUGE *tok_mem_end;
- #else
- eight_bits tok_mem[max_toks];
- eight_bits *tok_mem_end=tok_mem+max_toks-1;
- #endif
- eight_bits HUGE *tok_ptr; /* first unused position in |tok_mem| */
- @z
- ------------------------------------------------------------------------------
- @x l.165
- text_info->tok_start=tok_ptr=tok_mem;
- @y
- #ifdef __TURBOC__
- tok_mem=allocsafe(max_toks,sizeof(*tok_mem));
- tok_mem_end=tok_mem+max_toks-1;
- #endif
- text_info->tok_start=tok_ptr=tok_mem;
- @z
- ------------------------------------------------------------------------------
- @x l.175
- name_dir->equiv=(char *)text_info; /* the undefined section has no replacement text */
- @y
- name_dir->equiv=(char HUGE *)text_info; /* the undefined section has no replacement text */
- @z
- ------------------------------------------------------------------------------
- According to COMMON, names_match has to be declared with 4 parameters.
- @x l.181
- int names_match(p,first,l)
- name_pointer p; /* points to the proposed match */
- char *first; /* position of first character of string */
- int l; /* length of identifier */
- @y
- int names_match(name_pointer p,char *first,int l,eight_bits dummy)
- /* |p|: points to the proposed match */
- /* |first|: position of first character of string */
- /* |l|: length of identifier */
- /* |dummy|: not used by \.{TANGLE} */
- @z
- ------------------------------------------------------------------------------
- @x l.187
- return !strncmp(first,p->byte_start,l);
- @y
- return( !strncmp(first,p->byte_start,l) );
- @z
- ------------------------------------------------------------------------------
- @x l.196
- void
- init_node(node)
- name_pointer node;
- @y
- void init_node(name_pointer node)
- @z
- ------------------------------------------------------------------------------
- @x l.200
- node->equiv=(char *)text_info;
- @y
- node->equiv=(char HUGE *)text_info;
- @z
- ------------------------------------------------------------------------------
- According to COMMON, init_p has to be declared with 2 parameters.
- @x l.202
- void
- init_p() {}
- @y
- void init_p(name_pointer dummy1,eight_bits dummy2)
- {}
- @z
- ------------------------------------------------------------------------------
- @x l.258
- void
- store_two_bytes(x)
- sixteen_bits x;
- @y
- static void store_two_bytes(sixteen_bits x)
- @z
- ------------------------------------------------------------------------------
- @x l.295
- eight_bits *end_field; /* ending location of replacement text */
- eight_bits *byte_field; /* present location within replacement text */
- @y
- eight_bits HUGE *end_field; /* ending location of replacement text */
- eight_bits HUGE *byte_field; /* present location within replacement text */
- @z
- ------------------------------------------------------------------------------
- @x l.334
- void
- push_level(p) /* suspends the current level */
- name_pointer p;
- @y
- static void push_level(name_pointer p) /* suspends the current level */
- @z
- ------------------------------------------------------------------------------
- @x l.353
- void
- pop_level(flag) /* do this when |cur_byte| reaches |cur_end| */
- int flag; /* |flag==0| means we are in |output_defs| */
- @y
- static void pop_level(int flag) /* do this when |cur_byte| reaches |cur_end| */
- @z
- ------------------------------------------------------------------------------
- @x l.389
- void
- get_output() /* sends next token to |out_char| */
- @y
- static void get_output(void) /* sends next token to |out_char| */
- @z
- ------------------------------------------------------------------------------
- @x l.423
- if ((a+name_dir)->equiv!=(char *)text_info) push_level(a+name_dir);
- @y
- if ((a+name_dir)->equiv!=(char HUGE *)text_info) push_level(a+name_dir);
- @z
- ------------------------------------------------------------------------------
- @x l.476
- void
- flush_buffer() /* writes one line to output file */
- @y
- static void flush_buffer(void) /* writes one line to output file */
- @z
- ------------------------------------------------------------------------------
- @x l.526
- @<Predecl...@>=
- void phase_two();
-
- @ @c
- void
- phase_two () {
- @y
- @<Predecl...@>=
- static void phase_two();
-
- @ @c
- static void phase_two (void) {
- @z
- ------------------------------------------------------------------------------
- @x l.595
- @ @<Predecl...@>=
- void output_defs();
-
- @ @c
- void
- output_defs()
- @y
- @ @<Predecl...@>=
- static void output_defs(void);
-
- @ @c
- static void output_defs(void)
- @z
- ------------------------------------------------------------------------------
- @x l.641
- @<Predecl...@>=
- void out_char();
-
- @ @c
- void
- out_char(cur_char)
- eight_bits cur_char;
- {
- char *j, *k; /* pointer into |byte_mem| */
- @y
- @<Predecl...@>=
- static void out_char(eight_bits);
-
- @ @c
- static void out_char(eight_bits cur_char)
- {
- char HUGE *j;
- char HUGE *k; /* pointer into |byte_mem| */
- @z
- ------------------------------------------------------------------------------
- This part never came out right, so change it in a better fashion.
- @x l.655
- @/@t\4@>@<Case of an identifier@>;
- @/@t\4@>@<Case of a section number@>;
- @/@t\4@>@<Cases like \.{!=}@>;
- @y
- @#@<Case of an identifier@>;
- @/@<Case of a section number@>;
- @/@<Cases like \.{!=}@>;@#
- @z
- ------------------------------------------------------------------------------
- @x l.800
- eight_bits
- skip_ahead() /* skip to next control code */
- @y
- static eight_bits skip_ahead(void) /* skip to next control code */
- @z
- ------------------------------------------------------------------------------
- @x l.835
- int skip_comment(is_long_comment) /* skips over comments */
- boolean is_long_comment;
- @y
- static int skip_comment(boolean is_long_comment) /* skips over comments */
- @z
- ------------------------------------------------------------------------------
- @x l.885
- eight_bits
- get_next() /* produces the next input token */
- @y
- static eight_bits get_next(void) /* produces the next input token */
- @z
- ------------------------------------------------------------------------------
- @x l.1185
- void
- scan_repl(t) /* creates a replacement text */
- eight_bits t;
- @y
- static void scan_repl(eight_bits t) /* creates a replacement text */
- @z
- ------------------------------------------------------------------------------
- Some compilers complain about `missing space between macro name and its
- replacement list'. ANSI C requires a space after the closing parenthesis
- of a parametric macro.
- @x l.1196
- default: app_repl(a); /* store |a| in |tok_mem| */
- @y
- case ')': app_repl(a); if(t==macro) app_repl(' '); break;
- default: app_repl(a); /* store |a| in |tok_mem| */
- @z
- ------------------------------------------------------------------------------
- According to COMMON, a dummy third argument is supplied to id_lookup.
- @x l.1214
- {int a=id_lookup(id_first,id_loc)-name_dir; app_repl((a / 0400)+0200);
- @y
- {int a=id_lookup(id_first,id_loc,' ')-name_dir; app_repl((a / 0400)+0200);
- @z
- ------------------------------------------------------------------------------
- Again, according to COMMON, a dummy third argument is supplied to id_lookup.
- @x l.1218
- case identifier: a=id_lookup(id_first,id_loc)-name_dir;
- @y
- case identifier: a=id_lookup(id_first,id_loc,' ')-name_dir;
- @z
- ------------------------------------------------------------------------------
- @x l.1335
- void
- scan_section()
- @y
- static void scan_section(void)
- @z
- ------------------------------------------------------------------------------
- Once again, according to COMMON, a dummy third argument is supplied to
- id_lookup.
- @x l.386
- app_repl(((a=id_lookup(id_first,id_loc)-name_dir) / 0400)+0200);
- @y
- app_repl(((a=id_lookup(id_first,id_loc,' ')-name_dir) / 0400)+0200);
- @z
- ------------------------------------------------------------------------------
- @x l.1422
- else if (p->equiv==(char *)text_info) p->equiv=(char *)cur_text;
- @y
- else if (p->equiv==(char HUGE *)text_info) p->equiv=(char HUGE *)cur_text;
- @z
- ------------------------------------------------------------------------------
- @x l.1433
- @ @<Predec...@>=
- void phase_one();
-
- @ @c
- void
- phase_one() {
- @y
- @ @<Predec...@>=
- static void phase_one(void);
-
- @ @c
- static void phase_one(void) {
- @z
- ------------------------------------------------------------------------------
- @x l.1451
- @<Predecl...@>=
- void skip_limbo();
-
- @ @c
- void
- skip_limbo()
- @y
- @<Predecl...@>=
- static void skip_limbo(void);
-
- @ @c
- static void skip_limbo(void)
- @z
- ------------------------------------------------------------------------------
- @x l.1509
- @c
- void
- print_stats() {
- printf("\nMemory usage statistics:\n");
- printf("%ld names (out of %ld)\n",
- (long)(name_ptr-name_dir),(long)max_names);
- printf("%ld replacement texts (out of %ld)\n",
- (long)(text_ptr-text_info),(long)max_texts);
- printf("%ld bytes (out of %ld)\n",
- (long)(byte_ptr-byte_mem),(long)max_bytes);
- printf("%ld tokens (out of %ld)\n",
- (long)(tok_ptr-tok_mem),(long)max_toks);
- }
- @y
- @c
- void
- print_stats(void) {
- printf("\nMemory usage statistics:\n");
- #ifdef __TURBOC__
- printf("%ld names (out of %ld)\n",name_ptr-name_dir,(long)max_names);
- printf("%ld replacement texts (out of %ld)\n",text_ptr-text_info,(long)max_texts);
- printf("%ld bytes (out of %ld)\n",byte_ptr-byte_mem,(long)max_bytes);
- printf("%ld tokens (out of %ld)\n",tok_ptr-tok_mem,(long)max_toks);
- #else
- printf("%ld names (out of %ld)\n",
- (long)(name_ptr-name_dir),(long)max_names);
- printf("%ld replacement texts (out of %ld)\n",
- (long)(text_ptr-text_info),(long)max_texts);
- printf("%ld bytes (out of %ld)\n",
- (long)(byte_ptr-byte_mem),(long)max_bytes);
- printf("%ld tokens (out of %ld)\n",
- (long)(tok_ptr-tok_mem),(long)max_toks);
- #endif
- }
- @z
- ------------------------------------------------------------------------------
- @x l.1523
- @** Index.
- @y
- @* Function declarations. Here are declarations---conforming to
- {\mc ANSI~C}---of all functions in this code, as far as they are
- not already in |"common-p.h"|.
-
- @<Predecl...@>=
- static void store_two_bytes(sixteen_bits x);@/
- static void push_level(name_pointer p);@/
- static void pop_level(int);@/
- static void get_output(void);@/
- static void flush_buffer(void);@/
- static void phase_two(void);@/
- static eight_bits skip_ahead(void);@/
- static int skip_comment(boolean long_style);@/
- static eight_bits get_next(void);@/
- static void scan_repl(eight_bits t);@/
- static void scan_section(void);@/
- static void phase_one(void);@/
-
- @** Index.
- @z
- ------------------------------------------------------------------------------
-