From 1054071bd60937ae8a9fbc16c1407211c6198a55 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Wed, 23 Feb 2000 15:18:43 +0000 Subject: zsh-workers/9839 --- Src/Modules/mapfile.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) (limited to 'Src/Modules/mapfile.c') diff --git a/Src/Modules/mapfile.c b/Src/Modules/mapfile.c index 5bbc17eca..52c57a75c 100644 --- a/Src/Modules/mapfile.c +++ b/Src/Modules/mapfile.c @@ -248,7 +248,7 @@ get_contents(char *fname) val = NULL; if ((fd = open(fname, O_RDONLY | O_NOCTTY)) >= 0) { LinkList ll; - MUSTUSEHEAP("mapfile:get_contents"); + if ((ll = readoutput(fd, 1))) val = peekfirst(ll); } @@ -264,30 +264,27 @@ getpmmapfile(HashTable ht, char *name) char *contents; Param pm = NULL; - HEAPALLOC { - pm = (Param) zhalloc(sizeof(struct param)); - pm->nam = dupstring(name); - pm->flags = PM_SCALAR; - pm->sets.cfn = setpmmapfile; - pm->gets.cfn = strgetfn; - pm->unsetfn = unsetpmmapfile; - pm->ct = 0; - pm->env = NULL; - pm->ename = NULL; - pm->old = NULL; - pm->level = 0; - - pm->flags |= (mapfile_pm->flags & PM_READONLY); - - /* Set u.str to contents of file given by name */ - if ((contents = get_contents(pm->nam))) - pm->u.str = contents; - else { - pm->u.str = ""; - pm->flags |= PM_UNSET; - } - } LASTALLOC; - + pm = (Param) zhalloc(sizeof(struct param)); + pm->nam = dupstring(name); + pm->flags = PM_SCALAR; + pm->sets.cfn = setpmmapfile; + pm->gets.cfn = strgetfn; + pm->unsetfn = unsetpmmapfile; + pm->ct = 0; + pm->env = NULL; + pm->ename = NULL; + pm->old = NULL; + pm->level = 0; + + pm->flags |= (mapfile_pm->flags & PM_READONLY); + + /* Set u.str to contents of file given by name */ + if ((contents = get_contents(pm->nam))) + pm->u.str = contents; + else { + pm->u.str = ""; + pm->flags |= PM_UNSET; + } return (HashNode) pm; } -- cgit 1.4.1