[net.micro.mac] List of Lightspeed C patches

weber@brand.UUCP (Allan G. Weber) (06/18/86)

Last week I called Think Technologies about a bug I had found in the
Lightspeed C library routine SetEventMask().  They already knew of the bug
and were willing to send me the current list of patches for the Lightspeed C
compiler and library (version 1.02).  They also gave their permission for me
to post the patches to Usenet, so here is a typed-in copy of what I recieved
from them.

				Allan Weber
				USC Signal & Image Processing Institute
				Weber%Brand@USC-ECL.ARPA
				...sdcrdcf!usc-oberon!brand!weber
				

========================== start of patch list ===============================
(C) Copyright 1985, 1986. THINK Technologies, Inc.  All rights reserved.

LightspeedC is a trademark of:

    THINK Technologies, Inc.
    420 Bedford Street Suite 350
    Lexington, MA 02173
    (617) 863-1099 (customer service for registered LightspeedC users)

This list contains patches for problems with LightspeedC version 1.02
as of 6/11/86

The suggested way to apply these patches is to use a binary file searching and
editing program (such as FEDIT) to find the hexadecimal sequence marked
"Change:".  This sequence should then be replaced with the hexadecimal
sequence marked "to:"

*******************************************************************************

Compiler crashes when a label is first referenced at an inner scope
in a function without arguments  or locals.

    Change:  7001 1B40 F47F
        to:  3B7C 0101 F47E

*******************************************************************************

Incorrect code is generated when a pointer to an object of
size >=128 is auto-incremented or auto-decremented.

    Change:  197C 0004 0001 196D
        to:  197C 0004 FFE5 196D

*******************************************************************************

Incorrect code is generated for certain long bitfields.

    Change:  122E FFF3 4881 9240 5341 E841
        to:  721F 9240 E841 D241 4E71 4E71

*******************************************************************************

File behind "Link Errors" window is not saved.

    Change:  09D6 FFF8 6000 0030
        to:  09D6 FFF8 6000 0028

    Change:  F630 588F 4A40 6600 0008 7000 6000 0046
        to:  F630 588F 660A 604C 2F2D FAAC 42A7 A921

*******************************************************************************

Constant is lost in conversion from integer to floating point.

    Change:  4EBA 0346 48A7 8000 660C 0C2C 0008 0000 660E 548F 4E75 0C40 0008
        to:  4EAD 0212 7408 4EBA 0340 48A7 8000 6608 B414 660C 548F 4E75 B280

*******************************************************************************

Wrong register usage in condition operator ( ?: )

    Change:  6708 816D E48A
        to:  6708 4E71 4E71

*******************************************************************************
<<<<<<<<<<<<<<<<<<<<<<<<<<<<END OF COMPILER PATCHES>>>>>>>>>>>>>>>>>>>>>>>>>>>>

The following is a patch to the MacTraps Library that came with
the LightspeedC 1.02 Compiler:

Apple's SetEventMask glue moves a long instead of a word and also trashes stack

SetEventMask glue does a MOVE.L instead of a MOVE.W

    Change:  225F 21DF 0144 4ED1
        to:  225F 31DF 0144 4ED1

remember to reload MacTraps into any affected projects!

*******************************************************************************

This list contains source code patches for the currently known problems with
LightspeedC libraries included with version 1.02 of the compiler
(also as of 6/11/86)

The suggested way to apply these patches is to:

1)  Make sure you have gathered all of the necessary include files such that
    the original file will compile prior to making any changes.

2)  Open the appropriate project (i.e. stdio) with LightspeedC.

3)  Save a copy of the original file (use "Save a Copy As" under File menu) in
    case you mess up.

4)  Correct the source text for the appropriate file included on the
    LightspeedC Library disk (LS2.Libraries)

5)  Recompile the file (with "MacsBug Symbols" option OFF).

6)  Turn the "Compact Project" option ON and close the project.

7)  The patched library project can now be re-included in your other
    working projects.

*******************************************************************************

From the project "stdio":

*********************************************************************
*fseek(fileptr,1,offset);                                           *
*                                                                   *
*Should seek offset bytes from the current mark, but seeks from the *
*beginning of the file.                                             *
*                                                                   *
*Work around - use fseek(fileptr,0,ftell(fileptr)+offset);          *
*                                                                   *
*Fix in code:                                                       *

