freeswitch/libs/libedit/patches/15-filecomplete.c.patch

99 lines
2.4 KiB
Diff

--- export/src/filecomplete.c 2007-08-31 00:02:46.000000000 +0200
+++ ../src/filecomplete.c 2007-08-31 00:03:08.000000000 +0200
@@ -31,8 +31,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 <config.h>
+
+#ifdef __GNUC__
+# undef alloca
+# define alloca(n) __builtin_alloca (n)
+#else
+# ifdef HAVE_ALLOCA_H
+# include <alloca.h>
+# else
+# ifndef _AIX
+extern char *alloca ();
+# endif
+# endif
+#endif
-#include "config.h"
#if !defined(lint) && !defined(SCCSID)
__RCSID("$NetBSD: filecomplete.c,v 1.10 2006/11/09 16:58:38 christos Exp $");
#endif /* not lint && not SCCSID */
@@ -49,14 +68,8 @@
#include <limits.h>
#include <errno.h>
#include <fcntl.h>
-#ifdef HAVE_VIS_H
#include <vis.h>
-#else
-#include "np/vis.h"
-#endif
-#ifdef HAVE_ALLOCA_H
-#include <alloca.h>
-#endif
+
#include "el.h"
#include "fcns.h" /* for EL_NUM_FCNS */
#include "histedit.h"
@@ -101,11 +114,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)
@@ -211,11 +236,8 @@
/* otherwise, get first entry where first */
/* filename_len characters are equal */
if (entry->d_name[0] == filename[0]
-#if defined(__SVR4) || defined(__linux__)
+ /* Some dirents have d_namlen, but it is not portable. */
&& strlen(entry->d_name) >= filename_len
-#else
- && entry->d_namlen >= filename_len
-#endif
&& strncmp(entry->d_name, filename,
filename_len) == 0)
break;
@@ -223,12 +245,8 @@
if (entry) { /* match found */
-#if defined(__SVR4) || defined(__linux__)
+ /* Some dirents have d_namlen, but it is not portable. */
len = strlen(entry->d_name);
-#else
- len = entry->d_namlen;
-#endif
-
temp = malloc(strlen(dirname) + len + 1);
if (temp == NULL)
return NULL;