home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / c / cweb / cweave.ch < prev    next >
Encoding:
Text File  |  1994-08-12  |  70.7 KB  |  2,287 lines

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