aboutsummaryrefslogtreecommitdiff
path: root/readline/shell.c
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2015-07-25 15:41:05 -0400
committerPatrick Palka <patrick@parcs.ath.cx>2015-07-25 15:57:00 -0400
commit5836a818eccb180d75c92ce4c861abb6fe8dec23 (patch)
tree624044ca5df5a6c192e47933a735ab4fe9aaea71 /readline/shell.c
parentb8cc7b2e9afab37eb9a7cff0d3ae4ebbcf7d494f (diff)
downloadfsf-binutils-gdb-5836a818eccb180d75c92ce4c861abb6fe8dec23.zip
fsf-binutils-gdb-5836a818eccb180d75c92ce4c861abb6fe8dec23.tar.gz
fsf-binutils-gdb-5836a818eccb180d75c92ce4c861abb6fe8dec23.tar.bz2
Revert "Sync readline/ to version 7.0 alpha"
This reverts commit b558ff043d41ba8d17a82f5f9ae5f9dade66160e. This reverts commit 4a11f2065906976675808364ddbd1c0f77eea41f. The initial import commit failed to retain local changes made to readline's configure.in (and the commit message erroneously stated that there were no local changes that needed to be reapplied). Also the import caused a couple of build errors and a scattering of testsuite regressions throughout many arches. It's probably better to start over with this import, hopefully more carefully next time.
Diffstat (limited to 'readline/shell.c')
-rw-r--r--readline/shell.c48
1 files changed, 19 insertions, 29 deletions
diff --git a/readline/shell.c b/readline/shell.c
index 6947295..ac0fb36 100644
--- a/readline/shell.c
+++ b/readline/shell.c
@@ -59,8 +59,6 @@
#include "rlstdc.h"
#include "rlshell.h"
-#include "rldefs.h"
-
#include "xmalloc.h"
#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS)
@@ -122,27 +120,31 @@ sh_single_quote (string)
/* Set the environment variables LINES and COLUMNS to lines and cols,
respectively. */
-static char setenv_buf[INT_STRLEN_BOUND (int) + 1];
-static char putenv_buf1[INT_STRLEN_BOUND (int) + 6 + 1]; /* sizeof("LINES=") == 6 */
-static char putenv_buf2[INT_STRLEN_BOUND (int) + 8 + 1]; /* sizeof("COLUMNS=") == 8 */
-
void
sh_set_lines_and_columns (lines, cols)
int lines, cols;
{
-#if defined (HAVE_SETENV)
- sprintf (setenv_buf, "%d", lines);
- setenv ("LINES", setenv_buf, 1);
+ char *b;
- sprintf (setenv_buf, "%d", cols);
- setenv ("COLUMNS", setenv_buf, 1);
+#if defined (HAVE_SETENV)
+ b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
+ sprintf (b, "%d", lines);
+ setenv ("LINES", b, 1);
+ xfree (b);
+
+ b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
+ sprintf (b, "%d", cols);
+ setenv ("COLUMNS", b, 1);
+ xfree (b);
#else /* !HAVE_SETENV */
# if defined (HAVE_PUTENV)
- sprintf (putenv_buf1, "LINES=%d", lines);
- putenv (putenv_buf1);
+ b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
+ sprintf (b, "LINES=%d", lines);
+ putenv (b);
- sprintf (putenv_buf2, "COLUMNS=%d", cols);
- putenv (putenv_buf2);
+ b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
+ sprintf (b, "COLUMNS=%d", cols);
+ putenv (b);
# endif /* HAVE_PUTENV */
#endif /* !HAVE_SETENV */
}
@@ -157,27 +159,15 @@ sh_get_env_value (varname)
char *
sh_get_home_dir ()
{
- static char *home_dir = (char *)NULL;
+ char *home_dir;
struct passwd *entry;
- if (home_dir)
- return (home_dir);
-
home_dir = (char *)NULL;
#if defined (HAVE_GETPWUID)
-# if defined (__TANDEM)
- entry = getpwnam (getlogin ());
-# else
entry = getpwuid (getuid ());
-# endif
if (entry)
- home_dir = savestring (entry->pw_dir);
-#endif
-
-#if defined (HAVE_GETPWENT)
- endpwent (); /* some systems need this */
+ home_dir = entry->pw_dir;
#endif
-
return (home_dir);
}