From e9d495346765b24a29f4856dd99db079593ff095 Mon Sep 17 00:00:00 2001 From: dteske Date: Mon, 1 Feb 2016 00:44:29 +0000 Subject: [PATCH] MFC revisions 294860,294862,294892-294893,294922 r294860: Add keep_tite configuration option r294862: Bump copyrights r294892: Remove unused function prototype r294893: Fix a crash if `-D' is used without `-t title' r294922: Fix fatal warn when compiling under GCC 5.2.0 Approved by: re (marius) --- lib/libdpv/dialog_util.c | 7 +++++++ lib/libdpv/dialog_util.h | 1 - lib/libdpv/dpv.3 | 5 +++-- lib/libdpv/dpv.c | 7 +++++-- lib/libdpv/dpv.h | 3 ++- lib/libdpv/dpv_private.h | 3 ++- sys/sys/param.h | 2 +- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/libdpv/dialog_util.c b/lib/libdpv/dialog_util.c index d047a25e5ae3..21baf98606fb 100644 --- a/lib/libdpv/dialog_util.c +++ b/lib/libdpv/dialog_util.c @@ -261,6 +261,13 @@ dialog_spawn_gauge(char *init_prompt, pid_t *pid) errx(EXIT_FAILURE, "Out of memory?!"); sprintf(dargv[n++], "--title"); dargv[n++] = title; + } else { + if ((dargv[n] = malloc(8)) == NULL) + errx(EXIT_FAILURE, "Out of memory?!"); + sprintf(dargv[n++], "--title"); + if ((dargv[n] = malloc(1)) == NULL) + errx(EXIT_FAILURE, "Out of memory?!"); + *dargv[n++] = '\0'; } if (backtitle != NULL) { if ((dargv[n] = malloc(12)) == NULL) diff --git a/lib/libdpv/dialog_util.h b/lib/libdpv/dialog_util.h index e279c3f0621a..b0c73c52e446 100644 --- a/lib/libdpv/dialog_util.h +++ b/lib/libdpv/dialog_util.h @@ -55,7 +55,6 @@ extern int dheight, dwidth; __BEGIN_DECLS uint8_t dialog_prompt_nlstate(const char *_prompt); -void dialog_gauge_free(void); void dialog_maxsize_free(void); char *dialog_prompt_lastline(char *_prompt, uint8_t _nlstate); int dialog_maxcols(void); diff --git a/lib/libdpv/dpv.3 b/lib/libdpv/dpv.3 index 4779540bcdcc..97461eb4105e 100644 --- a/lib/libdpv/dpv.3 +++ b/lib/libdpv/dpv.3 @@ -1,4 +1,4 @@ -.\" Copyright (c) 2013-2015 Devin Teske +.\" Copyright (c) 2013-2016 Devin Teske .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd Oct 22, 2015 +.Dd Jan 26, 2016 .Dt DPV 3 .Os .Sh NAME @@ -64,6 +64,7 @@ argument contains the following properties for configuring global display features: .Bd -literal -offset indent struct dpv_config { + uint8_t keep_tite; /* Cleaner exit for scripts */ enum dpv_display display_type; /* Def. DPV_DISPLAY_LIBDIALOG */ enum dpv_output output_type; /* Default DPV_OUTPUT_NONE */ int debug; /* Enable debug on stderr */ diff --git a/lib/libdpv/dpv.c b/lib/libdpv/dpv.c index d3506ca9d82d..8ac39b10f86c 100644 --- a/lib/libdpv/dpv.c +++ b/lib/libdpv/dpv.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013-2014 Devin Teske + * Copyright (c) 2013-2016 Devin Teske * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -69,6 +69,7 @@ long long dpv_overall_read = 0; static char pathbuf[PATH_MAX]; /* Extra display information */ +uint8_t keep_tite = FALSE; /* dpv_config.keep_tite */ uint8_t no_labels = FALSE; /* dpv_config.options & DPV_NO_LABELS */ uint8_t wide = FALSE; /* dpv_config.options & DPV_WIDE_MODE */ char *aprompt = NULL; /* dpv_config.aprompt */ @@ -150,6 +151,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list) dialog_updates_per_second = DIALOG_UPDATES_PER_SEC; display_limit = DISPLAY_LIMIT_DEFAULT; display_type = DPV_DISPLAY_LIBDIALOG; + keep_tite = FALSE; label_size = LABEL_SIZE_DEFAULT; msg_done = NULL; msg_fail = NULL; @@ -193,6 +195,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list) dialog_updates_per_second = config->dialog_updates_per_second; display_limit = config->display_limit; display_type = config->display_type; + keep_tite = config->keep_tite; label_size = config->label_size; msg_done = (char *)config->msg_done; msg_fail = (char *)config->msg_fail; @@ -695,7 +698,7 @@ dpv(struct dpv_config *config, struct dpv_file_node *file_list) close(dialog_out); waitpid(pid, (int *)NULL, 0); } - if (!dpv_interrupt) + if (!keep_tite && !dpv_interrupt) printf("\n"); } else warnx("%s: %lli overall read", __func__, dpv_overall_read); diff --git a/lib/libdpv/dpv.h b/lib/libdpv/dpv.h index 03768a7ced40..a79962b3a624 100644 --- a/lib/libdpv/dpv.h +++ b/lib/libdpv/dpv.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013-2014 Devin Teske + * Copyright (c) 2013-2016 Devin Teske * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,6 +97,7 @@ struct dpv_file_node { * Anatomy of config option to pass as dpv() config argument */ struct dpv_config { + uint8_t keep_tite; /* Prevent visually distracting exit */ enum dpv_display display_type; /* Display (default TYPE_LIBDIALOG) */ enum dpv_output output_type; /* Output (default TYPE_NONE) */ int debug; /* Enable debugging output on stderr */ diff --git a/lib/libdpv/dpv_private.h b/lib/libdpv/dpv_private.h index 5164eb321ed2..fd4734c330da 100644 --- a/lib/libdpv/dpv_private.h +++ b/lib/libdpv/dpv_private.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2013-2014 Devin Teske + * Copyright (c) 2013-2016 Devin Teske * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,6 +38,7 @@ extern uint8_t debug; extern unsigned int dpv_nfiles; /* Extra display information */ +extern uint8_t keep_tite; extern uint8_t no_labels; extern uint8_t wide; extern char *msg_done, *msg_fail, *msg_pending; diff --git a/sys/sys/param.h b/sys/sys/param.h index 1fd1313f938f..f1786f47d177 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1002508 /* Master, propagated to newvers */ +#define __FreeBSD_version 1002509 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,