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