home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / dev / c / cweb / cweave.ch < prev    next >
Encoding:
Text File  |  1994-12-14  |  73.0 KB  |  2,331 lines

  1.                                 -*-Web-*-
  2. This file, CWEAVE.CH, is part of CWEB (Version 3.3 [patch level 11]).
  3. It is a changefile for CWEAVE.W, Version 3.3.
  4.  
  5. Authors and Contributors:
  6. (JFA) Jorge Fernandez Arnaiz
  7.   (arnaiz@@redvax1.dgsca.unam.mx).
  8.  
  9. (BOB) (bob@microprograms.com).
  10.  
  11. (H2B) Hans-Hermann Bode, Universität Osnabrück,
  12.   (hhbode@@dosuni1.rz.uni-osnabrueck.de or HHBODE@@DOSUNI1.BITNET).
  13.  
  14. (GG) Giuseppe Ghibò,
  15.   (ghibo@@galileo.polito.it).
  16.  
  17. (KG) Klaus Guntermann, TH Darmstadt,
  18.   (guntermann@@iti.informatik.th-darmstadt.de).
  19.  
  20. (AS) Andreas Scherer, RWTH Aachen,
  21.   (scherer@@genesis.informatik.rwth-aachen.de).
  22.  
  23. (CS) Carsten Steger, Universität München,
  24.   (carsten.steger@@informatik.tu-muenchen.de).
  25.  
  26. (TW) Tomas Willis,
  27.   (tomas@@cae.wisc.edu).
  28.  
  29. Caveat utilitor:  Some of the source code introduced by this change file is
  30. made conditional to the use of specific compilers on specific systems.
  31. This applies to places marked with `#ifdef __MSDOS__' and `#ifdef __TURBOC__',
  32. `#ifdef _AMIGA' and `#ifdef __SASC'.
  33.  
  34. Some of the changes made in this document are marked by one or more
  35. keywords to indicate that they are somehow related to each other:
  36.  
  37.      - None: These changes are necessary for the indentification
  38.        of this port.
  39.  
  40.      - ANSI: This distribution of CWEB 3.3 not only fully supports
  41.        the writing and documentation of ANSI-C programs, but has been
  42.        transformed into a set of ANSI-C programs (in fact C++ programs)
  43.        by adding function prototypes, standard header files, explicit
  44.        casts, and other features.
  45.  
  46.      - EXTENSIONS: New flags and their effects are introduced by such
  47.        changes.  There are no new CWEB commands (yet).
  48.  
  49.      - MEMORY ALLOCATION: All internal arrays are replaced by pointers
  50.        that address dynamically allocated memory blocks.  Although there
  51.        is no external configuration file or other possibility of changing
  52.        the dimensions at runtime, this effort has the positive effect that
  53.        all source modules can be compiled in the "NEAR" data segment, thus
  54.        making the programs "pure" and enabling them to be made "resident"
  55.        on the Amiga.
  56.  
  57.      - OUTPUT: All three programs of the CWEB system write into
  58.        temporary files first, then they check if there are any
  59.        differences between the current run and possible earlier runs
  60.        and their results, before activating the output "for real".
  61.  
  62.      - SYSTEM DEPENDENCIES: Should be clear.  These changes are caused
  63.        by porting CWEB to other systems than UNIX.  Care has been taken
  64.        to make these points safe on all machines.
  65.  
  66.      - TRANSLATION: For support of the "locale.library" mechanism of the
  67.        Commodore Amiga, all internal strings of characters have been
  68.        replaced by references to an external array in "cweb.h".  The
  69.        portable part of this produces the English default, but on the
  70.        Amiga system support for other languages is given by means of
  71.        "language catalogs".
  72.  
  73. This program is distributed WITHOUT ANY WARRANTY, express or implied.
  74.  
  75. The following copyright notice extends to this changefile only, not to
  76. the masterfile CWEAVE.W.
  77.  
  78. Copyright (C) 1993,1994 Andreas Scherer
  79. Copyright (C) 1991,1993 Carsten Steger
  80. Copyright (C) 1991-1993 Hans-Hermann Bode
  81.  
  82. Permission is granted to make and distribute verbatim copies of this
  83. document provided that the copyright notice and this permission notice
  84. are preserved on all copies.
  85.  
  86. Permission is granted to copy and distribute modified versions of this
  87. document under the conditions for verbatim copying, provided that the
  88. entire resulting derived work is given a different name and distributed
  89. under the terms of a permission notice identical to this one.
  90.  
  91. Version history:
  92.  
  93. Version    Date        Author    Comment
  94. a1/t1    10 Oct 1991    H2B    First attempt for CWEAVE.W 2.1.
  95. p2    13 Feb 1992    H2B    Updated for CWEAVE.W 2.4, ANSI and Turbo
  96.                 changefiles merged together, typesetting of
  97.                 certain ANSI and special constructions fixed.
  98. p3    16 Apr 1992    H2B    Updated for CWEAVE.W 2.5.
  99. p4    22 Jun 1992    H2B    Updated for CWEAVE.W 2.6, retaining hack for
  100.                 underlining of customized iddentifiers.
  101. p5    21 Jul 1992    H2B    Extensions for C++ implemented.
  102. p5a    24 Jul 1992    KG    adaptions for other ANSI C compiler
  103. p5b    28 Jul 1992    H2B    Remaining headers converted to ANSI style.
  104. p5c    30 Jul 1992    KG    removed comments used after #endif
  105. p6    06 Sep 1992    H2B    Updated for CWEAVE.W 2.7, |dot_dot_dot| added,
  106.                 proper typesetting of formatted macro
  107.                 identifiers provided, bug in processing
  108.                 short comments fixed.
  109. p6a     15 Mar 1993     AS      adaptions for SAS/C 6.0 and use of German
  110.                                 macro file dcwebmac.tex
  111. p6b     28 Jul 1993     AS      new patch level due to minor changes
  112.         01 Aug 1993     AS      missing `ptrdiff_t' datatype included
  113. p6c    04 Sep 1993    AS    new patch level in accordance with Common
  114. p6d    09 Oct 1993    AS    Updated for CWEAVE.W 2.8. (This was p7)
  115. p7    13 Nov 1992    H2B    Converted to master change file, updated for
  116.                 CWEAVE.W 2.8. [Not released.]
  117. p7.5    29 Nov 1992    H2B    Updated for CWEAVE.W 2.9beta. [Not released.]
  118. p8    04 Dec 1992    H2B    Updated for CWEAVE.W 2.9++ (stuff went into
  119.                 the source file). [Not released.]
  120. p8a    10 Mar 1993    H2B    Restructured for public release. [Not released.]
  121. p8b    15 Apr 1993    H2B    Updated for CWEAVE.W 3.0beta. [Not released.]
  122. p8c    21 Jun 1993    H2B    Updated for final CWEAVE.W 3.0.
  123. p8d    25 Oct 1993    AS    Incorporated with AMIGA version 2.8 [p7] and
  124.                 updated to version 3.0.
  125. p8e    04 Nov 1993    AS    Minor bug fixed for UNIX and GNU-C.
  126. p9    18 Nov 1993    AS    Updated for CWEAVE.W 3.1.
  127. p9a    30 Nov 1993    AS    Minor changes and corrections.
  128. p9b    06 Dec 1993    AS    Multilinguality implemented.
  129. p9c    18 Jan 1994    AS    Version information included.
  130.     03 Mar 1994    AS    `fflush' added for `Writing the index'.
  131. p9d    13 May 1994    AS    Dynamic memory allocation.
  132.     02 Jul 1994    AS    Portability version.
  133. p10    12 Aug 1994    AS    Updated for CWEAVE.W 3.2.
  134. p10a    24 Aug 1994    AS    New option flag list.
  135.     21 Sep 1994    AS    Output bug fixed.
  136.     26 Sep 1994    AS    Replace `calloc' by `malloc'.
  137. p10b    11 Oct 1994    AS    Write to check_file and compare results.
  138.     18 Oct 1994    AS    Some refinements for C++ compilation.
  139.     12 Nov 1994    AS    Use SEPARATORS instead of the multi-way
  140.                 selection for '/', ':', '\', etc.
  141.     13 Nov 1994    AS    Take care of opened system resources and
  142.                 temporary files in case of an user abort.
  143. p11    03 Dec 1994    AS    Updated for CWEB 3.3.
  144.     13 Dec 1994    AS    There have been corrections in Stanford.
  145. ------------------------------------------------------------------------------
  146. @x l.1
  147. % This file is part of CWEB.
  148. % This program by Silvio Levy and Donald E. Knuth
  149. % is based on a program by Knuth.
  150. % It is distributed WITHOUT ANY WARRANTY, express or implied.
  151. % Version 3.3 --- December 1994
  152.  
  153. % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
  154. @y
  155. % This file, CWEAVE.W, is part of CWEB.
  156. % This program by Silvio Levy and Donald E. Knuth
  157. % is based on a program by Knuth.
  158. % It is distributed WITHOUT ANY WARRANTY, express or implied.
  159. % Version 2.6 --- Don Knuth, June 1992
  160. % Version 2.6 [p5] --- Hans-Hermann Bode, July 1992
  161. % Version 2.6 [p5a] --- Klaus Guntermann, July 1992
  162. % Version 2.6 [p5b] --- Hans-Hermann Bode, July 1992
  163. % Version 2.6 [p5c] --- Klaus Guntermann, July 1992
  164. % Version 2.7 --- Don Knuth, July 1992
  165. % Version 2.7 [p6] --- Hans-Hermann Bode, September 1992
  166. % Version 2.7 [p6a] --- Andreas Scherer, March 1993
  167. % Version 2.7 [p6b] --- Andreas Scherer, July 1993
  168. % Version 2.7 [p6c] --- Andreas Scherer, September 1993
  169. % Version 2.8 --- Don Knuth, September 1992
  170. % Version 2.8 [p7] --- Andreas Scherer, October 1993
  171. % Version 3.0 --- Don Knuth, June 1993
  172. % Version 3.0 [p8c] --- Hans-Hermann Bode, June 1993
  173. % Version 3.0 [p8d] --- Andreas Scherer, October 1993
  174. % Version 3.0 [p8e] --- Andreas Scherer, November 1993
  175. % Version 3.1 --- Don Knuth, November 1993
  176. % Version 3.1 [p9] --- Andreas Scherer, November 1993
  177. % Version 3.1 [p9a] --- Andreas Scherer, November 1993
  178. % Version 3.1 [p9b] --- Andreas Scherer, December 1993
  179. % Version 3.1 [p9c] --- Andreas Scherer, January 1994
  180. % Version 3.1 [p9d] --- Andreas Scherer, July 1994
  181. % Version 3.2 --- Don Knuth, July 1994
  182. % Version 3.2 [p10] --- Andreas Scherer, August 1994
  183. % Version 3.2 [p10a] --- Andreas Scherer, September 1994
  184. % Version 3.2 [p10b] --- Andreas Scherer, October 1994
  185. % Version 3.3 --- Don Knuth, December 1994
  186. % Version 3.3 [p11] --- Andreas Scherer, December 1994
  187.  
  188. % Copyright (C) 1987,1990,1993 Silvio Levy and Donald E. Knuth
  189. % Copyright (C) 1991-1993 Hans-Hermann Bode
  190. % Copyright (C) 1991,1993 Carsten Steger
  191. % Copyright (C) 1993,1994 Andreas Scherer
  192. @z
  193. ------------------------------------------------------------------------------
  194. @x l.30
  195. \def\title{CWEAVE (Version 3.3)}
  196. @y
  197. \def\title{CWEAVE (Version 3.3 [p11])}
  198. @z
  199. ------------------------------------------------------------------------------
  200. @x l.34
  201.   \centerline{(Version 3.3)}
  202. @y
  203.   \centerline{(Version 3.3 [p11])}
  204. @z
  205. ------------------------------------------------------------------------------
  206. @x l.38
  207. Copyright \copyright\ 1987, 1990, 1993 Silvio Levy and Donald E. Knuth
  208. @y
  209. Copyright \copyright\ 1987, 1990, 1993 Silvio Levy and Donald E. Knuth
  210. \smallskip\noindent
  211. Copyright \copyright\ 1991--1993 Hans-Hermann Bode
  212. \smallskip\noindent
  213. Copyright \copyright\ 1991, 1993 Carsten Steger
  214. \smallskip\noindent
  215. Copyright \copyright\ 1993, 1994 Andreas Scherer
  216. @z
  217. ------------------------------------------------------------------------------
  218. Activate this, if only the changed modules should be printed.
  219. x l.51
  220. \let\maybe=\iftrue
  221. y
  222. \let\maybe=\iffalse
  223. z
  224. ------------------------------------------------------------------------------
  225. TRANSLATION
  226. @x l.64
  227. @d banner "This is CWEAVE (Version 3.3)\n"
  228. @y
  229. @d banner get_string(MSG_BANNER_CW1)
  230. @z
  231. ------------------------------------------------------------------------------
  232. ANSI
  233. @x l.73
  234. @ We predeclare several standard system functions here instead of including
  235. their system header files, because the names of the header files are not as
  236. standard as the names of the functions. (For example, some \CEE/ environments
  237. have \.{<string.h>} where others have \.{<strings.h>}.)
  238.  
  239. @<Predecl...@>=
  240. extern int strlen(); /* length of string */
  241. extern int strcmp(); /* compare strings lexicographically */
  242. extern char* strcpy(); /* copy one string to another */
  243. extern int strncmp(); /* compare up to $n$ string characters */
  244. extern char* strncpy(); /* copy up to $n$ string characters */
  245. @y
  246. @ For string handling we include the {\mc ANSI C} system header file instead
  247. of predeclaring the standard system functions |strlen|, |strcmp|, |strcpy|,
  248. |strncmp|, and |strncpy|.
  249. @^system dependencies@>
  250.  
  251. @<Include files@>=
  252. #include <string.h>
  253. @z
  254. ------------------------------------------------------------------------------
  255. ANSI
  256. @x l.94
  257. int main (ac, av)
  258. int ac; /* argument count */
  259. char **av; /* argument values */
  260. @y
  261. int main (int ac, char **av)
  262. /* argument count and argument values */
  263. @z
  264. ==============================================================================
  265. The following changes will effect `common.h', so the line numbers refer
  266. to a different source file!
  267. ------------------------------------------------------------------------------
  268. SYSTEM DEPENDENCIES
  269. @x l.24
  270. First comes general stuff:
  271.  
  272. @y
  273. First comes general stuff.
  274. In {\mc TURBO} \CEE/, we use |huge| pointers instead of large arrays.
  275. @^system dependencies@>
  276.  
  277. @f far int
  278. @f huge int
  279. @f HUGE int
  280. @#
  281. @z
  282. ------------------------------------------------------------------------------
  283. SYSTEM DEPENDENCIES
  284. @x l.33
  285. extern int phase; /* which phase are we in? */
  286. @y
  287. extern int phase; /* which phase are we in? */
  288. @#
  289. #ifdef __TURBOC__
  290. #define HUGE huge
  291. #else
  292. #define HUGE
  293. #endif
  294. @^system dependencies@>
  295. @z
  296. ------------------------------------------------------------------------------
  297. SYSTEM DEPENDENCIES, TRANSLATION
  298. @x l.35
  299. @ @<Include files@>=
  300. #include <stdio.h>
  301. @y
  302. @ Version~2.1 of the {\mc AMIGA} operating system introduced localization
  303. of programs and applications by means of ``language catalogs'' that contain
  304. replacement strings for terminal texts produced by suitably prepared programs.
  305. The complete \.{CWEB} system has been modified to accommodate this great idea
  306. and so the \.{cweb.h} header file with the original English strings is
  307. included in this section.  Other systems than the {\mc AMIGA} will have to do
  308. the language conversion by different means, so a little bit of care is to be
  309. taken with what follows.
  310. @^system dependencies@>
  311.  
  312. @f type int /* \.{type} becomes the pseudotype \&{type} */
  313. @#
  314. @d alloc_object(object,size,@!type)
  315.    if(!(object = (type *)malloc((size)*sizeof(type))))
  316.       fatal("",get_string(MSG_FATAL_CO85));
  317.  
  318. @<Include files@>=
  319. #include <stdio.h>
  320. @#
  321. #ifdef __TURBOC__
  322. #include <io.h>
  323. #endif
  324. @#
  325. #ifndef _AMIGA /* non-{\mc AMIGA} systems don't know about \.{<exec/types.h>} */
  326. typedef long int LONG; /* excerpt from \.{<exec/types.h>} */
  327. typedef char * STRPTR; /* ditto, but \UNIX/ says it's signed. */
  328. #define EXEC_TYPES_H 1 /* don't include \.{<exec/types.h>} in \.{"cweb.h"} */
  329. #endif
  330. @#
  331. #ifdef STRINGARRAY
  332. #undef STRINGARRAY /* don't include the string array |AppStrings| again */
  333. #endif
  334. #define get_string(n) AppStrings[n].as_Str
  335. @#
  336. #include "cweb.h"
  337. @#
  338. struct AppString
  339. {
  340.    LONG   as_ID;
  341.    STRPTR as_Str;
  342. };
  343. @#
  344. extern struct AppString AppStrings[];
  345. @z
  346. ------------------------------------------------------------------------------
  347. MEMORY ALLOCATION
  348. @x l.58
  349. char section_text[longest_name+1]; /* name being sought for */
  350. char *section_text_end = section_text+longest_name; /* end of |section_text| */
  351. @y
  352. char *section_text; /* name being sought for */
  353. char *section_text_end; /* end of |section_text| */
  354. @z
  355. ------------------------------------------------------------------------------
  356. MEMORY ALLOCATION
  357. @x l.73
  358. extern char buffer[]; /* where each line of input goes */
  359. @y
  360. extern char *buffer; /* where each line of input goes */
  361. @z
  362. ------------------------------------------------------------------------------
  363. ANSI
  364. @x l.79
  365. @d length(c) (c+1)->byte_start-(c)->byte_start /* the length of a name */
  366. @y
  367. @d length(c) (size_t)((c+1)->byte_start-(c)->byte_start) /* the length of a name */
  368. @z
  369. ------------------------------------------------------------------------------
  370. SYSTEM DEPENDENCIES, MEMORY ALLOCATION
  371. @x l.88
  372. typedef struct name_info {
  373.   char *byte_start; /* beginning of the name in |byte_mem| */
  374.   struct name_info *link;
  375.   union {
  376.     struct name_info *Rlink; /* right link in binary search tree for section
  377.       names */
  378.     char Ilk; /* used by identifiers in \.{CWEAVE} only */
  379.   } dummy;
  380.   char *equiv_or_xref; /* info corresponding to names */
  381. } name_info; /* contains information about an identifier or section name */
  382. typedef name_info *name_pointer; /* pointer into array of \&{name\_info}s */
  383. typedef name_pointer *hash_pointer;
  384. extern char byte_mem[]; /* characters of names */
  385. extern char *byte_mem_end; /* end of |byte_mem| */
  386. extern name_info name_dir[]; /* information about names */
  387. extern name_pointer name_dir_end; /* end of |name_dir| */
  388. extern name_pointer name_ptr; /* first unused position in |byte_start| */
  389. extern char *byte_ptr; /* first unused position in |byte_mem| */
  390. @y
  391. typedef struct name_info {
  392.   char HUGE *byte_start; /* beginning of the name in |byte_mem| */
  393.   struct name_info HUGE *link;
  394.   union {
  395.     struct name_info HUGE *Rlink; /* right link in binary search tree for section
  396.       names */  
  397.     char Ilk; /* used by identifiers in \.{WEAVE} only */
  398.   } dummy;
  399.   void HUGE *equiv_or_xref; /* info corresponding to names */
  400. } name_info; /* contains information about an identifier or section name */
  401. typedef name_info HUGE *name_pointer; /* pointer into array of |name_info|s */
  402. typedef name_pointer *hash_pointer;
  403. extern name_pointer name_dir; /* information about names */
  404. extern name_pointer name_dir_end; /* end of |name_dir| */
  405. extern name_pointer name_ptr; /* first unused position in |byte_start| */
  406. extern char HUGE *byte_mem; /* characters of names */
  407. extern char HUGE *byte_mem_end; /* end of |byte_mem| */
  408. extern char HUGE *byte_ptr; /* first unused position in |byte_mem| */
  409. #ifdef __TURBOC__
  410. extern void far *allocsafe(unsigned long,unsigned long);
  411. #endif
  412. @^system dependencies@>
  413. @z
  414. ------------------------------------------------------------------------------
  415. MEMORY ALLOCATION
  416. @x l.106
  417. extern name_pointer hash[]; /* heads of hash lists */
  418. @y
  419. extern name_pointer *hash; /* heads of hash lists */
  420. @z
  421. ------------------------------------------------------------------------------
  422. ANSI
  423. @x l.109
  424. extern name_pointer id_lookup(); /* looks up a string in the identifier table */
  425. extern name_pointer section_lookup(); /* finds section name */
  426. extern void print_section_name(), sprint_section_name();
  427. @y
  428. extern int names_match(name_pointer,char *,int,eight_bits);@/
  429. extern name_pointer id_lookup(char *,char *,char);
  430.    /* looks up a string in the identifier table */
  431. extern name_pointer prefix_lookup(char *,char *); /* finds section name given a prefix */
  432. extern name_pointer section_lookup(char *,char *,int);@/
  433. extern void init_node(name_pointer);@/
  434. extern void init_p(name_pointer,eight_bits);@/
  435. extern void print_prefix_name(name_pointer);@/
  436. extern void print_section_name(name_pointer);@/
  437. extern void sprint_section_name(char *,name_pointer);@/
  438. @z
  439. ------------------------------------------------------------------------------
  440. ANSI, TRANSLATION
  441. @x l.117
  442. @d fatal_message 3 /* |history| value when we had to stop prematurely */
  443. @d mark_harmless {if (history==spotless) history=harmless_message;}
  444. @d mark_error history=error_message
  445. @d confusion(s) fatal("! This can't happen: ",s)
  446.  
  447. @<Common...@>=
  448. extern history; /* indicates how bad this run was */
  449. extern err_print(); /* print error message and context */
  450. extern wrap_up(); /* indicate |history| and exit */
  451. extern void fatal(); /* issue error message and die */
  452. extern void overflow(); /* succumb because a table has overflowed */
  453. @y
  454. @d fatal_message 3 /* |history| value when we had to stop prematurely */
  455. @d mark_harmless {if (history==spotless) history=harmless_message;}
  456. @d mark_error history=error_message
  457. @d confusion(s) fatal(get_string(MSG_FATAL_CO66),s)
  458.  
  459. @<Common...@>=
  460. extern history; /* indicates how bad this run was */
  461. extern int wrap_up(void); /* indicate |history| and exit */
  462. extern void err_print(char *); /* prints error message and context */
  463. extern void fatal(char *,char *); /* issue error message and die */
  464. extern void overflow(char *); /* succumb because a table has overflowed */
  465. @z
  466. ------------------------------------------------------------------------------
  467. SYSTEM DEPENDENCIES
  468. @x l.131
  469. @d max_file_name_length 60
  470. @y
  471. @d max_file_name_length 256
  472. @z
  473. ------------------------------------------------------------------------------
  474. MEMORY ALLOCATION, OUTPUT
  475. @x l.139
  476. extern FILE *file[]; /* stack of non-change files */
  477. extern FILE *change_file; /* change file */
  478. extern char C_file_name[]; /* name of |C_file| */
  479. extern char tex_file_name[]; /* name of |tex_file| */
  480. extern char idx_file_name[]; /* name of |idx_file| */
  481. extern char scn_file_name[]; /* name of |scn_file| */
  482. extern char file_name[][max_file_name_length];
  483.   /* stack of non-change file names */
  484. extern char change_file_name[]; /* name of change file */
  485. extern line[]; /* number of current line in the stacked files */
  486. @y
  487. extern FILE **file; /* stack of non-change files */
  488. extern FILE *change_file; /* change file */
  489. extern char *C_file_name; /* name of |C_file| */
  490. extern char *tex_file_name; /* name of |tex_file| */
  491. extern char *idx_file_name; /* name of |idx_file| */
  492. extern char *scn_file_name; /* name of |scn_file| */
  493. extern char *check_file_name; /* name of |check_file| */
  494. extern char **file_name; /* stack of non-change file names */
  495. extern char *change_file_name; /* name of change file */
  496. extern char *use_language; /* prefix to \.{cwebmac.tex} in \TEX/ output */
  497. extern int *line; /* number of current line in the stacked files */
  498. @z
  499. ------------------------------------------------------------------------------
  500. ANSI
  501. @x l.153
  502. extern reset_input(); /* initialize to read the web file and change file */
  503. extern get_line(); /* inputs the next line */
  504. extern check_complete(); /* checks that all changes were picked up */
  505. @y
  506. extern boolean get_line(void); /* inputs the next line */
  507. extern void check_complete(void); /* checks that all changes were picked up */
  508. extern void reset_input(void); /* initialize to read the web file and change file */
  509. @z
  510. ------------------------------------------------------------------------------
  511. MEMORY ALLOCATION
  512. @x l.161
  513. extern boolean changed_section[]; /* is the section changed? */
  514. @y
  515. extern boolean *changed_section; /* is the section changed? */
  516. @z
  517. ------------------------------------------------------------------------------
  518. EXTENSIONS
  519. @x l.165
  520. @ Code related to command line arguments:
  521. @d show_banner flags['b'] /* should the banner line be printed? */
  522. @d show_progress flags['p'] /* should progress reports be printed? */
  523. @d show_happiness flags['h'] /* should lack of errors be announced? */
  524. @y
  525. @ Code related to command line arguments:
  526. @d show_banner flags['b'] /* should the banner line be printed? */
  527. @d show_happiness flags['h'] /* should lack of errors be announced? */
  528. @d show_progress flags['p'] /* should progress reports be printed? */
  529. @d indent_param_decl flags['i'] /* should formal parameter declarations be indented? */
  530. @d send_error_messages flags['m'] /* should {\mc AREXX} communication be used? */
  531. @d order_decl_stmt flags['o'] /* should declarations and statements be separated? */
  532. @z
  533. ------------------------------------------------------------------------------
  534. @x l.173
  535. extern boolean flags[]; /* an option for each 7-bit code */
  536. @y
  537. extern boolean flags[]; /* an option for each 8-bit code */
  538. @z
  539. ------------------------------------------------------------------------------
  540. OUTPUT
  541. @x l.186
  542. extern FILE *scn_file; /* where list of sections from \.{CWEAVE} goes */
  543. @y
  544. extern FILE *scn_file; /* where list of sections from \.{CWEAVE} goes */
  545. extern FILE *check_file; /* temporary output file */
  546. @z
  547. ------------------------------------------------------------------------------
  548. ANSI
  549. @x l.192
  550. extern void common_init();
  551. @y
  552. extern void common_init(void);
  553. extern void print_stats(void);
  554. @z
  555. ==============================================================================
  556. SYSTEM DEPENDENCIES
  557. @x l.223
  558. typedef struct xref_info {
  559.   sixteen_bits num; /* section number plus zero or |def_flag| */
  560.   struct xref_info *xlink; /* pointer to the previous cross-reference */
  561. } xref_info;
  562. typedef xref_info *xref_pointer;
  563. @y
  564. typedef struct xref_info {
  565.   sixteen_bits num; /* section number plus zero or |def_flag| */
  566.   struct xref_info HUGE *xlink; /* pointer to the previous cross-reference */
  567. } xref_info;
  568. typedef xref_info HUGE *xref_pointer;
  569. @z
  570. ------------------------------------------------------------------------------
  571. MEMORY ALLOCATION
  572. @x l.230
  573. xref_info xmem[max_refs]; /* contains cross-reference information */
  574. xref_pointer xmem_end = xmem+max_refs-1;
  575. @y
  576. xref_pointer xmem; /* contains cross-reference information */
  577. xref_pointer xmem_end;
  578. @z
  579. ------------------------------------------------------------------------------
  580. MEMORY ALLOCATION, SYSTEM DEPENDENCIES
  581. @x l.244
  582. xref_ptr=xmem; name_dir->xref=(char*)xmem; xref_switch=0; section_xref_switch=0;
  583. @y
  584. alloc_object(section_text,longest_name+1,char);
  585. section_text_end = section_text + longest_name;
  586. #ifdef __TURBOC__
  587. xmem=(xref_pointer)allocsafe(max_refs,sizeof(*xmem));
  588. #else
  589. alloc_object(xmem,max_refs,xref_info);
  590. #endif
  591. xmem_end = xmem + max_refs - 1;
  592. xref_ptr=xmem; name_dir->xref=(void HUGE*)xmem;
  593. xref_switch=0; section_xref_switch=0;
  594. @^system dependencies@>
  595. @z
  596. ------------------------------------------------------------------------------
  597. TRANSLATION
  598. @x l.256
  599. @d append_xref(c) if (xref_ptr==xmem_end) overflow("cross-reference");
  600. @y
  601. @d append_xref(c) if (xref_ptr==xmem_end) overflow(get_string(MSG_OVERFLOW_CW21));
  602. @z
  603. ------------------------------------------------------------------------------
  604. ANSI
  605. @x l.262
  606. @c
  607. void
  608. new_xref(p)
  609. name_pointer p;
  610. @y
  611. @c static void new_xref(name_pointer p)
  612. @z
  613. ------------------------------------------------------------------------------
  614. SYSTEM DEPENDENCIES
  615. @x l.279
  616.   append_xref(m); xref_ptr->xlink=q; p->xref=(char*)xref_ptr;
  617. @y
  618.   append_xref(m); xref_ptr->xlink=q; p->xref=(void HUGE*)xref_ptr;
  619. @z
  620. ------------------------------------------------------------------------------
  621. ANSI
  622. @x l.293
  623. @c
  624. void
  625. new_section_xref(p)
  626. name_pointer p;
  627. @y
  628. @c static void new_section_xref(name_pointer p)
  629. @z
  630. ------------------------------------------------------------------------------
  631. SYSTEM DEPENDENCIES
  632. @x l.306
  633.   if (r==xmem) p->xref=(char*)xref_ptr;
  634. @y
  635.   if (r==xmem) p->xref=(void HUGE*)xref_ptr;
  636. @z
  637. ------------------------------------------------------------------------------
  638. ANSI
  639. @x l.313
  640. @c
  641. void
  642. set_file_flag(p)
  643. name_pointer p;
  644. @y
  645. @c static void set_file_flag(name_pointer p)
  646. @z
  647. ------------------------------------------------------------------------------
  648. SYSTEM DEPENDENCIES
  649. @x l.323
  650.   p->xref = (char *)xref_ptr;
  651. @y
  652.   p->xref = (void HUGE*)xref_ptr;
  653. @z
  654. ------------------------------------------------------------------------------
  655. MEMORY ALLOCATION, SYSTEM DEPENDENCIES
  656. @x l.334
  657. typedef token *token_pointer;
  658. typedef token_pointer *text_pointer;
  659. @y
  660. typedef token HUGE *token_pointer;
  661. typedef token_pointer HUGE *text_pointer;
  662. @z
  663. ------------------------------------------------------------------------------
  664. MEMORY ALLOCATION, SYSTEM DEPENDENCIES
  665. @x l.343
  666. token tok_mem[max_toks]; /* tokens */
  667. token_pointer tok_mem_end = tok_mem+max_toks-1; /* end of |tok_mem| */
  668. token_pointer tok_start[max_texts]; /* directory into |tok_mem| */
  669. token_pointer tok_ptr; /* first unused position in |tok_mem| */
  670. text_pointer text_ptr; /* first unused position in |tok_start| */
  671. text_pointer tok_start_end = tok_start+max_texts-1; /* end of |tok_start| */
  672. @y
  673. token_pointer tok_mem; /* tokens */
  674. token_pointer tok_mem_end; /* end of |tok_mem| */
  675. token_pointer tok_ptr; /* first unused position in |tok_mem| */
  676. text_pointer tok_start; /* directory into |tok_mem| */
  677. text_pointer tok_start_end; /* end of |tok_start| */
  678. text_pointer text_ptr; /* first unused position in |tok_start| */
  679. @z
  680. ------------------------------------------------------------------------------
  681. MEMORY ALLOCATION, SYSTEM DEPENDENCIES
  682. @x l.353
  683. tok_ptr=tok_mem+1; text_ptr=tok_start+1; tok_start[0]=tok_mem+1;
  684. @y
  685. #ifdef __TURBOC__
  686. tok_mem=(token_pointer)allocsafe(max_toks,sizeof(*tok_mem));
  687. #else
  688. alloc_object(tok_mem,max_toks,token);
  689. #endif
  690. tok_mem_end = tok_mem + max_toks - 1;
  691. alloc_object(tok_start,max_texts,token_pointer);
  692. tok_start_end = tok_start + max_texts - 1;
  693. tok_ptr=tok_mem+1; text_ptr=tok_start+1; tok_start[0]=tok_mem+1;
  694. @^system dependencies@>
  695. @z
  696. ------------------------------------------------------------------------------
  697. ANSI
  698. @x l.359
  699. @c
  700. int names_match(p,first,l,t)
  701. name_pointer p; /* points to the proposed match */
  702. char *first; /* position of first character of string */
  703. int l; /* length of identifier */
  704. eight_bits t; /* desired ilk */
  705. @y
  706. @c int names_match(@t\1\1@>
  707.   name_pointer p, /* points to the proposed match */
  708.   char *first, /* position of first character of string */
  709.   int l, /* length of identifier */
  710.   eight_bits t@t\2\2@>) /* desired |ilk| */
  711. @z
  712. ------------------------------------------------------------------------------
  713. ANSI
  714. @x l.370
  715. void
  716. init_p(p,t)
  717. name_pointer p;
  718. eight_bits t;
  719. @y
  720. void init_p(name_pointer p,eight_bits t)
  721. @z
  722. ------------------------------------------------------------------------------
  723. SYSTEM DEPENDENCIES
  724. @x l.375
  725.   p->ilk=t; p->xref=(char*)xmem;
  726. @y
  727.   p->ilk=t; p->xref=(void HUGE*)xmem;
  728. @z
  729. ------------------------------------------------------------------------------
  730. ANSI
  731. @x l.378
  732. void
  733. init_node(p)
  734. name_pointer p;
  735. @y
  736. void init_node(name_pointer p)
  737. @z
  738. ------------------------------------------------------------------------------
  739. SYSTEM DEPENDENCIES
  740. @x l.382
  741.   p->xref=(char*)xmem;
  742. @y
  743.   p->xref=(void HUGE*)xmem;
  744. @z
  745. ------------------------------------------------------------------------------
  746. MEMORY ALLOCATION
  747. @x l.522
  748. eight_bits ccode[256]; /* meaning of a char following \.{@@} */
  749.  
  750. @ @<Set ini...@>=
  751. {int c; for (c=0; c<256; c++) ccode[c]=0;}
  752. @y
  753. eight_bits *ccode; /* meaning of a char following \.{@@} */
  754.  
  755. @ @<Set ini...@>=
  756. {int c;
  757. alloc_object(ccode,256,eight_bits);
  758. for (c=0; c<256; c++) ccode[c]=0;}
  759. @z
  760. ------------------------------------------------------------------------------
  761. ANSI
  762. @x l.562
  763. @<Predec...@>=
  764. void   skip_limbo();
  765.  
  766. @ @c
  767. void
  768. skip_limbo() {
  769. @y
  770. @<Predec...@>=
  771. static void skip_limbo(void);
  772.  
  773. @ @c
  774. static void skip_limbo(void) {
  775. @z
  776. ------------------------------------------------------------------------------
  777. ANSI
  778. @x l.587
  779. @c
  780. unsigned
  781. skip_TeX() /* skip past pure \TEX/ code */
  782. @y
  783. @c static unsigned skip_TeX(void) /* skip past pure \TEX/ code */
  784. @z
  785. ------------------------------------------------------------------------------
  786. ANSI
  787. @x l.645
  788. #include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */
  789. #include <stdlib.h> /* definition of |exit| */
  790. @y
  791. #include <ctype.h> /* definition of |isalpha|, |isdigit| and so on */
  792. #include <stdlib.h> /* definition of |exit| */
  793. #include <stddef.h> /* type definition of |ptrdiff_t| */
  794. @z
  795. ------------------------------------------------------------------------------
  796. ANSI
  797. @x l.655
  798. @<Predecl...@>=
  799. eight_bits get_next();
  800.  
  801. @ @c
  802. eight_bits
  803. get_next() /* produces the next input token */
  804. {@+eight_bits c; /* the current character */
  805. @y
  806. @<Predecl...@>=
  807. static eight_bits get_next(void);
  808.  
  809. @ @c
  810. static eight_bits get_next(void) /* produces the next input token */
  811. {
  812.   eight_bits c; /* the current character */
  813. @z
  814. ------------------------------------------------------------------------------
  815. TRANSLATION
  816. @x l.821
  817.         err_print("! String didn't end"); loc=limit; break;
  818. @y
  819.         err_print(get_string(MSG_ERROR_CT67_1)); loc=limit; break;
  820. @z
  821. ------------------------------------------------------------------------------
  822. TRANSLATION
  823. @x l.825
  824.         err_print("! Input ended in middle of string"); loc=buffer; break;
  825. @y
  826.         err_print(get_string(MSG_ERROR_CT67_2)); loc=buffer; break;
  827. @z
  828. ------------------------------------------------------------------------------
  829. TRANSLATION
  830. @x l.840
  831.     printf("\n! String too long: ");
  832. @y
  833.     printf(get_string(MSG_ERROR_CT67_3));
  834. @z
  835. ------------------------------------------------------------------------------
  836. TRANSLATION
  837. @x l.855
  838.     case translit_code: err_print("! Use @@l in limbo only"); continue;
  839. @y
  840.     case translit_code: err_print(get_string(MSG_ERROR_CT68_1)); continue;
  841. @z
  842. ------------------------------------------------------------------------------
  843. TRANSLATION
  844. @x l.894
  845.     err_print("! Input ended in section name");
  846. @y
  847.     err_print(get_string(MSG_ERROR_CT72_1));
  848. @z
  849. ------------------------------------------------------------------------------
  850. TRANSLATION
  851. @x l.907
  852.   printf("\n! Section name too long: ");
  853. @y
  854.   printf(get_string(MSG_ERROR_CT72_2));
  855. @z
  856. ------------------------------------------------------------------------------
  857. TRANSLATION
  858. @x l.921
  859.     err_print("! Section name didn't end"); break;
  860. @y
  861.     err_print(get_string(MSG_ERROR_CT73_1)); break;
  862. @z
  863. ------------------------------------------------------------------------------
  864. TRANSLATION
  865. @x l.925
  866.     err_print("! Control codes are forbidden in section name"); break;
  867. @y
  868.     err_print(get_string(MSG_ERROR_CW54)); break;
  869. @z
  870. ------------------------------------------------------------------------------
  871. ANSI
  872. @x l.933
  873. @<Predecl...@>=
  874. void skip_restricted();
  875.  
  876. @ @c
  877. void
  878. skip_restricted()
  879. @y
  880. @<Predecl...@>=
  881. void skip_restricted(void);
  882.  
  883. @ @c
  884. void skip_restricted(void)
  885. @z
  886. ------------------------------------------------------------------------------
  887. TRANSLATION
  888. @x l.945
  889.     err_print("! Control text didn't end"); loc=limit;
  890. @y
  891.     err_print(get_string(MSG_ERROR_CW56_1)); loc=limit;
  892. @z
  893. ------------------------------------------------------------------------------
  894. TRANSLATION
  895. @x l.951
  896.       err_print("! Control codes are forbidden in control text");
  897. @y
  898.       err_print(get_string(MSG_ERROR_CW56_2));
  899. @z
  900. ------------------------------------------------------------------------------
  901. TRANSLATION
  902. @x l.964
  903.   if (loc>=limit) err_print("! Verbatim string didn't end");
  904. @y
  905.   if (loc>=limit) err_print(get_string(MSG_ERROR_CT74));
  906. @z
  907. ------------------------------------------------------------------------------
  908. ANSI
  909. @x l.983
  910. @ The overall processing strategy in phase one has the following
  911. straightforward outline.
  912.  
  913. @<Predecl...@>=
  914. void phase_one();
  915.  
  916. @ @c
  917. void
  918. phase_one() {
  919. @y
  920. @ The overall processing strategy in phase one has the following
  921. straightforward outline.
  922.  
  923. @<Predecl...@>=
  924. static void phase_one(void);
  925.  
  926. @ @c
  927. static void phase_one(void) {
  928. @z
  929. ------------------------------------------------------------------------------
  930. TRANSLATION
  931. @x l.1004
  932.   if (++section_count==max_sections) overflow("section number");
  933. @y
  934.   if (++section_count==max_sections) overflow(get_string(MSG_OVERFLOW_CW61));
  935. @z
  936. ------------------------------------------------------------------------------
  937. ANSI
  938. @x l.1035
  939. +wildcard| and |xref_typewriter==identifier+typewriter| and |normal==0|.
  940.  
  941. @<Predecl...@>=
  942. void C_xref();
  943.  
  944. @ @c
  945. void
  946. C_xref( spec_ctrl ) /* makes cross-references for \CEE/ identifiers */
  947.   eight_bits spec_ctrl;
  948. @y
  949. +wildcard| and |xref_typewriter==identifier+typewriter| and finally
  950. |normal==0|.
  951.  
  952. @<Predecl...@>=
  953. static void C_xref(eight_bits);
  954.  
  955. @ @c
  956. static void C_xref( eight_bits spec_ctrl )
  957.    /* makes cross-references for \CEE/ identifiers */
  958. @z
  959. ------------------------------------------------------------------------------
  960. ANSI
  961. @x l.1065
  962. @<Predecl...@>=
  963. void outer_xref();
  964.  
  965. @ @c
  966. void
  967. outer_xref() /* extension of |C_xref| */
  968. @y
  969. @<Predecl...@>=
  970. static void outer_xref(void);
  971.  
  972. @ @c
  973. static void outer_xref(void) /* extension of |C_xref| */
  974. @z
  975. ------------------------------------------------------------------------------
  976. TRANSLATION
  977. @x l.1095
  978.     case translit_code: err_print("! Use @@l in limbo only"); continue;
  979. @y
  980.     case translit_code: err_print(get_string(MSG_ERROR_CT68_1)); continue;
  981. @z
  982. ------------------------------------------------------------------------------
  983. SYSTEM DEPENDENCIES
  984. @x l.1168
  985.             else lhs->xref=(char*)q->xlink;
  986. @y
  987.             else lhs->xref=(void HUGE*)q->xlink;
  988. @z
  989. ------------------------------------------------------------------------------
  990. TRANSLATION
  991. @x l.1182
  992.     err_print("! Missing left identifier of @@s");
  993. @y
  994.     err_print(get_string(MSG_ERROR_CW71_1));
  995. @z
  996. ------------------------------------------------------------------------------
  997. TRANSLATION
  998. @x l.1187
  999.       err_print("! Missing right identifier of @@s");
  1000. @y
  1001.       err_print(get_string(MSG_ERROR_CW71_2));
  1002. @z
  1003. ------------------------------------------------------------------------------
  1004. ANSI
  1005. @x l.1226
  1006. @<Predecl...@>=
  1007. void section_check();
  1008.  
  1009. @ @c
  1010. void
  1011. section_check(p)
  1012. name_pointer p; /* print anomalies in subtree |p| */
  1013. @y
  1014. @<Predecl...@>=
  1015. static void section_check(name_pointer);
  1016.  
  1017. @ @c
  1018. static void section_check(name_pointer p)
  1019.    /* print anomalies in subtree |p| */
  1020. @z
  1021. ------------------------------------------------------------------------------
  1022. TRANSLATION
  1023. @x l.1240
  1024.       printf("\n! Never defined: <"); print_section_name(p); putchar('>'); mark_harmless;
  1025. @y
  1026.       printf(get_string(MSG_WARNING_CW75_1));
  1027.       print_section_name(p); putchar('>'); mark_harmless;
  1028. @z
  1029. ------------------------------------------------------------------------------
  1030. TRANSLATION
  1031. @x l.1245
  1032.       printf("\n! Never used: <"); print_section_name(p); putchar('>'); mark_harmless;
  1033. @y
  1034.       printf(get_string(MSG_WARNING_CW75_2));
  1035.       print_section_name(p); putchar('>'); mark_harmless;
  1036. @z
  1037. ------------------------------------------------------------------------------
  1038. MEMORY ALLOCATION
  1039. @x l.1261
  1040. char out_buf[line_length+1]; /* assembled characters */
  1041. char *out_ptr; /* just after last character in |out_buf| */
  1042. char *out_buf_end = out_buf+line_length; /* end of |out_buf| */
  1043. @y
  1044. char *out_buf; /* assembled characters */
  1045. char *out_buf_end; /* end of |out_buf| */
  1046. char *out_ptr; /* just after last character in |out_buf| */
  1047. @z
  1048. ------------------------------------------------------------------------------
  1049. ANSI
  1050. @x l.1283
  1051. void
  1052. flush_buffer(b,per_cent,carryover)
  1053. char *b;  /* outputs from |out_buf+1| to |b|,where |b<=out_ptr| */
  1054. boolean per_cent,carryover;
  1055. @y
  1056. static void flush_buffer(char *b,boolean per_cent,boolean carryover)
  1057.    /* outputs from |out_buf+1| to |b|, where |b<=out_ptr| */
  1058. @z
  1059. ------------------------------------------------------------------------------
  1060. ANSI
  1061. @x l.1299
  1062.   if (b<out_ptr) strncpy(out_buf+1,b+1,out_ptr-b);
  1063. @y
  1064.   if (b<out_ptr) strncpy(out_buf+1,b+1,(size_t)(out_ptr-b));
  1065. @z
  1066. ------------------------------------------------------------------------------
  1067. ANSI
  1068. @x l.1312
  1069. void
  1070. finish_line() /* do this at the end of a line */
  1071. @y
  1072. static void finish_line(void) /* do this at the end of a line */
  1073. @z
  1074. ------------------------------------------------------------------------------
  1075. MEMORY ALLOCATION, EXTENSIONS
  1076. @x l.1324
  1077. @ In particular, the |finish_line| procedure is called near the very
  1078. beginning of phase two. We initialize the output variables in a slightly
  1079. tricky way so that the first line of the output file will be
  1080. `\.{\\input cwebmac}'.
  1081.  
  1082. @<Set init...@>=
  1083. out_ptr=out_buf+1; out_line=1; active_file=tex_file;
  1084. *out_ptr='c'; tex_printf("\\input cwebma");
  1085. @y
  1086. @ In particular, the |finish_line| procedure is called near the very
  1087. beginning of phase two. We initialize the output variables in a slightly
  1088. tricky way so that the first line of the output file will be dependent of
  1089. the user language set by the `\.{+l}' option and its argument.  If you call
  1090. \.{CWEAVE} with `\.{+lX}' (or `\.{-lX} as well), where `\.X' is the
  1091. (possibly empty) string of characters to the right of~`\.l', `\.X'~will be
  1092. prepended to `\.{cwebmac.tex}', e.g., if you call \.{CWEAVE} with
  1093. `\.{+ldeutsch}', you will receive the line `\.{\\input deutschcwebmac}'.
  1094.  
  1095. @<Set init...@>=
  1096. alloc_object(out_buf,line_length+1,char);
  1097. out_buf_end = out_buf + line_length;
  1098. out_ptr=out_buf+1; out_line=1; active_file=tex_file; *out_ptr='c';
  1099. tex_printf("\\input ");
  1100. fprintf(active_file,"%s",use_language);
  1101. tex_printf("cwebma");
  1102. @z
  1103. ------------------------------------------------------------------------------
  1104. ANSI
  1105. @x l.1344
  1106. void
  1107. out_str(s) /* output characters from |s| to end of string */
  1108. char *s;
  1109. @y
  1110. static void out_str(char*s) /* output characters from |s| to end of string */
  1111. @z
  1112. ------------------------------------------------------------------------------
  1113. ANSI
  1114. @x l.1362
  1115. @<Predecl...@>=
  1116. void break_out();
  1117.  
  1118. @ @c
  1119. void
  1120. break_out() /* finds a way to break the output line */
  1121. @y
  1122. @<Predecl...@>=
  1123. static void break_out(void);
  1124.  
  1125. @ @c static void break_out(void) /* finds a way to break the output line */
  1126. @z
  1127. ------------------------------------------------------------------------------
  1128. TRANSLATION
  1129. @x l.1388
  1130.   printf("\n! Line had to be broken (output l. %d):\n",out_line);
  1131. @y
  1132.   printf(get_string(MSG_WARNING_CW85),out_line);
  1133. @z
  1134. ------------------------------------------------------------------------------
  1135. ANSI
  1136. @x l.1401
  1137. void
  1138. out_section(n)
  1139. sixteen_bits n;
  1140. @y
  1141. static void out_section(sixteen_bits n)
  1142. @z
  1143. ------------------------------------------------------------------------------
  1144. ANSI, SYSTEM DEPENDENCIES
  1145. @x l.1415
  1146. void
  1147. out_name(p)
  1148. name_pointer p;
  1149. {
  1150.   char *k, *k_end=(p+1)->byte_start; /* pointers into |byte_mem| */
  1151. @y
  1152. static void out_name(name_pointer p)
  1153. {
  1154.   char HUGE *k;
  1155.   char HUGE *k_end=(p+1)->byte_start; /* pointers into |byte_mem| */
  1156. @z
  1157. ------------------------------------------------------------------------------
  1158. ANSI
  1159. @x l.1442
  1160. void
  1161. copy_limbo()
  1162. @y
  1163. static void copy_limbo(void)
  1164. @z
  1165. ------------------------------------------------------------------------------
  1166. TRANSLATION
  1167. @x l.1461
  1168.         default: err_print("! Double @@ should be used in limbo");
  1169. @y
  1170.         default: err_print(get_string(MSG_ERROR_CT93));
  1171. @z
  1172. ------------------------------------------------------------------------------
  1173. ANSI
  1174. @x l.1477
  1175. eight_bits
  1176. copy_TeX()
  1177. @y
  1178. static eight_bits copy_TeX(void)
  1179. @z
  1180. ------------------------------------------------------------------------------
  1181. TRANSLATION
  1182. @x l.1503
  1183. @d app_tok(c) {if (tok_ptr+2>tok_mem_end) overflow("token"); *(tok_ptr++)=c;}
  1184. @y
  1185. @d app_tok(c) {if (tok_ptr+2>tok_mem_end)
  1186.     overflow(get_string(MSG_OVERFLOW_CT26));
  1187.   *(tok_ptr++)=c;}
  1188. @z
  1189. ------------------------------------------------------------------------------
  1190. ANSI
  1191. @x l.1505
  1192. @<Predec...@>=
  1193. int copy_comment();
  1194.  
  1195. @ @c
  1196. int copy_comment(is_long_comment,bal) /* copies \TEX/ code in comments */
  1197. boolean is_long_comment; /* is this a traditional \CEE/ comment? */
  1198. int bal; /* brace balance */
  1199. @y
  1200. @<Predec...@>=
  1201. static int copy_comment(boolean,int);
  1202.  
  1203. @ @c static copy_comment(@t\1\1@> /* copies \TeX\ code in comments */
  1204.   boolean is_long_comment, /* is this a traditional \CEE/ comment? */
  1205.   int bal@t\2\2@>) /* brace balance */
  1206. @z
  1207. ------------------------------------------------------------------------------
  1208. TRANSLATION
  1209. @x l.1518
  1210.           err_print("! Input ended in mid-comment");
  1211. @y
  1212.           err_print(get_string(MSG_ERROR_CT60_1));
  1213. @z
  1214. ------------------------------------------------------------------------------
  1215. TRANSLATION
  1216. @x l.1524
  1217.         if (bal>1) err_print("! Missing } in comment");
  1218. @y
  1219.         if (bal>1) err_print(get_string(MSG_ERROR_CW92_1));
  1220. @z
  1221. ------------------------------------------------------------------------------
  1222. TRANSLATION
  1223. @x l.1540
  1224.       else {err_print("! Extra } in comment");
  1225. @y
  1226.       else {err_print(get_string(MSG_ERROR_CW92_2));
  1227. @z
  1228. ------------------------------------------------------------------------------
  1229. TRANSLATION
  1230. @x l.1552
  1231.   if (bal>1) err_print("! Missing } in comment");
  1232. @y
  1233.   if (bal>1) err_print(get_string(MSG_ERROR_CW92_1));
  1234. @z
  1235. ------------------------------------------------------------------------------
  1236. TRANSLATION
  1237. @x l.1560
  1238.     err_print("! Illegal use of @@ in comment");
  1239. @y
  1240.     err_print(get_string(MSG_ERROR_CW94));
  1241. @z
  1242. ------------------------------------------------------------------------------
  1243. MEMORY ALLOCATION
  1244. @x l.1670
  1245. char cat_name[256][12];
  1246. eight_bits cat_index;
  1247.  
  1248. @ @<Set in...@>=
  1249. @y
  1250. char **cat_name;
  1251. eight_bits cat_index;
  1252.  
  1253. @ @<Set in...@>=
  1254.     alloc_object(cat_name,256,char *);
  1255.     for(cat_index=0; cat_index<255; cat_index++)
  1256.       alloc_object(cat_name[cat_index],12,char);
  1257. @z
  1258. ------------------------------------------------------------------------------
  1259. ANSI
  1260. @x l.1734
  1261. void
  1262. print_cat(c) /* symbolic printout of a category */
  1263. eight_bits c;
  1264. @y
  1265. static void print_cat(eight_bits c) /* symbolic printout of a category */
  1266. @z
  1267. ------------------------------------------------------------------------------
  1268. MEMORY ALLOCATION
  1269. @x l.2025
  1270. scrap scrap_info[max_scraps]; /* memory array for scraps */
  1271. scrap_pointer scrap_info_end=scrap_info+max_scraps -1; /* end of |scrap_info| */
  1272. @y
  1273. scrap_pointer scrap_info; /* memory array for scraps */
  1274. scrap_pointer scrap_info_end; /* end of |scrap_info| */
  1275. @z
  1276. ------------------------------------------------------------------------------
  1277. MEMORY ALLOCATION
  1278. @x l.2034
  1279. @ @<Set init...@>=
  1280. scrap_base=scrap_info+1;
  1281. max_scr_ptr=scrap_ptr=scrap_info;
  1282. @y
  1283. @ @<Set init...@>=
  1284. alloc_object(scrap_info,max_scraps,scrap);
  1285. scrap_info_end = scrap_info + max_scraps - 1;
  1286. scrap_base=scrap_info+1;
  1287. max_scr_ptr=scrap_ptr=scrap_info;
  1288. @z
  1289. ------------------------------------------------------------------------------
  1290. ANSI
  1291. @x l.2062
  1292. void
  1293. print_text(p) /* prints a token list for debugging; not used in |main| */
  1294. text_pointer p;
  1295. @y
  1296. static void print_text(text_pointer p)
  1297.    /* prints a token list for debugging; not used in |main| */
  1298. @z
  1299. ------------------------------------------------------------------------------
  1300. ANSI
  1301. @x l.2180
  1302. @d app(a) *(tok_ptr++)=a
  1303. @d app1(a) *(tok_ptr++)=tok_flag+(int)((a)->trans-tok_start)
  1304. @y
  1305. @d app(a) *(tok_ptr++)=(token)(a)
  1306. @d app1(a) *(tok_ptr++)=(token)(tok_flag+(int)((a)->trans-tok_start))
  1307. @z
  1308. ------------------------------------------------------------------------------
  1309. ANSI
  1310. @x l.2186
  1311. @ @c
  1312. void
  1313. app_str(s)
  1314. char *s;
  1315. @y
  1316. @ @c static void app_str(char *s)
  1317. @z
  1318. ------------------------------------------------------------------------------
  1319. ANSI
  1320. @x l.2194
  1321. void
  1322. big_app(a)
  1323. token a;
  1324. @y
  1325. static void big_app(token a)
  1326. @z
  1327. ------------------------------------------------------------------------------
  1328. ANSI
  1329. @x l.2211
  1330. void
  1331. big_app1(a)
  1332. scrap_pointer a;
  1333. @y
  1334. static void big_app1(scrap_pointer a)
  1335. @z
  1336. ------------------------------------------------------------------------------
  1337. ANSI
  1338. @x l.2312
  1339. token_pointer
  1340. find_first_ident(p)
  1341. text_pointer p;
  1342. @y
  1343. static token_pointer find_first_ident(text_pointer p)
  1344. @z
  1345. ------------------------------------------------------------------------------
  1346. ANSI
  1347. @x l.2339
  1348. void
  1349. make_reserved(p) /* make the first identifier in |p->trans| like |int| */
  1350. scrap_pointer p;
  1351. @y
  1352. static void make_reserved(scrap_pointer p)
  1353. /* make the first identifier in |p->trans| like |int| */
  1354. @z
  1355. ------------------------------------------------------------------------------
  1356. ANSI
  1357. @x l.2356
  1358.   (name_dir+(sixteen_bits)(tok_value%id_flag))->ilk=raw_int;
  1359. @y
  1360.   (name_dir+(ptrdiff_t)(tok_value%id_flag))->ilk=raw_int;
  1361. @z
  1362. ------------------------------------------------------------------------------
  1363. ANSI
  1364. @x l.2370
  1365. void
  1366. make_underlined(p)
  1367. /* underline the entry for the first identifier in |p->trans| */
  1368. scrap_pointer p;
  1369. @y
  1370. static void make_underlined(scrap_pointer p)
  1371. /* underline the entry for the first identifier in |p->trans| */
  1372. @z
  1373. ------------------------------------------------------------------------------
  1374. ANSI
  1375. @x l.2387
  1376. @<Predecl...@>=
  1377. void  underline_xref();
  1378.  
  1379. @ @c
  1380. void
  1381. underline_xref(p)
  1382. name_pointer p;
  1383. @y
  1384. @<Predecl...@>=
  1385. static void underline_xref(name_pointer);
  1386.  
  1387. @ @c
  1388. static void underline_xref(name_pointer p)
  1389. @z
  1390. ------------------------------------------------------------------------------
  1391. SYSTEM DEPENDENCIES
  1392. @x l.2423
  1393.   p->xref=(char*)xref_ptr;
  1394. @y
  1395.   p->xref=(void HUGE*)xref_ptr;
  1396. @z
  1397. ------------------------------------------------------------------------------
  1398. EXTENSIONS
  1399. CWeave indents declarations after old-style function definitions.  With the
  1400. `-i' option they will come out flush left.  You won't see any difference if
  1401. you use the ANSI-style function definitions.
  1402. @x l.2432
  1403. @<Cases for |exp|@>=
  1404. if (cat1==lbrace || cat1==int_like || cat1==decl) {
  1405.   make_underlined(pp); big_app1(pp); big_app(indent); app(indent);
  1406.   reduce(pp,1,fn_decl,0,1);
  1407. }
  1408. @y
  1409. @<Cases for |exp|@>=
  1410. if(cat1==lbrace || cat1==int_like || cat1==decl) {
  1411.   make_underlined(pp); big_app1(pp);
  1412.   if (indent_param_decl) {
  1413.     big_app(indent); app(indent);
  1414.   }
  1415.   reduce(pp,1,fn_decl,0,1);
  1416. }
  1417. @z
  1418. ----------------------------------------------------------------------
  1419. EXTENSIONS
  1420. @x l.2537
  1421. @ @<Cases for |decl_head|@>=
  1422. if (cat1==comma) {
  1423.   big_app2(pp); big_app(' '); reduce(pp,2,decl_head,-1,33);
  1424. }
  1425. else if (cat1==unorbinop) {
  1426.   big_app1(pp); big_app('{'); big_app1(pp+1); big_app('}');
  1427.   reduce(pp,2,decl_head,-1,34);
  1428. }
  1429. else if (cat1==exp && cat2!=lpar && cat2!=exp) {
  1430.   make_underlined(pp+1); squash(pp,2,decl_head,-1,35);
  1431. }
  1432. else if ((cat1==binop||cat1==colon) && cat2==exp && (cat3==comma ||
  1433.     cat3==semi || cat3==rpar))
  1434.   squash(pp,3,decl_head,-1,36);
  1435. else if (cat1==cast) squash(pp,2,decl_head,-1,37);
  1436. else if (cat1==lbrace || (cat1==int_like&&cat2!=colcol) || cat1==decl) {
  1437.   big_app1(pp); big_app(indent); app(indent); reduce(pp,1,fn_decl,0,38);
  1438. }
  1439. else if (cat1==semi) squash(pp,2,decl,-1,39);
  1440. @y
  1441. @ @<Cases for |decl_head|@>=
  1442. if (cat1==comma) {
  1443.   big_app2(pp); big_app(' '); reduce(pp,2,decl_head,-1,33);
  1444. }
  1445. else if (cat1==unorbinop) {
  1446.   big_app1(pp); big_app('{'); big_app1(pp+1); big_app('}');
  1447.   reduce(pp,2,decl_head,-1,34);
  1448. }
  1449. else if (cat1==exp && cat2!=lpar && cat2!=exp) {
  1450.   make_underlined(pp+1); squash(pp,2,decl_head,-1,35);
  1451. }
  1452. else if ((cat1==binop||cat1==colon) && cat2==exp && (cat3==comma ||
  1453.     cat3==semi || cat3==rpar))
  1454.   squash(pp,3,decl_head,-1,36);
  1455. else if (cat1==cast) squash(pp,2,decl_head,-1,37);
  1456. else if (cat1==lbrace || (cat1==int_like&&cat2!=colcol) || cat1==decl) {
  1457.   big_app1(pp);
  1458.   if (indent_param_decl) {
  1459.     big_app(indent); app(indent);
  1460.   }
  1461.   reduce(pp,1,fn_decl,0,38);
  1462. }
  1463. else if (cat1==semi) squash(pp,2,decl,-1,39);
  1464. @z
  1465. ------------------------------------------------------------------------------
  1466. EXTENSIONS
  1467. The original manual described the `-o' option for CWEAVE, but this was not
  1468. yet present.  Here is a simple implementation.  The purpose is to suppress
  1469. the extra space between local variable declarations and the first statement
  1470. in a function block.
  1471. @x l.2562
  1472. else if (cat1==stmt || cat1==function) {
  1473.   big_app1(pp); big_app(big_force);
  1474.   big_app1(pp+1); reduce(pp,2,cat1,-1,41);
  1475. }
  1476. @y
  1477. else if (cat1==stmt || cat1==function) {
  1478.   big_app1(pp);
  1479.   if(order_decl_stmt) big_app(big_force);
  1480.   else big_app(force);
  1481.   big_app1(pp+1); reduce(pp,2,cat1,-1,41);
  1482. }
  1483. @z
  1484. ------------------------------------------------------------------------------
  1485. EXTENSION
  1486. @x l.2608
  1487. @ @<Cases for |fn_decl|@>=
  1488. if (cat1==decl) {
  1489.   big_app1(pp); big_app(force); big_app1(pp+1); reduce(pp,2,fn_decl,0,51);
  1490. }
  1491. else if (cat1==stmt) {
  1492.   big_app1(pp); app(outdent); app(outdent); big_app(force);
  1493.   big_app1(pp+1); reduce(pp,2,function,-1,52);
  1494. }
  1495. @y
  1496. @ @<Cases for |fn_decl|@>=
  1497. if (cat1==decl) {
  1498.   big_app1(pp); big_app(force); big_app1(pp+1); reduce(pp,2,fn_decl,0,51);
  1499. }
  1500. else if (cat1==stmt) {
  1501.   big_app1(pp);
  1502.   if (indent_param_decl) {
  1503.     app(outdent); app(outdent);
  1504.   }
  1505.   big_app(force);
  1506.   big_app1(pp+1); reduce(pp,2,function,-1,52);
  1507. }
  1508. @z
  1509. ----------------------------------------------------------------------
  1510. ANSI
  1511. @x l.2868
  1512. void
  1513. reduce(j,k,c,d,n)
  1514. scrap_pointer j;
  1515. eight_bits c;
  1516. short k, d, n;
  1517. @y
  1518. static void reduce(scrap_pointer j, short k, eight_bits c, short d, short n)
  1519. @z
  1520. ------------------------------------------------------------------------------
  1521. SYSTEM DEPENDENCIES
  1522. @x l.2890
  1523. @ @<Change |pp| to $\max...@>=
  1524. @y
  1525. @ @<Change |pp| to $\max...@>=
  1526. #ifdef __TURBOC__
  1527. if (d<0 && pp+d>pp) pp=scrap_base; /* segmented architecture caused wrap */
  1528. else
  1529. #endif
  1530. @z
  1531. ------------------------------------------------------------------------------
  1532. ANSI
  1533. @x l.2898
  1534. void
  1535. squash(j,k,c,d,n)
  1536. scrap_pointer j;
  1537. eight_bits c;
  1538. short k, d, n;
  1539. @y
  1540. static void squash(scrap_pointer j, short k, eight_bits c, short d, short n)
  1541. @z
  1542. ------------------------------------------------------------------------------
  1543. TRANSLATION
  1544. @x l.2933
  1545.     overflow("token");
  1546. @y
  1547.     overflow(get_string(MSG_OVERFLOW_CT30));
  1548. @z
  1549. ------------------------------------------------------------------------------
  1550. TRANSLATION
  1551. @x l.2937
  1552.     overflow("text");
  1553. @y
  1554.     overflow(get_string(MSG_OVERFLOW_CT76));
  1555. @z
  1556. ------------------------------------------------------------------------------
  1557. ANSI
  1558. @x l.2994
  1559. text_pointer
  1560. translate() /* converts a sequence of scraps */
  1561. @y
  1562. static text_pointer translate(void) /* converts a sequence of scraps */
  1563. @z
  1564. ------------------------------------------------------------------------------
  1565. TRANSLATION
  1566. @x l.3017
  1567.     if (tok_ptr+6>tok_mem_end) overflow("token");
  1568. @y
  1569.     if (tok_ptr+6>tok_mem_end) overflow(get_string(MSG_OVERFLOW_CT26));
  1570. @z
  1571. ------------------------------------------------------------------------------
  1572. TRANSLATION
  1573. @x l.3024
  1574.   printf("\nIrreducible scrap sequence in section %d:",section_count);
  1575. @y
  1576.   printf(get_string(MSG_WARNING_CW171),section_count);
  1577. @z
  1578. ------------------------------------------------------------------------------
  1579. TRANSLATION
  1580. @x l.3034
  1581.   printf("\nTracing after l. %d:\n",cur_line); mark_harmless;
  1582. @y
  1583.   printf(get_string(MSG_WARNING_CW172),cur_line); mark_harmless;
  1584. @z
  1585. ------------------------------------------------------------------------------
  1586. ANSI
  1587. @x l.3059
  1588. void
  1589. C_parse(spec_ctrl) /* creates scraps from \CEE/ tokens */
  1590.   eight_bits spec_ctrl;
  1591. @y
  1592. static void C_parse(eight_bits spec_ctrl)
  1593.   /* creates scraps from \CEE/ tokens */
  1594. @z
  1595. ------------------------------------------------------------------------------
  1596. TRANSLATION
  1597. @x l.3162
  1598.   overflow("scrap/token/text");
  1599. @y
  1600.   overflow(get_string(MSG_OVERFLOW_CW176));
  1601. @z
  1602. ------------------------------------------------------------------------------
  1603. TRANSLATION
  1604. @x l.3246
  1605.         else err_print("! Double @@ should be used in strings");
  1606. @y
  1607.         else err_print(get_string(MSG_ERROR_CT80));
  1608. @z
  1609. ------------------------------------------------------------------------------
  1610. ANSI
  1611. @x l.3288
  1612. @<Predec...@>=
  1613. void app_cur_id();
  1614.  
  1615. @ @c
  1616. void
  1617. app_cur_id(scrapping)
  1618. boolean scrapping; /* are we making this into a scrap? */
  1619. @y
  1620. @<Predec...@>=
  1621. void app_cur_id(boolean);
  1622.  
  1623. @ @c
  1624. void app_cur_id(boolean scrapping) /* are we making this into a scrap? */
  1625. @z
  1626. ------------------------------------------------------------------------------
  1627. ANSI
  1628. @x l.3313
  1629. text_pointer
  1630. C_translate()
  1631. @y
  1632. static text_pointer C_translate(void)
  1633. @z
  1634. ------------------------------------------------------------------------------
  1635. TRANSLATION
  1636. @x l.3320
  1637.   if (next_control!='|') err_print("! Missing '|' after C text");
  1638. @y
  1639.   if (next_control!='|') err_print(get_string(MSG_ERROR_CW182));
  1640. @z
  1641. ------------------------------------------------------------------------------
  1642. ANSI
  1643. @x l.3335
  1644. void
  1645. outer_parse() /* makes scraps from \CEE/ tokens and comments */
  1646. @y
  1647. static void outer_parse(void) /* makes scraps from \CEE/ tokens and comments */
  1648. @z
  1649. ------------------------------------------------------------------------------
  1650. MEMORY ALLOCATION
  1651. @x l.3426
  1652. output_state stack[stack_size]; /* info for non-current levels */
  1653. stack_pointer stack_ptr; /* first unused location in the output state stack */
  1654. stack_pointer stack_end=stack+stack_size-1; /* end of |stack| */
  1655. @y
  1656. stack_pointer stack; /* info for non-current levels */
  1657. stack_pointer stack_end; /* end of |stack| */
  1658. stack_pointer stack_ptr; /* first unused location in the output state stack */
  1659. @z
  1660. ------------------------------------------------------------------------------
  1661. MEMORY ALLOCATION
  1662. @x l.3431
  1663. @ @<Set init...@>=
  1664. max_stack_ptr=stack;
  1665. @y
  1666. @ @<Set init...@>=
  1667. alloc_object(stack,stack_size,output_state);
  1668. stack_end = stack + stack_size - 1;
  1669. max_stack_ptr=stack;
  1670. @z
  1671. ------------------------------------------------------------------------------
  1672. ANSI
  1673. @x l.3439
  1674. void
  1675. push_level(p) /* suspends the current level */
  1676. text_pointer p;
  1677. @y
  1678. static void push_level(text_pointer p) /* suspends the current level */
  1679. @z
  1680. ------------------------------------------------------------------------------
  1681. TRANSLATION
  1682. @x l.3443
  1683.   if (stack_ptr==stack_end) overflow("stack");
  1684. @y
  1685.   if (stack_ptr==stack_end) overflow(get_string(MSG_OVERFLOW_CT30));
  1686. @z
  1687. ------------------------------------------------------------------------------
  1688. ANSI
  1689. @x l.3459
  1690. void
  1691. pop_level()
  1692. @y
  1693. static void pop_level(void)
  1694. @z
  1695. ------------------------------------------------------------------------------
  1696. ANSI
  1697. @x l.3481
  1698. eight_bits
  1699. get_output() /* returns the next token of output */
  1700. @y
  1701. static eight_bits get_output(void) /* returns the next token of output */
  1702. @z
  1703. ------------------------------------------------------------------------------
  1704. ANSI
  1705. @x l.3499
  1706.   return(a);
  1707. @y
  1708.   return((eight_bits)a);
  1709. @z
  1710. ------------------------------------------------------------------------------
  1711. ANSI
  1712. @x l.3523
  1713. void
  1714. output_C() /* outputs the current token list */
  1715. @y
  1716. static void output_C(void) /* outputs the current token list */
  1717. @z
  1718. ------------------------------------------------------------------------------
  1719. ANSI
  1720. @x l.3543
  1721. @<Predecl...@>=
  1722. void make_output();
  1723.  
  1724. @ @c
  1725. void
  1726. make_output() /* outputs the equivalents of tokens */
  1727. @y
  1728. @<Predecl...@>=
  1729. static void make_output(void);
  1730.  
  1731. @ @c
  1732. static void make_output(void) /* outputs the equivalents of tokens */
  1733. @z
  1734. ------------------------------------------------------------------------------
  1735. SYSTEM DEPENDENCIES
  1736. @x l.3554
  1737.   char *k, *k_limit; /* indices into |scratch| */
  1738. @y
  1739.   char HUGE *k;
  1740.   char HUGE *k_limit; /* indices into |scratch| */
  1741. @z
  1742. ------------------------------------------------------------------------------
  1743. SYSTEM DEPENDENCIES
  1744. We need a huge pointer here instead of j; k seems a good choice, since it is
  1745. declared as index into byte_mem anyhow.
  1746. @x l.3600
  1747.     for (p=cur_name->byte_start;p<(cur_name+1)->byte_start;p++)
  1748.       out(isxalpha(*p)? 'x':*p);
  1749. @y
  1750. #ifdef __TURBOC__
  1751.     for (k=cur_name->byte_start;k<(cur_name+1)->byte_start;k++)
  1752.       out(isxalpha(*k)? 'x':*k);
  1753. #else
  1754.     for (p=cur_name->byte_start;p<(cur_name+1)->byte_start;p++)
  1755.       out(isxalpha(*p)? 'x':*p);
  1756. #endif
  1757. @^system dependencies@>
  1758. @z
  1759. ------------------------------------------------------------------------------
  1760. SYSTEM DEPENDENCIES
  1761. @x l.3606
  1762.     for (p=cur_name->byte_start;p<(cur_name+1)->byte_start;p++)
  1763.       if (xislower(*p)) { /* not entirely uppercase */
  1764. @y
  1765. #ifdef __TURBOC__
  1766.     for (k=cur_name->byte_start;k<(cur_name+1)->byte_start;k++)
  1767.       if (xislower(*k)) { /* not entirely uppercase */
  1768. #else
  1769.     for (p=cur_name->byte_start;p<(cur_name+1)->byte_start;p++)
  1770.       if (xislower(*p)) { /* not entirely uppercase */
  1771. #endif
  1772. @^system dependencies@>
  1773. @z
  1774. ------------------------------------------------------------------------------
  1775. TRANSLATION
  1776. @x l.3757
  1777.   printf("\n! Illegal control code in section name: <");
  1778. @y
  1779.   printf(get_string(MSG_ERROR_CW201));
  1780. @z
  1781. ------------------------------------------------------------------------------
  1782. TRANSLATION
  1783. @x l.3772
  1784.     printf("\n! C text in section name didn't end: <");
  1785. @y
  1786.     printf(get_string(MSG_ERROR_CW202));
  1787. @z
  1788. ------------------------------------------------------------------------------
  1789. TRANSLATION
  1790. @x l.3784
  1791.       if (j>buffer+long_buf_size-3) overflow("buffer");
  1792. @y
  1793.       if (j>buffer+long_buf_size-3) overflow(get_string(MSG_OVERFLOW_CW202));
  1794. @z
  1795. ------------------------------------------------------------------------------
  1796. TRANSLATION
  1797. @x l.3792
  1798.   if (j>buffer+long_buf_size-4) overflow("buffer");
  1799. @y
  1800.   if (j>buffer+long_buf_size-4) overflow(get_string(MSG_OVERFLOW_CW202));
  1801. @z
  1802. ------------------------------------------------------------------------------
  1803. ANSI
  1804. @x l.3803
  1805. @<Predecl...@>=
  1806. void phase_two();
  1807.  
  1808. @ @c
  1809. void
  1810. phase_two() {
  1811. @y
  1812. @<Predecl...@>=
  1813. static void phase_two(void);
  1814.  
  1815. @ @c
  1816. static void phase_two(void) {
  1817. @z
  1818. ------------------------------------------------------------------------------
  1819. TRANSLATION
  1820. @x l.3809
  1821. reset_input(); if (show_progress) printf("\nWriting the output file...");
  1822. @y
  1823. reset_input(); if (show_progress) printf(get_string(MSG_PROGRESS_CW204));
  1824. @z
  1825. ------------------------------------------------------------------------------
  1826. TRANSLATION
  1827. @x l.3892
  1828.         err_print("! TeX string should be in C text only"); break;
  1829. @y
  1830.         err_print(get_string(MSG_ERROR_CW209_1)); break;
  1831. @z
  1832. ------------------------------------------------------------------------------
  1833. TRANSLATION
  1834. @x l.3898
  1835.         err_print("! You can't do that in TeX text"); break;
  1836. @y
  1837.         err_print(get_string(MSG_ERROR_CW209_2)); break;
  1838. @z
  1839. ------------------------------------------------------------------------------
  1840. ANSI
  1841. @x l.3926
  1842. @<Predecl...@>=
  1843. void finish_C();
  1844.  
  1845. @ @c
  1846. void
  1847. finish_C(visible) /* finishes a definition or a \CEE/ part */
  1848.   boolean visible; /* nonzero if we should produce \TEX/ output */
  1849. @y
  1850. @<Predecl...@>=
  1851. static void finish_C(boolean);
  1852.  
  1853. @ @c
  1854. static void finish_C(@t\1\1@> /* finishes a definition or a \Cee\ part */
  1855.   boolean visible@t\2\2@>) /* nonzero if we should produce \TeX\ output */
  1856. @z
  1857. ------------------------------------------------------------------------------
  1858. TRANSLATION
  1859. @x l.3970
  1860.     err_print("! Improper macro definition");
  1861. @y
  1862.     err_print(get_string(MSG_ERROR_CW213));
  1863. @z
  1864. ------------------------------------------------------------------------------
  1865. TRANSLATION
  1866. @x l.3979
  1867.       default: err_print("! Improper macro definition"); break;
  1868. @y
  1869.       default: err_print(get_string(MSG_ERROR_CW213)); break;
  1870. @z
  1871. ------------------------------------------------------------------------------
  1872. TRANSLATION
  1873. @x l.4005
  1874.   if (scrap_ptr!=scrap_info+2) err_print("! Improper format definition");
  1875. @y
  1876.   if (scrap_ptr!=scrap_info+2) err_print(get_string(MSG_ERROR_CW214));
  1877. @z
  1878. ------------------------------------------------------------------------------
  1879. TRANSLATION
  1880. @x l.4040
  1881.   err_print("! You need an = sign after the section name");
  1882. @y
  1883.   err_print(get_string(MSG_ERROR_CW217));
  1884. @z
  1885. ------------------------------------------------------------------------------
  1886. TRANSLATION
  1887. @x l.4062
  1888.   err_print("! You can't do that in C text");
  1889. @y
  1890.   err_print(get_string(MSG_ERROR_CW218));
  1891. @z
  1892. ------------------------------------------------------------------------------
  1893. ANSI
  1894. @x l.4097
  1895. @<Predecl...@>=
  1896. void footnote();
  1897.  
  1898. @ @c
  1899. void
  1900. footnote(flag) /* outputs section cross-references */
  1901. sixteen_bits flag;
  1902. @y
  1903. @<Predecl...@>=
  1904. static void footnote(sixteen_bits);
  1905.  
  1906. @ @c
  1907. static void footnote(sixteen_bits flag) /* outputs section cross-references */
  1908. @z
  1909. ------------------------------------------------------------------------------
  1910. ANSI, TRANSLATION, OUTPUT
  1911. Switching from the automatic string to `get_string' causes a timing
  1912. problem.  Obviously the output is buffered, so `fflush' its contents.
  1913. @x l.4146
  1914. @<Predecl...@>=
  1915. void phase_three();
  1916.  
  1917. @ @c
  1918. void
  1919. phase_three() {
  1920. if (no_xref) {
  1921.   finish_line();
  1922.   out_str("\\end");
  1923. @.\\end@>
  1924.   finish_line();
  1925. }
  1926. else {
  1927.   phase=3; if (show_progress) printf("\nWriting the index...");
  1928. @.Writing the index...@>
  1929.   finish_line();
  1930.   if ((idx_file=fopen(idx_file_name,"w"))==NULL)
  1931.     fatal("! Cannot open index file ",idx_file_name);
  1932. @.Cannot open index file@>
  1933.   if (change_exists) {
  1934.     @<Tell about changed sections@>; finish_line(); finish_line();
  1935.   }
  1936.   out_str("\\inx"); finish_line();
  1937. @.\\inx@>
  1938.   active_file=idx_file; /* change active file to the index file */
  1939.   @<Do the first pass of sorting@>;
  1940.   @<Sort and output the index@>;
  1941.   finish_line(); fclose(active_file); /* finished with |idx_file| */
  1942.   active_file=tex_file; /* switch back to |tex_file| for a tic */
  1943.   out_str("\\fin"); finish_line();
  1944. @.\\fin@>
  1945.   if ((scn_file=fopen(scn_file_name,"w"))==NULL)
  1946.     fatal("! Cannot open section file ",scn_file_name);
  1947. @.Cannot open section file@>
  1948.   active_file=scn_file; /* change active file to section listing file */
  1949.   @<Output all the section names@>;
  1950.   finish_line(); fclose(active_file); /* finished with |scn_file| */
  1951.   active_file=tex_file;
  1952.   if (group_found) out_str("\\con");@+else out_str("\\end");
  1953. @.\\con@>
  1954. @.\\end@>
  1955.   finish_line();
  1956.   fclose(active_file);
  1957. }
  1958. if (show_happiness) printf("\nDone.");
  1959. check_complete(); /* was all of the change file used? */
  1960. }
  1961. @y
  1962. @<Predecl...@>=
  1963. static void phase_three(void);
  1964.  
  1965. @ @c
  1966. static void phase_three(void) {
  1967. if (no_xref) {
  1968.   finish_line();
  1969.   out_str("\\end");
  1970. @.\\end@>
  1971.   active_file=tex_file;
  1972. }
  1973. else {
  1974.   phase=3;
  1975.   if (show_progress) {
  1976.     printf(get_string(MSG_PROGRESS_CW225)); fflush(stdout);
  1977.   }
  1978. @.Writing the index...@>
  1979.   finish_line();
  1980.   if ((idx_file=fopen(idx_file_name,"w"))==NULL)
  1981.     fatal(get_string(MSG_FATAL_CW225_1),idx_file_name);
  1982. @.Cannot open index file@>
  1983.   if (change_exists) {
  1984.     @<Tell about changed sections@>; finish_line(); finish_line();
  1985.   }
  1986.   out_str("\\inx"); finish_line();
  1987. @.\\inx@>
  1988.   active_file=idx_file; /* change active file to the index file */
  1989.   @<Do the first pass of sorting@>;
  1990.   @<Sort and output the index@>;
  1991.   finish_line(); fclose(active_file); /* finished with |idx_file| */
  1992.   active_file=tex_file; /* switch back to |tex_file| for a tic */
  1993.   out_str("\\fin"); finish_line();
  1994. @.\\fin@>
  1995.   if ((scn_file=fopen(scn_file_name,"w"))==NULL)
  1996.     fatal(get_string(MSG_FATAL_CW225_2),scn_file_name);
  1997. @.Cannot open section file@>
  1998.   active_file=scn_file; /* change active file to section listing file */
  1999.   @<Output all the section names@>;
  2000.   finish_line(); fclose(active_file); /* finished with |scn_file| */
  2001.   active_file=tex_file;
  2002.   if (group_found) out_str("\\con");@+else out_str("\\end");
  2003. @.\\con@>
  2004. @.\\end@>
  2005. }
  2006. finish_line(); fclose(active_file); active_file=NULL;
  2007. @<Update the result when it has changed@>@;
  2008. if (show_happiness) printf(get_string(MSG_PROGRESS_CT42_3));
  2009. check_complete(); /* was all of the change file used? */
  2010. }
  2011. @z
  2012. ------------------------------------------------------------------------------
  2013. MEMORY ALLOCATION
  2014. @x l.4224
  2015. name_pointer bucket[256];
  2016. name_pointer next_name; /* successor of |cur_name| when sorting */
  2017. name_pointer blink[max_names]; /* links in the buckets */
  2018. @y
  2019. name_pointer *bucket;
  2020. name_pointer next_name; /* successor of |cur_name| when sorting */
  2021. name_pointer *blink; /* links in the buckets */
  2022. @z
  2023. ------------------------------------------------------------------------------
  2024. SYSTEM DEPENDENCIES
  2025. @x l.4238
  2026.     if (cur_name->xref!=(char*)xmem) {
  2027. @y
  2028.     if (cur_name->xref!=(void HUGE*)xmem) {
  2029. @z
  2030. ------------------------------------------------------------------------------
  2031. SYSTEM DEPENDENCIES
  2032. @x l.4268
  2033. char *cur_byte; /* index into |byte_mem| */
  2034. @y
  2035. char HUGE *cur_byte; /* index into |byte_mem| */
  2036. @z
  2037. ------------------------------------------------------------------------------
  2038. MEMORY ALLOCATION
  2039. @x l.4272
  2040. @ @<Set init...@>=
  2041. max_sort_ptr=scrap_info;
  2042. @y
  2043. @ @<Set init...@>=
  2044. alloc_object(bucket,256,name_pointer);
  2045. alloc_object(blink,max_names,name_pointer);
  2046. max_sort_ptr=scrap_info;
  2047. @z
  2048. ------------------------------------------------------------------------------
  2049. MEMORY ALLOCATION
  2050. The \.{@@t} feature causes problems when there are `<' or `>' operators
  2051. placed directly aside the `@t...@>' group.  Most of the other C operators
  2052. work fine.  Provide an improvement of the documentation.
  2053. @x l.4275
  2054. @ The desired alphabetic order is specified by the |collate| array; namely,
  2055. |collate[0]<collate[1]<@t$\cdots$@><collate[100]|.
  2056.  
  2057. @<Global...@>=
  2058. eight_bits collate[102+128]; /* collation order */
  2059. @^high-bit character handling@>
  2060. @y
  2061. @ The desired alphabetic order is specified by the |collate| array; namely,
  2062. |collate[0]@t${}<\cdots<{}$@>collate[100]|.
  2063.  
  2064. @<Global...@>=
  2065. eight_bits *collate; /* collation order */
  2066. @^high-bit character handling@>
  2067. @z
  2068. ------------------------------------------------------------------------------
  2069. ANSI, MEMORY ALLOCATION
  2070. @x l.4289
  2071. collate[0]=0; strcpy(collate+1," \1\2\3\4\5\6\7\10\11\12\13\14\15\16\17\
  2072. \20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\
  2073. !\42#$%&'()*+,-./:;<=>?@@[\\]^`{|}~_\
  2074. abcdefghijklmnopqrstuvwxyz0123456789\
  2075. \200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\
  2076. \220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\
  2077. \240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\
  2078. \260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\
  2079. \300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\
  2080. \320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\
  2081. \340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\
  2082. \360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\
  2083. ");
  2084. @y
  2085. alloc_object(collate,102+128,eight_bits);
  2086. collate[0]=0; strcpy((char *)collate+1,
  2087.   " \1\2\3\4\5\6\7\10\11\12\13\14\15\16\17"@|
  2088.   "\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37"@|
  2089.   "!\42#$%&'()*+,-./:;<=>?@@[\\]^`{|}~_abcdefghijklmnopqrstuvwxyz0123456789"@|
  2090.   "\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217"@|
  2091.   "\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237"@|
  2092.   "\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257"@|
  2093.   "\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277"@|
  2094.   "\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"@|
  2095.   "\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"@|
  2096.   "\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357"@|
  2097.   "\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377");
  2098. @z
  2099. ------------------------------------------------------------------------------
  2100. ANSI
  2101. @x l.4311
  2102. @<Predecl...@>=
  2103. void  unbucket();
  2104.  
  2105. @ @c
  2106. void
  2107. unbucket(d) /* empties buckets having depth |d| */
  2108. eight_bits d;
  2109. @y
  2110. @<Predecl...@>=
  2111. static void unbucket(eight_bits);
  2112.  
  2113. @ @c
  2114. static void unbucket(eight_bits d) /* empties buckets having depth |d| */
  2115. @z
  2116. ------------------------------------------------------------------------------
  2117. TRANSLATION
  2118. @x l.4323
  2119.     if (sort_ptr>=scrap_info_end) overflow("sorting");
  2120. @y
  2121.     if (sort_ptr>=scrap_info_end) overflow(get_string(MSG_OVERFLOW_CW237));
  2122. @z
  2123. ------------------------------------------------------------------------------
  2124. SYSTEM DEPENDENCIES
  2125. @x l.4372
  2126.     else {char *j;
  2127. @y
  2128.     else {char HUGE *j;
  2129. @z
  2130. ------------------------------------------------------------------------------
  2131. SYSTEM DEPENDENCIES
  2132. @x l.4387
  2133.   case custom: case quoted: {char *j; out_str("$\\");
  2134. @y
  2135.   case custom: case quoted: {char HUGE *j; out_str("$\\");
  2136. @z
  2137. ------------------------------------------------------------------------------
  2138. ANSI
  2139. @x l.4431
  2140. @<Predecl...@>=
  2141. void section_print();
  2142.  
  2143. @ @c
  2144. void
  2145. section_print(p) /* print all section names in subtree |p| */
  2146. name_pointer p;
  2147. @y
  2148. @<Predecl...@>=
  2149. static void section_print(name_pointer);
  2150.  
  2151. @ @c
  2152. static void section_print(name_pointer p) /* print all section names in subtree |p| */
  2153. @z
  2154. ------------------------------------------------------------------------------
  2155. ANSI, TRANSLATION
  2156. @x l.4453
  2157. @ Because on some systems the difference between two pointers is a |long|
  2158. rather than an |int|, we use \.{\%ld} to print these quantities.
  2159.  
  2160. @c
  2161. void
  2162. print_stats() {
  2163.   printf("\nMemory usage statistics:\n");
  2164. @.Memory usage statistics:@>
  2165.   printf("%ld names (out of %ld)\n",
  2166.             (long)(name_ptr-name_dir),(long)max_names);
  2167.   printf("%ld cross-references (out of %ld)\n",
  2168.             (long)(xref_ptr-xmem),(long)max_refs);
  2169.   printf("%ld bytes (out of %ld)\n",
  2170.             (long)(byte_ptr-byte_mem),(long)max_bytes);
  2171.   printf("Parsing:\n");
  2172.   printf("%ld scraps (out of %ld)\n",
  2173.             (long)(max_scr_ptr-scrap_info),(long)max_scraps);
  2174.   printf("%ld texts (out of %ld)\n",
  2175.             (long)(max_text_ptr-tok_start),(long)max_texts);
  2176.   printf("%ld tokens (out of %ld)\n",
  2177.             (long)(max_tok_ptr-tok_mem),(long)max_toks);
  2178.   printf("%ld levels (out of %ld)\n",
  2179.             (long)(max_stack_ptr-stack),(long)stack_size);
  2180.   printf("Sorting:\n");
  2181.   printf("%ld levels (out of %ld)\n",
  2182.             (long)(max_sort_ptr-scrap_info),(long)max_scraps);
  2183. }
  2184. @y
  2185. @ {\mc ANSI C} declares the difference between two pointers to be of type
  2186. |ptrdiff_t| which equals |long| on (almost) all systems instead of |int|,
  2187. so we use \.{\%ld} to print these quantities and cast them to |long|
  2188. explicitly.
  2189.  
  2190. @c
  2191. void print_stats(void) {
  2192.   printf(get_string(MSG_STATS_CT95_1));
  2193. @.Memory usage statistics:@>
  2194.   printf(get_string(MSG_STATS_CT95_2),
  2195.             (long)(name_ptr-name_dir),(long)max_names);
  2196.   printf(get_string(MSG_STATS_CW248_1),
  2197.             (long)(xref_ptr-xmem),(long)max_refs);
  2198.   printf(get_string(MSG_STATS_CT95_4),
  2199.             (long)(byte_ptr-byte_mem),(long)max_bytes);
  2200.   printf(get_string(MSG_STATS_CW248_2));
  2201.   printf(get_string(MSG_STATS_CW248_3),
  2202.             (long)(max_scr_ptr-scrap_info),(long)max_scraps);
  2203.   printf(get_string(MSG_STATS_CW248_4),
  2204.             (long)(max_text_ptr-tok_start),(long)max_texts);
  2205.   printf(get_string(MSG_STATS_CT95_5),
  2206.             (long)(max_tok_ptr-tok_mem),(long)max_toks);
  2207.   printf(get_string(MSG_STATS_CW248_5),
  2208.             (long)(max_stack_ptr-stack),(long)stack_size);
  2209.   printf(get_string(MSG_STATS_CW248_6));
  2210.   printf(get_string(MSG_STATS_CW248_5),
  2211.             (long)(max_sort_ptr-scrap_info),(long)max_scraps);
  2212. }
  2213. @z
  2214. ------------------------------------------------------------------------------
  2215. ANSI, SYSTEM DEPENDENCIES, OUTPUT
  2216. @x l.4481
  2217. @** Index.
  2218. @y
  2219. @** Function declarations.  Here are declarations---conforming to
  2220. {\mc ANSI~C}---of all functions in this code, as far as they are
  2221. not already in |"common.h"|.  These are private to \.{CWEAVE}.
  2222.  
  2223. @<Predecl...@>=
  2224. static eight_bits copy_TeX(void);@/
  2225. static eight_bits get_output(void);@/
  2226. static text_pointer C_translate(void);@/
  2227. static text_pointer translate(void);@/
  2228. static token_pointer find_first_ident(text_pointer);@/
  2229. static unsigned skip_TeX(void);@/
  2230. static void app_str(char *);@/
  2231. static void big_app(token);@/
  2232. static void big_app1(scrap_pointer);@/
  2233. static void copy_limbo(void);@/
  2234. static void C_parse(eight_bits);@/
  2235. static void finish_line(void);@/
  2236. static void flush_buffer(char *,boolean,boolean);@/
  2237. static void make_reserved(scrap_pointer);@/
  2238. static void make_underlined(scrap_pointer);@/
  2239. static void new_section_xref(name_pointer);@/
  2240. static void new_xref(name_pointer);@/
  2241. static void outer_parse(void);@/
  2242. static void output_C(void);@/
  2243. static void out_name(name_pointer);@/
  2244. static void out_section(sixteen_bits);@/
  2245. static void out_str(char *);@/
  2246. static void pop_level(void);@/
  2247. static void print_cat(eight_bits);@/
  2248. static void print_text(text_pointer p);@/
  2249. static void push_level(text_pointer);@/
  2250. static void reduce(scrap_pointer,short,eight_bits,short,short);@/
  2251. static void set_file_flag(name_pointer);@/
  2252. static void skip_limbo(void);@/
  2253. static void squash(scrap_pointer,short,eight_bits,short,short);@/
  2254. #ifdef DEAD_CODE
  2255. static void out_str_del(char *,char *);@/
  2256. #endif
  2257.  
  2258. @* Version information.  The {\mc AMIGA} operating system provides the
  2259. `version' command and good programs answer with some informations about
  2260. their creation date and their current version.
  2261.  
  2262. @<Glob...@>=
  2263. #ifdef __SASC
  2264. const char Version[] = "$VER: CWeave 3.3 [p11] ("__DATE__", "__TIME__")\n";
  2265. #endif
  2266. @^system dependencies@>
  2267.  
  2268. @* Output file update.  Most \CEE/ projects are controlled by a
  2269. \.{makefile} which automatically takes care of the temporal dependecies
  2270. between the different source modules.  It is suitable that \.{CWEB} doesn't
  2271. create new output for all existing files, when there are only changes to
  2272. some of them.  Thus the \.{make} process will only recompile those modules
  2273. where necessary. The idea and basic implementation of this mechanism can
  2274. be found in the program \.{NUWEB} by Preston Briggs, to whom credit is due.
  2275.  
  2276. @d free_object(object)
  2277.    if(object) {
  2278.       free(object);
  2279.       object=NULL;
  2280.       }
  2281.  
  2282. @<Update the result...@>=
  2283. if(tex_file=fopen(tex_file_name,"r")) {
  2284.   char *x,*y;
  2285.   int x_size,y_size;
  2286.  
  2287.   if(!(check_file=fopen(check_file_name,"r")))
  2288.     fatal(get_string(MSG_FATAL_CO78),check_file_name);
  2289.  
  2290.   alloc_object(x,BUFSIZ,char);
  2291.   alloc_object(y,BUFSIZ,char);
  2292.  
  2293.   @<Compare the temporary output to the previous output@>@;
  2294.  
  2295.   fclose(tex_file); tex_file=NULL;
  2296.   fclose(check_file); check_file=NULL;
  2297.  
  2298.   @<Take appropriate action depending on the comparison@>@;
  2299.  
  2300.   free_object(y);
  2301.   free_object(x);
  2302.   }
  2303. else
  2304.   rename(check_file_name,tex_file_name); /* This was the first run */
  2305.  
  2306. check_file_name=NULL; /* We want to get rid of the temporary file */
  2307.  
  2308. @ We hope that this runs fast on most systems.
  2309.  
  2310. @<Compare the temp...@>=
  2311. do {
  2312.   x_size = fread(x,1,BUFSIZ,tex_file);
  2313.   y_size = fread(y,1,BUFSIZ,check_file);
  2314.   } while((x_size == y_size) && !memcmp(x,y,x_size) &&
  2315.           !feof(tex_file) && !feof(check_file));
  2316.  
  2317. @ Note the superfluous call to |remove| before |rename|.  We're using it to
  2318. get around a bug in some implementations of |rename|.
  2319.  
  2320. @<Take appropriate action...@>=
  2321. if((x_size != y_size) || memcmp(x,y,x_size)) {
  2322.   remove(tex_file_name);
  2323.   rename(check_file_name,tex_file_name);
  2324.   }
  2325. else
  2326.   remove(check_file_name); /* The output remains untouched */
  2327.  
  2328. @** Index.
  2329. @z
  2330. ------------------------------------------------------------------------------
  2331.