home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Journal 1990 - 1995 / CUJ.iso / mac / 1990.txt next >
Text File  |  1996-02-07  |  3MB  |  96,735 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613. We Have Mail
  614. Dear Mr. Ward:
  615. I am not much of a letter writer, but after reading the July 89 issue of the C
  616. Users Journal I felt I could save some of your readers a lot of time tracking
  617. down a problem with the Microsoft C, version 5.10 memory allocation routines.
  618. Enclosed is a listing and the output from the program.
  619. This may help Steven Isaacson who is having memory allocation problems using
  620. Vitamin C. I found this problem after a week of tracking down a memory leak
  621. problem in a very large application. My final solution was to write my own
  622. malloc()/free() rountines that call DOS directly. This will let the DOS
  623. allocator do what it is supposed to do. No time penalty was noticed in our
  624. application.
  625. Note if you do write your own malloc()/free() routines, call them something
  626. else! MSC uses these routines internally and makes assumptions about what data
  627. is located outside the allocated area. I always use a malloc()/free() shell to
  628. test for things like memory leaks and the free of a non-allocated block. It
  629. also will give you an easy way to install a global 'out of memory' error
  630. handler.
  631. The code supplied by Leonard Zerman on finding the amount of free space in a
  632. system is simplistic and very limited. A better routine would build a linked
  633. list of elements and then the variable vptrarray could be made a single
  634. pointer to the head of the list. The entire routine becomes dynamic, much more
  635. robust, and there is no danger of overflowing a statically allocated array.
  636. See the supplied code for an example.
  637. The linked list implementation has the side effect that it will work on a
  638. virtual memory system. Why you would want to do this is beyond me, but it
  639. could be considered a very time consuming way to find out what swapmax is set
  640. to on a UNIX system.
  641. If you have any questions, please contact me. My phone number is (408)
  642. 988-3818. My fax number is (408) 748-1424.
  643. Sincerely yours,
  644. Jim Schimandle
  645. Primary Syncretics
  646. 473 Sapena Court, Unit #6
  647. Santa Clara, CA 95054
  648. Thanks for the information. We've included your code in Listing 1. -- rlw
  649. Dear Mr. Ward:
  650. I'm new to programming and need to extract information from old mainframe
  651. files. Each file has its own annoying attributes.
  652. Some files are reports for printing on 132 column paper with headers on each
  653. page along with errors in tabulation and decimal point alignment.
  654. I'd like to know enough about grep, awk, sed, and tr so I'm not reinventing
  655. the wheel with my C programs for file manipulation.
  656. Where can I find an understandable and brief overview of these UNIX tools? (I
  657. know nothing about regular expressions, scanning, and syntactic analysis.)
  658. Sincerely,
  659. Orion C. Whitaker, M.D.
  660. 400 Brookline Ave., #22F
  661. Boston, MA 02215
  662. I suggest The UNIX Programming Environment by Kernighan and Pike. This is a
  663. tidy little book that does more to explain how the tools work and work
  664. together than any other book I've seen. While it's insightful, it's also a
  665. good teaching text.
  666. You should also consider The Awk Programming Language by Aho, Kernighan and
  667. Weinberger (the A. W. K. in awk).
  668. If our readers know of other texts that do a good job of explaining how to use
  669. the UNIX language-oriented tools, I'd like to hear from you. -- rlw
  670. Thank you for your letter/brochure. First, I have some questions. I studied
  671. BASIC last Semester at Comm. College, and would now like to learn C. My major
  672. problem is MY computer. I have a Commodore 64 with 256K RAM expansion, and
  673. plan to use Abacus Software's Super C Compiler 64. I am a retiree with little
  674. prospect of buying a new computer.
  675. 1. Do you offer much in this format, or am I butting my head against a wall?
  676. 2. Would it be practical for me to attend a class where they are using,
  677. probably, IBM compatibles, and do my homework on my system? Would work
  678. developed on my system operate on "IBM"s? The disks are not compatible, but
  679. could my work be 'retyped' into the "IBM"?
  680. I have Standard C by Plauger & Brodie, and Transactor Magazine has articles
  681. which look like they will be useful when I learn more.
  682. Les Maynard
  683. P.O. Box 915
  684. Palmer, AK 99645
  685. Unfortunately, we can't write Commodore disks. However, it's my understanding
  686. that if you have the right Commodore drive you can get a program that will let
  687. you read MS-DOS disks directly.
  688. Whether you can do your C homework on your Commodore depends on several
  689. things:
  690. 1) Is your instructor willing to accept Commodore output. If you have to run
  691. your work on an MS-DOS host to make it acceptable, it probably won't work.
  692. 2) What subjects and exercises will the class focus upon? If writing direct to
  693. the IBM video display is one of the exercises, it probably isn't reasonable
  694. for you to try to work along on the Commodore. If, on the other hand, the
  695. class will confine itself to general, portable language features and concepts,
  696. you will have less trouble.
  697. 3) How adept are you at researching your own system? At some point (probably
  698. several points), a classroom illustration isn't going to work on your machine.
  699. It really isn't fair to expect the instructor to research the problem for you.
  700. Can you find your own way?
  701. 4) Is your Commodore implementation complete enough to support the scope of
  702. the class? Will you be asked to write programs that exceed the memory space?
  703. Will you need doubles? Will the exercises require elaborate pre-processor
  704. capabilities?
  705. At the very least you should have a serious talk with the instructor before
  706. you enroll.
  707. Whether work you develop will run on an IBM depends entirely upon the code. If
  708. you confine yourself to generic file processing and discipline yourself to
  709. avoid or at least properly hide any Commodore peculiarities, then your code
  710. should run in the IBM environment. (You might find some helpful ideas in
  711. Rainer Gerhard's story in this issue.) Please note these are major ifs even
  712. for very experienced C programmers. -- rlw
  713. Dear CUG,
  714. I am writing to warn you and other users of the problems I have found with LEX
  715. part 1 and 2 on disk number 172 and 173. The program generates code which
  716. crashes the system when run. The problem is in llstin(). If _tabp is NULL, it
  717. assigns it to the return of lexswitch(). lexswitch() returns a pointer to the
  718. previous table, which is NULL when first cared. The results is _tabp being set
  719. to NULL forever. Since this table contains pointers to functions, the program
  720. jumps off to an unknown address. The source code that was provided will NOT
  721. generate this code, indicating that the exe file was not built from this
  722. source! So, I rebuilt it and, in testing, found the new exe produced different
  723. tables than the release program did.
  724. There are various solutions to this problem. One is by setting _tabp to the
  725. location of the table in the .lxi. The solution is to edit the generated
  726. source file each time and removing the assignment statement to _tabp in
  727. llstin(). Or you could alternately change lexswitch() to return the new value.
  728. I don't like the last one because all the documentation states the return
  729. value is a pointer to the previous table. Since I am using the -s option, I
  730. edit the file as there is another problem with that option.
  731. The problem with the -s option may only exist with Microsoft C. llstin() is
  732. declared as a void at the beginning. The function itself is NOT. The compiler
  733. produces a diagnostic error. With the incorrect source, the only way around
  734. this is to edit the file. (A REAL PAIN if you are using a make file to build
  735. the final program.)
  736. I also have a copy of "Bison". It has worked very well with one exception. I
  737. found I had to include stdlib.h in simple.prs in order to get rid of several
  738. warning messages under c