Source-Changes-HG archive

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

[src/trunk]: src/lib/libedit get rid of PATH_MAX.



details:   https://anonhg.NetBSD.org/src/rev/36c7ab27158a
branches:  trunk
changeset: 789623:36c7ab27158a
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Aug 28 08:05:21 2013 +0000

description:
get rid of PATH_MAX.

diffstat:

 lib/libedit/readline.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (42 lines):

diff -r a9060fa1348a -r 36c7ab27158a lib/libedit/readline.c
--- a/lib/libedit/readline.c    Wed Aug 28 07:34:13 2013 +0000
+++ b/lib/libedit/readline.c    Wed Aug 28 08:05:21 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: readline.c,v 1.108 2013/05/28 00:10:34 christos Exp $  */
+/*     $NetBSD: readline.c,v 1.109 2013/08/28 08:05:21 christos Exp $  */
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include "config.h"
 #if !defined(lint) && !defined(SCCSID)
-__RCSID("$NetBSD: readline.c,v 1.108 2013/05/28 00:10:34 christos Exp $");
+__RCSID("$NetBSD: readline.c,v 1.109 2013/08/28 08:05:21 christos Exp $");
 #endif /* not lint && not SCCSID */
 
 #include <sys/types.h>
@@ -236,13 +236,20 @@
 _default_history_file(void)
 {
        struct passwd *p;
-       static char path[PATH_MAX];
+       static char *path;
+       size_t len;
 
-       if (*path)
+       if (path)
                return path;
+
        if ((p = getpwuid(getuid())) == NULL)
                return NULL;
-       (void)snprintf(path, sizeof(path), "%s/.history", p->pw_dir);
+
+       len = strlen(p->pw_dir) + sizeof("/.history");
+       if ((path = malloc(len)) == NULL)
+               return NULL;
+
+       (void)snprintf(path, len, "%s/.history", p->pw_dir);
        return path;
 }
 



Home | Main Index | Thread Index | Old Index