X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=readline%2Fshell.c;h=346f8113d43d742191f34f431d55e94316e4431d;hb=26bb3ddd506a68a8315a4d4215aaff52260fdf95;hp=35b1c1d6ea96835f758f9035fa9495bb8a8f75d0;hpb=430b783269262185201724109a07d3e9a937bca3;p=deliverable%2Fbinutils-gdb.git diff --git a/readline/shell.c b/readline/shell.c index 35b1c1d6ea..346f8113d4 100644 --- a/readline/shell.c +++ b/readline/shell.c @@ -27,7 +27,6 @@ #endif #include -#include #if defined (HAVE_UNISTD_H) # include @@ -49,8 +48,10 @@ # include #endif +#if defined (HAVE_FCNTL_H) #include -#ifdef HAVE_PWD_H +#endif +#if defined (HAVE_PWD_H) #include #endif @@ -60,9 +61,9 @@ #include "rlshell.h" #include "xmalloc.h" -#if !defined (HAVE_GETPW_DECLS) +#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS) extern struct passwd *getpwuid PARAMS((uid_t)); -#endif /* !HAVE_GETPW_DECLS */ +#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */ #ifndef NULL # define NULL 0 @@ -125,23 +126,27 @@ sh_set_lines_and_columns (lines, cols) { char *b; -#if defined (HAVE_PUTENV) - b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1); - sprintf (b, "LINES=%d", lines); - putenv (b); - b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1); - sprintf (b, "COLUMNS=%d", cols); - putenv (b); -#else /* !HAVE_PUTENV */ -# if defined (HAVE_SETENV) +#if defined (HAVE_SETENV) b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1); sprintf (b, "%d", lines); setenv ("LINES", b, 1); + free (b); + b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1); sprintf (b, "%d", cols); setenv ("COLUMNS", b, 1); -# endif /* HAVE_SETENV */ -#endif /* !HAVE_PUTENV */ + free (b); +#else /* !HAVE_SETENV */ +# if defined (HAVE_PUTENV) + b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1); + sprintf (b, "LINES=%d", lines); + putenv (b); + + b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1); + sprintf (b, "COLUMNS=%d", cols); + putenv (b); +# endif /* HAVE_PUTENV */ +#endif /* !HAVE_SETENV */ } char * @@ -158,7 +163,7 @@ sh_get_home_dir () struct passwd *entry; home_dir = (char *)NULL; -#ifdef HAVE_GETPWUID +#if defined (HAVE_GETPWUID) entry = getpwuid (getuid ()); if (entry) home_dir = entry->pw_dir; @@ -176,7 +181,7 @@ int sh_unset_nodelay_mode (fd) int fd; { -#ifdef HAVE_FNCTL +#if defined (HAVE_FCNTL) int flags, bflags; if ((flags = fcntl (fd, F_GETFL, 0)) < 0)