The following reply was made to PR bin/172542; it has been noted by GNATS.

From: Jan Beich <jbe...@tormail.org>
To: Peter Jeremy <pe...@rulingia.com>
Cc: bug-follo...@freebsd.org
Subject: Re: bin/172542: [patch] FICL assumes standalone environment for 
testmain
Date: Thu, 01 Aug 2013 04:43:04 +0000

 --=-=-=
 Content-Type: text/plain
 
 testmain was further broken by freaddir in r253172.
 
 
 --=-=-=
 Content-Type: text/x-patch
 Content-Disposition: attachment; filename=ficl_testmain.diff
 
 Index: sys/boot/ficl/loader.c
 ===================================================================
 --- sys/boot/ficl/loader.c     (revision 253788)
 +++ sys/boot/ficl/loader.c     (working copy)
 @@ -33,11 +33,17 @@
  *******************************************************************/
  
  #ifdef TESTMAIN
 +#include <sys/stat.h>
 +#include <dirent.h>
 +#include <fcntl.h>
 +#include <stdio.h>
  #include <stdlib.h>
 +#include <time.h>
 +#include <unistd.h>
  #else
  #include <stand.h>
 +#include "bootstrap.h"
  #endif
 -#include "bootstrap.h"
  #include <string.h>
  #include "ficl.h"
  
 @@ -135,9 +141,9 @@ void
  ficlGetenv(FICL_VM *pVM)
  {
  #ifndef TESTMAIN
 -      char    *name;
 +      char    *name, *value;
  #endif
 -      char    *namep, *value;
 +      char    *namep;
        int     names;
  
  #if FICL_ROBUST > 1
 @@ -243,9 +249,9 @@ void
  ficlFindfile(FICL_VM *pVM)
  {
  #ifndef TESTMAIN
 -      char    *name;
 +      char    *type, *name;
  #endif
 -      char    *type, *namep, *typep;
 +      char    *namep, *typep;
        struct  preloaded_file* fp;
        int     names, types;
  
 @@ -511,7 +517,7 @@ static void pfread(FICL_VM *pVM)
   */
  static void pfreaddir(FICL_VM *pVM)
  {
 -    struct dirent *d;
 +    struct dirent *d = NULL;
      int fd;
  
  #if FICL_ROBUST > 1
 @@ -519,7 +525,15 @@ static void pfreaddir(FICL_VM *pVM)
  #endif
  
      fd = stackPopINT(pVM->pStack);
 +#ifdef TESTMAIN
 +    static DIR *dir;
 +    if (lseek(fd, 0, SEEK_CUR) == 0)
 +       dir = fdopendir(fd);
 +    if (dir != NULL)
 +       d = readdir(dir);
 +#else
      d = readdirfd(fd);
 +#endif
      if (d != NULL) {
          stackPushPtr(pVM->pStack, d->d_name);
          stackPushINT(pVM->pStack, strlen(d->d_name));
 
 --=-=-=--
_______________________________________________
freebsd-bugs@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"

Reply via email to