[comp.os.minix] ST/PC V1.5.0 ls/qsort bug fix

schiers@imdm.uke.uni-hamburg.dbp.de (Carsten Schiers) (02/09/90)

In the V1.5.0 distribution occured a bug, causing a SIG=11, when the 
ls command was used with -lR flags and an empty directory was examined. 
This is due to a bug in the /usr/src/lib/ansi/qsort.c function when the 
number of elements to be sorted equals zero. A bug fix is included.

After aplying this patch, recompile at least ls.c. With this fix, 
ls V1.5.0 works correctly, as far as we tested it.
 
Carsten Schiers & Juergen Wulff
             
Carsten Schiers
---------------------------------------------
DFNet:    schiers@imdm.uke.uni-hamburg.dbp.de
Usenet:   unido!imdm.uke.uni-hamburg.dbp.de!schiers
Bitnet:   schiers%imdm.uke.uni-hamburg.dbp.de@dfngate
Internet: schiers%imdm.uke.uni-hamburg.dbp.de@relay.cs.net

Juergen Wulff
---------------------------------------------
DFNet:    wulff@imdm.uke.uni-hamburg.dbp.de
Usenet:   unido!imdm.uke.uni-hamburg.dbp.de!wulff
Bitnet:   wulff%imdm.uke.uni-hamburg.dbp.de@dfngate
Internet: wulff%imdm.uke.uni-hamburg.dbp.de@relay.cs.net

-------------------------------- cut here --------------------------------
*** qsort.c.150	Thu Feb  8 19:31:46 1990
--- qsort.c	Thu Feb  8 19:31:01 1990
***************
*** 9,16 ****
  size_t nel, width;
  _PROTOTYPE( int (*compar), (const void *, const void *));
  {
!   qcompar = compar;
!   qsort1((char *) base, (char *) base + (nel - 1) * width, width);
  }
  
  PRIVATE void qsort1(a1, a2, width)
--- 9,19 ----
  size_t nel, width;
  _PROTOTYPE( int (*compar), (const void *, const void *));
  {
!   if (nel!=0)
!     {
!       qcompar = compar;
!       qsort1((char *) base, (char *) base + (nel - 1) * width, width);
!     }
  }
  
  PRIVATE void qsort1(a1, a2, width)