home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / lang / lightspe.pat < prev    next >
Text File  |  1987-06-07  |  12KB  |  332 lines

  1. Last week I called Think Technologies about a bug I had found in the
  2. Lightspeed C library routine SetEventMask().  They already knew of the bug
  3. and were willing to send me the current list of patches for the Lightspeed C
  4. compiler and library (version 1.02).  They also gave their permission for me
  5. to post the patches to Usenet, so here is a typed-in copy of what I recieved
  6. from them.
  7.  
  8.                 Allan Weber
  9.                 USC Signal & Image Processing Institute
  10.                 Weber%Brand@USC-ECL.ARPA
  11.                 ...sdcrdcf!usc-oberon!brand!weber
  12.                 
  13.  
  14. ========================== start of patch list ===============================
  15. (C) Copyright 1985, 1986. THINK Technologies, Inc.  All rights reserved.
  16.  
  17. LightspeedC is a trademark of:
  18.  
  19.     THINK Technologies, Inc.
  20.     420 Bedford Street Suite 350
  21.     Lexington, MA 02173
  22.     (617) 863-1099 (customer service for registered LightspeedC users)
  23.  
  24. This list contains patches for problems with LightspeedC version 1.02
  25. as of 6/11/86
  26.  
  27. The suggested way to apply these patches is to use a binary file searching and
  28. editing program (such as FEDIT) to find the hexadecimal sequence marked
  29. "Change:".  This sequence should then be replaced with the hexadecimal
  30. sequence marked "to:"
  31.  
  32. *******************************************************************************
  33.  
  34. Compiler crashes when a label is first referenced at an inner scope
  35. in a function without arguments  or locals.
  36.  
  37.     Change:  7001 1B40 F47F
  38.         to:  3B7C 0101 F47E
  39.  
  40. *******************************************************************************
  41.  
  42. Incorrect code is generated when a pointer to an object of
  43. size >=128 is auto-incremented or auto-decremented.
  44.  
  45.     Change:  197C 0004 0001 196D
  46.         to:  197C 0004 FFE5 196D
  47.  
  48. *******************************************************************************
  49.  
  50. Incorrect code is generated for certain long bitfields.
  51.  
  52.     Change:  122E FFF3 4881 9240 5341 E841
  53.         to:  721F 9240 E841 D241 4E71 4E71
  54.  
  55. *******************************************************************************
  56.  
  57. File behind "Link Errors" window is not saved.
  58.  
  59.     Change:  09D6 FFF8 6000 0030
  60.         to:  09D6 FFF8 6000 0028
  61.  
  62.     Change:  F630 588F 4A40 6600 0008 7000 6000 0046
  63.         to:  F630 588F 660A 604C 2F2D FAAC 42A7 A921
  64.  
  65. *******************************************************************************
  66.  
  67. Constant is lost in conversion from integer to floating point.
  68.  
  69.     Change:  4EBA 0346 48A7 8000 660C 0C2C 0008 0000 660E 548F 4E75 0C40 0008
  70.         to:  4EAD 0212 7408 4EBA 0340 48A7 8000 6608 B414 660C 548F 4E75 B280
  71.  
  72. *******************************************************************************
  73.  
  74. Wrong register usage in condition operator ( ?: )
  75.  
  76.     Change:  6708 816D E48A
  77.         to:  6708 4E71 4E71
  78.  
  79. *******************************************************************************
  80. <<<<<<<<<<<<<<<<<<<<<<<<<<<<END OF COMPILER PATCHES>>>>>>>>>>>>>>>>>>>>>>>>>>>>
  81.  
  82. The following is a patch to the MacTraps Library that came with
  83. the LightspeedC 1.02 Compiler:
  84.  
  85. Apple's SetEventMask glue moves a long instead of a word and also trashes stack
  86.  
  87. SetEventMask glue does a MOVE.L instead of a MOVE.W
  88.  
  89.     Change:  225F 21DF 0144 4ED1
  90.         to:  225F 31DF 0144 4ED1
  91.  
  92. remember to reload MacTraps into any affected projects!
  93.  
  94. *******************************************************************************
  95.  
  96. This list contains source code patches for the currently known problems with
  97. LightspeedC libraries included with version 1.02 of the compiler
  98. (also as of 6/11/86)
  99.  
  100. The suggested way to apply these patches is to:
  101.  
  102. 1)  Make sure you have gathered all of the necessary include files such that
  103.     the original file will compile prior to making any changes.
  104.  
  105. 2)  Open the appropriate project (i.e. stdio) with LightspeedC.
  106.  
  107. 3)  Save a copy of the original file (use "Save a Copy As" under File menu) in
  108.     case you mess up.
  109.  
  110. 4)  Correct the source text for the appropriate file included on the
  111.     LightspeedC Library disk (LS2.Libraries)
  112.  
  113. 5)  Recompile the file (with "MacsBug Symbols" option OFF).
  114.  
  115. 6)  Turn the "Compact Project" option ON and close the project.
  116.  
  117. 7)  The patched library project can now be re-included in your other
  118.     working projects.
  119.  
  120. *******************************************************************************
  121.  
  122. From the project "stdio":
  123.  
  124. *********************************************************************
  125. *fseek(fileptr,1,offset);                                           *
  126. *                                                                   *
  127. *Should seek offset bytes from the current mark, but seeks from the *
  128. *beginning of the file.                                             *
  129. *                                                                   *
  130. *Work around - use fseek(fileptr,0,ftell(fileptr)+offset);          *
  131. *                                                                   *
  132. *Fix in code:                                                       *
  133.  
  134. In the file stdfile_pos.c
  135.  
  136.         case 1:
  137.             type = fsFromMark;
  138.             if (err = who->last_error = PBGetEof(&pb,false))
  139.                 {
  140.                 errno = err;
  141.                 return(EOF);
  142.             }
  143.             eofile = (long)pb.ioMisc;   /* get logical EOF */
  144.             if ((posfile = ftell(who)) == -1L)
  145.                 return(EOF);
  146.             if (posfile+offset > eofile)
  147.                 return(write_from_eof(posfile+offset-eofile,eofile,who));
  148. Add ==>     offset += posfile; /* point to real position */
  149.             break;
  150.         case 2:
  151.             type = fsFromLEOF;
  152.             if (err = who->last_error = PBGetEOF(&pb,false))
  153.                 {
  154.                 errno = err;
  155.                 return(EOF);
  156.             }
  157. Add ==>     eofile = pb.ioPosOffset;
  158.             if (offset>0)
  159.                 return(write_from_eof(offset,pb.ioMisc,who));
  160. Add ==>     offset += eofile; /* point to real position */
  161.             break;
  162.  
  163. *********************************************************************
  164.  
  165. *********************************************************************
  166. *Printf("%g",1000.) prints 1 instead of 1000                        *
  167. *                                                                   *
  168. *Work around - Use %f or %e instead of %g                           *
  169. *                                                                   *
  170. *Fix in code:                                                       *
  171. *                                                                   *
  172. In the file printf-1.c
  173.  
  174. Search for:
  175.             if (strip_it)
  176.  
  177. and change the code from:
  178.  
  179.                     /* strip trailing zeros */
  180.                             if (strip_it)
  181.                                 {
  182.                                 while ((*bufptr == '0')||(*bufptr == '.'))
  183.                                     bufptr--;
  184.                                 *(++bufptr) = '\0';
  185.                             }
  186.  
  187. to:
  188.                     /* strip trailing zeros */
  189.                             if (strip_it)
  190.                                 {
  191.                                 while (*bufptr == '0')
  192.                                     bufptr--;
  193.                                 if (*bufptr == '.')
  194.                                     bufptr--;
  195.                                 *(++bufptr) = '\0';
  196.                             }
  197. *********************************************************************
  198.  
  199. *********************************************************************
  200. *printf("*\t\t\t*") only tabs once instead of 3 times               *
  201. *                                                                   *
  202. *Work around - Use printf("* \t \t \t*")                            *
  203. *                                                                   *
  204. *Fix in code:                                                       *
  205. *                                                                   *
  206. In the file printf-2.c
  207.  
  208. Search for:
  209.  
  210.         case '\t' : cursor_plot(false);
  211.                     while (((col-1) % _tab_width) || (col-1 == 0))
  212.                         {
  213.                         cursor_plot(true);
  214.                         col++;
  215.                     }
  216.  
  217. and change to:
  218.  
  219.         case '\t' : cursor_plot(false);
  220.  
  221.                     do  {
  222.                         cursor_plot(true);
  223.                         col++;
  224.                     }while ((col-1) % _tab_width)
  225.  
  226. *                                                                   *
  227. *********************************************************************
  228.  
  229. *******************************************************************************
  230.  
  231.  
  232. From the project "unix":
  233.  
  234. *******************************************************************************
  235.  
  236. qsort trashes memory with large sorts
  237.  
  238. in the file qsort.c, change the following line:
  239.  
  240.     change: static int qsize;
  241.  
  242.     to:     static unsigned long qsize;
  243.  
  244. *******************************************************************************
  245.  
  246. *********************************************************************
  247. *creat(filename,mode)                                               *
  248. *open(filename,mode)                                                *
  249. *                                                                   *
  250. * If you pass O_RDWR|O_CREAT to creat as the mode, the open will    *
  251. * fail if the file doesn't already exist.                           *
  252. *                                                                   *
  253. *Work around - make sure the file is created first.  This can be    *
  254. * done in the editor by bringing up a NEW file and then SAVE AS...  *
  255. * using the same name of the file you are using in open and creat.  *
  256. *                                                                   *
  257. *Fix in code:                                                       *
  258. *                                                                   *
  259. In the file unixfileio.c
  260.  
  261. Search for:
  262.  
  263.     nonstdmode:
  264.             if (mode & O_TRUNC)
  265.                 stdmode[i++] = 'w';
  266.             else
  267.             if (mode & O_APPEND)
  268.                 stdmode[i++] = 'a';
  269.             else
  270.                 stdmode[i++] = 'r';
  271.  
  272.             stdmode[i++] = '+';
  273.             break;
  274.  
  275. and change to:
  276.  
  277.     nonstdmode:
  278.             if ((mode & O_CREAT)||(mode & O_TRUNC))
  279.                 stdmode[i++] = 'w';
  280.             else
  281.             if (mode & O_APPEND)
  282.                 stdmode[i++] = 'a';
  283.             else
  284.                 stdmode[i++] = 'r';
  285.  
  286.             stdmode[i++] = '+';
  287.             break;
  288. *                                                                   *
  289. *********************************************************************
  290.  
  291. *********************************************************************
  292. *read(fildes,buf,nbytes)                                            *
  293. *                                                                   *
  294. * If you read from an empty file, or have an immediate EOF          *
  295. * read returns -1 instead of 0.                                     *
  296. *                                                                   *
  297. * Work around - Test for -1 and ignore it (it's an immediate EOF)   *
  298. *                                                                   *
  299. *Fix in code:                                                       *
  300. *                                                                   *
  301. In the file unixfileio.c
  302.  
  303.     Search for the function fileop()
  304.     and add the 2 lines shown below:
  305.  
  306. static int fileop(fildes, buffer, nbytes, op)
  307. register unsigned int fildes;
  308. char *buffer;
  309. unsigned nbytes;
  310. int (*op)();
  311. {
  312. int actcount;
  313.  
  314.     if (invalidfildes(fildes))
  315.         return(-1);
  316.  
  317.     if (actcount = (*op)(buffer, sizeof(*buffer), nbytes, &_file[fildes]))
  318.         return(actcount);
  319.  
  320. /* *** add the next two lines *** */
  321.     if (_file[fildes].last_error == eofErr)
  322.         return(0);
  323.  
  324.     errno = EIO;
  325.     return (-1);
  326. }
  327. *                                                                   *
  328. *                                                                   *
  329. *********************************************************************
  330. ===================== end of patch list =================================
  331.  
  332.