forked from Mirrors/freeswitch
c5c13c2668
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5044 d0543943-73ff-0310-b7d9-9358b9ac24b2
99 lines
2.4 KiB
Diff
99 lines
2.4 KiB
Diff
--- export/src/filecomplete.c 2007-03-02 22:26:59.000000000 +0100
|
|
+++ ../src/filecomplete.c 2007-03-02 22:38:45.000000000 +0100
|
|
@@ -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;
|