100 lines
4.7 KiB
Text
100 lines
4.7 KiB
Text
Notes on the THINK C version of Flex 2.4.6
|
||
Scott Hofmann 23-JUL-94
|
||
Internet: scotth@visix.com
|
||
|
||
The only changes needed to compile Flex 2.4.6 under Symantec C++ 6.0 was
|
||
to #include <console.h> in main.c and call ccommand() just before flexinit()
|
||
in main(). The notes below are mostly of historical significance only; most
|
||
of the workarounds below were to get around restrictions/problems in earlier
|
||
versions of THINK C. The only section which still applies is Russell Finn's
|
||
description of how to make Flex generate output of type 'KAHL'. Also, 4-byte
|
||
ints must be used by any project which uses Flex output.
|
||
|
||
If you want to recreate the project, you'll need to add the files
|
||
alloca.c and xmalloc.c in this directory. Both files are copylefted; see
|
||
the GNU General Public License for details. You will also need to recompile
|
||
both the ANSI and unix libraries to use 4 byte ints, and if you want the
|
||
files that flex creates to have 'KAHL' as the creator you'll need to apply
|
||
Russell Finn's patch.
|
||
|
||
Notes on the THINK C version of Flex 2.3.7
|
||
Jonas Barklund, 25-JAN-92
|
||
Internet: jonas@csd.uu.se
|
||
|
||
I have merged the sources for Flex version 2.3.7 with the older version
|
||
which was hacked for THINK C version 4. I have conditionalized the code
|
||
so that I think it should work with both THINK C version 4 and 5 (for
|
||
those of you who don't know: the THINK_C symbol is defined as 1 in version
|
||
4 and as 5 in version 5). I have put in some missing prototypes, so it
|
||
compiles also with "require prototypes" on.
|
||
|
||
Most of the notes below still apply, in particular that about the MakeRes
|
||
program.
|
||
|
||
|
||
Notes on the THINK C version of Flex
|
||
Russell S. Finn, 19-FEB-90
|
||
Internet: rsfinn@athena.mit.edu, rsfinn@neutron.lcs.mit.edu
|
||
CompuServe: 76377,1107
|
||
GEnie: RSFINN
|
||
|
||
Flex appears to be covered by a copyright notice from the University of
|
||
California, similar to the one covering Berkeley Unix; the Free Software
|
||
Foundation is not part of the picture here. So here is a version
|
||
created with THINK C 4.0, along with the source code; as with the
|
||
Bison distribution, I am including *all* of the source code I received
|
||
with the package.
|
||
|
||
The current version (modification date January 25, 1990) has only the
|
||
bare-bones interface provided by the THINK C library routine "ccommand",
|
||
which allows the user to type a command line and to redirect the output.
|
||
Perhaps someday I may try to implement a "real" user interface; perhaps
|
||
not.
|
||
|
||
The only modifications made to the source file are surrounded by "#ifdef
|
||
THINK_C"..."#endif"; in theory, then, these sources could be recompiled
|
||
on another system if necessary. These are the actual files modified:
|
||
alloca.c, dfa.c, flexdef.h, main.c, misc.c, scan.c, sym.c. Most of these
|
||
changes were minor, and many of them would have been unnecessary if the
|
||
original Flex source code had been written for an ANSI-compliant C compiler.
|
||
In addition, the file "macutils.c" is completely new; see the discussion
|
||
of "MakeRes" below.
|
||
|
||
THINK C users may find it convenient to have the output text files written
|
||
by Flex be THINK C documents. To do this, create a copy of the "ANSI"
|
||
project called "ANSI-KAHL", and a copy of the file "fopen.c" called
|
||
"fopen-KAHL.c". In the copy, find the routine "setfiletype", and replace
|
||
the lines:
|
||
if (!(oflag & F_BINARY))
|
||
pb.ioFlFndrInfo.fdType = 'TEXT';
|
||
with the lines:
|
||
if (!(oflag & F_BINARY)) {
|
||
pb.ioFlFndrInfo.fdType = 'TEXT';
|
||
pb.ioFlFndrInfo.fdCreator = 'KAHL';
|
||
}
|
||
Replace "fopen.c" with the new "fopen-KAHL.c", rebuild the new project
|
||
"ANSI-KAHL", and use this project in the project file "Flex.<2E>"
|
||
instead of the "ANSI" project.
|
||
|
||
** The "MakeRes" program
|
||
|
||
The output files created by Flex contain large amounts of preinitialized
|
||
static data; the file "scan.c" contained in the Flex.<2E> project is one
|
||
such file. However, the Macintosh architecture limits normal applications
|
||
to 32K of global data. In many cases (including Flex), this limit can
|
||
be surpassed by the static data generated by Flex.
|
||
|
||
The solution I have implemented for the THINK C version of Flex is to
|
||
extract the data tables from the Flex output file, and paste them into
|
||
the file "MakeRes.c". Then, by recompiling and running the program in
|
||
the "MakeRes.<2E>" project (it is not necessary to create an application),
|
||
a resource file called "Flex.<2E>.rsrc" is created in the current directory.
|
||
The Flex output file "scan.c" has been modified to load the static data
|
||
from the resource fork of the Flex application. This is done by calling
|
||
the "load_table" function, which is defined in the file "macutils.c".
|
||
|
||
In the application for which I needed Flex, the data tables were small
|
||
enough that I didn't need to do this. However, if your application
|
||
requires you to do this, simply follow the model of "scan.c"; the MakeRes
|
||
project and source code has been included for your use.
|
||
|