From owner-svn-src-projects@freebsd.org Mon Jan 27 20:47:24 2020 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 911C222E7AA for ; Mon, 27 Jan 2020 20:47:24 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4861yh43Hxz4BGN; Mon, 27 Jan 2020 20:47:24 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6BF31FF3E; Mon, 27 Jan 2020 20:47:24 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00RKlOXV031799; Mon, 27 Jan 2020 20:47:24 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00RKlIwI031771; Mon, 27 Jan 2020 20:47:18 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202001272047.00RKlIwI031771@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Mon, 27 Jan 2020 20:47:18 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r357179 - in projects/clang1000-import: bin/pwait bin/pwait/tests contrib/libxo contrib/libxo/doc contrib/libxo/encoder/csv contrib/libxo/libxo contrib/libxo/tests/core contrib/libxo/te... X-SVN-Group: projects X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in projects/clang1000-import: bin/pwait bin/pwait/tests contrib/libxo contrib/libxo/doc contrib/libxo/encoder/csv contrib/libxo/libxo contrib/libxo/tests/core contrib/libxo/tests/core/saved lib/libxo ... X-SVN-Commit-Revision: 357179 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Jan 2020 20:47:24 -0000 Author: dim Date: Mon Jan 27 20:47:18 2020 New Revision: 357179 URL: https://svnweb.freebsd.org/changeset/base/357179 Log: Merge ^/head r357119 through r357178. Modified: projects/clang1000-import/bin/pwait/pwait.1 projects/clang1000-import/bin/pwait/pwait.c projects/clang1000-import/bin/pwait/tests/pwait_test.sh projects/clang1000-import/contrib/libxo/configure.ac projects/clang1000-import/contrib/libxo/doc/api.rst projects/clang1000-import/contrib/libxo/doc/encoders.rst projects/clang1000-import/contrib/libxo/doc/options.rst projects/clang1000-import/contrib/libxo/encoder/csv/enc_csv.c projects/clang1000-import/contrib/libxo/libxo/libxo.c projects/clang1000-import/contrib/libxo/libxo/xo.h projects/clang1000-import/contrib/libxo/libxo/xo_encoder.c projects/clang1000-import/contrib/libxo/libxo/xo_encoder.h projects/clang1000-import/contrib/libxo/tests/core/Makefile.am projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.H.out projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.HIPx.out projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.HP.out projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.J.out projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.JP.out projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.T.err projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.X.out projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.XP.out projects/clang1000-import/contrib/libxo/tests/core/test_02.c projects/clang1000-import/contrib/libxo/tests/core/test_12.c projects/clang1000-import/lib/libxo/add.man projects/clang1000-import/lib/libxo/libxo/xo_config.h projects/clang1000-import/sbin/newfs_msdos/mkfs_msdos.c projects/clang1000-import/share/mk/bsd.compat.mk projects/clang1000-import/sys/conf/Makefile.mips projects/clang1000-import/sys/conf/Makefile.powerpc projects/clang1000-import/sys/conf/kern.post.mk projects/clang1000-import/sys/dev/mrsas/mrsas_cam.c projects/clang1000-import/sys/dev/msk/if_msk.c projects/clang1000-import/sys/dev/netmap/netmap_mem2.c projects/clang1000-import/sys/dev/sound/pci/emu10k1.c projects/clang1000-import/sys/dev/sound/pci/emu10kx-pcm.c projects/clang1000-import/sys/fs/msdosfs/msdosfsmount.h projects/clang1000-import/sys/fs/nfsserver/nfs_nfsdstate.c projects/clang1000-import/sys/geom/geom_subr.c projects/clang1000-import/sys/geom/stripe/g_stripe.c projects/clang1000-import/sys/kern/vfs_default.c projects/clang1000-import/sys/kern/vfs_subr.c projects/clang1000-import/sys/netinet/ip_divert.c projects/clang1000-import/sys/sys/tree.h projects/clang1000-import/sys/tools/vnode_if.awk projects/clang1000-import/sys/ufs/ffs/ffs_vfsops.c projects/clang1000-import/sys/ufs/ufs/ufs_vnops.c projects/clang1000-import/sys/x86/cpufreq/hwpstate_amd.c projects/clang1000-import/sys/x86/iommu/intel_dmar.h projects/clang1000-import/sys/x86/iommu/intel_drv.c projects/clang1000-import/sys/x86/iommu/intel_gas.c projects/clang1000-import/tests/sys/kern/ptrace_test.c projects/clang1000-import/tests/sys/netinet/Makefile projects/clang1000-import/tools/build/Makefile projects/clang1000-import/usr.bin/xohtml/xohtml.sh projects/clang1000-import/usr.sbin/makefs/msdos/msdosfs_denode.c projects/clang1000-import/usr.sbin/makefs/msdos/msdosfs_vnops.c Directory Properties: projects/clang1000-import/ (props changed) projects/clang1000-import/contrib/libxo/ (props changed) Modified: projects/clang1000-import/bin/pwait/pwait.1 ============================================================================== --- projects/clang1000-import/bin/pwait/pwait.1 Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/bin/pwait/pwait.1 Mon Jan 27 20:47:18 2020 (r357179) @@ -32,7 +32,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 7, 2017 +.Dd January 26, 2020 .Dt PWAIT 1 .Os .Sh NAME @@ -41,7 +41,7 @@ .Sh SYNOPSIS .Nm .Op Fl t Ar duration -.Op Fl v +.Op Fl ov .Ar pid \&... .Sh DESCRIPTION @@ -51,6 +51,8 @@ utility will wait until each of the given processes ha .Pp The following option is available: .Bl -tag -width indent +.It Fl o +Exit when any of the given processes has terminated. .It Fl t Ar duration If any process is still running after .Ar duration , Modified: projects/clang1000-import/bin/pwait/pwait.c ============================================================================== --- projects/clang1000-import/bin/pwait/pwait.c Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/bin/pwait/pwait.c Mon Jan 27 20:47:18 2020 (r357179) @@ -53,8 +53,7 @@ static void usage(void) { - fprintf(stderr, "usage: pwait [-t timeout] [-v] pid ...\n"); - exit(EX_USAGE); + errx(EX_USAGE, "usage: pwait [-t timeout] [-ov] pid ..."); } /* @@ -64,25 +63,30 @@ int main(int argc, char *argv[]) { struct itimerval itv; - int kq; struct kevent *e; - int tflag, verbose; - int opt, nleft, n, i, duplicate, status; + int oflag, tflag, verbose; + int i, kq, n, nleft, opt, status; long pid; - char *s, *end; + char *end, *s; double timeout; - tflag = verbose = 0; + oflag = 0; + tflag = 0; + verbose = 0; memset(&itv, 0, sizeof(itv)); - while ((opt = getopt(argc, argv, "t:v")) != -1) { + + while ((opt = getopt(argc, argv, "ot:v")) != -1) { switch (opt) { + case 'o': + oflag = 1; + break; case 't': tflag = 1; errno = 0; timeout = strtod(optarg, &end); - if (end == optarg || errno == ERANGE || - timeout < 0) + if (end == optarg || errno == ERANGE || timeout < 0) { errx(EX_DATAERR, "timeout value"); + } switch(*end) { case 0: case 's': @@ -96,8 +100,9 @@ main(int argc, char *argv[]) default: errx(EX_DATAERR, "timeout unit"); } - if (timeout > 100000000L) + if (timeout > 100000000L) { errx(EX_DATAERR, "timeout value"); + } itv.it_value.tv_sec = (time_t)timeout; timeout -= (time_t)timeout; itv.it_value.tv_usec = @@ -115,77 +120,96 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (argc == 0) + if (argc == 0) { usage(); + } kq = kqueue(); - if (kq == -1) - err(1, "kqueue"); + if (kq == -1) { + err(EX_OSERR, "kqueue"); + } e = malloc((argc + tflag) * sizeof(struct kevent)); - if (e == NULL) - err(1, "malloc"); + if (e == NULL) { + err(EX_OSERR, "malloc"); + } nleft = 0; for (n = 0; n < argc; n++) { s = argv[n]; - if (!strncmp(s, "/proc/", 6)) /* Undocumented Solaris compat */ + /* Undocumented Solaris compat */ + if (!strncmp(s, "/proc/", 6)) { s += 6; + } errno = 0; pid = strtol(s, &end, 10); if (pid < 0 || *end != '\0' || errno != 0) { warnx("%s: bad process id", s); continue; } - duplicate = 0; - for (i = 0; i < nleft; i++) - if (e[i].ident == (uintptr_t)pid) - duplicate = 1; - if (!duplicate) { - EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, - 0, NULL); - if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) - warn("%ld", pid); - else - nleft++; + for (i = 0; i < nleft; i++) { + if (e[i].ident == (uintptr_t)pid) { + break; + } } + if (i < nleft) { + /* Duplicate. */ + continue; + } + EV_SET(e + nleft, pid, EVFILT_PROC, EV_ADD, NOTE_EXIT, 0, NULL); + if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) { + warn("%ld", pid); + if (oflag) { + exit(EX_OK); + } + } else { + nleft++; + } } - if (tflag) { + if (nleft > 0 && tflag) { /* * Explicitly detect SIGALRM so that an exit status of 124 * can be returned rather than 142. */ EV_SET(e + nleft, SIGALRM, EVFILT_SIGNAL, EV_ADD, 0, 0, NULL); - if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) + if (kevent(kq, e + nleft, 1, NULL, 0, NULL) == -1) { err(EX_OSERR, "kevent"); + } /* Ignore SIGALRM to not interrupt kevent(2). */ signal(SIGALRM, SIG_IGN); - if (setitimer(ITIMER_REAL, &itv, NULL) == -1) + if (setitimer(ITIMER_REAL, &itv, NULL) == -1) { err(EX_OSERR, "setitimer"); + } } while (nleft > 0) { n = kevent(kq, NULL, 0, e, nleft + tflag, NULL); - if (n == -1) - err(1, "kevent"); + if (n == -1) { + err(EX_OSERR, "kevent"); + } for (i = 0; i < n; i++) { if (e[i].filter == EVFILT_SIGNAL) { - if (verbose) + if (verbose) { printf("timeout\n"); - return (124); + } + exit(124); } if (verbose) { status = e[i].data; - if (WIFEXITED(status)) + if (WIFEXITED(status)) { printf("%ld: exited with status %d.\n", (long)e[i].ident, WEXITSTATUS(status)); - else if (WIFSIGNALED(status)) + } else if (WIFSIGNALED(status)) { printf("%ld: killed by signal %d.\n", (long)e[i].ident, WTERMSIG(status)); - else + } else { printf("%ld: terminated.\n", (long)e[i].ident); + } + } + if (oflag) { + exit(EX_OK); } --nleft; } Modified: projects/clang1000-import/bin/pwait/tests/pwait_test.sh ============================================================================== --- projects/clang1000-import/bin/pwait/tests/pwait_test.sh Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/bin/pwait/tests/pwait_test.sh Mon Jan 27 20:47:18 2020 (r357179) @@ -232,6 +232,85 @@ timeout_many_cleanup() wait $p1 $p5 $p10 >/dev/null 2>&1 } +atf_test_case or_flag +or_flag_head() +{ + atf_set "descr" "Test OR flag" +} + +or_flag_body() +{ + sleep 2 & + p2=$! + + sleep 4 & + p4=$! + + sleep 6 & + p6=$! + + atf_check \ + -o inline:"$p2: exited with status 0.\n" \ + -e empty \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o -v $p2 $p4 $p6 + + atf_check \ + -o empty \ + -e inline:"pwait: $p2: No such process\n" \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o $p2 $p4 $p6 + + atf_check \ + -o empty \ + -e empty \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o $p4 $p6 + + atf_check \ + -o empty \ + -e inline:"pwait: $p4: No such process\n" \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o $p4 $p6 + + atf_check \ + -o inline:"$p6: exited with status 0.\n" \ + -e empty \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o -v $p6 + + atf_check \ + -o empty \ + -e inline:"pwait: $p6: No such process\n" \ + -s exit:0 \ + timeout --preserve-status 15 pwait -o $p6 + + atf_check \ + -o empty \ + -e inline:"kill: $p2: No such process\n" \ + -s exit:1 \ + kill -0 $p2 + + atf_check \ + -o empty \ + -e inline:"kill: $p4: No such process\n" \ + -s exit:1 \ + kill -0 $p4 + + atf_check \ + -o empty \ + -e inline:"kill: $p6: No such process\n" \ + -s exit:1 \ + kill -0 $p6 + +} + +or_flag_cleanup() +{ + kill $p2 $p4 $p6 >/dev/null 2>&1 + wait $p2 $p4 $p6 >/dev/null 2>&1 +} + atf_init_test_cases() { atf_add_test_case basic @@ -239,4 +318,5 @@ atf_init_test_cases() atf_add_test_case timeout_trigger_timeout atf_add_test_case timeout_no_timeout atf_add_test_case timeout_many + atf_add_test_case or_flag } Modified: projects/clang1000-import/contrib/libxo/configure.ac ============================================================================== --- projects/clang1000-import/contrib/libxo/configure.ac Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/configure.ac Mon Jan 27 20:47:18 2020 (r357179) @@ -12,7 +12,7 @@ # AC_PREREQ(2.2) -AC_INIT([libxo], [1.3.1], [phil@juniper.net]) +AC_INIT([libxo], [1.4.0], [phil@juniper.net]) AM_INIT_AUTOMAKE([-Wall -Werror foreign -Wno-portability]) # Support silent build rules. Requires at least automake-1.11. Modified: projects/clang1000-import/contrib/libxo/doc/api.rst ============================================================================== --- projects/clang1000-import/contrib/libxo/doc/api.rst Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/doc/api.rst Mon Jan 27 20:47:18 2020 (r357179) @@ -1204,6 +1204,11 @@ message associated with either *errno* or the *code* p xo_err(1, "cannot open file '%s'", filename); .. index:: xo_error +.. index:: xo_error_h +.. index:: xo_error_hv +.. index:: xo_errorn +.. index:: xo_errorn_h +.. index:: xo_errorn_hv xo_error ~~~~~~~~ @@ -1214,6 +1219,50 @@ xo_error :type fmt: const char * :returns: void +.. c:function:: void xo_error_h (xo_handle_t *xop, const char *fmt, ...) + + :param xop: libxo handle pointer + :type xop: xo_handle_t * + :param fmt: Format string + :type fmt: const char * + :returns: void + +.. c:function:: void xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap) + + :param xop: libxo handle pointer + :type xop: xo_handle_t * + :param fmt: Format string + :type fmt: const char * + :param vap: variadic arguments + :type xop: va_list + :returns: void + +.. c:function:: void xo_errorn (const char *fmt, ...) + + :param fmt: Format string + :type fmt: const char * + :returns: void + +.. c:function:: void xo_errorn_h (xo_handle_t *xop, const char *fmt, ...) + + :param xop: libxo handle pointer + :type xop: xo_handle_t * + :param fmt: Format string + :type fmt: const char * + :returns: void + +.. c:function:: void xo_errorn_hv (xo_handle_t *xop, int need_newline, const char *fmt, va_list vap) + + :param xop: libxo handle pointer + :type xop: xo_handle_t * + :param need_newline: boolean indicating need for trailing newline + :type need_newline: int + :param fmt: Format string + :type fmt: const char * + :param vap: variadic arguments + :type xop: va_list + :returns: void + The `xo_error` function can be used for generic errors that should be reported over the handle, rather than to stderr. The `xo_error` function behaves like `xo_err` for TEXT and HTML output styles, but @@ -1225,6 +1274,16 @@ xo_error Does not compute JSON:: "error": { "message": "Does not compute" } + + The `xo_error_h` and `xo_error_hv` add a handle object and a + variadic-ized parameter to the signature, respectively. + + The `xo_errorn` function supplies a newline at the end the error + message if the format string does not include one. The + `xo_errorn_h` and `xo_errorn_hv` functions add a handle object and + a variadic-ized parameter to the signature, respectively. The + `xo_errorn_hv` function also adds a boolean to indicate the need for + a trailing newline. .. index:: xo_no_setlocale .. index:: Locale Modified: projects/clang1000-import/contrib/libxo/doc/encoders.rst ============================================================================== --- projects/clang1000-import/contrib/libxo/doc/encoders.rst Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/doc/encoders.rst Mon Jan 27 20:47:18 2020 (r357179) @@ -26,12 +26,13 @@ example uses the "cbor" encoder, saving the output int df --libxo encoder=cbor > df-output.cbor Encoders can support specific options that can be accessed by -following the encoder name with a colon (':') and one of more options, -separated by a plus sign "+":: +following the encoder name with a colon (':') or a plus sign ('+') and +one of more options, separated by the same character:: - df --libxo encoder=csv:path=filesystem+leaf=name+no-header + df --libxo encoder=csv+path=filesystem+leaf=name+no-header + df --libxo encoder=csv:path=filesystem:leaf=name:no-header -This example instructs libxo to load the "csv" encoder and pass the +These examples instructs libxo to load the "csv" encoder and pass the following options:: path=filesystem @@ -41,6 +42,10 @@ following options:: Each of these option is interpreted by the encoder, and all such options names and semantics are specific to the particular encoder. Refer to the intended encoder for documentation on its options. + +The string "@" can be used in place of the string "encoder=". + + df --libxo @csv:no-header .. _csv_encoder: Modified: projects/clang1000-import/contrib/libxo/doc/options.rst ============================================================================== --- projects/clang1000-import/contrib/libxo/doc/options.rst Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/doc/options.rst Mon Jan 27 20:47:18 2020 (r357179) @@ -162,3 +162,23 @@ foreground and background output to "yellow", give onl mapping, skipping the first four mappings with bare plus signs ("+"):: --libxo colors=++++yellow/yellow + +Encoders +-------- + +In addition to the four "built-in" formats, libxo supports an +extensible mechanism for adding encoders. These are activated +using the "encoder" keyword:: + + --libxo encoder=cbor + +The encoder can include encoder-specific options, separated by either +colons (":") or plus signs ("+"): + + --libxo encoder=csv+path=filesystem+leaf=name+no-header + --libxo encoder=csv:path=filesystem:leaf=name:no-header + +For brevity, the string "@" can be used in place of the string +"encoder=". + + df --libxo @csv:no-header Modified: projects/clang1000-import/contrib/libxo/encoder/csv/enc_csv.c ============================================================================== --- projects/clang1000-import/contrib/libxo/encoder/csv/enc_csv.c Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/encoder/csv/enc_csv.c Mon Jan 27 20:47:18 2020 (r357179) @@ -41,10 +41,12 @@ * (double) quote characters. * - Leading and trialing whitespace require fields be quoted. * - * Cheesy, but simple. The RFC also requires MS-DOS end-of-line, which - * we only do with the "dos" option. Strange that we still live in a - * DOS-friendly world, but then again, we make spaceships based on the - * horse butts (http://www.astrodigital.org/space/stshorse.html). + * Cheesy, but simple. The RFC also requires MS-DOS end-of-line, + * which we only do with the "dos" option. Strange that we still live + * in a DOS-friendly world, but then again, we make spaceships based + * on the horse butts (http://www.astrodigital.org/space/stshorse.html + * though the "built by English expatriates” bit is rubbish; better to + * say the first engines used in America were built by Englishmen.) */ #include @@ -655,10 +657,12 @@ csv_record_path (xo_handle_t *xop, csv_private_t *csv, /* * Extract the option values. The format is: - * -libxo encoder=csv:kw=val+kw=val+kw=val,pretty,etc + * -libxo encoder=csv:kw=val:kw=val:kw=val,pretty + * -libxo encoder=csv+kw=val+kw=val+kw=val,pretty */ static int -csv_options (xo_handle_t *xop, csv_private_t *csv, const char *raw_opts) +csv_options (xo_handle_t *xop, csv_private_t *csv, + const char *raw_opts, char opts_char) { ssize_t len = strlen(raw_opts); char *options = alloca(len + 1); @@ -667,7 +671,7 @@ csv_options (xo_handle_t *xop, csv_private_t *csv, con char *cp, *ep, *np, *vp; for (cp = options, ep = options + len + 1; cp && cp < ep; cp = np) { - np = strchr(cp, '+'); + np = strchr(cp, opts_char); if (np) *np++ = '\0'; @@ -761,7 +765,11 @@ csv_handler (XO_ENCODER_HANDLER_ARGS) break; case XO_OP_OPTIONS: - rc = csv_options(xop, csv, value); + rc = csv_options(xop, csv, value, ':'); + break; + + case XO_OP_OPTIONS_PLUS: + rc = csv_options(xop, csv, value, '+'); break; case XO_OP_OPEN_LIST: Modified: projects/clang1000-import/contrib/libxo/libxo/libxo.c ============================================================================== --- projects/clang1000-import/contrib/libxo/libxo/libxo.c Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/libxo/libxo.c Mon Jan 27 20:47:18 2020 (r357179) @@ -2371,6 +2371,25 @@ xo_set_options (xo_handle_t *xop, const char *input) if (np) *np++ = '\0'; + /* + * "@foo" is a shorthand for "encoder=foo". This is driven + * chiefly by a desire to make pluggable encoders not appear + * so distinct from built-in encoders. + */ + if (*cp == '@') { + vp = cp + 1; + + if (*vp == '\0') + xo_failure(xop, "missing value for encoder option"); + else { + rc = xo_encoder_init(xop, vp); + if (rc) + xo_warnx("error initializing encoder: %s", vp); + } + + continue; + } + vp = strchr(cp, '='); if (vp) *vp++ = '\0'; @@ -8007,7 +8026,7 @@ xo_finish_atexit (void) * Generate an error message, such as would be displayed on stderr */ void -xo_error_hv (xo_handle_t *xop, const char *fmt, va_list vap) +xo_errorn_hv (xo_handle_t *xop, int need_newline, const char *fmt, va_list vap) { xop = xo_default(xop); @@ -8015,13 +8034,15 @@ xo_error_hv (xo_handle_t *xop, const char *fmt, va_lis * If the format string doesn't end with a newline, we pop * one on ourselves. */ - ssize_t len = strlen(fmt); - if (len > 0 && fmt[len - 1] != '\n') { - char *newfmt = alloca(len + 2); - memcpy(newfmt, fmt, len); - newfmt[len] = '\n'; - newfmt[len + 1] = '\0'; - fmt = newfmt; + if (need_newline) { + ssize_t len = strlen(fmt); + if (len > 0 && fmt[len - 1] != '\n') { + char *newfmt = alloca(len + 2); + memcpy(newfmt, fmt, len); + newfmt[len] = '\n'; + newfmt[len + 1] = '\0'; + fmt = newfmt; + } } switch (xo_style(xop)) { @@ -8069,7 +8090,7 @@ xo_error_h (xo_handle_t *xop, const char *fmt, ...) va_list vap; va_start(vap, fmt); - xo_error_hv(xop, fmt, vap); + xo_errorn_hv(xop, 0, fmt, vap); va_end(vap); } @@ -8082,11 +8103,34 @@ xo_error (const char *fmt, ...) va_list vap; va_start(vap, fmt); - xo_error_hv(NULL, fmt, vap); + xo_errorn_hv(NULL, 0, fmt, vap); va_end(vap); } +void +xo_errorn_h (xo_handle_t *xop, const char *fmt, ...) +{ + va_list vap; + + va_start(vap, fmt); + xo_errorn_hv(xop, 1, fmt, vap); + va_end(vap); +} + /* + * Generate an error message, such as would be displayed on stderr + */ +void +xo_errorn (const char *fmt, ...) +{ + va_list vap; + + va_start(vap, fmt); + xo_errorn_hv(NULL, 1, fmt, vap); + va_end(vap); +} + +/* * Parse any libxo-specific options from the command line, removing them * so the main() argument parsing won't see them. We return the new value * for argc or -1 for error. If an error occurred, the program should @@ -8099,21 +8143,30 @@ xo_parse_args (int argc, char **argv) char *cp; int i, save; - /* Save our program name for xo_err and friends */ - xo_program = argv[0]; - cp = strrchr(xo_program, '/'); - if (cp) - xo_program = ++cp; - else - cp = argv[0]; /* Reset to front of string */ + /* + * If xo_set_program has always been called, we honor that value + */ + if (xo_program == NULL) { + /* Save our program name for xo_err and friends */ + xo_program = argv[0]; + cp = strrchr(xo_program, '/'); + if (cp) + xo_program = ++cp; + else + cp = argv[0]; /* Reset to front of string */ - /* GNU tools add an annoying ".test" as the program extension; remove it */ - size_t len = strlen(xo_program); - static const char gnu_ext[] = ".test"; - if (len >= sizeof(gnu_ext)) { - cp += len + 1 - sizeof(gnu_ext); - if (xo_streq(cp, gnu_ext)) - *cp = '\0'; + /* + * GNU libtool add an annoying ".test" as the program + * extension; we remove it. libtool also adds a "lt-" prefix + * that we cannot remove. + */ + size_t len = strlen(xo_program); + static const char gnu_ext[] = ".test"; + if (len >= sizeof(gnu_ext)) { + cp += len + 1 - sizeof(gnu_ext); + if (xo_streq(cp, gnu_ext)) + *cp = '\0'; + } } xo_handle_t *xop = xo_default(NULL); Modified: projects/clang1000-import/contrib/libxo/libxo/xo.h ============================================================================== --- projects/clang1000-import/contrib/libxo/libxo/xo.h Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/libxo/xo.h Mon Jan 27 20:47:18 2020 (r357179) @@ -389,6 +389,15 @@ xo_error_h (xo_handle_t *xop, const char *fmt, ...); void xo_error (const char *fmt, ...); +void +xo_errorn_hv (xo_handle_t *xop, int need_newline, const char *fmt, va_list vap); + +void +xo_errorn_h (xo_handle_t *xop, const char *fmt, ...); + +void +xo_errorn (const char *fmt, ...); + xo_ssize_t xo_flush_h (xo_handle_t *xop); Modified: projects/clang1000-import/contrib/libxo/libxo/xo_encoder.c ============================================================================== --- projects/clang1000-import/contrib/libxo/libxo/xo_encoder.c Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/libxo/xo_encoder.c Mon Jan 27 20:47:18 2020 (r357179) @@ -290,8 +290,21 @@ xo_encoder_init (xo_handle_t *xop, const char *name) { xo_encoder_setup(); - const char *opts = strchr(name, ':'); + char opts_char = '\0'; + const char *col_opts = strchr(name, ':'); + const char *plus_opts = strchr(name, '+'); + + /* + * Find the option-separating character (plus or colon) which + * appears first in the options string. + */ + const char *opts = (col_opts == NULL) ? plus_opts + : (plus_opts == NULL) ? col_opts + : (plus_opts < col_opts) ? plus_opts : col_opts; + if (opts) { + opts_char = *opts; + /* Make a writable copy of the name */ size_t len = strlen(name); char *copy = alloca(len + 1); @@ -329,7 +342,11 @@ xo_encoder_init (xo_handle_t *xop, const char *name) int rc = xo_encoder_handle(xop, XO_OP_CREATE, name, NULL, 0); if (rc == 0 && opts != NULL) { - rc = xo_encoder_handle(xop, XO_OP_OPTIONS, name, opts, 0); + xo_encoder_op_t op; + + /* Encoder API is limited, so we're stuck with two different options */ + op = (opts_char == '+') ? XO_OP_OPTIONS_PLUS : XO_OP_OPTIONS; + rc = xo_encoder_handle(xop, op, name, opts, 0); } return rc; Modified: projects/clang1000-import/contrib/libxo/libxo/xo_encoder.h ============================================================================== --- projects/clang1000-import/contrib/libxo/libxo/xo_encoder.h Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/libxo/xo_encoder.h Mon Jan 27 20:47:18 2020 (r357179) @@ -90,6 +90,7 @@ typedef unsigned xo_encoder_op_t; #define XO_OP_ATTRIBUTE 15 /* Attribute name/value */ #define XO_OP_VERSION 16 /* Version string */ #define XO_OP_OPTIONS 17 /* Additional command line options */ +#define XO_OP_OPTIONS_PLUS 18 /* Additional command line options */ #define XO_ENCODER_HANDLER_ARGS \ xo_handle_t *xop __attribute__ ((__unused__)), \ Modified: projects/clang1000-import/contrib/libxo/tests/core/Makefile.am ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/Makefile.am Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/Makefile.am Mon Jan 27 20:47:18 2020 (r357179) @@ -88,7 +88,7 @@ TEST_JIG = \ TEST_JIG2 = \ echo "... $$test ... $$fmt ..."; \ -xoopts==warn,encoder=csv$$csv ; \ +xoopts==warn,$$csv ; \ ${TEST_JIG}; true; TEST_FORMATS = T XP JP HP X J H HIPx @@ -111,9 +111,12 @@ test tests: ${bin_PROGRAMS} done) \ done) -@ (${TEST_TRACE} test=test_01.c; base=test_01; \ - ( fmt=Ecsv1; csv= ; ${TEST_JIG2} ); \ - ( fmt=Ecsv2; csv=:path=top/data/item+no-header ; ${TEST_JIG2} ); \ - ( fmt=Ecsv3; csv=:path=item+leafs=sku.sold+no-quotes ; ${TEST_JIG2} ); \ + ( fmt=Ecsv1; csv=encoder=csv ; \ + ${TEST_JIG2} ); \ + ( fmt=Ecsv2; csv=encoder=csv:path=top/data/item:no-header ; \ + ${TEST_JIG2} ); \ + ( fmt=Ecsv3; csv=@csv:path=item:leafs=sku.sold:no-quotes ; \ + ${TEST_JIG2} ); \ ) Modified: projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.H.out ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.H.out Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.H.out Mon Jan 27 20:47:18 2020 (r357179) @@ -4,4 +4,7 @@
length
abcdef
close
-1
returned
Bad file descriptor
good
close
-1
returned
Bad fi
good
improper use of profanity; ten yard penalty; first down
20
30
40
file
0
bytes
1
byte
2
bytes
3
bytes
4
bytes
10
/
20
/
30
mbufs <&> in use (current/cache/total)
50
from
Boston
64
left out of
640
64
left out of
640
beforeworkingafter:
string
:
10
11
1010
packets here/there/everywhere
1010
packets here/there/everywhere
(
15
/
20
/
125
)
(
15
/
20
/
125
)
(
15
/
20
/
125
)
(
15
/
20
/
125
)
Humanize:
21
,
57 K
,
96M
,
44M
,
1.2G
one
two
three
(null)
1:
1000
2:
test5000
3:
ten-longx
4:
xtest
this is an error
two more errors
this is an warning
two more warnings
V1/V2 packets
:
10
0004
tries
improper use of profanity; ten yard penalty; first down
Shut 'er down, Clancey! She's a-pumpin' mud! <>!,"!<> +
err message (1)
err message (2) +
err message (1) +
err message (2)
\ No newline at end of file Modified: projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.HIPx.out ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.HIPx.out Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.HIPx.out Mon Jan 27 20:47:18 2020 (r357179) @@ -225,3 +225,18 @@
Shut 'er down, Clancey! She's a-pumpin' mud! <>!,"!<>
+
+
err message (1)
+
+
+
err message (2) +
+
+
+
err message (1) +
+
+
+
err message (2) +
+
Modified: projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.HP.out ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.HP.out Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.HP.out Mon Jan 27 20:47:18 2020 (r357179) @@ -225,3 +225,18 @@
Shut 'er down, Clancey! She's a-pumpin' mud! <>!,"!<>
+
+
err message (1)
+
+
+
err message (2) +
+
+
+
err message (1) +
+
+
+
err message (2) +
+
Modified: projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.J.out ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.J.out Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.J.out Mon Jan 27 20:47:18 2020 (r357179) @@ -1 +1 @@ -{"top": {"data": {"name":"em0","flags":"0x8843","name":"em0","flags":"0x8843","what":"braces","length":"abcdef","fd":-1,"error":"Bad file descriptor","test":"good","fd":-1,"error":"Bad fi","test":"good","lines":20,"words":30,"characters":40, "bytes": [0,1,2,3,4],"mbuf-current":10,"mbuf-cache":20,"mbuf-total":30,"distance":50,"location":"Boston","memory":64,"total":640,"memory":64,"total":640,"ten":10,"eleven":11,"unknown":1010,"unknown":1010,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"val1":21,"val2":58368,"val3":100663296,"val4":44470272,"val5":1342172800, "flag": ["one","two","three"],"works":null,"empty-tag":true,"t1":"1000","t2":"test5000","t3":"ten-longx","t4":"xtest", "__error": {"message":"this is an error"}, "__error": {"message":"two more errors"}, "__warning": {"message":"this is an warning"}, "__warning": {"message":"two more warnings"},"count":10,"test":4, "error": {"message":"Shut 'er down, Clancey! S he's a-pumpin' mud! <>!,\"!<>\n"}}}} +{"top": {"data": {"name":"em0","flags":"0x8843","name":"em0","flags":"0x8843","what":"braces","length":"abcdef","fd":-1,"error":"Bad file descriptor","test":"good","fd":-1,"error":"Bad fi","test":"good","lines":20,"words":30,"characters":40, "bytes": [0,1,2,3,4],"mbuf-current":10,"mbuf-cache":20,"mbuf-total":30,"distance":50,"location":"Boston","memory":64,"total":640,"memory":64,"total":640,"ten":10,"eleven":11,"unknown":1010,"unknown":1010,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"min":15,"cur":20,"max":125,"val1":21,"val2":58368,"val3":100663296,"val4":44470272,"val5":1342172800, "flag": ["one","two","three"],"works":null,"empty-tag":true,"t1":"1000","t2":"test5000","t3":"ten-longx","t4":"xtest", "__error": {"message":"this is an error"}, "__error": {"message":"two more errors"}, "__warning": {"message":"this is an warning"}, "__warning": {"message":"two more warnings"},"count":10,"test":4, "error": {"message":"Shut 'er down, Clancey! S he's a-pumpin' mud! <>!,\"!<>\n"}, "error": {"message":"err message (1)"}, "error": {"message":"err message (2)\n"}, "error": {"message":"err message (1)\n"}, "error": {"message":"err message (2)\n"}}}} Modified: projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.JP.out ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.JP.out Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.JP.out Mon Jan 27 20:47:18 2020 (r357179) @@ -80,6 +80,18 @@ "test": 4, "error": { "message": "Shut 'er down, Clancey! She's a-pumpin' mud! <>!,\"!<>\n" + }, + "error": { + "message": "err message (1)" + }, + "error": { + "message": "err message (2)\n" + }, + "error": { + "message": "err message (1)\n" + }, + "error": { + "message": "err message (2)\n" } } } Modified: projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.T.err ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.T.err Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.T.err Mon Jan 27 20:47:18 2020 (r357179) @@ -1,2 +1,5 @@ test_02: key field emitted after normal value field: 'name' Shut 'er down, Clancey! She's a-pumpin' mud! <>!,"!<> +err message (1)err message (2) +err message (1) +err message (2) Modified: projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.X.out ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.X.out Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.X.out Mon Jan 27 20:47:18 2020 (r357179) @@ -4,4 +4,7 @@ abcdef-1Bad file descriptorgood-1Bad figoodimproper use of profanity; ten yard penalty; first down 2030400123410203050Boston646406464010111010101015201251520125152012515201252158368100663296444702721342172800onetwothreenull1000test5000ten-longxxtest<__error>this is an error<__error>two more er rors<__warning>this is an warning<__warning>two more warnings104improper use of profanity; ten yard penalty; first down Shut 'er down, Clancey! She's a-pumpin' mud! <>!,"!<> +err message (1)err message (2) +err message (1) +err message (2) \ No newline at end of file Modified: projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.XP.out ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.XP.out Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/saved/test_02.XP.out Mon Jan 27 20:47:18 2020 (r357179) @@ -87,5 +87,20 @@ Shut 'er down, Clancey! She's a-pumpin' mud! <>!,"!<> + + err message (1) + + + err message (2) + + + + err message (1) + + + + err message (2) + + Modified: projects/clang1000-import/contrib/libxo/tests/core/test_02.c ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/test_02.c Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/test_02.c Mon Jan 27 20:47:18 2020 (r357179) @@ -21,6 +21,8 @@ int main (int argc, char **argv) { + xo_set_program("test_02"); + argc = xo_parse_args(argc, argv); if (argc < 0) return 1; @@ -144,6 +146,10 @@ main (int argc, char **argv) "ten yard penalty", "first down"); xo_error("Shut 'er down, Clancey! She's a-pumpin' mud! <>!,\"!<>\n"); + xo_error("err message (%d)", 1); + xo_error("err message (%d)\n", 2); + xo_errorn("err message (%d)", 1); + xo_errorn("err message (%d)\n", 2); xo_close_container("data"); Modified: projects/clang1000-import/contrib/libxo/tests/core/test_12.c ============================================================================== --- projects/clang1000-import/contrib/libxo/tests/core/test_12.c Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/contrib/libxo/tests/core/test_12.c Mon Jan 27 20:47:18 2020 (r357179) @@ -25,6 +25,8 @@ main (int argc, char **argv) xo_emit_flags_t flags = XOEF_RETAIN; int opt_color = 1; + xo_set_program("test_12"); + argc = xo_parse_args(argc, argv); if (argc < 0) return 1; Modified: projects/clang1000-import/lib/libxo/add.man ============================================================================== --- projects/clang1000-import/lib/libxo/add.man Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/lib/libxo/add.man Mon Jan 27 20:47:18 2020 (r357179) @@ -3,10 +3,10 @@ .Fx uses .Nm libxo -version 1.3.1. +version 1.4.0. Complete documentation can be found on github: .Bd -literal -offset indent -https://juniper.github.io/libxo/1.3.1/html/index.html +https://juniper.github.io/libxo/1.4.0/html/index.html .Ed .Pp .Nm libxo Modified: projects/clang1000-import/lib/libxo/libxo/xo_config.h ============================================================================== --- projects/clang1000-import/lib/libxo/libxo/xo_config.h Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/lib/libxo/libxo/xo_config.h Mon Jan 27 20:47:18 2020 (r357179) @@ -183,16 +183,16 @@ /* #undef LIBXO_TEXT_ONLY */ /* Version number as dotted value */ -#define LIBXO_VERSION "1.3.1" +#define LIBXO_VERSION "1.4.0" /* Version number extra information */ #define LIBXO_VERSION_EXTRA "" /* Version number as a number */ -#define LIBXO_VERSION_NUMBER 1003001 +#define LIBXO_VERSION_NUMBER 1004000 /* Version number as string */ -#define LIBXO_VERSION_STRING "1003001" +#define LIBXO_VERSION_STRING "1004000" /* Enable local wcwidth implementation */ #define LIBXO_WCWIDTH 1 @@ -210,7 +210,7 @@ #define PACKAGE_NAME "libxo" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "libxo 1.3.1" +#define PACKAGE_STRING "libxo 1.4.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "libxo" @@ -219,7 +219,7 @@ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "1.3.1" +#define PACKAGE_VERSION "1.4.0" /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be @@ -236,7 +236,7 @@ /* #undef USE_INT_RETURN_CODES */ /* Version number of package */ -#define VERSION "1.3.1" +#define VERSION "1.4.0" /* Retain hash bucket size */ /* #undef XO_RETAIN_SIZE */ Modified: projects/clang1000-import/sbin/newfs_msdos/mkfs_msdos.c ============================================================================== --- projects/clang1000-import/sbin/newfs_msdos/mkfs_msdos.c Mon Jan 27 20:46:26 2020 (r357178) +++ projects/clang1000-import/sbin/newfs_msdos/mkfs_msdos.c Mon Jan 27 20:47:18 2020 (r357179) @@ -31,10 +31,15 @@ static const char rcsid[] = #endif /* not lint */ #include +#ifdef MAKEFS +/* In the makefs case we only want struct disklabel */ +#include +#else #include #include #include #include +#endif #include #include @@ -285,14 +290,18 @@ mkfs_msdos(const char *fname, const char *dtype, const if (!S_ISREG(sb.st_mode)) warnx("warning, %s is not a regular file", fname); } else { -#ifndef MAKEFS +#ifdef MAKEFS *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***