--- export/src/filecomplete.c 2009-09-05 13:37:56.000000000 +0200 +++ ../src/filecomplete.c 2009-09-05 13:47:56.000000000 +0200 @@ -28,8 +28,27 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ + +/* AIX requires this to be the first thing in the file. */ +#if defined (_AIX) && !defined (__GNUC__) + #pragma alloca +#endif + +#include + +#ifdef __GNUC__ +# undef alloca +# define alloca(n) __builtin_alloca (n) +#else +# ifdef HAVE_ALLOCA_H +# include +# else +# ifndef _AIX +extern char *alloca (); +# endif +# endif +#endif -#include "config.h" #if !defined(lint) && !defined(SCCSID) __RCSID("$NetBSD: filecomplete.c,v 1.15 2009/02/16 00:15:45 christos Exp $"); #endif /* not lint && not SCCSID */ @@ -46,14 +65,8 @@ #include #include #include -#ifdef HAVE_VIS_H #include -#else -#include "np/vis.h" -#endif -#ifdef HAVE_ALLOCA_H -#include -#endif + #include "el.h" #include "fcns.h" /* for EL_NUM_FCNS */ #include "histedit.h" @@ -98,11 +111,23 @@ temp[len - 2] = '\0'; } if (temp[0] == 0) { +#ifdef HAVE_GETPW_R_POSIX if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf), &pass) != 0) pass = NULL; +#elif HAVE_GETPW_R_DRAFT + pass = getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf)); +#else + pass = getpwuid(getuid()); +#endif } else { +#ifdef HAVE_GETPW_R_POSIX if (getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf), &pass) != 0) pass = NULL; +#elif HAVE_GETPW_R_DRAFT + pass = getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf)); +#else + pass = getpwnam(temp); +#endif } free(temp); /* value no more needed */ if (pass == NULL) @@ -208,11 +233,8 @@ /* otherwise, get first entry where first */ /* filename_len characters are equal */ if (entry->d_name[0] == filename[0] -#if HAVE_STRUCT_DIRENT_D_NAMLEN - && entry->d_namlen >= filename_len -#else + /* Some dirents have d_namlen, but it is not portable. */ && strlen(entry->d_name) >= filename_len -#endif && strncmp(entry->d_name, filename, filename_len) == 0) break; @@ -220,11 +242,8 @@ if (entry) { /* match found */ -#if HAVE_STRUCT_DIRENT_D_NAMLEN - len = entry->d_namlen; -#else + /* Some dirents have d_namlen, but it is not portable. */ len = strlen(entry->d_name); -#endif temp = malloc(strlen(dirname) + len + 1); if (temp == NULL)