summaryrefslogtreecommitdiff
path: root/gnu/lib/libreadline
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1994-12-30 14:39:39 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1994-12-30 14:39:39 +0000
commit7ccdf7da4c0576b7fbc4f4bc8c3db2a6b4de5503 (patch)
treeeee5621af0a02dd71c665103cbf8a73c845a2d8d /gnu/lib/libreadline
parent7658fd20d711001705cde6e1725eed545e58a2ea (diff)
Notes
Diffstat (limited to 'gnu/lib/libreadline')
-rw-r--r--gnu/lib/libreadline/rltty.c8
-rw-r--r--gnu/lib/libreadline/tilde.c21
2 files changed, 12 insertions, 17 deletions
diff --git a/gnu/lib/libreadline/rltty.c b/gnu/lib/libreadline/rltty.c
index a007beb88e29..02c036d05c54 100644
--- a/gnu/lib/libreadline/rltty.c
+++ b/gnu/lib/libreadline/rltty.c
@@ -22,15 +22,15 @@
675 Mass Ave, Cambridge, MA 02139, USA. */
#define READLINE_LIBRARY
+#if defined (HAVE_CONFIG_H)
+# include "config.h"
+#endif
+
#include <sys/types.h>
#include <signal.h>
#include <errno.h>
#include <stdio.h>
-#if defined (HAVE_CONFIG_H)
-# include "config.h"
-#endif
-
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
diff --git a/gnu/lib/libreadline/tilde.c b/gnu/lib/libreadline/tilde.c
index 84c24b745c51..da75d957863d 100644
--- a/gnu/lib/libreadline/tilde.c
+++ b/gnu/lib/libreadline/tilde.c
@@ -250,22 +250,16 @@ tilde_expand_word (filename)
}
else
{
- char u_name[257];
- struct passwd *user_entry;
char *username;
- int i, c;
+ struct passwd *user_entry;
+ int i;
- username = u_name;
- for (i = 1; c = dirname[i]; i++)
- {
- if (c == '/')
- break;
- else
- username[i - 1] = c;
- }
+ username = xmalloc (strlen (dirname));
+ for (i = 1; dirname[i] && dirname[i] != '/'; i++)
+ username[i - 1] = dirname[i];
username[i - 1] = '\0';
- if (!(user_entry = getpwnam (username)))
+ if ((user_entry = getpwnam (username)) == 0)
{
/* If the calling program has a special syntax for
expanding tildes, and we couldn't find a standard
@@ -298,7 +292,8 @@ tilde_expand_word (filename)
free (dirname);
dirname = temp_name;
}
- endpwent ();
+ endpwent ();
+ free (username);
}
}
return (dirname);