[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MiNT] scandir() bug



Hello.

It seems that the MiNTLib's scandir() function is buggy.

See the example at the bottom of the man page:
http://man7.org/linux/man-pages/man3/scandir.3.html
I also provide it as attachment, slightly cleaned up.

On Cygwin, it works fine.
On MiNT, it displays rubbish.

This scandir() bug is the cause of trouble in arc:
http://vincent.riviere.free.fr/soft/m68k-atari-mint/archives/mint/arc/

arc a archive.arc Makefile
Creating new archive: archive.arc
Cannot read file:
No files were added.

NB: The scandir() source is there:
http://sparemint.atariforge.net/cgi-bin/cvsweb/mintlib/dirent/scandir.c?rev=1.2&content-type=text/x-cvsweb-markup
I don't fully understand it.
I suspect some mess with malloc().

--
Vincent Rivière
/* print files in current directory in reverse order */
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>

int
main(void)
{
   struct dirent **namelist;
   int n;

   n = scandir(".", &namelist, NULL, alphasort);
   if (n < 0)
       perror("scandir");
   else {
       while (n--) {
           printf("%s\n", namelist[n]->d_name);
           free(namelist[n]);
       }
       free(namelist);
   }

   return 0;   
}