diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-03-02 06:23:57 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-03-02 06:23:57 +0000 |
commit | e52ae7d7cb3b9267a450ee786b056b14391f2f50 (patch) | |
tree | 852bbb003a1438d75ce8016c9feef856d56fd2fd /lib/libcurses/tinfo/comp_parse.c | |
parent | aedffcef562be3c46e9a21641c0a65c968b1d889 (diff) |
ncurses-4.2-990301
Diffstat (limited to 'lib/libcurses/tinfo/comp_parse.c')
-rw-r--r-- | lib/libcurses/tinfo/comp_parse.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/libcurses/tinfo/comp_parse.c b/lib/libcurses/tinfo/comp_parse.c index 954f8e10d37..b5cb6716e83 100644 --- a/lib/libcurses/tinfo/comp_parse.c +++ b/lib/libcurses/tinfo/comp_parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: comp_parse.c,v 1.2 1999/02/24 06:31:10 millert Exp $ */ +/* $OpenBSD: comp_parse.c,v 1.3 1999/03/02 06:23:28 millert Exp $ */ /**************************************************************************** * Copyright (c) 1998 Free Software Foundation, Inc. * @@ -54,10 +54,9 @@ #include <ctype.h> #include <tic.h> -#include <term.h> #include <term_entry.h> -MODULE_ID("$From: comp_parse.c,v 1.26 1999/02/19 10:38:13 tom Exp $") +MODULE_ID("$From: comp_parse.c,v 1.34 1999/02/27 22:13:02 tom Exp $") static void sanity_check(TERMTYPE *); void (*_nc_check_termtype)(TERMTYPE *) = sanity_check; @@ -88,13 +87,11 @@ ENTRY *_nc_head, *_nc_tail; static void enqueue(ENTRY *ep) /* add an entry to the in-core list */ { - ENTRY *newp = (ENTRY *)malloc(sizeof(ENTRY)); + ENTRY *newp = _nc_copy_entry(ep); if (newp == NULL) _nc_err_abort("Out of memory"); - (void) memcpy(newp, ep, sizeof(ENTRY)); - newp->last = _nc_tail; _nc_tail = newp; @@ -178,6 +175,7 @@ void _nc_read_entry_source(FILE *fp, char *buf, if (silent) _nc_suppress_warnings = TRUE; /* shut the lexer up, too */ + memset(&thisentry, 0, sizeof(thisentry)); for (_nc_reset_input(fp, buf); _nc_parse_entry(&thisentry, literal, silent) != ERR; ) { if (!isalnum(thisentry.tterm.term_names[0])) @@ -289,15 +287,16 @@ int _nc_resolve_uses(void) TERMTYPE thisterm; char filename[PATH_MAX]; + memset(&thisterm, 0, sizeof(thisterm)); if (_nc_read_entry(lookfor, filename, &thisterm) == 1) { DEBUG(2, ("%s: resolving use=%s (compiled)", child, lookfor)); - rp = (ENTRY *)malloc(sizeof(ENTRY)); + rp = typeMalloc(ENTRY,1); if (rp == NULL) _nc_err_abort("Out of memory"); - memcpy(&rp->tterm, &thisterm, sizeof(TERMTYPE)); + rp->tterm = thisterm; rp->nuses = 0; rp->next = lastread; lastread = rp; @@ -338,6 +337,7 @@ int _nc_resolve_uses(void) keepgoing = FALSE; for_entry_list(qp) + { if (qp->nuses > 0) { DEBUG(2, ("%s: attempting merge", _nc_first_name(qp->tterm.term_names))); @@ -359,7 +359,7 @@ int _nc_resolve_uses(void) * as a side effect, copy into the merged entry the name * field and string table pointer. */ - memcpy(&merged, &qp->tterm, sizeof(TERMTYPE)); + _nc_copy_termtype(&merged, &(qp->tterm)); /* * Now merge in each use entry in the proper @@ -377,7 +377,10 @@ int _nc_resolve_uses(void) /* * Replace the original entry with the merged one. */ - memcpy(&qp->tterm, &merged, sizeof(TERMTYPE)); + FreeIfNeeded(qp->tterm.Booleans); + FreeIfNeeded(qp->tterm.Numbers); + FreeIfNeeded(qp->tterm.Strings); + qp->tterm = merged; /* * We know every entry is resolvable because name resolution @@ -387,6 +390,7 @@ int _nc_resolve_uses(void) incomplete: keepgoing = TRUE; } + } } while (keepgoing); @@ -399,13 +403,13 @@ int _nc_resolve_uses(void) */ for_entry_list(qp) { - for (j = 0; j < BOOLCOUNT; j++) + for_each_boolean(j, &(qp->tterm)) if (qp->tterm.Booleans[j] == CANCELLED_BOOLEAN) qp->tterm.Booleans[j] = FALSE; - for (j = 0; j < NUMCOUNT; j++) + for_each_number(j, &(qp->tterm)) if (qp->tterm.Numbers[j] == CANCELLED_NUMERIC) qp->tterm.Numbers[j] = ABSENT_NUMERIC; - for (j = 0; j < STRCOUNT; j++) + for_each_string(j, &(qp->tterm)) if (qp->tterm.Strings[j] == CANCELLED_STRING) qp->tterm.Strings[j] = ABSENT_STRING; } |