1Notes on the THINK C version of Flex 2.4.6
2Scott Hofmann 23-JUL-94
3Internet: scotth@visix.com
4
5The only changes needed to compile Flex 2.4.6 under Symantec C++ 6.0 was
6to #include <console.h> in main.c and call ccommand() just before flexinit()
7in main(). The notes below are mostly of historical significance only; most
8of the workarounds below were to get around restrictions/problems in earlier
9versions of THINK C. The only section which still applies is Russell Finn's 
10description of how to make Flex generate output of type 'KAHL'. Also, 4-byte
11ints must be used by any project which uses Flex output.
12
13If you want to recreate the project, you'll need to add the files 
14alloca.c and xmalloc.c in this directory. Both files are copylefted; see
15the GNU General Public License for details. You will also need to recompile
16both the ANSI and unix libraries to use 4 byte ints, and if you want the
17files that flex creates to have 'KAHL' as the creator you'll need to apply
18Russell Finn's patch.
19
20Notes on the THINK C version of Flex 2.3.7
21Jonas Barklund, 25-JAN-92
22Internet: jonas@csd.uu.se
23
24I have merged the sources for Flex version 2.3.7 with the older version
25which was hacked for THINK C version 4. I have conditionalized the code
26so that I think it should work with both THINK C version 4 and 5 (for
27those of you who don't know: the THINK_C symbol is defined as 1 in version
284 and as 5 in version 5). I have put in some missing prototypes, so it
29compiles also with "require prototypes" on.
30
31Most of the notes below still apply, in particular that about the MakeRes
32program.
33
34
35Notes on the THINK C version of Flex
36Russell S. Finn, 19-FEB-90
37Internet: rsfinn@athena.mit.edu, rsfinn@neutron.lcs.mit.edu
38CompuServe: 76377,1107
39GEnie: RSFINN
40
41Flex appears to be covered by a copyright notice from the University of
42California, similar to the one covering Berkeley Unix; the Free Software
43Foundation is not part of the picture here.  So here is a version
44created with THINK C 4.0, along with the source code; as with the
45Bison distribution, I am including *all* of the source code I received
46with the package.
47
48The current version (modification date January 25, 1990) has only the
49bare-bones interface provided by the THINK C library routine "ccommand",
50which allows the user to type a command line and to redirect the output.
51Perhaps someday I may try to implement a "real" user interface; perhaps
52not.
53
54The only modifications made to the source file are surrounded by "#ifdef
55THINK_C"..."#endif"; in theory, then, these sources could be recompiled
56on another system if necessary.  These are the actual files modified:
57alloca.c, dfa.c, flexdef.h, main.c, misc.c, scan.c, sym.c.  Most of these
58changes were minor, and many of them would have been unnecessary if the
59original Flex source code had been written for an ANSI-compliant C compiler.
60In addition, the file "macutils.c" is completely new; see the discussion
61of "MakeRes" below.
62
63THINK C users may find it convenient to have the output text files written
64by Flex be THINK C documents.  To do this, create a copy of the "ANSI"
65project called "ANSI-KAHL", and a copy of the file "fopen.c" called
66"fopen-KAHL.c".  In the copy, find the routine "setfiletype", and replace
67the lines:
68	if (!(oflag & F_BINARY))
69		pb.ioFlFndrInfo.fdType = 'TEXT';
70with the lines:
71	if (!(oflag & F_BINARY)) {
72		pb.ioFlFndrInfo.fdType = 'TEXT';
73		pb.ioFlFndrInfo.fdCreator = 'KAHL';
74		}
75Replace "fopen.c" with the new "fopen-KAHL.c", rebuild the new project
76"ANSI-KAHL", and use this project in the project file "Flex.�"
77instead of the "ANSI" project.
78
79** The "MakeRes" program
80
81The output files created by Flex contain large amounts of preinitialized
82static data; the file "scan.c" contained in the Flex.� project is one
83such file.  However, the Macintosh architecture limits normal applications
84to 32K of global data.  In many cases (including Flex), this limit can
85be surpassed by the static data generated by Flex.
86
87The solution I have implemented for the THINK C version of Flex is to
88extract the data tables from the Flex output file, and paste them into
89the file "MakeRes.c".  Then, by recompiling and running the program in
90the "MakeRes.�" project (it is not necessary to create an application),
91a resource file called "Flex.�.rsrc" is created in the current directory.
92The Flex output file "scan.c" has been modified to load the static data
93from the resource fork of the Flex application.  This is done by calling
94the "load_table" function, which is defined in the file "macutils.c".
95
96In the application for which I needed Flex, the data tables were small
97enough that I didn't need to do this.  However, if your application
98requires you to do this, simply follow the model of "scan.c"; the MakeRes
99project and source code has been included for your use.
100
101