In the file stdfile_pos.c

        case 1:
            type = fsFromMark;
            if (err = who->last_error = PBGetEof(&pb,false))
                {
                errno = err;
                return(EOF);
            }
            eofile = (long)pb.ioMisc;   /* get logical EOF */
            if ((posfile = ftell(who)) == -1L)
                return(EOF);
            if (posfile+offset > eofile)
                return(write_from_eof(posfile+offset-eofile,eofile,who));
Add ==>     offset += posfile; /* point to real position */
            break;
        case 2:
            type = fsFromLEOF;
            if (err = who->last_error = PBGetEOF(&pb,false))
                {
                errno = err;
                return(EOF);
            }
Add ==>     eofile = pb.ioPosOffset;
            if (offset>0)
                return(write_from_eof(offset,pb.ioMisc,who));
Add ==>     offset += eofile; /* point to real position */
            break;

*********************************************************************

*********************************************************************
*Printf("%g",1000.) prints 1 instead of 1000                        *
*                                                                   *
*Work around - Use %f or %e instead of %g                           *
*                                                                   *
*Fix in code:                                                       *
*                                                                   *
In the file printf-1.c

Search for:
            if (strip_it)

and change the code from:

                    /* strip trailing zeros */
                            if (strip_it)
                                {
                                while ((*bufptr == '0')||(*bufptr == '.'))
                                    bufptr--;
                                *(++bufptr) = '\0';
                            }

to:
                    /* strip trailing zeros */
                            if (strip_it)
                                {
                                while (*bufptr == '0')
                                    bufptr--;
                                if (*bufptr == '.')
                                    bufptr--;
                                *(++bufptr) = '\0';
                            }
*********************************************************************

*********************************************************************
*printf("*\t\t\t*") only tabs once instead of 3 times               *
*                                                                   *
*Work around - Use printf("* \t \t \t*")                            *
*                                                                   *
*Fix in code:                                                       *
*                                                                   *
In the file printf-2.c

Search for:

        case '\t' : cursor_plot(false);
                    while (((col-1) % _tab_width) || (col-1 == 0))
                        {
                        cursor_plot(true);
                        col++;
                    }

and change to:

        case '\t' : cursor_plot(false);

                    do  {
                        cursor_plot(true);
                        col++;
                    }while ((col-1) % _tab_width)

*                                                                   *
*********************************************************************

*******************************************************************************


From the project "unix":

*******************************************************************************

qsort trashes memory with large sorts

in the file qsort.c, change the following line:

    change: static int qsize;

    to:     static unsigned long qsize;

*******************************************************************************

*********************************************************************
*creat(filename,mode)                                               *
*open(filename,mode)                                                *
*                                                                   *
* If you pass O_RDWR|O_CREAT to creat as the mode, the open will    *
* fail if the file doesn't already exist.                           *
*                                                                   *
*Work around - make sure the file is created first.  This can be    *
* done in the editor by bringing up a NEW file and then SAVE AS...  *
* using the same name of the file you are using in open and creat.  *
*                                                                   *
*Fix in code:                                                       *
*                                                                   *
In the file unixfileio.c

Search for:

    nonstdmode:
            if (mode & O_TRUNC)
                stdmode[i++] = 'w';
            else
            if (mode & O_APPEND)
                stdmode[i++] = 'a';
            else
                stdmode[i++] = 'r';

            stdmode[i++] = '+';
            break;

and change to:

    nonstdmode:
            if ((mode & O_CREAT)||(mode & O_TRUNC))
                stdmode[i++] = 'w';
            else
            if (mode & O_APPEND)
                stdmode[i++] = 'a';
            else
                stdmode[i++] = 'r';

            stdmode[i++] = '+';
            break;
*                                                                   *
*********************************************************************

*********************************************************************
*read(fildes,buf,nbytes)                                            *
*                                                                   *
* If you read from an empty file, or have an immediate EOF          *
* read returns -1 instead of 0.                                     *
*                                                                   *
* Work around - Test for -1 and ignore it (it's an immediate EOF)   *
*                                                                   *
*Fix in code:                                                       *
*                                                                   *
In the file unixfileio.c

    Search for the function fileop()
    and add the 2 lines shown below:

static int fileop(fildes, buffer, nbytes, op)
register unsigned int fildes;
char *buffer;
unsigned nbytes;
int (*op)();
{
int actcount;

    if (invalidfildes(fildes))
        return(-1);

    if (actcount = (*op)(buffer, sizeof(*buffer), nbytes, &_file[fildes]))
        return(actcount);

/* *** add the next two lines *** */
    if (_file[fildes].last_error == eofErr)
        return(0);

    errno = EIO;
    return (-1);
}
*                                                                   *
*                                                                   *
*********************************************************************
===================== end of patch list =================================