Module Name: src Committed By: christos Date: Fri Mar 27 15:11:57 UTC 2020
Modified Files: src/distrib/sets/lists/base: mi src/lib/libterminfo: compile.c term.c term_private.h tparm.c src/share/terminfo: Makefile src/usr.bin/tic: tic.c Log Message: As described in tech-userlevel: - Modify the writing code to only write entries in the new format for the terminal descriptions that require it. - Store new format entries as <name>@v3 - Store old format entries with clamped values as <name> for backwards compatibility - Lookup first <name>@v3 and then <name> if that is not found. - Don't create terminfo2 anymore; old programs keep working with clamped entries, and new programs be able to use the wide fields with using the original db file. To generate a diff of this commit: cvs rdiff -u -r1.1233 -r1.1234 src/distrib/sets/lists/base/mi cvs rdiff -u -r1.14 -r1.15 src/lib/libterminfo/compile.c cvs rdiff -u -r1.30 -r1.31 src/lib/libterminfo/term.c cvs rdiff -u -r1.12 -r1.13 src/lib/libterminfo/term_private.h cvs rdiff -u -r1.17 -r1.18 src/lib/libterminfo/tparm.c cvs rdiff -u -r1.4 -r1.5 src/share/terminfo/Makefile cvs rdiff -u -r1.32 -r1.33 src/usr.bin/tic/tic.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/base/mi diff -u src/distrib/sets/lists/base/mi:1.1233 src/distrib/sets/lists/base/mi:1.1234 --- src/distrib/sets/lists/base/mi:1.1233 Sun Mar 22 16:21:53 2020 +++ src/distrib/sets/lists/base/mi Fri Mar 27 11:11:57 2020 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1233 2020/03/22 20:21:53 thorpej Exp $ +# $NetBSD: mi,v 1.1234 2020/03/27 15:11:57 christos Exp $ # # Note: Don't delete entries from here - mark them as "obsolete" instead, # unless otherwise stated below. @@ -4841,7 +4841,8 @@ ./usr/share/misc/more.help base-obsolete obsolete ./usr/share/misc/nslookup.help base-obsolete obsolete ./usr/share/misc/terminfo base-terminfo-share share -./usr/share/misc/terminfo2.cdb base-terminfo-share share +./usr/share/misc/terminfo.cdb base-terminfo-share share +./usr/share/misc/terminfo2.cdb base-obsolete obsolete ./usr/share/misc/units.lib base-reference-share share ./usr/share/misc/usb_hid_usages base-reference-share share ./usr/share/misc/vgrindefs.db base-groff-share share Index: src/lib/libterminfo/compile.c diff -u src/lib/libterminfo/compile.c:1.14 src/lib/libterminfo/compile.c:1.15 --- src/lib/libterminfo/compile.c:1.14 Fri Mar 13 11:19:25 2020 +++ src/lib/libterminfo/compile.c Fri Mar 27 11:11:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: compile.c,v 1.14 2020/03/13 15:19:25 roy Exp $ */ +/* $NetBSD: compile.c,v 1.15 2020/03/27 15:11:57 christos Exp $ */ /* * Copyright (c) 2009, 2010, 2011, 2020 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: compile.c,v 1.14 2020/03/13 15:19:25 roy Exp $"); +__RCSID("$NetBSD: compile.c,v 1.15 2020/03/27 15:11:57 christos Exp $"); #if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H #include <sys/endian.h> @@ -87,7 +87,7 @@ _ti_grow_tbuf(TBUF *tbuf, size_t len) } char * -_ti_find_cap(TBUF *tbuf, char type, short ind) +_ti_find_cap(TIC *tic, TBUF *tbuf, char type, short ind) { size_t n; uint16_t num; @@ -106,7 +106,7 @@ _ti_find_cap(TBUF *tbuf, char type, shor cap++; break; case 'n': - cap += sizeof(uint32_t); + cap += _ti_numsize(tic); break; case 's': num = le16dec(cap); @@ -121,7 +121,7 @@ _ti_find_cap(TBUF *tbuf, char type, shor } char * -_ti_find_extra(TBUF *tbuf, const char *code) +_ti_find_extra(TIC *tic, TBUF *tbuf, const char *code) { size_t n; uint16_t num; @@ -142,7 +142,7 @@ _ti_find_extra(TBUF *tbuf, const char *c cap++; break; case 'n': - cap += sizeof(uint32_t); + cap += _ti_numsize(tic); break; case 's': num = le16dec(cap); @@ -156,16 +156,58 @@ _ti_find_extra(TBUF *tbuf, const char *c return NULL; } +void +_ti_encode_num(TIC *tic, TBUF *rbuf, int num) +{ + if (_ti_numsize(tic) == sizeof(uint16_t)) { + if (num > SHRT_MAX) + num = SHRT_MAX; + le16enc(rbuf->buf + rbuf->bufpos, (uint16_t)num); + } else { + le32enc(rbuf->buf + rbuf->bufpos, (uint32_t)num); + } + rbuf->bufpos += _ti_numsize(tic); +} + +int +_ti_decode_num(int rtype, const char **cap) +{ + int rv; + + if (rtype == TERMINFO_RTYPE_O1) { + rv = (int)le16dec(*cap); + *cap += sizeof(uint16_t); + } else { + rv = (int)le32dec(*cap); + *cap += sizeof(uint32_t); + } + return rv; +} + +char * +_ti_getname(int rtype, const char *orig) +{ + char *name; + + if (rtype == TERMINFO_RTYPE) { + if (asprintf(&name, "%s@v3", orig) < 0) + name = NULL; + } else { + name = strdup(orig); + } + return name; +} + size_t -_ti_store_extra(TIC *tic, int wrn, char *id, char type, char flag, int num, - char *str, size_t strl, int flags) +_ti_store_extra(TIC *tic, int wrn, const char *id, char type, char flag, + int num, const char *str, size_t strl, int flags) { size_t l; _DIAGASSERT(tic != NULL); if (strcmp(id, "use") != 0) { - if (_ti_find_extra(&tic->extras, id) != NULL) + if (_ti_find_extra(tic, &tic->extras, id) != NULL) return 0; if (!(flags & TIC_EXTRA)) { if (wrn != 0) @@ -182,7 +224,7 @@ _ti_store_extra(TIC *tic, int wrn, char } if (!_ti_grow_tbuf(&tic->extras, - l + strl + sizeof(uint16_t) + sizeof(uint32_t) + 1)) + l + strl + sizeof(uint16_t) + _ti_numsize(tic) + 1)) return 0; le16enc(tic->extras.buf + tic->extras.bufpos, (uint16_t)l); tic->extras.bufpos += sizeof(uint16_t); @@ -194,8 +236,7 @@ _ti_store_extra(TIC *tic, int wrn, char tic->extras.buf[tic->extras.bufpos++] = flag; break; case 'n': - le32enc(tic->extras.buf + tic->extras.bufpos, (uint32_t)num); - tic->extras.bufpos += sizeof(uint32_t); + _ti_encode_num(tic, &tic->extras, num); break; case 's': le16enc(tic->extras.buf + tic->extras.bufpos, (uint16_t)strl); @@ -239,7 +280,7 @@ _ti_flatten(uint8_t **buf, const TIC *ti return -1; cap = *buf; - *cap++ = TERMINFO_RTYPE; /* Record type 3 */ + *cap++ = tic->rtype; le16enc(cap, (uint16_t)len); cap += sizeof(uint16_t); memcpy(cap, tic->name, len); @@ -451,6 +492,17 @@ _ti_get_token(char **cap, char sep) return token; } +static int +_ti_find_rtype(const char *cap) +{ + for (const char *ptr = cap; (ptr = strchr(ptr, '#')) != NULL;) { + if (strtol(++ptr, NULL, 0) > SHRT_MAX) { + return TERMINFO_RTYPE; + } + } + return TERMINFO_RTYPE_O1; +} + TIC * _ti_compile(char *cap, int flags) { @@ -467,7 +519,7 @@ _ti_compile(char *cap, int flags) name = _ti_get_token(&cap, ','); if (name == NULL) { - dowarn(flags, "no seperator found: %s", cap); + dowarn(flags, "no separator found: %s", cap); return NULL; } desc = strrchr(name, '|'); @@ -494,14 +546,16 @@ _ti_compile(char *cap, int flags) if (tic == NULL) return NULL; + tic->rtype = (flags & TIC_COMPAT_V1) ? TERMINFO_RTYPE_O1 : + _ti_find_rtype(cap); buf.buf = NULL; buf.buflen = 0; - tic->name = strdup(name); + tic->name = _ti_getname(tic->rtype, name); if (tic->name == NULL) goto error; if (alias != NULL && flags & TIC_ALIAS) { - tic->alias = strdup(alias); + tic->alias = _ti_getname(tic->rtype, alias); if (tic->alias == NULL) goto error; } @@ -533,7 +587,7 @@ _ti_compile(char *cap, int flags) /* Don't use the string if we already have it */ ind = (short)_ti_strindex(token); if (ind != -1 && - _ti_find_cap(&tic->strs, 's', ind) != NULL) + _ti_find_cap(tic, &tic->strs, 's', ind) != NULL) continue; /* Encode the string to our scratch buffer */ @@ -579,7 +633,7 @@ _ti_compile(char *cap, int flags) /* Don't use the number if we already have it */ ind = (short)_ti_numindex(token); if (ind != -1 && - _ti_find_cap(&tic->nums, 'n', ind) != NULL) + _ti_find_cap(tic, &tic->nums, 'n', ind) != NULL) continue; cnum = strtol(p, &e, 0); @@ -600,14 +654,12 @@ _ti_compile(char *cap, int flags) num, NULL, 0, flags); else { if (_ti_grow_tbuf(&tic->nums, - sizeof(uint16_t) + sizeof(uint32_t))==NULL) + sizeof(uint16_t) + _ti_numsize(tic))==NULL) goto error; le16enc(tic->nums.buf + tic->nums.bufpos, (uint16_t)ind); tic->nums.bufpos += sizeof(uint16_t); - le32enc(tic->nums.buf + tic->nums.bufpos, - (uint32_t)num); - tic->nums.bufpos += sizeof(uint32_t); + _ti_encode_num(tic, &tic->nums, num); tic->nums.entries++; } continue; @@ -622,21 +674,22 @@ _ti_compile(char *cap, int flags) ind = (short)_ti_flagindex(token); if (ind == -1 && flag == CANCELLED_BOOLEAN) { if ((ind = (short)_ti_numindex(token)) != -1) { - if (_ti_find_cap(&tic->nums, 'n', ind) != NULL) + if (_ti_find_cap(tic, &tic->nums, 'n', ind) + != NULL) continue; - if (_ti_grow_tbuf(&tic->nums, - sizeof(uint16_t) * 2) == NULL) + if (_ti_grow_tbuf(&tic->nums, sizeof(uint16_t) + + _ti_numsize(tic)) == NULL) goto error; le16enc(tic->nums.buf + tic->nums.bufpos, (uint16_t)ind); tic->nums.bufpos += sizeof(uint16_t); - le32enc(tic->nums.buf + tic->nums.bufpos, - (uint32_t)CANCELLED_NUMERIC); - tic->nums.bufpos += sizeof(uint32_t); + _ti_encode_num(tic, &tic->nums, + CANCELLED_NUMERIC); tic->nums.entries++; continue; } else if ((ind = (short)_ti_strindex(token)) != -1) { - if (_ti_find_cap(&tic->strs, 's', ind) != NULL) + if (_ti_find_cap(tic, &tic->strs, 's', ind) + != NULL) continue; if (_ti_grow_tbuf(&tic->strs, (sizeof(uint16_t) * 2) + 1) == NULL) @@ -652,7 +705,7 @@ _ti_compile(char *cap, int flags) if (ind == -1) _ti_store_extra(tic, 1, token, 'f', flag, 0, NULL, 0, flags); - else if (_ti_find_cap(&tic->flags, 'f', ind) == NULL) { + else if (_ti_find_cap(tic, &tic->flags, 'f', ind) == NULL) { if (_ti_grow_tbuf(&tic->flags, sizeof(uint16_t) + 1) == NULL) goto error; Index: src/lib/libterminfo/term.c diff -u src/lib/libterminfo/term.c:1.30 src/lib/libterminfo/term.c:1.31 --- src/lib/libterminfo/term.c:1.30 Fri Mar 13 11:19:25 2020 +++ src/lib/libterminfo/term.c Fri Mar 27 11:11:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: term.c,v 1.30 2020/03/13 15:19:25 roy Exp $ */ +/* $NetBSD: term.c,v 1.31 2020/03/27 15:11:57 christos Exp $ */ /* * Copyright (c) 2009, 2010, 2011, 2020 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: term.c,v 1.30 2020/03/13 15:19:25 roy Exp $"); +__RCSID("$NetBSD: term.c,v 1.31 2020/03/27 15:11:57 christos Exp $"); #include <sys/stat.h> @@ -48,7 +48,7 @@ __RCSID("$NetBSD: term.c,v 1.30 2020/03/ * Although we can read v1 structure (which includes v2 alias records) * we really want a v3 structure to get numerics of type int rather than short. */ -#define _PATH_TERMINFO "/usr/share/misc/terminfo2:/usr/share/misc/terminfo" +#define _PATH_TERMINFO "/usr/share/misc/terminfo" static char __ti_database[PATH_MAX]; const char *_ti_database; @@ -150,13 +150,7 @@ _ti_readterm(TERMINAL *term, const char for (; num != 0; num--) { ind = le16dec(cap); cap += sizeof(uint16_t); - if (rtype == TERMINFO_RTYPE_O1) { - term->nums[ind] = (int)le16dec(cap); - cap += sizeof(uint16_t); - } else { - term->nums[ind] = (int)le32dec(cap); - cap += sizeof(uint32_t); - } + term->nums[ind] = _ti_decode_num(rtype, &cap); if (flags == 0 && !VALID_NUMERIC(term->nums[ind])) term->nums[ind] = ABSENT_NUMERIC; } @@ -213,13 +207,7 @@ _ti_readterm(TERMINAL *term, const char break; case 'n': ud->flag = ABSENT_BOOLEAN; - if (rtype == TERMINFO_RTYPE_O1) { - ud->num = (int)le16dec(cap); - cap += sizeof(uint16_t); - } else { - ud->num = (int)le32dec(cap); - cap += sizeof(uint32_t); - } + ud->num = _ti_decode_num(rtype, &cap); if (flags == 0 && !VALID_NUMERIC(ud->num)) ud->num = ABSENT_NUMERIC; @@ -323,7 +311,7 @@ _ti_dbgetterm(TERMINAL *term, const char goto out; /* If the entry is an alias, load the indexed terminfo description. */ - if (data8[0] == 2) { + if (data8[0] == TERMINFO_ALIAS) { if (cdbr_get(db, le32dec(data8 + 1), &data, &len)) goto out; data8 = data; @@ -453,6 +441,15 @@ _ti_getterm(TERMINAL *term, const char * int r; size_t i; const struct compiled_term *t; + char *namev3; + + namev3 = _ti_getname(TERMINFO_RTYPE, name); + if (namev3 != NULL) { + r = _ti_findterm(term, namev3, flags); + free(namev3); + if (r == 1) + return r; + } r = _ti_findterm(term, name, flags); if (r == 1) Index: src/lib/libterminfo/term_private.h diff -u src/lib/libterminfo/term_private.h:1.12 src/lib/libterminfo/term_private.h:1.13 --- src/lib/libterminfo/term_private.h:1.12 Fri Mar 13 11:19:25 2020 +++ src/lib/libterminfo/term_private.h Fri Mar 27 11:11:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: term_private.h,v 1.12 2020/03/13 15:19:25 roy Exp $ */ +/* $NetBSD: term_private.h,v 1.13 2020/03/27 15:11:57 christos Exp $ */ /* * Copyright (c) 2009, 2010, 2013, 2020 The NetBSD Foundation, Inc. @@ -140,6 +140,7 @@ void _ti_setospeed(TERMINAL *); #define TIC_ALIAS (1 << 2) #define TIC_COMMENT (1 << 3) #define TIC_EXTRA (1 << 4) +#define TIC_COMPAT_V1 (1 << 5) #define UINT16_T_MAX 0xffff @@ -154,18 +155,25 @@ typedef struct { char *name; char *alias; char *desc; + int rtype; TBUF flags; TBUF nums; TBUF strs; TBUF extras; } TIC; +#define _ti_numsize(tic) \ + ((tic)->rtype == TERMINFO_RTYPE_O1 ? sizeof(uint16_t) : sizeof(uint32_t)) + char *_ti_grow_tbuf(TBUF *, size_t); char *_ti_get_token(char **, char); -char *_ti_find_cap(TBUF *, char, short); -char *_ti_find_extra(TBUF *, const char *); -size_t _ti_store_extra(TIC *, int, char *, char, char, int, - char *, size_t, int); +char *_ti_find_cap(TIC *, TBUF *, char, short); +char *_ti_find_extra(TIC *, TBUF *, const char *); +char *_ti_getname(int, const char *); +size_t _ti_store_extra(TIC *, int, const char *, char, char, int, + const char *, size_t, int); +void _ti_encode_num(TIC *, TBUF *, int ); +int _ti_decode_num(int, const char **); TIC *_ti_compile(char *, int); ssize_t _ti_flatten(uint8_t **, const TIC *); void _ti_freetic(TIC *); Index: src/lib/libterminfo/tparm.c diff -u src/lib/libterminfo/tparm.c:1.17 src/lib/libterminfo/tparm.c:1.18 --- src/lib/libterminfo/tparm.c:1.17 Thu May 4 05:42:23 2017 +++ src/lib/libterminfo/tparm.c Fri Mar 27 11:11:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tparm.c,v 1.17 2017/05/04 09:42:23 roy Exp $ */ +/* $NetBSD: tparm.c,v 1.18 2020/03/27 15:11:57 christos Exp $ */ /* * Copyright (c) 2009, 2011, 2013 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: tparm.c,v 1.17 2017/05/04 09:42:23 roy Exp $"); +__RCSID("$NetBSD: tparm.c,v 1.18 2020/03/27 15:11:57 christos Exp $"); #include <sys/param.h> #include <assert.h> @@ -265,7 +265,8 @@ _ti_tiparm(TERMINAL *term, const char *s /* Handle formatting. */ fp = fmt; *fp++ = '%'; - done = dot = minus = width = precision = 0; + done = dot = minus = 0; + width = precision = 0; val = 0; while (done == 0 && (size_t)(fp - fmt) < sizeof(fmt)) { switch (c) { Index: src/share/terminfo/Makefile diff -u src/share/terminfo/Makefile:1.4 src/share/terminfo/Makefile:1.5 --- src/share/terminfo/Makefile:1.4 Fri Mar 13 11:19:25 2020 +++ src/share/terminfo/Makefile Fri Mar 27 11:11:57 2020 @@ -1,12 +1,12 @@ -# $NetBSD: Makefile,v 1.4 2020/03/13 15:19:25 roy Exp $ +# $NetBSD: Makefile,v 1.5 2020/03/27 15:11:57 christos Exp $ # from: @(#)Makefile 8.1 (Berkeley) 6/8/93 -CLEANFILES= terminfo2.cdb -realall: terminfo2.cdb -FILES=terminfo2.cdb terminfo +CLEANFILES= terminfo.cdb +realall: terminfo.cdb +FILES=terminfo.cdb terminfo FILESDIR=${BINDIR}/misc -terminfo2.cdb: terminfo ${TOOL_TIC} +terminfo.cdb: terminfo ${TOOL_TIC} ${_MKTARGET_CREATE} ${TOOL_TIC} -ax -o ${.TARGET} "${.CURDIR}/terminfo" Index: src/usr.bin/tic/tic.c diff -u src/usr.bin/tic/tic.c:1.32 src/usr.bin/tic/tic.c:1.33 --- src/usr.bin/tic/tic.c:1.32 Fri Mar 13 11:19:25 2020 +++ src/usr.bin/tic/tic.c Fri Mar 27 11:11:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tic.c,v 1.32 2020/03/13 15:19:25 roy Exp $ */ +/* $NetBSD: tic.c,v 1.33 2020/03/27 15:11:57 christos Exp $ */ /* * Copyright (c) 2009, 2010, 2020 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: tic.c,v 1.32 2020/03/13 15:19:25 roy Exp $"); +__RCSID("$NetBSD: tic.c,v 1.33 2020/03/27 15:11:57 christos Exp $"); #include <sys/types.h> #include <sys/queue.h> @@ -167,6 +167,7 @@ process_entry(TBUF *buf, int flags) char *p, *e, *alias; TERM *term; TIC *tic; + TBUF sbuf = *buf; if (buf->bufpos == 0) return 0; @@ -211,13 +212,17 @@ process_entry(TBUF *buf, int flags) free(alias); } + if (tic->rtype == TERMINFO_RTYPE) + return process_entry(&sbuf, flags | TIC_COMPAT_V1); + return 0; } static void merge(TIC *rtic, TIC *utic, int flags) { - char *cap, flag, *code, type, *str; + char flag, type; + const char *cap, *code, *str; short ind, len; int num; size_t n; @@ -228,7 +233,7 @@ merge(TIC *rtic, TIC *utic, int flags) cap += sizeof(uint16_t); flag = *cap++; if (VALID_BOOLEAN(flag) && - _ti_find_cap(&rtic->flags, 'f', ind) == NULL) + _ti_find_cap(rtic, &rtic->flags, 'f', ind) == NULL) { _ti_grow_tbuf(&rtic->flags, sizeof(uint16_t) + 1); le16enc(rtic->flags.buf + rtic->flags.bufpos, ind); @@ -242,17 +247,15 @@ merge(TIC *rtic, TIC *utic, int flags) for (n = utic->nums.entries; n > 0; n--) { ind = le16dec(cap); cap += sizeof(uint16_t); - num = le32dec(cap); - cap += sizeof(uint32_t); + num = _ti_decode_num(utic->rtype, &cap); if (VALID_NUMERIC(num) && - _ti_find_cap(&rtic->nums, 'n', ind) == NULL) + _ti_find_cap(rtic, &rtic->nums, 'n', ind) == NULL) { grow_tbuf(&rtic->nums, sizeof(uint16_t) + - sizeof(uint32_t)); + _ti_numsize(rtic)); le16enc(rtic->nums.buf + rtic->nums.bufpos, ind); rtic->nums.bufpos += sizeof(uint16_t); - le32enc(rtic->nums.buf + rtic->nums.bufpos, num); - rtic->nums.bufpos += sizeof(uint32_t); + _ti_encode_num(rtic, &rtic->nums, num); rtic->nums.entries++; } } @@ -264,7 +267,7 @@ merge(TIC *rtic, TIC *utic, int flags) len = le16dec(cap); cap += sizeof(uint16_t); if (len > 0 && - _ti_find_cap(&rtic->strs, 's', ind) == NULL) + _ti_find_cap(rtic, &rtic->strs, 's', ind) == NULL) { grow_tbuf(&rtic->strs, (sizeof(uint16_t) * 2) + len); le16enc(rtic->strs.buf + rtic->strs.bufpos, ind); @@ -295,8 +298,7 @@ merge(TIC *rtic, TIC *utic, int flags) continue; break; case 'n': - num = le32dec(cap); - cap += sizeof(uint32_t); + num = _ti_decode_num(utic->rtype, &cap); if (!VALID_NUMERIC(num)) continue; break; @@ -328,7 +330,8 @@ merge_use(int flags) if (term->base_term != NULL) continue; rtic = term->tic; - while ((cap = _ti_find_extra(&rtic->extras, "use")) != NULL) { + while ((cap = _ti_find_extra(rtic, &rtic->extras, "use")) + != NULL) { if (*cap++ != 's') { dowarn("%s: use is not string", rtic->name); break; @@ -351,15 +354,16 @@ merge_use(int flags) dowarn("%s: uses itself", rtic->name); goto remove; } - if (_ti_find_extra(&utic->extras, "use") != NULL) { + if (_ti_find_extra(utic, &utic->extras, "use") + != NULL) { skipped++; break; } - cap = _ti_find_extra(&rtic->extras, "use"); + cap = _ti_find_extra(rtic, &rtic->extras, "use"); merge(rtic, utic, flags); remove: /* The pointers may have changed, find the use again */ - cap = _ti_find_extra(&rtic->extras, "use"); + cap = _ti_find_extra(rtic, &rtic->extras, "use"); if (cap == NULL) dowarn("%s: use no longer exists - impossible", rtic->name);