From: Ulrich Drepper Date: Fri, 27 Feb 1998 10:22:03 +0000 (+0000) Subject: POSIX.1 says that argv[0] *should* be provided, but does not require it. X-Git-Tag: cvs/before-sparc-2_0_x-branch~199 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0a54f052b55ea3d7eb04cb7e4c1dd83ef2adc390;p=thirdparty%2Fglibc.git POSIX.1 says that argv[0] *should* be provided, but does not require it. Handle missing argv[] values gracefully. --- diff --git a/posix/execl.c b/posix/execl.c index 9aa13b958fb..b6dbb1a0a18 100644 --- a/posix/execl.c +++ b/posix/execl.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991, 1992, 1994 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1992, 1994, 1998 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 @@ -37,11 +37,11 @@ DEFUN(execl, (path, arg), CONST char *path AND CONST char *arg DOTS) argv[0] = arg; va_start (args, arg); - i = 1; - do + i = 0; + while (argv[i++] != NULL) { argv[i] = va_arg (args, CONST char *); - } while (argv[i++] != NULL); + } va_end (args); return __execve (path, (char *CONST *) argv, __environ); diff --git a/posix/execle.c b/posix/execle.c index a36d49a407e..fd343be3a47 100644 --- a/posix/execle.c +++ b/posix/execle.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1991 Free Software Foundation, Inc. +/* Copyright (C) 1991, 1998 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 @@ -32,11 +32,11 @@ DEFUN(execle, (path), CONST char *path AND CONST char *arg DOTS) va_start(args, arg); argv[0] = arg; - i = 1; - do + i = 0; + while (argv[i++] != NULL) { argv[i] = va_arg(args, CONST char *); - } while (argv[i++] != NULL); + } envp = va_arg(args, CONST char *CONST *); va_end(args);