aboutsummaryrefslogtreecommitdiff
path: root/posix/glob.c
diff options
context:
space:
mode:
Diffstat (limited to 'posix/glob.c')
-rw-r--r--posix/glob.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/posix/glob.c b/posix/glob.c
index 6d9af10..6a82fe0 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -37,6 +37,8 @@
/* #define NDEBUG 1 */
#include <assert.h>
+#include <stdio.h> /* Needed on stupid SunOS for assert. */
+
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
@@ -69,7 +71,7 @@
#endif
#endif
-#if !defined (_AMIGA) && !defined (VMS) && !defined(WIN32)
+#if !defined (_AMIGA) && !defined (VMS) && !defined(WINDOWS32)
#include <pwd.h>
#endif
@@ -113,7 +115,7 @@ extern int errno;
#endif
-#if (defined (POSIX) || defined (WIN32)) && !defined (__GNU_LIBRARY__)
+#if (defined (POSIX) || defined (WINDOWS32)) && !defined (__GNU_LIBRARY__)
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
#define REAL_DIR_ENTRY(dp) 1
@@ -173,7 +175,7 @@ extern void bcopy ();
__inline
#endif
#ifndef __SASC
-#ifdef WIN32
+#ifdef WINDOWS32
static void *
#else
static char *
@@ -203,11 +205,11 @@ my_realloc (p, n)
#include <alloca.h>
#else /* Not HAVE_ALLOCA_H. */
#ifndef _AIX
-#ifdef WIN32
+#ifdef WINDOWS32
#include <malloc.h>
#else
extern char *alloca ();
-#endif /* WIN32 */
+#endif /* WINDOWS32 */
#endif /* Not _AIX. */
#endif /* sparc or HAVE_ALLOCA_H. */
#endif /* GCC. */
@@ -265,7 +267,8 @@ static
inline
#endif
const char *
-next_brace_sub (const char *begin)
+next_brace_sub (begin)
+ const char *begin;
{
unsigned int depth = 0;
const char *cp = begin;
@@ -504,17 +507,15 @@ glob (pattern, flags, errfunc, pglob)
if (home_dir == NULL || home_dir[0] == '\0')
home_dir = "SYS:";
#else
-#ifdef WIN32
+#ifdef WINDOWS32
if (home_dir == NULL || home_dir[0] == '\0')
home_dir = "c:/users/default"; /* poor default */
#else
if (home_dir == NULL || home_dir[0] == '\0')
{
- extern char *getlogin __P ((void));
- extern int getlogin_r __P ((char *, size_t));
int success;
-
#if defined HAVE_GETLOGIN_R || defined _LIBC
+ extern int getlogin_r __P ((char *, size_t));
size_t buflen = sysconf (_SC_LOGIN_NAME_MAX) + 1;
char *name;
@@ -522,11 +523,13 @@ glob (pattern, flags, errfunc, pglob)
/* `sysconf' does not support _SC_LOGIN_NAME_MAX. Try
a moderate value. */
buflen = 16;
- name = __alloca (buflen);
+ name = (char *) __alloca (buflen);
success = getlogin_r (name, buflen) >= 0;
#else
+ extern char *getlogin __P ((void));
char *name;
+
success = (name = getlogin ()) != NULL;
#endif
if (success)
@@ -536,7 +539,7 @@ glob (pattern, flags, errfunc, pglob)
char *pwtmpbuf;
struct passwd pwbuf, *p;
- pwtmpbuf = __alloca (pwbuflen);
+ pwtmpbuf = (char *) __alloca (pwbuflen);
success = (__getpwnam_r (name, &pwbuf, pwtmpbuf,
pwbuflen, &p) >= 0);
@@ -550,7 +553,7 @@ glob (pattern, flags, errfunc, pglob)
}
if (home_dir == NULL || home_dir[0] == '\0')
home_dir = (char *) "~"; /* No luck. */
-#endif /* WIN32 */
+#endif /* WINDOWS32 */
#endif
/* Now construct the full directory. */
if (dirname[1] == '\0')
@@ -559,13 +562,13 @@ glob (pattern, flags, errfunc, pglob)
{
char *newp;
size_t home_len = strlen (home_dir);
- newp = __alloca (home_len + dirlen);
+ newp = (char *) __alloca (home_len + dirlen);
memcpy (newp, home_dir, home_len);
memcpy (&newp[home_len], &dirname[1], dirlen);
dirname = newp;
}
}
-#if !defined _AMIGA && !defined WIN32
+#if !defined _AMIGA && !defined WINDOWS32
else
{
char *end_name = strchr (dirname, '/');
@@ -576,7 +579,7 @@ glob (pattern, flags, errfunc, pglob)
user_name = dirname + 1;
else
{
- user_name = __alloca (end_name - dirname);
+ user_name = (char *) __alloca (end_name - dirname);
memcpy (user_name, dirname + 1, end_name - dirname);
user_name[end_name - dirname - 1] = '\0';
}
@@ -585,7 +588,7 @@ glob (pattern, flags, errfunc, pglob)
{
#if defined HAVE_GETPWNAM_R || defined _LIBC
size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
- char *pwtmpbuf = __alloca (buflen);
+ char *pwtmpbuf = (char *) __alloca (buflen);
struct passwd pwbuf, *p;
if (__getpwnam_r (user_name, &pwbuf, pwtmpbuf, buflen, &p) >= 0)
home_dir = p->pw_dir;
@@ -605,14 +608,14 @@ glob (pattern, flags, errfunc, pglob)
char *newp;
size_t home_len = strlen (home_dir);
size_t rest_len = end_name == NULL ? 0 : strlen (end_name);
- newp = __alloca (home_len + rest_len + 1);
+ newp = (char *) __alloca (home_len + rest_len + 1);
memcpy (newp, home_dir, home_len);
memcpy (&newp[home_len], end_name, rest_len);
newp[home_len + rest_len] = '\0';
dirname = newp;
}
}
-#endif /* Not Amiga && not Win32. */
+#endif /* Not Amiga && not WINDOWS32. */
}
#endif /* Not VMS. */