diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 2000-02-23 15:18:43 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 2000-02-23 15:18:43 +0000 |
commit | 1054071bd60937ae8a9fbc16c1407211c6198a55 (patch) | |
tree | d91747424173fe809ec204864df49009874b6282 /Src/Modules/mapfile.c | |
parent | 2b37049c221501c6ae77e0308634aebcdb10060d (diff) | |
download | zsh-1054071bd60937ae8a9fbc16c1407211c6198a55.tar.gz zsh-1054071bd60937ae8a9fbc16c1407211c6198a55.tar.xz zsh-1054071bd60937ae8a9fbc16c1407211c6198a55.zip |
zsh-workers/9839
Diffstat (limited to 'Src/Modules/mapfile.c')
-rw-r--r-- | Src/Modules/mapfile.c | 47 |
1 files changed, 22 insertions, 25 deletions
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; } |