diff --git a/NEWS b/NEWS index 6d1ce55396..c42cee9f85 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Changes from 1.21.99.6 to 1.21.99.6 +- ignore OSVERSION if set but ABI is not set + Changes from 1.21.99.4 to 1.21.99.5 - the pkg target ABI is now dynamically detected, pkg can be used to cross install packages among OS. diff --git a/auto.def b/auto.def index a4276cb045..5fd49fbd7e 100644 --- a/auto.def +++ b/auto.def @@ -6,7 +6,7 @@ use cc cc-lib cc-shared pkg-config set maj_ver 1 set med_ver 21 set min_ver 99 -set dev_ver 3 +set dev_ver 6 define PKG_API [expr {$maj_ver * 1000000 + $med_ver * 1000 + $min_ver}] define VERSION $maj_ver.$med_ver.$min_ver[expr {$dev_ver ? ".$dev_ver" : ""}] diff --git a/libpkg/Makefile.autosetup b/libpkg/Makefile.autosetup index 754f1e8d58..ee82e93eac 100644 --- a/libpkg/Makefile.autosetup +++ b/libpkg/Makefile.autosetup @@ -208,6 +208,6 @@ install: all pkg.h lib$(LIB)$(LIBSOEXT) lib$(LIB)_flat.a ln -sf lib$(LIB)$(LIBSOEXT) $(DESTDIR)$(libdir)/lib$(LIB)$(SH_SOEXT) install -m 644 lib$(LIB)_flat.a $(DESTDIR)$(libdir)/lib$(LIB).a install -m 644 pkg.h $(DESTDIR)$(includedir)/ - install -m 644 pkgvec.h $(DESTDIR)$(includedir)/ + install -m 644 $(top_srcdir)/libpkg/pkg/vec.h $(DESTDIR)$(includedir)/pkg install -m 644 $(top_srcdir)/libpkg/pkg/audit.h $(DESTDIR)$(includedir)/pkg install -m 644 pkg.pc $(DESTDIR)$(pkgconfigdir)/ diff --git a/libpkg/pkg.h.in b/libpkg/pkg.h.in index f798b3a0c9..6b82d2329d 100644 --- a/libpkg/pkg.h.in +++ b/libpkg/pkg.h.in @@ -46,7 +46,7 @@ extern "C" { #include #include #include -#include +#include /* The expected name of the pkg(8) binary executable. */ #ifndef PKG_EXEC_NAME @@ -136,7 +136,7 @@ struct pkg_kv { char *value; }; -typedef pkgvec_t(struct pkg_kv *) pkg_kvl_t; +typedef vec_t(struct pkg_kv *) pkg_kvl_t; /** * The system-wide pkg(8) status: ie. is it a) installed or otherwise diff --git a/libpkg/pkgvec.h b/libpkg/pkg/vec.h similarity index 77% rename from libpkg/pkgvec.h rename to libpkg/pkg/vec.h index 817e515f62..d4c72247ac 100644 --- a/libpkg/pkgvec.h +++ b/libpkg/pkg/vec.h @@ -10,38 +10,38 @@ #include #include -#define pkgvec_t(Type) \ +#define vec_t(Type) \ struct { Type *d; size_t len, cap; } -#define pkgvec_init(v) \ +#define vec_init(v) \ memset((v), 0, sizeof(*(v))) -#define pkgvec_free(v) \ +#define vec_free(v) \ do { \ free((v)->d); \ (v)->d == NULL; \ memset((v), 0, sizeof(*(v))); \ } while (0) -#define pkgvec_free_and_free(v, free_func) \ +#define vec_free_and_free(v, free_func) \ do { \ for (size_t _i=0; _i < (v)->len ; _i++) { \ free_func((v)->d[_i]); \ (v)->d[_i] = NULL; \ } \ - pkgvec_free((v)); \ + vec_free((v)); \ } while(0) -#define pkgvec_first(v) \ +#define vec_first(v) \ (v)->d[0] -#define pkgvec_last(v) \ +#define vec_last(v) \ (v)->d[(v)->len -1] -#define pkgvec_clear(v) \ +#define vec_clear(v) \ (v)->len = 0 -#define pkgvec_clear_and_free(v, free_func) \ +#define vec_clear_and_free(v, free_func) \ do { \ for (size_t _i=0; _i < (v)->len ; _i++) { \ free_func((v)->d[_i]); \ @@ -50,7 +50,7 @@ (v)->len = 0; \ } while (0) -#define pkgvec_push(v, _d) \ +#define vec_push(v, _d) \ do { \ if ((v)->len + 1 > (v)->cap) { \ if ((v)->cap == 0) \ @@ -64,8 +64,8 @@ (v)->d[(v)->len++] = (_d); \ } while (0) \ -#define pkgvec_pop(v) \ +#define vec_pop(v) \ (v)->d[--(v)->len] -typedef pkgvec_t(char *) charv_t; -typedef pkgvec_t(const char *) c_charv_t; +typedef vec_t(char *) charv_t; +typedef vec_t(const char *) c_charv_t; diff --git a/libpkg/pkg_add.c b/libpkg/pkg_add.c index ff4f47e815..017c0aee1c 100644 --- a/libpkg/pkg_add.c +++ b/libpkg/pkg_add.c @@ -435,7 +435,7 @@ get_tempdir(int rootfd, const char *path, tempdirs_t *tempdirs, c_charv_t *symli tmpdir = open_tempdir(rootfd, path, symlinks_allowed); if (tmpdir != NULL) - pkgvec_push(tempdirs, tmpdir); + vec_push(tempdirs, tmpdir); return (tmpdir); } @@ -1089,7 +1089,7 @@ pkg_extract_finalize(struct pkg *pkg, tempdirs_t *tempdirs) return (EPKG_FATAL); } if (tempdirs != NULL) - pkgvec_free(tempdirs); + vec_free(tempdirs); return (EPKG_OK); } @@ -1361,8 +1361,8 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags, assert(path != NULL); - pkgvec_init(&tempdirs); - pkgvec_init(&symlinks_allowed); + vec_init(&tempdirs); + vec_init(&symlinks_allowed); /* * Open the package archive file, read all the meta files and set the @@ -1465,7 +1465,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags, */ if (extract) { pkg_register_cleanup_callback(pkg_rollback_cb, pkg); - pkgvec_push(&symlinks_allowed, pkg->prefix); + vec_push(&symlinks_allowed, pkg->prefix); retcode = do_extract(a, ae, nfiles, pkg, local, &tempdirs, &symlinks_allowed); pkg_unregister_cleanup_callback(pkg_rollback_cb, pkg); if (retcode != EPKG_OK) { @@ -1564,7 +1564,7 @@ pkg_add_common(struct pkgdb *db, const char *path, unsigned flags, } cleanup: - pkgvec_free(&symlinks_allowed); + vec_free(&symlinks_allowed); if (openxact) pkgdb_register_finale(db, retcode, NULL); @@ -1665,10 +1665,10 @@ pkg_add_fromdir(struct pkg *pkg, const char *src) tempdirs_t tempdirs; c_charv_t symlinks_allowed; - pkgvec_init(&symlinks_allowed); - pkgvec_push(&symlinks_allowed, pkg->prefix); - pkgvec_init(&hardlinks); - pkgvec_init(&tempdirs); + vec_init(&symlinks_allowed); + vec_push(&symlinks_allowed, pkg->prefix); + vec_init(&hardlinks); + vec_init(&tempdirs); install_as_user = (getenv("INSTALL_AS_USER") != NULL); fromfd = open(src, O_DIRECTORY); @@ -1736,7 +1736,7 @@ pkg_add_fromdir(struct pkg *pkg, const char *src) continue; if (fstatat(fromfd, RELATIVE_PATH(f->path), &st, AT_SYMLINK_NOFOLLOW) == -1) { - pkgvec_free_and_free(&hardlinks, free); + vec_free_and_free(&hardlinks, free); close(fromfd); pkg_fatal_errno("%s%s", src, f->path); } @@ -1789,7 +1789,7 @@ pkg_add_fromdir(struct pkg *pkg, const char *src) if ((link_len = readlinkat(fromfd, RELATIVE_PATH(f->path), target, sizeof(target))) == -1) { - pkgvec_free_and_free(&hardlinks, free); + vec_free_and_free(&hardlinks, free); close(fromfd); pkg_fatal_errno("Impossible to read symlinks " "'%s'", f->path); @@ -1802,7 +1802,7 @@ pkg_add_fromdir(struct pkg *pkg, const char *src) } else if (S_ISREG(st.st_mode)) { if ((fd = openat(fromfd, RELATIVE_PATH(f->path), O_RDONLY)) == -1) { - pkgvec_free_and_free(&hardlinks, free); + vec_free_and_free(&hardlinks, free); close(fromfd); pkg_fatal_errno("Impossible to open source file" " '%s'", RELATIVE_PATH(f->path)); @@ -1832,7 +1832,7 @@ pkg_add_fromdir(struct pkg *pkg, const char *src) h->ino = st.st_ino; h->dev = st.st_dev; h->path = f->path; - pkgvec_push(&hardlinks, h); + vec_push(&hardlinks, h); } close(fd); } else { @@ -1845,8 +1845,8 @@ pkg_add_fromdir(struct pkg *pkg, const char *src) retcode = pkg_extract_finalize(pkg, &tempdirs); cleanup: - pkgvec_free(&symlinks_allowed); - pkgvec_free_and_free(&hardlinks, free); + vec_free(&symlinks_allowed); + vec_free_and_free(&hardlinks, free); close(fromfd); return (retcode); } diff --git a/libpkg/pkg_config.c b/libpkg/pkg_config.c index be7be58811..c6af00d6c1 100644 --- a/libpkg/pkg_config.c +++ b/libpkg/pkg_config.c @@ -529,10 +529,10 @@ pkg_external_libs_version(void) { pkg_kvl_t *kvl = xcalloc(1, sizeof(*kvl)); - pkgvec_push(kvl, pkg_kv_new("libcurl", curl_version())); - pkgvec_push(kvl, pkg_kv_new("libarchive", archive_version_string())); - pkgvec_push(kvl, pkg_kv_new("sqlite", sqlite3_libversion())); - pkgvec_push(kvl, pkg_kv_new("openssl", OpenSSL_version(OPENSSL_VERSION))); + vec_push(kvl, pkg_kv_new("libcurl", curl_version())); + vec_push(kvl, pkg_kv_new("libarchive", archive_version_string())); + vec_push(kvl, pkg_kv_new("sqlite", sqlite3_libversion())); + vec_push(kvl, pkg_kv_new("openssl", OpenSSL_version(OPENSSL_VERSION))); return (kvl); } @@ -1066,10 +1066,11 @@ config_init_abi(struct pkg_abi *abi) pkg_os_to_string(abi->os)); } } - } else if (env_osversion_string != NULL) { - pkg_emit_error("Setting OSVERSION requires setting ABI as well"); - return (EPKG_FATAL); } else { + if (env_osversion_string != NULL) { + dbg(1, "Setting OSVERSION requires setting ABI as well (ignoring)"); + unsetenv("OSVERSION"); + } if (pkg_abi_from_file(abi) != EPKG_OK) { return (false); } diff --git a/libpkg/pkg_create.c b/libpkg/pkg_create.c index 3e39715395..88939ab0f9 100644 --- a/libpkg/pkg_create.c +++ b/libpkg/pkg_create.c @@ -70,7 +70,7 @@ pkg_create_from_dir(struct pkg *pkg, const char *root, ucl_object_t *obj; hardlinks_t hardlinks; - pkgvec_init(&hardlinks); + vec_init(&hardlinks); if (pkg_is_valid(pkg) != EPKG_OK) { pkg_emit_error("the package is not valid"); return (EPKG_FATAL); @@ -96,13 +96,13 @@ pkg_create_from_dir(struct pkg *pkg, const char *root, if (lstat(fpath, &st) == -1) { pkg_emit_error("file '%s' is missing", fpath); - pkgvec_free_and_free(&hardlinks, free); + vec_free_and_free(&hardlinks, free); return (EPKG_FATAL); } if (!(S_ISREG(st.st_mode) || S_ISLNK(st.st_mode))) { pkg_emit_error("file '%s' is not a regular file or symlink", fpath); - pkgvec_free_and_free(&hardlinks, free); + vec_free_and_free(&hardlinks, free); return (EPKG_FATAL); } @@ -117,13 +117,13 @@ pkg_create_from_dir(struct pkg *pkg, const char *root, file->sum = pkg_checksum_generate_file(fpath, PKG_HASH_TYPE_SHA256_HEX); if (file->sum == NULL) { - pkgvec_free_and_free(&hardlinks, free); + vec_free_and_free(&hardlinks, free); return (EPKG_FATAL); } counter_count(); } - pkgvec_free_and_free(&hardlinks, free); + vec_free_and_free(&hardlinks, free); counter_end(); diff --git a/libpkg/pkg_jobs.c b/libpkg/pkg_jobs.c index bbc459b315..90843404ee 100644 --- a/libpkg/pkg_jobs.c +++ b/libpkg/pkg_jobs.c @@ -29,7 +29,6 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "pkgvec.h" #ifdef HAVE_CONFIG_H #include "pkg_config.h" #endif @@ -121,9 +120,9 @@ int pkg_jobs_set_repository(struct pkg_jobs *j, const char *ident) { c_charv_t idents; - pkgvec_init(&idents); + vec_init(&idents); if (ident != NULL) - pkgvec_push(&idents, ident); + vec_push(&idents, ident); return (pkg_jobs_set_repositories(j, &idents)); } diff --git a/libpkg/pkg_ports.c b/libpkg/pkg_ports.c index d48429e4c7..b20f796d47 100644 --- a/libpkg/pkg_ports.c +++ b/libpkg/pkg_ports.c @@ -1046,7 +1046,7 @@ plist_new(struct pkg *pkg, const char *stage) p->post_install_buf = xstring_new(); p->pre_deinstall_buf = xstring_new(); p->post_deinstall_buf = xstring_new(); - pkgvec_init(&p->hardlinks); + vec_init(&p->hardlinks); populate_keywords(p); @@ -1072,7 +1072,7 @@ plist_free(struct plist *p) free(p->uname); free(p->gname); - pkgvec_free_and_free(&p->hardlinks, free); + vec_free_and_free(&p->hardlinks, free); xstring_free(p->post_deinstall_buf); xstring_free(p->post_install_buf); diff --git a/libpkg/pkgdb.c b/libpkg/pkgdb.c index 8b31785ad7..0ba9c938c7 100644 --- a/libpkg/pkgdb.c +++ b/libpkg/pkgdb.c @@ -51,7 +51,7 @@ #include "private/utils.h" #include "private/pkg_deps.h" #include "tllist.h" -#include "pkgvec.h" +#include "pkg/vec.h" #include "private/db_upgrades.h" @@ -987,12 +987,12 @@ pkgdb_open_all(struct pkgdb **db_p, pkgdb_t type, const char *reponame) c_charv_t r; int ret; - pkgvec_init(&r); + vec_init(&r); if (reponame != NULL) - pkgvec_push(&r, reponame); + vec_push(&r, reponame); ret = pkgdb_open_all2(db_p, type, &r); - pkgvec_free(&r); + vec_free(&r); return (ret); } int diff --git a/libpkg/pkgdb_query.c b/libpkg/pkgdb_query.c index 48795f82af..c4b70f0fa1 100644 --- a/libpkg/pkgdb_query.c +++ b/libpkg/pkgdb_query.c @@ -34,7 +34,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "pkgvec.h" +#include "pkg/vec.h" #ifdef HAVE_CONFIG_H #include "pkg_config.h" #endif @@ -401,13 +401,13 @@ pkgdb_repo_query_cond(struct pkgdb *db, const char *cond, const char *pattern, m c_charv_t r; struct pkgdb_it *ret; - pkgvec_init(&r); + vec_init(&r); if (repo != NULL) - pkgvec_push(&r, repo); + vec_push(&r, repo); ret = pkgdb_repo_query_cond2(db, cond, pattern, match, &r); - pkgvec_free(&r); + vec_free(&r); return (ret); } @@ -548,12 +548,12 @@ pkgdb_repo_search(struct pkgdb *db, const char *pattern, match_t match, c_charv_t r; struct pkgdb_it *ret; - pkgvec_init(&r); + vec_init(&r); if (repo != NULL) - pkgvec_push(&r, repo); + vec_push(&r, repo); ret = pkgdb_repo_search2(db, pattern, match, field, sort, &r); - pkgvec_free(&r); + vec_free(&r); return (ret); } @@ -595,14 +595,14 @@ pkgdb_all_search(struct pkgdb *db, const char *pattern, match_t match, c_charv_t r; struct pkgdb_it *ret; - pkgvec_init(&r); + vec_init(&r); if (repo != NULL) - pkgvec_push(&r, repo); + vec_push(&r, repo); ret = pkgdb_all_search2(db, pattern, match, field, sort, &r); - pkgvec_free(&r); + vec_free(&r); return (ret); } diff --git a/libpkg/private/utils.h b/libpkg/private/utils.h index 53dca3fe8e..d5e96fdcf8 100644 --- a/libpkg/private/utils.h +++ b/libpkg/private/utils.h @@ -58,7 +58,7 @@ struct hardlink { dev_t dev; const char *path; }; -typedef pkgvec_t(struct hardlink *) hardlinks_t; +typedef vec_t(struct hardlink *) hardlinks_t; struct tempdir { char name[PATH_MAX]; @@ -66,7 +66,7 @@ struct tempdir { size_t len; int fd; }; -typedef pkgvec_t(struct tempdir *) tempdirs_t; +typedef vec_t(struct tempdir *) tempdirs_t; struct dns_srvinfo { unsigned int type; diff --git a/libpkg/utils.c b/libpkg/utils.c index f63295931d..fa3172148b 100644 --- a/libpkg/utils.c +++ b/libpkg/utils.c @@ -53,7 +53,7 @@ #include #include "pkg.h" -#include "pkgvec.h" +#include "pkg/vec.h" #include "private/event.h" #include "private/pkg_abi.h" #include "private/utils.h" @@ -332,7 +332,7 @@ check_for_hardlink(hardlinks_t *hl, struct stat *st) h = xcalloc(1, sizeof(*h)); h->ino = st->st_ino; h->dev = st->st_dev; - pkgvec_push(hl, h); + vec_push(hl, h); return (false); } diff --git a/src/fetch.c b/src/fetch.c index 8a636e62f7..c66e3c7c2b 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -82,7 +82,7 @@ exec_fetch(int argc, char **argv) { NULL, 0, NULL, 0 }, }; - pkgvec_init(&reponames); + vec_init(&reponames); while ((ch = getopt_long(argc, argv, "+aCdgiqr:Uuxyo:", longopts, NULL)) != -1) { switch (ch) { case 'a': @@ -104,7 +104,7 @@ exec_fetch(int argc, char **argv) quiet = true; break; case 'r': - pkgvec_push(&reponames, optarg); + vec_push(&reponames, optarg); break; case 'u': f |= PKG_FLAG_UPGRADES_FOR_INSTALLED; diff --git a/src/install.c b/src/install.c index f0a70d6939..a28bdb50ac 100644 --- a/src/install.c +++ b/src/install.c @@ -98,7 +98,7 @@ exec_install(int argc, char **argv) quiet = true; } - pkgvec_init(&reponames); + vec_init(&reponames); while ((ch = getopt_long(argc, argv, "+ACfFgiIlMnqr:RUxy", longopts, NULL)) != -1) { switch (ch) { case 'A': @@ -139,7 +139,7 @@ exec_install(int argc, char **argv) quiet = true; break; case 'r': - pkgvec_push(&reponames, optarg); + vec_push(&reponames, optarg); break; case 'R': f |= PKG_FLAG_RECURSIVE; diff --git a/src/pkgcli.h b/src/pkgcli.h index c780437245..0e5c84b86b 100644 --- a/src/pkgcli.h +++ b/src/pkgcli.h @@ -14,7 +14,7 @@ #include #include #include -#include +#include #define pkg_warnx(fmt, ...) pkg_fprintf(stderr, "%S: " fmt, getprogname(), __VA_ARGS__, -1) #define ll_foreach(head, el) for (el=head; el != NULL; el = (el)->next) diff --git a/src/rquery.c b/src/rquery.c index 9aa14d4346..13549466db 100644 --- a/src/rquery.c +++ b/src/rquery.c @@ -138,7 +138,7 @@ exec_rquery(int argc, char **argv) portsdir = pkg_object_string(pkg_config_get("PORTSDIR")); - pkgvec_init(&reponames); + vec_init(&reponames); while ((ch = getopt_long(argc, argv, "+aCgiIxe:r:U", longopts, NULL)) != -1) { switch (ch) { case 'a': @@ -160,7 +160,7 @@ exec_rquery(int argc, char **argv) index_output = true; break; case 'r': - pkgvec_push(&reponames, optarg); + vec_push(&reponames, optarg); break; case 'U': auto_update = false; diff --git a/src/search.c b/src/search.c index 78463ccfce..7f02ce0fad 100644 --- a/src/search.c +++ b/src/search.c @@ -280,7 +280,7 @@ exec_search(int argc, char **argv) { NULL, 0, NULL, 0 }, }; - pkgvec_init(&reponames); + vec_init(&reponames); while ((ch = getopt_long(argc, argv, "+CcDdefgiL:opqQ:r:RS:sUx", longopts, NULL)) != -1) { switch (ch) { case 'C': @@ -323,7 +323,7 @@ exec_search(int argc, char **argv) opt |= modifier_opt(optarg); break; case 'r': - pkgvec_push(&reponames, optarg); + vec_push(&reponames, optarg); break; case 'R': opt = INFO_RAW; diff --git a/src/update.c b/src/update.c index 63ab4268a2..518a2bbf3e 100644 --- a/src/update.c +++ b/src/update.c @@ -158,7 +158,7 @@ exec_update(int argc, char **argv) { NULL, 0, NULL, 0 }, }; - pkgvec_init(&reponames); + vec_init(&reponames); while ((ch = getopt_long(argc, argv, "+fqr:", longopts, NULL)) != -1) { switch (ch) { case 'f': @@ -168,7 +168,7 @@ exec_update(int argc, char **argv) quiet = true; break; case 'r': - pkgvec_push(&reponames, optarg); + vec_push(&reponames, optarg); break; default: usage_update(); diff --git a/src/upgrade.c b/src/upgrade.c index f17e0eda63..f5de181aa3 100644 --- a/src/upgrade.c +++ b/src/upgrade.c @@ -268,7 +268,7 @@ exec_upgrade(int argc, char **argv) }; nbactions = nbdone = 0; - pkgvec_init(&reponames); + vec_init(&reponames); while ((ch = getopt_long(argc, argv, "+CfFgiInqr:Uxyv", longopts, NULL)) != -1) { switch (ch) { @@ -300,7 +300,7 @@ exec_upgrade(int argc, char **argv) quiet = true; break; case 'r': - pkgvec_push(&reponames, optarg); + vec_push(&reponames, optarg); break; case 'U': auto_update = false; diff --git a/src/version.c b/src/version.c index f2ad6ba04f..85e1749b25 100644 --- a/src/version.c +++ b/src/version.c @@ -831,7 +831,7 @@ exec_version(int argc, char **argv) { NULL, 0, NULL, 0 }, }; - pkgvec_init(&reponames); + vec_init(&reponames); while ((ch = getopt_long(argc, argv, "+Ce:g:hIiL:l:n:O:oPqRr:TtUvx:", longopts, NULL)) != -1) { switch (ch) { @@ -885,7 +885,7 @@ exec_version(int argc, char **argv) break; case 'r': opt |= VERSION_SOURCE_REMOTE; - pkgvec_push(&reponames, optarg); + vec_push(&reponames, optarg); break; case 'T': opt |= VERSION_TESTPATTERN; diff --git a/tests/lib/vec.c b/tests/lib/vec.c index eff37c8668..e89c9649fa 100644 --- a/tests/lib/vec.c +++ b/tests/lib/vec.c @@ -6,8 +6,8 @@ #include #include -#include #include +#include ATF_TC_WITHOUT_HEAD(c_charv_t); ATF_TC_WITHOUT_HEAD(c_charv_contains); @@ -17,107 +17,107 @@ ATF_TC_BODY(c_charv_t, tc) { c_charv_t list; - pkgvec_init(&list); - ATF_REQUIRE_EQ_MSG(list.d, NULL, "pkgvec_init failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 0, "pkgvec_init failed"); - ATF_REQUIRE_EQ_MSG(list.len, 0, "pkgvec_init failed"); - - pkgvec_push(&list, "test1"); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 1, "pkgvec_push failed"); - ATF_REQUIRE_EQ_MSG(list.len, 1, "pkgvec_push failed"); - - pkgvec_push(&list, "test2"); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push2 failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 2, "pkgvec_push2 failed"); - ATF_REQUIRE_EQ_MSG(list.len, 2, "pkgvec_push2 failed"); - - pkgvec_push(&list, "test3"); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push3 failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 4, "pkgvec_push3 failed"); - ATF_REQUIRE_EQ_MSG(list.len, 3, "pkgvec_push3 failed"); - - ATF_REQUIRE_STREQ_MSG(pkgvec_first(&list), "test1", "pkgvec_first failed"); - ATF_REQUIRE_STREQ_MSG(pkgvec_last(&list), "test3", "pkgvec_last failed"); - - pkgvec_clear(&list); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_clear failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 4, "pkgvec_clear failed"); - ATF_REQUIRE_EQ_MSG(list.len, 0, "pkgvec_clear failed"); - - pkgvec_free(&list); - ATF_REQUIRE_EQ_MSG(list.d, NULL, "pkgvec_free failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 0, "pkgvec_free failed"); - ATF_REQUIRE_EQ_MSG(list.len, 0, "pkgvec_free failed"); + vec_init(&list); + ATF_REQUIRE_EQ_MSG(list.d, NULL, "vec_init failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 0, "vec_init failed"); + ATF_REQUIRE_EQ_MSG(list.len, 0, "vec_init failed"); + + vec_push(&list, "test1"); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 1, "vec_push failed"); + ATF_REQUIRE_EQ_MSG(list.len, 1, "vec_push failed"); + + vec_push(&list, "test2"); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push2 failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 2, "vec_push2 failed"); + ATF_REQUIRE_EQ_MSG(list.len, 2, "vec_push2 failed"); + + vec_push(&list, "test3"); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push3 failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 4, "vec_push3 failed"); + ATF_REQUIRE_EQ_MSG(list.len, 3, "vec_push3 failed"); + + ATF_REQUIRE_STREQ_MSG(vec_first(&list), "test1", "vec_first failed"); + ATF_REQUIRE_STREQ_MSG(vec_last(&list), "test3", "vec_last failed"); + + vec_clear(&list); + ATF_REQUIRE_MSG(list.d != NULL, "vec_clear failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 4, "vec_clear failed"); + ATF_REQUIRE_EQ_MSG(list.len, 0, "vec_clear failed"); + + vec_free(&list); + ATF_REQUIRE_EQ_MSG(list.d, NULL, "vec_free failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 0, "vec_free failed"); + ATF_REQUIRE_EQ_MSG(list.len, 0, "vec_free failed"); } ATF_TC_BODY(charv_t, tc) { charv_t list; - pkgvec_init(&list); - ATF_REQUIRE_EQ_MSG(list.d, NULL, "pkgvec_init failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 0, "pkgvec_init failed"); - ATF_REQUIRE_EQ_MSG(list.len, 0, "pkgvec_init failed"); - - pkgvec_push(&list, xstrdup("test1")); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 1, "pkgvec_push failed"); - ATF_REQUIRE_EQ_MSG(list.len, 1, "pkgvec_push failed"); - - pkgvec_push(&list, xstrdup("test2")); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push2 failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 2, "pkgvec_push2 failed"); - ATF_REQUIRE_EQ_MSG(list.len, 2, "pkgvec_push2 failed"); - - pkgvec_push(&list, xstrdup("test3")); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push3 failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 4, "pkgvec_push3 failed"); - ATF_REQUIRE_EQ_MSG(list.len, 3, "pkgvec_push3 failed"); - - ATF_REQUIRE_STREQ_MSG(pkgvec_first(&list), "test1", "pkgvec_first failed"); - ATF_REQUIRE_STREQ_MSG(pkgvec_last(&list), "test3", "pkgvec_last failed"); - - pkgvec_clear_and_free(&list, free); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_clear failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 4, "pkgvec_clear failed"); - ATF_REQUIRE_EQ_MSG(list.len, 0, "pkgvec_clear failed"); - - pkgvec_free_and_free(&list, free); - ATF_REQUIRE_EQ_MSG(list.d, NULL, "pkgvec_free failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 0, "pkgvec_free failed"); - ATF_REQUIRE_EQ_MSG(list.len, 0, "pkgvec_free failed"); + vec_init(&list); + ATF_REQUIRE_EQ_MSG(list.d, NULL, "vec_init failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 0, "vec_init failed"); + ATF_REQUIRE_EQ_MSG(list.len, 0, "vec_init failed"); + + vec_push(&list, xstrdup("test1")); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 1, "vec_push failed"); + ATF_REQUIRE_EQ_MSG(list.len, 1, "vec_push failed"); + + vec_push(&list, xstrdup("test2")); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push2 failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 2, "vec_push2 failed"); + ATF_REQUIRE_EQ_MSG(list.len, 2, "vec_push2 failed"); + + vec_push(&list, xstrdup("test3")); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push3 failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 4, "vec_push3 failed"); + ATF_REQUIRE_EQ_MSG(list.len, 3, "vec_push3 failed"); + + ATF_REQUIRE_STREQ_MSG(vec_first(&list), "test1", "vec_first failed"); + ATF_REQUIRE_STREQ_MSG(vec_last(&list), "test3", "vec_last failed"); + + vec_clear_and_free(&list, free); + ATF_REQUIRE_MSG(list.d != NULL, "vec_clear failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 4, "vec_clear failed"); + ATF_REQUIRE_EQ_MSG(list.len, 0, "vec_clear failed"); + + vec_free_and_free(&list, free); + ATF_REQUIRE_EQ_MSG(list.d, NULL, "vec_free failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 0, "vec_free failed"); + ATF_REQUIRE_EQ_MSG(list.len, 0, "vec_free failed"); } ATF_TC_BODY(c_charv_contains, tc) { c_charv_t list; - pkgvec_init(&list); - ATF_REQUIRE_EQ_MSG(list.d, NULL, "pkgvec_init failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 0, "pkgvec_init failed"); - ATF_REQUIRE_EQ_MSG(list.len, 0, "pkgvec_init failed"); + vec_init(&list); + ATF_REQUIRE_EQ_MSG(list.d, NULL, "vec_init failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 0, "vec_init failed"); + ATF_REQUIRE_EQ_MSG(list.len, 0, "vec_init failed"); - pkgvec_push(&list, "test1"); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 1, "pkgvec_push failed"); - ATF_REQUIRE_EQ_MSG(list.len, 1, "pkgvec_push failed"); + vec_push(&list, "test1"); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 1, "vec_push failed"); + ATF_REQUIRE_EQ_MSG(list.len, 1, "vec_push failed"); - pkgvec_push(&list, "test2"); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push2 failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 2, "pkgvec_push2 failed"); - ATF_REQUIRE_EQ_MSG(list.len, 2, "pkgvec_push2 failed"); + vec_push(&list, "test2"); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push2 failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 2, "vec_push2 failed"); + ATF_REQUIRE_EQ_MSG(list.len, 2, "vec_push2 failed"); - pkgvec_push(&list, "test3"); - ATF_REQUIRE_MSG(list.d != NULL, "pkgvec_push3 failed"); - ATF_REQUIRE_EQ_MSG(list.cap, 4, "pkgvec_push3 failed"); - ATF_REQUIRE_EQ_MSG(list.len, 3, "pkgvec_push3 failed"); + vec_push(&list, "test3"); + ATF_REQUIRE_MSG(list.d != NULL, "vec_push3 failed"); + ATF_REQUIRE_EQ_MSG(list.cap, 4, "vec_push3 failed"); + ATF_REQUIRE_EQ_MSG(list.len, 3, "vec_push3 failed"); ATF_REQUIRE_EQ_MSG(c_charv_contains(&list, "Test3", true), false, "c_charv_contains not case sensitive"); ATF_REQUIRE_EQ_MSG(c_charv_contains(&list, "Test3", false), true, "c_charv_contains not case insensitive"); ATF_REQUIRE_EQ_MSG(c_charv_contains(&list, "aest3", false), false, "c_charv_contains should not find anything"); - pkgvec_free(&list); + vec_free(&list); } ATF_TP_ADD_TCS(tp)