summaryrefslogtreecommitdiff
path: root/libiberty/getopt.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@delorie.com>2005-05-24 21:01:33 +0000
committerDJ Delorie <dj@delorie.com>2005-05-24 21:01:33 +0000
commitcf3e417217878eda27dbf11a1fc8051bbe329648 (patch)
treea8edbdff8932f8c03ae76964a3cb541e21da134c /libiberty/getopt.c
parent4bb30907acdef3f90a7cdf602c85dae7c771058b (diff)
downloadbinutils-redhat-cf3e417217878eda27dbf11a1fc8051bbe329648.tar.gz
merge from gcc
Diffstat (limited to 'libiberty/getopt.c')
-rw-r--r--libiberty/getopt.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/libiberty/getopt.c b/libiberty/getopt.c
index d09ce5a66b..0b5c2e8f6a 100644
--- a/libiberty/getopt.c
+++ b/libiberty/getopt.c
@@ -212,8 +212,16 @@ static char *posixly_correct;
/* Avoid depending on library functions or files
whose names are inconsistent. */
-#ifndef getenv
-extern char *getenv ();
+#if HAVE_STDLIB_H && HAVE_DECL_GETENV
+# include <stdlib.h>
+#elif !defined(getenv)
+# ifdef __cplusplus
+extern "C" {
+# endif /* __cplusplus */
+extern char *getenv (const char *);
+# ifdef __cplusplus
+}
+# endif /* __cplusplus */
#endif
static char *
@@ -325,7 +333,7 @@ exchange (char **argv)
{
/* We must extend the array. The user plays games with us and
presents new arguments. */
- char *new_str = malloc (top + 1);
+ char *new_str = (char *) malloc (top + 1);
if (new_str == NULL)
nonoption_flags_len = nonoption_flags_max_len = 0;
else