-/* Copyright (C) 1991, 1992, 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 94, 97, 98, 99 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <alloca.h>
#include <unistd.h>
#include <stdarg.h>
#include <stddef.h>
#include <string.h>
+#include <stackinfo.h>
+
#ifndef HAVE_GNU_LD
# define __environ environ
#endif
argv[0] = arg;
va_start (args, arg);
- i = 1;
- do
+ i = 0;
+ while (argv[i++] != NULL)
{
if (i == argv_max)
{
const char **nptr = alloca ((argv_max *= 2) * sizeof (const char *));
+#ifndef _STACK_GROWS_UP
if ((char *) nptr + argv_max == (char *) argv)
{
/* Stack grows down. */
argv = (const char **) memcpy (nptr, argv, i);
argv_max += i;
}
- else if ((char *) argv + i == (char *) nptr)
+ else
+#endif
+#ifndef _STACK_GROWS_DOWN
+ if ((char *) argv + i == (char *) nptr)
/* Stack grows up. */
argv_max += i;
else
+#endif
/* We have a hole in the stack. */
argv = (const char **) memcpy (nptr, argv, i);
}
argv[i] = va_arg (args, const char *);
}
- while (argv[i++] != NULL);
va_end (args);
return __execve (path, (char *const *) argv, __environ);