home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume22 / crefine / part04 < prev    next >
Encoding:
Text File  |  1991-08-26  |  45.2 KB  |  1,269 lines

  1. Newsgroups: comp.sources.misc
  2. From: Lutz Prechelt <prechelt@i41s14.ira.uka.de>
  3. Subject:  v22i066:  crefine - C-Refine preprocessor, Part04/04
  4. Message-ID: <1991Aug26.032439.15277@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 49cda8a68d998752ae112de6e81040ce
  6. Date: Mon, 26 Aug 1991 03:24:39 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Lutz Prechelt <prechelt@i41s14.ira.uka.de>
  10. Posting-number: Volume 22, Issue 66
  11. Archive-name: crefine/part04
  12. Environment: UNIX, MS-DOS, TOS, C, C++, Objective-C
  13.  
  14. #! /bin/sh
  15. # into a shell via "sh file" or similar.  To overwrite existing files,
  16. # type "sh file -c".
  17. # The tool that generated this appeared in the comp.sources.unix newsgroup;
  18. # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
  19. # Contents:  COPYING Makefile cr_decl.h cr_talk.cr cr_texts.h erato.c
  20. #   erato.cr getargs.h std.h
  21. # Wrapped by kent@sparky on Sun Aug 25 21:56:47 1991
  22. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  23. echo If this archive is complete, you will see the following message:
  24. echo '          "shar: End of archive 4 (of 4)."'
  25. if test -f 'COPYING' -a "${1}" != "-c" ; then 
  26.   echo shar: Will not clobber existing file \"'COPYING'\"
  27. else
  28.   echo shar: Extracting \"'COPYING'\" \(12488 characters\)
  29.   sed "s/^X//" >'COPYING' <<'END_OF_FILE'
  30. X
  31. X            GNU GENERAL PUBLIC LICENSE
  32. X             Version 1, February 1989
  33. X
  34. X Copyright (C) 1989 Free Software Foundation, Inc.
  35. X                    675 Mass Ave, Cambridge, MA 02139, USA
  36. X Everyone is permitted to copy and distribute verbatim copies
  37. X of this license document, but changing it is not allowed.
  38. X
  39. X                Preamble
  40. X
  41. X  The license agreements of most software companies try to keep users
  42. Xat the mercy of those companies.  By contrast, our General Public
  43. XLicense is intended to guarantee your freedom to share and change free
  44. Xsoftware--to make sure the software is free for all its users.  The
  45. XGeneral Public License applies to the Free Software Foundation's
  46. Xsoftware and to any other program whose authors commit to using it.
  47. XYou can use it for your programs, too.
  48. X
  49. X  When we speak of free software, we are referring to freedom, not
  50. Xprice.  Specifically, the General Public License is designed to make
  51. Xsure that you have the freedom to give away or sell copies of free
  52. Xsoftware, that you receive source code or can get it if you want it,
  53. Xthat you can change the software or use pieces of it in new free
  54. Xprograms; and that you know you can do these things.
  55. X
  56. X  To protect your rights, we need to make restrictions that forbid
  57. Xanyone to deny you these rights or to ask you to surrender the rights.
  58. XThese restrictions translate to certain responsibilities for you if you
  59. Xdistribute copies of the software, or if you modify it.
  60. X
  61. X  For example, if you distribute copies of a such a program, whether
  62. Xgratis or for a fee, you must give the recipients all the rights that
  63. Xyou have.  You must make sure that they, too, receive or can get the
  64. Xsource code.  And you must tell them their rights.
  65. X
  66. X  We protect your rights with two steps: (1) copyright the software, and
  67. X(2) offer you this license which gives you legal permission to copy,
  68. Xdistribute and/or modify the software.
  69. X
  70. X  Also, for each author's protection and ours, we want to make certain
  71. Xthat everyone understands that there is no warranty for this free
  72. Xsoftware.  If the software is modified by someone else and passed on, we
  73. Xwant its recipients to know that what they have is not the original, so
  74. Xthat any problems introduced by others will not reflect on the original
  75. Xauthors' reputations.
  76. X
  77. X  The precise terms and conditions for copying, distribution and
  78. Xmodification follow.
  79. X
  80. X            GNU GENERAL PUBLIC LICENSE
  81. X   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  82. X
  83. X  0. This License Agreement applies to any program or other work which
  84. Xcontains a notice placed by the copyright holder saying it may be
  85. Xdistributed under the terms of this General Public License.  The
  86. X"Program", below, refers to any such program or work, and a "work based
  87. Xon the Program" means either the Program or any work containing the
  88. XProgram or a portion of it, either verbatim or with modifications.  Each
  89. Xlicensee is addressed as "you".
  90. X
  91. X  1. You may copy and distribute verbatim copies of the Program's source
  92. Xcode as you receive it, in any medium, provided that you conspicuously and
  93. Xappropriately publish on each copy an appropriate copyright notice and
  94. Xdisclaimer of warranty; keep intact all the notices that refer to this
  95. XGeneral Public License and to the absence of any warranty; and give any
  96. Xother recipients of the Program a copy of this General Public License
  97. Xalong with the Program.  You may charge a fee for the physical act of
  98. Xtransferring a copy.
  99. X
  100. X  2. You may modify your copy or copies of the Program or any portion of
  101. Xit, and copy and distribute such modifications under the terms of Paragraph
  102. X1 above, provided that you also do the following:
  103. X
  104. X    a) cause the modified files to carry prominent notices stating that
  105. X    you changed the files and the date of any change; and
  106. X
  107. X    b) cause the whole of any work that you distribute or publish, that
  108. X    in whole or in part contains the Program or any part thereof, either
  109. X    with or without modifications, to be licensed at no charge to all
  110. X    third parties under the terms of this General Public License (except
  111. X    that you may choose to grant warranty protection to some or all
  112. X    third parties, at your option).
  113. X
  114. X    c) If the modified program normally reads commands interactively when
  115. X    run, you must cause it, when started running for such interactive use
  116. X    in the simplest and most usual way, to print or display an
  117. X    announcement including an appropriate copyright notice and a notice
  118. X    that there is no warranty (or else, saying that you provide a
  119. X    warranty) and that users may redistribute the program under these
  120. X    conditions, and telling the user how to view a copy of this General
  121. X    Public License.
  122. X
  123. X    d) You may charge a fee for the physical act of transferring a
  124. X    copy, and you may at your option offer warranty protection in
  125. X    exchange for a fee.
  126. X
  127. XMere aggregation of another independent work with the Program (or its
  128. Xderivative) on a volume of a storage or distribution medium does not bring
  129. Xthe other work under the scope of these terms.
  130. X
  131. X  3. You may copy and distribute the Program (or a portion or derivative of
  132. Xit, under Paragraph 2) in object code or executable form under the terms of
  133. XParagraphs 1 and 2 above provided that you also do one of the following:
  134. X
  135. X    a) accompany it with the complete corresponding machine-readable
  136. X    source code, which must be distributed under the terms of
  137. X    Paragraphs 1 and 2 above; or,
  138. X
  139. X    b) accompany it with a written offer, valid for at least three
  140. X    years, to give any third party free (except for a nominal charge
  141. X    for the cost of distribution) a complete machine-readable copy of the
  142. X    corresponding source code, to be distributed under the terms of
  143. X    Paragraphs 1 and 2 above; or,
  144. X
  145. X    c) accompany it with the information you received as to where the
  146. X    corresponding source code may be obtained.  (This alternative is
  147. X    allowed only for noncommercial distribution and only if you
  148. X    received the program in object code or executable form alone.)
  149. X
  150. XSource code for a work means the preferred form of the work for making
  151. Xmodifications to it.  For an executable file, complete source code means
  152. Xall the source code for all modules it contains; but, as a special
  153. Xexception, it need not include source code for modules which are standard
  154. Xlibraries that accompany the operating system on which the executable
  155. Xfile runs, or for standard header files or definitions files that
  156. Xaccompany that operating system.
  157. X
  158. X  4. You may not copy, modify, sublicense, distribute or transfer the
  159. XProgram except as expressly provided under this General Public License.
  160. XAny attempt otherwise to copy, modify, sublicense, distribute or transfer
  161. Xthe Program is void, and will automatically terminate your rights to use
  162. Xthe Program under this License.  However, parties who have received
  163. Xcopies, or rights to use copies, from you under this General Public
  164. XLicense will not have their licenses terminated so long as such parties
  165. Xremain in full compliance.
  166. X
  167. X  5. By copying, distributing or modifying the Program (or any work based
  168. Xon the Program) you indicate your acceptance of this license to do so,
  169. Xand all its terms and conditions.
  170. X
  171. X  6. Each time you redistribute the Program (or any work based on the
  172. XProgram), the recipient automatically receives a license from the original
  173. Xlicensor to copy, distribute or modify the Program subject to these
  174. Xterms and conditions.  You may not impose any further restrictions on the
  175. Xrecipients' exercise of the rights granted herein.
  176. X
  177. X  7. The Free Software Foundation may publish revised and/or new versions
  178. Xof the General Public License from time to time.  Such new versions will
  179. Xbe similar in spirit to the present version, but may differ in detail to
  180. Xaddress new problems or concerns.
  181. X
  182. XEach version is given a distinguishing version number.  If the Program
  183. Xspecifies a version number of the license which applies to it and "any
  184. Xlater version", you have the option of following the terms and conditions
  185. Xeither of that version or of any later version published by the Free
  186. XSoftware Foundation.  If the Program does not specify a version number of
  187. Xthe license, you may choose any version ever published by the Free Software
  188. XFoundation.
  189. X
  190. X  8. If you wish to incorporate parts of the Program into other free
  191. Xprograms whose distribution conditions are different, write to the author
  192. Xto ask for permission.  For software which is copyrighted by the Free
  193. XSoftware Foundation, write to the Free Software Foundation; we sometimes
  194. Xmake exceptions for this.  Our decision will be guided by the two goals
  195. Xof preserving the free status of all derivatives of our free software and
  196. Xof promoting the sharing and reuse of software generally.
  197. X
  198. X                NO WARRANTY
  199. X
  200. X  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  201. XFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  202. XOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  203. XPROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  204. XOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  205. XMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  206. XTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  207. XPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  208. XREPAIR OR CORRECTION.
  209. X
  210. X  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  211. XWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  212. XREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  213. XINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  214. XOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  215. XTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  216. XYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  217. XPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  218. XPOSSIBILITY OF SUCH DAMAGES.
  219. X
  220. X             END OF TERMS AND CONDITIONS
  221. X
  222. X    Appendix: How to Apply These Terms to Your New Programs
  223. X
  224. X  If you develop a new program, and you want it to be of the greatest
  225. Xpossible use to humanity, the best way to achieve this is to make it
  226. Xfree software which everyone can redistribute and change under these
  227. Xterms.
  228. X
  229. X  To do so, attach the following notices to the program.  It is safest to
  230. Xattach them to the start of each source file to most effectively convey
  231. Xthe exclusion of warranty; and each file should have at least the
  232. X"copyright" line and a pointer to where the full notice is found.
  233. X
  234. X    <one line to give the program's name and a brief idea of what it does.>
  235. X    Copyright (C) 19yy  <name of author>
  236. X
  237. X    This program is free software; you can redistribute it and/or modify
  238. X    it under the terms of the GNU General Public License as published by
  239. X    the Free Software Foundation; either version 1, or (at your option)
  240. X    any later version.
  241. X
  242. X    This program is distributed in the hope that it will be useful,
  243. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  244. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  245. X    GNU General Public License for more details.
  246. X
  247. X    You should have received a copy of the GNU General Public License
  248. X    along with this program; if not, write to the Free Software
  249. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  250. X
  251. XAlso add information on how to contact you by electronic and paper mail.
  252. X
  253. XIf the program is interactive, make it output a short notice like this
  254. Xwhen it starts in an interactive mode:
  255. X
  256. X    Gnomovision version 69, Copyright (C) 19xx name of author
  257. X    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  258. X    This is free software, and you are welcome to redistribute it
  259. X    under certain conditions; type `show c' for details.
  260. X
  261. XThe hypothetical commands `show w' and `show c' should show the
  262. Xappropriate parts of the General Public License.  Of course, the
  263. Xcommands you use may be called something other than `show w' and `show
  264. Xc'; they could even be mouse-clicks or menu items--whatever suits your
  265. Xprogram.
  266. X
  267. XYou should also get your employer (if you work as a programmer) or your
  268. Xschool, if any, to sign a "copyright disclaimer" for the program, if
  269. Xnecessary.  Here a sample; alter the names:
  270. X
  271. X  Yoyodyne, Inc., hereby disclaims all copyright interest in the
  272. X  program `Gnomovision' (a program to direct compilers to make passes
  273. X  at assemblers) written by James Hacker.
  274. X
  275. X  <signature of Ty Coon>, 1 April 1989
  276. X  Ty Coon, President of Vice
  277. X
  278. XThat's all there is to it!
  279. END_OF_FILE
  280.   if test 12488 -ne `wc -c <'COPYING'`; then
  281.     echo shar: \"'COPYING'\" unpacked with wrong size!
  282.   fi
  283.   # end of 'COPYING'
  284. fi
  285. if test -f 'Makefile' -a "${1}" != "-c" ; then 
  286.   echo shar: Will not clobber existing file \"'Makefile'\"
  287. else
  288.   echo shar: Extracting \"'Makefile'\" \(1694 characters\)
  289.   sed "s/^X//" >'Makefile' <<'END_OF_FILE'
  290. X#Makefile for C-Refine
  291. X#Author: Lutz Prechelt, Karlsruhe, Germany
  292. X#Date  : 11.06.91
  293. X
  294. X# Usage:
  295. X# Perhaps change the macro CC below if you want to use a different compiler
  296. X# and in CFLAGS set 'ansi=1' if it is ANSI-C.
  297. X# Then call
  298. X#   make crefine
  299. X# to get a version of crefine that is at first made from 
  300. X# the unC-Refine'd sources of C-Refine.
  301. X# With this version of C-Refine you can then bootstrap C-Refine by
  302. X# 'touch'ing the .cr files and again executing
  303. X#   make crefine
  304. X# You should normally remove the -n0 option from CRFLAGS so to get only such
  305. X# messages from your compiler that point to the .cr file instead of to 
  306. X# the .c file
  307. X#
  308. X# Translation is done in two phases with separate rules:
  309. X#   First from .cr to .c if the .cr file is newer,
  310. X#   then from .c to .o
  311. X# In the makefiles of bigger projects I usually prefer to hold all the
  312. X# .c files in some temp directory, so that they don't clobber your working
  313. X# directory and to have a single rule going from .cr to .o
  314. X# Be careful to keep a copy of 'crefine' when experimenting
  315. X# with changes!
  316. X#
  317. XCLD=    getargs.o  crefine.o  cr_talk.o  cr_getln.o
  318. XCS=     getargs.c crefine.c cr_talk.c cr_getln.c
  319. XHS=     getargs.h crefine.h cr_talk.h cr_getln.h std.h cr_texts.h
  320. X
  321. XCR=crefine
  322. XCRFLAGS= -ac -s- -T8
  323. XCC=cc
  324. XCFLAGS=  -I"." -DNDEBUG=1 -Ddebug=0 -Dunix=1 -Dms_dos=0 -Dansi=0 -Ddeutsch=0
  325. XLDFLAGS= 
  326. X
  327. X%.c: %.cr
  328. X    $(CR) $(CRFLAGS) $*.cr
  329. X
  330. X%.o: %.c
  331. X    $(CC) $(CFLAGS) -c $<
  332. X
  333. Xcrefine: a.out
  334. X    mv a.out crefine
  335. X
  336. Xa.out:  $(CLD)
  337. X    $(CC) $(LDFLAGS) $(CLD)
  338. X
  339. Xgetargs.o: getargs.h  std.h
  340. X
  341. Xcrefine.o: cr_decl.h getargs.h std.h
  342. X
  343. Xcr_talk.o: cr_decl.h  cr_texts.h  std.h
  344. X
  345. Xcr_getln.o: cr_decl.h std.h
  346. X
  347. Xclean:
  348. X    -rm core  a.out  *~  crefine.c  cr_getln.c  cr_talk.c  *.o
  349. X
  350. X
  351. X
  352. END_OF_FILE
  353.   if test 1694 -ne `wc -c <'Makefile'`; then
  354.     echo shar: \"'Makefile'\" unpacked with wrong size!
  355.   fi
  356.   # end of 'Makefile'
  357. fi
  358. if test -f 'cr_decl.h' -a "${1}" != "-c" ; then 
  359.   echo shar: Will not clobber existing file \"'cr_decl.h'\"
  360. else
  361.   echo shar: Extracting \"'cr_decl.h'\" \(5687 characters\)
  362.   sed "s/^X//" >'cr_decl.h' <<'END_OF_FILE'
  363. X/*************************************************************************
  364. XProject : C-Refine Precompiler
  365. XModule  : Declarations for global Functions, Types and Data
  366. XAuthor  : Lutz Prechelt, Karlsruhe
  367. XDate    : 11.06.91  Version 16
  368. XCompiler: ANSI C
  369. X**************************************************************************/
  370. X/*
  371. X    Copyright (C) 1988,89,90,91 by Lutz Prechelt, Karlsruhe
  372. X
  373. X    This program is free software; you can redistribute it and/or modify
  374. X    it under the terms of the GNU General Public License as published by
  375. X    the Free Software Foundation; either version 1, or (at your option)
  376. X    any later version.
  377. X    This program is distributed in the hope that it will be useful,
  378. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  379. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  380. X    GNU General Public License for more details.
  381. X    You should have received a copy of the GNU General Public License
  382. X    along with this program; if not, write to the Free Software
  383. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  384. X*/
  385. X
  386. X/*************************************************************************
  387. X*********************** C - R e f i n e **********************************
  388. X**************************************************************************/
  389. X
  390. X#include "std.h"
  391. X
  392. X/***************** globale Typen und Konstanten **************************/
  393. X
  394. X#define normal    1        /* Types for LINE_INFO */
  395. X#define empty     2    /* empty line */
  396. X#define refcall   3    /* refinement call */
  397. X#define refcallr  4    /* dito with "removed semicolon" */
  398. X#define refdecl   5    /* refinement declaration */
  399. X#define leave     6    /* leave construct */
  400. X
  401. X#define TAB       9       /* has to be recognized */
  402. X
  403. X#if ms_dos
  404. X#define std_refinementsymbol   175   /* IBM: Double arrow to the right */
  405. X#else
  406. X#define std_refinementsymbol    96   /* ASCII: back quote */
  407. X#endif
  408. X
  409. X#if ms_dos
  410. X#define STD_MAXLINELENGTH  500
  411. X#define STD_MAXLINE        800    /* max. nr of lines per function */
  412. X#define STD_MAXREF         100    /* max. nr of refinements per function */
  413. X#define STD_S_SIZE       60000    /* wanted size of line buffer in bytes */
  414. X#else
  415. X#define STD_MAXLINELENGTH  500
  416. X#define STD_MAXLINE       2500
  417. X#define STD_MAXREF         200
  418. X#define STD_S_SIZE      150000
  419. X#endif
  420. X#define STD_MAXERRORS       20
  421. X#define STD_MAXWARNINGS     30
  422. X
  423. Xtypedef char *charp;   /* Needed: the SUN-OS Compiler is a fool */
  424. X
  425. Xtypedef struct { int type,      /* see #defines */
  426. X                     indent,    /* indent+length = width of line */
  427. X                     level,     /* Level at beginning of line */
  428. X                     line_no,   /* line number in source file */
  429. X                     length;    /* stored length in bytes */
  430. X                 charp start;
  431. X               } LINE_INFO;
  432. X
  433. Xtypedef struct { charp name;
  434. X                 int  firstentry,     /* pointer into LINE_INFO array */
  435. X                      calls,          /* nr of usages of this refinement */
  436. X                      semicolons;     /* nr of statements in body */
  437. X                 unsigned active:1,   /* we are just in it ? */
  438. X                          leave_it:1; /* there is a 'leave' for it ? */
  439. X               } REF_INFO;
  440. X
  441. Xtypedef LINE_INFO  *LINES;
  442. X
  443. Xtypedef REF_INFO   *REFS;
  444. X
  445. X/************************* External Functions ****************************/
  446. X
  447. X/***** crefine.c *****/
  448. Xextern int  crefine A((int, charp*));
  449. X/***** cr_getln.c *****/
  450. Xextern void get_line A((FILE*, LINE_INFO*, int*));
  451. X/***** cr_talk *****/
  452. Xextern void cout A((int));
  453. Xextern void error A((charp[], charp,  int));
  454. Xextern void fatal_error A((charp[], charp, int));
  455. Xextern void warning A((charp[], charp, int, int));
  456. X
  457. X/************************ globale Daten **********************************/
  458. X
  459. X
  460. X/* Meldungstexte */
  461. Xextern charp
  462. X usagestring[],
  463. X versionstring[],
  464. X expirestring[],
  465. X Tlistline[],
  466. X Tnear[],
  467. X Thas_expired[],
  468. X Wempty_function[],
  469. X Wlong_ref[],
  470. X Wref_often_used[],
  471. X Wref_unused[],
  472. X Wref_empty[],
  473. X Wcol0[],
  474. X Wnesting[],
  475. X Wmuch_indent[],
  476. X Wlong_string[],
  477. X Wlong_char[],
  478. X Eopen[],
  479. X Ereadinput[],
  480. X Ewriteoutput[],
  481. X Elevel0_ref[],
  482. X Elines_in_func[],
  483. X Ebytes_in_func[],
  484. X Eref_not_decl[],
  485. X Erecursive_ref[],
  486. X Eunknown_leave[],
  487. X Eleave_unpresent[],
  488. X Eref_multi_decl[],
  489. X Ememory[],
  490. X Eeof_brace[],
  491. X Eeof_comment[],
  492. X Eeof_string[],
  493. X Eeof_char[],
  494. X Erefdecl_syntax[],
  495. X Erefdecl_nested[],
  496. X Emany_braces[],
  497. X Erefname_missing[],
  498. X Emany_errors[],
  499. X Emany_warnings[];
  500. X
  501. X#ifdef DATA_HERE
  502. X#define extern
  503. X#endif
  504. X/***** Control *****/
  505. X#define FEEDBACK_INTERVAL  64
  506. Xextern bool option_anyway,
  507. X            option_comment,
  508. X            option_feedback,
  509. X            option_indent,
  510. X            option_ibmchars,
  511. X            option_list,
  512. X            option_cplusplus,
  513. X            option_quiet,
  514. X            option_small,
  515. X            stop_processing;
  516. X
  517. Xextern int  refinementsymbol,
  518. X            tabsize,
  519. X            numbering_level,
  520. X            msg_type,
  521. X            warning_level,
  522. X            maxerrors,
  523. X            maxwarnings;
  524. X
  525. X/***** Buffer  *****/
  526. Xextern charp  b,        /* Puffer fuer eine Zeile */
  527. X              s,        /* Naechste freie Position im Zeilenspeicher */
  528. X              s_root;   /* Beginn des Zeilenspeichers */
  529. Xextern unsigned
  530. X            maxline,
  531. X            maxref,
  532. X            b_size,   /* Groesse des Puffers fuer eine Zeile */
  533. X            s_size;   /* Gesamtgroesse des Zeilenspeichers */
  534. X
  535. X/***** Status *****/
  536. Xextern int  errors, warnings,
  537. X            line_no;
  538. Xextern bool error_in_this_function;
  539. Xextern char name_in[200],     /* Dateinamen: Eingabedatei/Ausgabedatei */
  540. X            modified_name_in[200],  /* (mit verdoppelten Backslashes) */
  541. X            name_out[200];
  542. X
  543. X
  544. X#ifdef DATA_HERE
  545. X#undef extern
  546. X#endif
  547. END_OF_FILE
  548.   if test 5687 -ne `wc -c <'cr_decl.h'`; then
  549.     echo shar: \"'cr_decl.h'\" unpacked with wrong size!
  550.   fi
  551.   # end of 'cr_decl.h'
  552. fi
  553. if test -f 'cr_talk.cr' -a "${1}" != "-c" ; then 
  554.   echo shar: Will not clobber existing file \"'cr_talk.cr'\"
  555. else
  556.   echo shar: Extracting \"'cr_talk.cr'\" \(3405 characters\)
  557.   sed "s/^X//" >'cr_talk.cr' <<'END_OF_FILE'
  558. X/*************************************************************************
  559. XProject : C-Refine Precompiler
  560. XModule  : Output functions for messages
  561. XAuthor  : Lutz Prechelt, Karlsruhe
  562. XDate    : 11.06.91  Version 16
  563. XCompiler: ANSI C, C-Refine
  564. X**************************************************************************/
  565. X/*
  566. X    Copyright (C) 1988,89,90,91 by Lutz Prechelt, Karlsruhe
  567. X
  568. X    This program is free software; you can redistribute it and/or modify
  569. X    it under the terms of the GNU General Public License as published by
  570. X    the Free Software Foundation; either version 1, or (at your option)
  571. X    any later version.
  572. X    This program is distributed in the hope that it will be useful,
  573. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  574. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  575. X    GNU General Public License for more details.
  576. X    You should have received a copy of the GNU General Public License
  577. X    along with this program; if not, write to the Free Software
  578. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  579. X*/
  580. X
  581. X/************************************************************************
  582. X*********************** C - R e f i n e *********************************
  583. X*************************************************************************/
  584. X
  585. X#include <stdio.h>
  586. X#include <string.h>
  587. X
  588. X#include "cr_decl.h"   /* global Functions, Types and Data */
  589. X#include "cr_texts.h"  /* message texts */
  590. X
  591. Xstatic void error_message A((charp[], charp[], charp, int));
  592. X
  593. X/************************* cout *******************************************/
  594. X
  595. Xextern void cout (i)
  596. X  int i;
  597. X{
  598. X  /* Writes number i on stderr (which is assumed to be a screen)
  599. X     with length five and positions the cursor back to the starting
  600. X     position with five backspaces.
  601. X     This is not very fast, but that doesn't matter.
  602. X  */
  603. X  fprintf (stderr, "%5d\b\b\b\b\b", i);
  604. X}
  605. X
  606. X/************************ error *******************************************/
  607. X
  608. Xstatic void error_message (type, message, object, line)
  609. X  charp type[], message[];
  610. X  charp object;
  611. X  int   line;
  612. X{
  613. X  fprintf (stdout, "\"%s\", line %d, %s: %s\n", name_in,
  614. X           line, type[msg_type], message[msg_type]);
  615. X  if (object != NULL) {
  616. X    char *nl = strchr (object, '\n');
  617. X    if (nl != NULL)     /* remove newline from object */
  618. X      *nl = 0;
  619. X   fprintf (stdout, "    %s \"%s\"\n", Tnear[msg_type], object);
  620. X   if (nl != NULL)
  621. X     *nl = '\n';
  622. X  }
  623. X}
  624. X
  625. X
  626. Xextern void error (message, object, line)
  627. X  charp message[];
  628. X  charp object;
  629. X  int   line;
  630. X{
  631. X  error_message (Terror, message, object, line);
  632. X  if (++errors > maxerrors)
  633. X     fatal_error (Emany_errors, "(-----ManteldesSchweigens-----)", line);
  634. X  error_in_this_function = true;
  635. X}
  636. X
  637. X/************************ fatal_error *************************************/
  638. X
  639. Xextern void fatal_error (message, object, line)
  640. X  charp message[];
  641. X  charp object;
  642. X  int   line;
  643. X{
  644. X  error_message (Tfatal_error, message, object, line);
  645. X  stop_processing = true;
  646. X  errors++;
  647. X}
  648. X
  649. X/************************ warning *****************************************/
  650. X
  651. Xextern void warning (message, object, line, level)
  652. X  charp message[];
  653. X  charp object;
  654. X  int   line, level;
  655. X{
  656. X  if (!error_in_this_function && level <= warning_level) {
  657. X     /* don't be too verbose */
  658. X     error_message (Twarning, message, object, line);
  659. X     if (++warnings > maxwarnings)
  660. X        fatal_error (Emany_warnings, NULL, line);
  661. X  }
  662. X}
  663. X
  664. END_OF_FILE
  665.   if test 3405 -ne `wc -c <'cr_talk.cr'`; then
  666.     echo shar: \"'cr_talk.cr'\" unpacked with wrong size!
  667.   fi
  668.   # end of 'cr_talk.cr'
  669. fi
  670. if test -f 'cr_texts.h' -a "${1}" != "-c" ; then 
  671.   echo shar: Will not clobber existing file \"'cr_texts.h'\"
  672. else
  673.   echo shar: Extracting \"'cr_texts.h'\" \(8508 characters\)
  674.   sed "s/^X//" >'cr_texts.h' <<'END_OF_FILE'
  675. X/*************************************************************************
  676. XProject : C-Refine Precompiler
  677. XModule  : Message texts
  678. XAuthor  : Lutz Prechelt, Karlsruhe
  679. XDate    : 29.01.91  Version 15
  680. XCompiler: ANSI C
  681. X**************************************************************************/
  682. X/*
  683. X    Copyright (C) 1988,89,90,91 by Lutz Prechelt, Karlsruhe
  684. X
  685. X    This program is free software; you can redistribute it and/or modify
  686. X    it under the terms of the GNU General Public License as published by
  687. X    the Free Software Foundation; either version 1, or (at your option)
  688. X    any later version.
  689. X    This program is distributed in the hope that it will be useful,
  690. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  691. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  692. X    GNU General Public License for more details.
  693. X    You should have received a copy of the GNU General Public License
  694. X    along with this program; if not, write to the Free Software
  695. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  696. X*/
  697. X
  698. Xcharp
  699. X  usagestring      [] = {
  700. X   "[optionen] eingabedatei [ausgabedatei] [optionen]",
  701. X   "[options] inputfile [outputfile] [options]",
  702. X   "[optionen] eingabedatei [ausgabedatei] [optionen]"
  703. X                        },
  704. X  versionstring    [] = {
  705. X   "Version 2.4   Januar '91",
  706. X   "Version 2.4   January '91",
  707. X   "Version 2.4   Jaenner '91"
  708. X                        },
  709. X  expirestring     [] = {
  710. X   "gueltig bis",
  711. X   "expires",
  712. X   "entschlaeft am"
  713. X                        },
  714. X  Terror           [] = {
  715. X   "Fehler",
  716. X   "error",
  717. X   "Fehler"
  718. X                        },
  719. X  Twarning         [] = {
  720. X   "Warnung",
  721. X   "warning",
  722. X   "Warnung"
  723. X                        },
  724. X  Tfatal_error     [] = {
  725. X   "Fataler Fehler",
  726. X   "fatal error",
  727. X   "fatal, fatal"
  728. X                        },
  729. X  Tlistline        [] = {
  730. X   "   /* %s  (Ebene %d) */",
  731. X   "   /* %s  (Level %d) */",
  732. X   "   /* %s  (Ebene %d) */"
  733. X                        },
  734. X  Tnear            [] = {
  735. X   "bei",
  736. X   "near",
  737. X   "bei"
  738. X                        },
  739. X  Thas_expired     [] = {
  740. X   "--- Diese (Test-)Version ist nicht mehr gueltig ---",
  741. X   "--- this (test-)version has expired ---",
  742. X   "--- Diese (Test-)Version ist friedlich entschlafen ---"
  743. X                        },
  744. X  Wempty_function  [] = {
  745. X   "Leere Funktion (aber mit Refinements)",
  746. X   "function is empty (but has refinements)",
  747. X   "Viel Gelaber und nix dahinter"
  748. X                        },
  749. X  Wlong_ref        [] = {
  750. X   "Sehr langes Refinement",
  751. X   "very long refinement",
  752. X   "Ist das Refinement nicht a bisserl arg lang ?"
  753. X                        },
  754. X  Wref_often_used  [] = {
  755. X   "Refinement ueber 5 mal benutzt",
  756. X   "refinement used more than 5 times",
  757. X   "hektisches ich-bin-ueberall-Refinement"
  758. X                        },
  759. X  Wref_unused      [] = {
  760. X   "Refinement wird nicht benutzt",
  761. X   "refinement unused",
  762. X   "ein Refinement steht im Walde...."
  763. X                        },
  764. X  Wref_empty       [] = {
  765. X   "Leeres Refinement",
  766. X   "refinement is empty",
  767. X   "Was will uns dieses Refinement sagen ?"
  768. X                        },
  769. X  Wcol0            [] = {
  770. X   "Unerwartete Zeichen in Spalte 0",
  771. X   "unexpected character in column 0",
  772. X   "Was tobt denn da in Spalte 0 rum ?"
  773. X                        },
  774. X  Wnesting         [] = {
  775. X   "Sehr tiefe Blockverschachtelung",
  776. X   "deep block-nesting",
  777. X   "SCHEISS STIL.  Verschachtele doch nicht so tief"
  778. X                        },
  779. X  Wmuch_indent     [] = {
  780. X   "Einrueckung evtl. nicht mehr darstellbar",
  781. X   "perhaps indentation will be reduced",
  782. X   "Das koennte ueber meinen (rechten) Horizont gehen"
  783. X                        },
  784. X  Wlong_string     [] = {
  785. X   "Langer Stringdenoter hier zu Ende",
  786. X   "end of long string denoter here",
  787. X   "Laaaaaanger Stringdenoter hoert hier auf (na endlich)"
  788. X                        },
  789. X  Wlong_char       [] = {
  790. X   "Langer Character-Denoter hier zu Ende",
  791. X   "end of long character denoter here",
  792. X   "Laaaaanger Character-Denoter hoert hier auf"
  793. X                        },
  794. X  Eopen            [] = {
  795. X   "\nKann Datei \"%s\" nicht oeffnen\n",
  796. X   "\nerror opening \"%s\"\n",
  797. X   "\nNa wo isse denn, die Datei \"%s\" ?\n"
  798. X                        },
  799. X  Ereadinput       [] = {
  800. X   "Kann Eingabedatei nicht lesen",
  801. X   "can't read inputfile",
  802. X   "akutes Eingabedateileseunvermoegen"
  803. X                        },
  804. X  Ewriteoutput     [] = {
  805. X   "Kann Ausgabedatei nicht beschreiben",
  806. X   "can't write outputfile",
  807. X   "akute Ausgabedateischreiblaehmung"
  808. X                        },
  809. X  Elevel0_ref      [] = {
  810. X   "Refinements ausserhalb einer Funktion gibts nicht",
  811. X   "refinements illegal outside functions",
  812. X   "Ein Refinement ?  Hier draussen in der Wueste ?"
  813. X                        },
  814. X  Elines_in_func   [] = {
  815. X   "Funktion hat zuviele Zeilen",
  816. X   "too many lines in function",
  817. X   "Soooo viele Zeilen in einer Funktion haelt ja kein Computer aus"
  818. X                        },
  819. X  Ebytes_in_func   [] = {
  820. X   "Funktion zu lang (in Bytes)",
  821. X   "too many bytes in function",
  822. X   "Tolle Funktion.  Aber, in Bytes betrachtet, entschieden zu gross."
  823. X                        },
  824. X  Eref_not_decl    [] = {
  825. X   "Refinement nicht deklariert",
  826. X   "undeclared refinement",
  827. X   "Wer oder was soll das sein ?"
  828. X                        },
  829. X  Erecursive_ref   [] = {
  830. X   "Rekursiver Refinementaufruf",
  831. X   "recursive call to refinement",
  832. X#define _rum_und_rum   "und rum und rum und rum und rum und rum und rum\
  833. X und rum und rum (rekursives Refinement)"
  834. X   _rum_und_rum
  835. X                        },
  836. X  Eunknown_leave   [] = {
  837. X   "zu verlassendes Refinement unbekannt",
  838. X   "refinement to leave is unknown",
  839. X   "WAS soll da verlassen werden ???"
  840. X                        },
  841. X  Eleave_unpresent [] = {
  842. X#define _unpresent "Wir sind nicht in diesem Refinement, also kann es\
  843. X auch nicht verlassen werden",
  844. X   _unpresent
  845. X   "you are not within this refinement, thus it's impossible to leave it",
  846. X#define _wenn_du   "Wenn Du denkst zu sein, wo ich denke (und du\
  847. X schreibst), dass du zu sein denkst, denkst du falsch."
  848. X   _wenn_du
  849. X                        },
  850. X  Eref_multi_decl  [] = {
  851. X   "Refinement mehrfach deklariert",
  852. X   "refinement declared more than once",
  853. X   "Langweilig!  Das Refinement gibts doch laengst"
  854. X                        },
  855. X  Ememory          [] = {
  856. X   "\n***** Speichermangel *****\n",
  857. X   "\n***** not enough memory *****\n",
  858. X   "\n  Des Bissele Speische is mi abe zu wenisch !\n"
  859. X                        },
  860. X  Eeof_brace       [] = {
  861. X   "Dateiende bei offener geschweifter Klammer",
  862. X   "EOF within block",
  863. X   "In der U-Bahn geboren, oder was ?   Mach erst mal alle Bloecke zu."
  864. X                        },
  865. X  Eeof_comment     [] = {
  866. X   "Dateiende im Kommentar",
  867. X   "EOF in comment",
  868. X#define _so_toll   "So toll sind Deine Kommentare nun auch nicht, dass\
  869. X sie bis ans Dateiende gehen sollten"
  870. X   _so_toll
  871. X                        },
  872. X  Eeof_string      [] = {
  873. X   "Dateiende im Stringdenoter",
  874. X   "EOF in string denoter",
  875. X   "Hoerst Du immer mitten im Satz auf ?  Da ist noch ein String offen"
  876. X                        },
  877. X  Eeof_char        [] = {
  878. X   "Dateiende im Character-Denoter",
  879. X   "EOF in character denoter",
  880. X   "EOF in Character-Denoter.  Demnaechst halbieren sie noch die Bits...."
  881. X                        },
  882. X  Erefdecl_syntax  [] = {
  883. X   "falsche Syntax fuer Refinementdeklaration",
  884. X   "illegal syntax for refinement declaration",
  885. X   "Es begann wie eine Refinementdeklaration. Aber dann....."
  886. X                        },
  887. X  Erefdecl_nested  [] = {
  888. X   "Mehr als ein Block offen bei Refinementdeklaration",
  889. X   "refinement declaration in nested block",
  890. X#define _du_bist "Du bist an dieser Stelle viel zu tief in dein Programm\
  891. X verstrickt, um ein Refinement zu deklarieren"
  892. X   _du_bist
  893. X                        },
  894. X  Emany_braces     [] = {
  895. X   "Zuviel schliessende Blockklammern",
  896. X   "too many closing braces",
  897. X#define _aufmachen   "Wenn Du jetzt noch eine Blockklammer aufmachst,\
  898. X dann sind gar keine mehr offen"
  899. X   _aufmachen
  900. X                        },
  901. X  Erefname_missing [] = {
  902. X   "Refinementsymbol ohne Refinementname",
  903. X   "refinement symbol found without refinement name",
  904. X   "Das Refinementsymbol fuehlt sich einsam so ganz ohne Name"
  905. X                        },
  906. X  Emany_errors     [] = {
  907. X   "Zu viele Fehler. Uebersetzung wird abgebrochen.",
  908. X   "too many errors,  compilation stopped",
  909. X   "Fiel zufiele Feeler"
  910. X                        },
  911. X  Emany_warnings   [] = {
  912. X   "Zu viele Warnungen. Uebersetzung wird abgebrochen",
  913. X   "too many warnings, compilation stopped",
  914. X   "(So viele Warnungen sind mir nicht geheuer)"
  915. X                        };
  916. X
  917. X
  918. END_OF_FILE
  919.   if test 8508 -ne `wc -c <'cr_texts.h'`; then
  920.     echo shar: \"'cr_texts.h'\" unpacked with wrong size!
  921.   fi
  922.   # end of 'cr_texts.h'
  923. fi
  924. if test -f 'erato.c' -a "${1}" != "-c" ; then 
  925.   echo shar: Will not clobber existing file \"'erato.c'\"
  926. else
  927.   echo shar: Extracting \"'erato.c'\" \(2259 characters\)
  928.   sed "s/^X//" >'erato.c' <<'END_OF_FILE'
  929. X
  930. X/*************************************************************************
  931. XModule  : C-Refine example program
  932. XAuthor  : Lutz Prechelt, Karlsruhe
  933. XDate    : 23.01.91
  934. X**************************************************************************
  935. X/*
  936. X    Copyright (C) 1988,90 by Lutz Prechelt, Karlsruhe
  937. X
  938. X    This program is free software; you can redistribute it and/or modify
  939. X    it under the terms of the GNU General Public License as published by
  940. X    the Free Software Foundation; either version 1, or (at your option)
  941. X    any later version.
  942. X    This program is distributed in the hope that it will be useful,
  943. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  944. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  945. X    GNU General Public License for more details.
  946. X    You should have received a copy of the GNU General Public License
  947. X    along with this program; if not, write to the Free Software
  948. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  949. X*/
  950. X
  951. X#define MAX        10000
  952. X#define PRIME      0
  953. X#define NON_PRIME  1
  954. X
  955. Xstatic int sieve[MAX+1];
  956. X
  957. Xint main ()
  958. X{
  959. X  {   /* initialize  (Level 1) */
  960. X  int current;
  961. X  for (current = 2; current <= MAX; current++)
  962. X    sieve[current] = PRIME;
  963. X  }
  964. X  {   /* do_sieve  (Level 1) */
  965. X  int current_prime = 1;
  966. X  for (;;) {
  967. X    {   /* find_next_bigger_prime  (Level 2) */
  968. X    int current_candidate = current_prime + 1;
  969. X    while (sieve[current_candidate] == NON_PRIME)
  970. X      if (current_candidate == MAX)
  971. X    goto do_sieve_1;
  972. X        /* leave two refinements at once */
  973. X      else
  974. X        current_candidate++;
  975. X    /* now current_candidate is a prime (or we leave `sieve) */
  976. X    current_prime = current_candidate;
  977. X    }
  978. X    /* perhaps STOP here */
  979. X    {   /* delete_all_multiples_of_current_prime  (Level 2) */
  980. X    int current = (
  981. X    2 * current_prime);
  982. X    while (current <= MAX) {
  983. X      sieve[current] = NON_PRIME;
  984. X      current += current_prime;
  985. X    }
  986. X    }
  987. X  }
  988. Xdo_sieve_1: ;
  989. X  }
  990. X  {   /* make_output  (Level 1) */
  991. X  int current;  /* different from 'current' above */
  992. X  printf ("The primes between 2 and %d are\n", MAX);
  993. X  for (current = 2; current <= MAX; current++)
  994. X    if ((
  995. X    sieve[current] == PRIME)
  996. X    )
  997. X      printf ("%5d ", current);
  998. X  }
  999. X  return (0);
  1000. X} /* end of main() */
  1001. END_OF_FILE
  1002.   if test 2259 -ne `wc -c <'erato.c'`; then
  1003.     echo shar: \"'erato.c'\" unpacked with wrong size!
  1004.   fi
  1005.   # end of 'erato.c'
  1006. fi
  1007. if test -f 'erato.cr' -a "${1}" != "-c" ; then 
  1008.   echo shar: Will not clobber existing file \"'erato.cr'\"
  1009. else
  1010.   echo shar: Extracting \"'erato.cr'\" \(2305 characters\)
  1011.   sed "s/^X//" >'erato.cr' <<'END_OF_FILE'
  1012. X/*************************************************************************
  1013. XModule  : C-Refine example program
  1014. XAuthor  : Lutz Prechelt, Karlsruhe
  1015. XDate    : 23.01.91
  1016. X**************************************************************************
  1017. X/*
  1018. X    Copyright (C) 1988,90 by Lutz Prechelt, Karlsruhe
  1019. X
  1020. X    This program is free software; you can redistribute it and/or modify
  1021. X    it under the terms of the GNU General Public License as published by
  1022. X    the Free Software Foundation; either version 1, or (at your option)
  1023. X    any later version.
  1024. X    This program is distributed in the hope that it will be useful,
  1025. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  1026. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1027. X    GNU General Public License for more details.
  1028. X    You should have received a copy of the GNU General Public License
  1029. X    along with this program; if not, write to the Free Software
  1030. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1031. X*/
  1032. X
  1033. X#define MAX        10000
  1034. X#define PRIME      0
  1035. X#define NON_PRIME  1
  1036. X
  1037. Xstatic int sieve[MAX+1];
  1038. X
  1039. Xint main ()
  1040. X{
  1041. X  `initialize;
  1042. X  `do sieve;
  1043. X  `make output;
  1044. X  return (0);
  1045. X  
  1046. X`initialize:
  1047. X  int current;
  1048. X  for (current = 2; current <= MAX; current++)
  1049. X    sieve[current] = PRIME;
  1050. X    
  1051. X`do sieve:
  1052. X  int current_prime = 1;
  1053. X  for (;;) {
  1054. X    `find next bigger prime;  /* perhaps STOP here */
  1055. X    `delete all multiples of current_prime;
  1056. X  }
  1057. X
  1058. X`find next bigger prime:
  1059. X  int current_candidate = current_prime + 1;
  1060. X  while (sieve[current_candidate] == NON_PRIME)
  1061. X    if (current_candidate == MAX)
  1062. X      leave `do sieve;    /* leave two refinements at once */
  1063. X    else
  1064. X      current_candidate++;
  1065. X  /* now current_candidate is a prime (or we leave `sieve) */
  1066. X  current_prime = current_candidate;
  1067. X  
  1068. X`delete all multiples of current_prime:
  1069. X  int current = `first multiple of current_prime;
  1070. X  while (current <= MAX) {
  1071. X    sieve[current] = NON_PRIME;
  1072. X    current += current_prime;
  1073. X  }
  1074. X  
  1075. X`first multiple of current_prime:
  1076. X  2 * current_prime
  1077. X
  1078. X`make output:
  1079. X  int current;  /* different from 'current' above */
  1080. X  printf ("The primes between 2 and %d are\n", MAX);
  1081. X  for (current = 2; current <= MAX; current++)
  1082. X    if (`current is prime)
  1083. X      printf ("%5d ", current);
  1084. X
  1085. X`current is prime:
  1086. X  sieve[current] == PRIME
  1087. X
  1088. X} /* end of main() */
  1089. END_OF_FILE
  1090.   if test 2305 -ne `wc -c <'erato.cr'`; then
  1091.     echo shar: \"'erato.cr'\" unpacked with wrong size!
  1092.   fi
  1093.   # end of 'erato.cr'
  1094. fi
  1095. if test -f 'getargs.h' -a "${1}" != "-c" ; then 
  1096.   echo shar: Will not clobber existing file \"'getargs.h'\"
  1097. else
  1098.   echo shar: Extracting \"'getargs.h'\" \(2150 characters\)
  1099.   sed "s/^X//" >'getargs.h' <<'END_OF_FILE'
  1100. X/*************************************************************************
  1101. XModule  : getargs -- command line option processor
  1102. XAuthor  : Lutz Prechelt, Karlsruhe
  1103. XDate    : 11.06.91  Version 2
  1104. XCompiler: should be portable
  1105. X          tried: MS-DOS 3.2, Microsoft C 5.0 (ANSI-C)
  1106. X          SUN-OS 4.03, 4.1 (K&R C)
  1107. X**************************************************************************/
  1108. X/*
  1109. X    Copyright (C) 1988,91 by Lutz Prechelt, Karlsruhe
  1110. X
  1111. X    This program is free software; you can redistribute it and/or modify
  1112. X    it under the terms of the GNU General Public License as published by
  1113. X    the Free Software Foundation; either version 1, or (at your option)
  1114. X    any later version.
  1115. X    This program is distributed in the hope that it will be useful,
  1116. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  1117. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1118. X    GNU General Public License for more details.
  1119. X    You should have received a copy of the GNU General Public License
  1120. X    along with this program; if not, write to the Free Software
  1121. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1122. X*/
  1123. X
  1124. X/************************************************************************
  1125. X*********************** g e t a r g s ***********************************
  1126. X*************************************************************************/
  1127. X
  1128. X#define INTEGER   0
  1129. X#define BOOLEAN   1
  1130. X#define CHARACTER 2
  1131. X#define STRING    3
  1132. X
  1133. Xtypedef struct {
  1134. X    char arg;
  1135. X    char type;
  1136. X    int  *variable;
  1137. X    char *errmsg;
  1138. X    } ARG;
  1139. X
  1140. X#define ARGTABSIZE(a) (sizeof (a) / sizeof (ARG))
  1141. X
  1142. Xextern int  getargs A((int *argc, char **argv, ARG argtab[], int argtabsize));
  1143. Xextern void print_usage A((char *progname, char *usage,
  1144. X                           ARG tabp[], int argtabsize));
  1145. X
  1146. X#if 0
  1147. X
  1148. XExample or template:
  1149. X
  1150. X/* Definition global (Initialization of Array) ! */
  1151. X
  1152. Xstatic ARG argtab[] = {
  1153. X  {'x', TYPE,   &var_x,      "function of option x" },
  1154. X  .
  1155. X  .
  1156. X};
  1157. X
  1158. X/* Call : */
  1159. X
  1160. X  if (getargs (&argc, argv, argtab, ARGTABSIZE (argtab)) || argc != 3)
  1161. X     print_usage (argv[0], "[options] inputfile outputfile [options]",
  1162. X                  argtab, ARGTABSIZE (argtab));
  1163. X
  1164. X#endif
  1165. X
  1166. END_OF_FILE
  1167.   if test 2150 -ne `wc -c <'getargs.h'`; then
  1168.     echo shar: \"'getargs.h'\" unpacked with wrong size!
  1169.   fi
  1170.   # end of 'getargs.h'
  1171. fi
  1172. if test -f 'std.h' -a "${1}" != "-c" ; then 
  1173.   echo shar: Will not clobber existing file \"'std.h'\"
  1174. else
  1175.   echo shar: Extracting \"'std.h'\" \(2012 characters\)
  1176.   sed "s/^X//" >'std.h' <<'END_OF_FILE'
  1177. X/*************************************************************************
  1178. XModule  : Header file: mothers little helpers --- bool, assert, prototype args 
  1179. XAuthor  : Lutz Prechelt, Karlsruhe
  1180. XDate    : 11.06.91
  1181. XCompiler: ANSI C, K&R C
  1182. X**************************************************************************
  1183. X/*
  1184. X    Copyright (C) 1988 by Lutz Prechelt, Karlsruhe
  1185. X
  1186. X    This program is free software; you can redistribute it and/or modify
  1187. X    it under the terms of the GNU General Public License as published by
  1188. X    the Free Software Foundation; either version 1, or (at your option)
  1189. X    any later version.
  1190. X    This program is distributed in the hope that it will be useful,
  1191. X    but WITHOUT ANY WARRANTY; without even the implied warranty of
  1192. X    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  1193. X    GNU General Public License for more details.
  1194. X    You should have received a copy of the GNU General Public License
  1195. X    along with this program; if not, write to the Free Software
  1196. X    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  1197. X*/
  1198. X
  1199. X#ifndef stdh_
  1200. X#define stdh_
  1201. X
  1202. X#if ansi
  1203. X#define A(a) a
  1204. X#else
  1205. X#define A(a) ()
  1206. X#endif
  1207. X
  1208. Xtypedef int  bool;   /* or 'enum' but some debuggers don't like that */
  1209. X#define true    1
  1210. X#define false   0
  1211. X
  1212. X#ifndef NDEBUG
  1213. X
  1214. X#define _assert_str "\nOOPS !!  Assertion failed: file \"%s\", line %d\
  1215. X  (CR to continue)"
  1216. Xstatic char _assert_string[] = _assert_str;
  1217. X#define _avoid_str "\nOOPS !!  %d happened in file \"%s\", line %d\
  1218. X  (CR to continue)"
  1219. Xstatic char _avoid_string[]  = _avoid_str;
  1220. X
  1221. X#define assert(e)  \
  1222. X     (!(e)  ? ( \
  1223. X                 fprintf(stderr, _assert_string,  __FILE__, __LINE__), \
  1224. X                 fgetc (stdin) \
  1225. X             ) \
  1226. X                : 1 \
  1227. X    )
  1228. X
  1229. X#define avoid(e,u)  \
  1230. X        ((e)!=(u) ? ( \
  1231. X                    fprintf(stderr, _avoid_string, (e), __FILE__, __LINE__), \
  1232. X                    fgetc (stdin) \
  1233. X                    ) \
  1234. X                  : 1 \
  1235. X        )
  1236. X
  1237. X#else
  1238. X
  1239. X#define assert(e)    1
  1240. X#define avoid(e,u)   1
  1241. X
  1242. X#endif /* NDEBUG */
  1243. X
  1244. X
  1245. X#endif
  1246. END_OF_FILE
  1247.   if test 2012 -ne `wc -c <'std.h'`; then
  1248.     echo shar: \"'std.h'\" unpacked with wrong size!
  1249.   fi
  1250.   # end of 'std.h'
  1251. fi
  1252. echo shar: End of archive 4 \(of 4\).
  1253. cp /dev/null ark4isdone
  1254. MISSING=""
  1255. for I in 1 2 3 4 ; do
  1256.     if test ! -f ark${I}isdone ; then
  1257.     MISSING="${MISSING} ${I}"
  1258.     fi
  1259. done
  1260. if test "${MISSING}" = "" ; then
  1261.     echo You have unpacked all 4 archives.
  1262.     rm -f ark[1-9]isdone
  1263. else
  1264.     echo You still must unpack the following archives:
  1265.     echo "        " ${MISSING}
  1266. fi
  1267. exit 0
  1268. exit 0 # Just in case...
  1269.