Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libedit use getpwent_r



details:   https://anonhg.NetBSD.org/src/rev/d79a8e8e65ab
branches:  trunk
changeset: 579953:d79a8e8e65ab
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 02 06:28:10 2005 +0000

description:
use getpwent_r

diffstat:

 lib/libedit/readline.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r aef90e7af217 -r d79a8e8e65ab lib/libedit/readline.c
--- a/lib/libedit/readline.c    Sat Apr 02 06:15:09 2005 +0000
+++ b/lib/libedit/readline.c    Sat Apr 02 06:28:10 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.c,v 1.49 2005/03/10 19:34:46 christos Exp $   */
+/*     $NetBSD: readline.c,v 1.50 2005/04/02 06:28:10 christos Exp $   */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.49 2005/03/10 19:34:46 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.50 2005/04/02 06:28:10 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -1550,7 +1550,8 @@
 char *
 username_completion_function(const char *text, int state)
 {
-       struct passwd *pwd;
+       struct passwd *pwd, pwres;
+       char pwbuf[1024];
 
        if (text[0] == '\0')
                return (NULL);
@@ -1561,7 +1562,8 @@
        if (state == 0)
                setpwent();
 
-       while ((pwd = getpwent()) && text[0] == pwd->pw_name[0]
+       while (getpwent_r(&pwres, pwbuf, sizeof(pwbuf), &pwd) == 0
+           && text[0] == pwd->pw_name[0]
            && strcmp(text, pwd->pw_name) == 0);
 
        if (pwd == NULL) {



Home | Main Index | Thread Index | Old Index