summary refs log tree commit diff
path: root/clients/cli/utils.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2018-04-23 18:00:21 +0200
committerMichael Biebl <biebl@debian.org>2018-04-23 18:00:21 +0200
commitf60117b41d5433be1b4a96d82cd11d0c3dce9b63 (patch)
tree2dd55c4ab0fdcbe9cddb26adb4a554b1a45c73c8 /clients/cli/utils.c
parent7e9ff09fcb2366b383b7ebbec80d2f6fff117290 (diff)
New upstream version 1.11.3 upstream/1.11.3
Diffstat (limited to 'clients/cli/utils.c')
-rw-r--r--clients/cli/utils.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/clients/cli/utils.c b/clients/cli/utils.c
index f20e24ce..71fdcf30 100644
--- a/clients/cli/utils.c
+++ b/clients/cli/utils.c
@@ -75,6 +75,7 @@ _meta_type_nmc_generic_info_get_fcn (const NMMetaAbstractInfo *abstract_info,
                                      NMMetaAccessorGetType get_type,
                                      NMMetaAccessorGetFlags get_flags,
                                      NMMetaAccessorGetOutFlags *out_flags,
+                                     gboolean *out_is_default,
                                      gpointer *out_to_free)
 {
 	const NmcMetaGenericInfo *info = (const NmcMetaGenericInfo *) abstract_info;
@@ -97,6 +98,7 @@ _meta_type_nmc_generic_info_get_fcn (const NMMetaAbstractInfo *abstract_info,
 		                      get_type,
 		                      get_flags,
 		                      out_flags,
+		                      out_is_default,
 		                      out_to_free);
 	}
 
@@ -524,7 +526,7 @@ nmc_count_color_escape_chars (const char *start, const char *end)
 			inside = TRUE;
 		if (inside)
 			num++;
-		if (*start == 'm') 
+		if (*start == 'm')
 			inside = FALSE;
 		start++;
 	}
@@ -603,9 +605,14 @@ int
 nmc_string_to_arg_array (const char *line, const char *delim, gboolean unquote,
                          char ***argv, int *argc)
 {
+	gs_free const char **arr0 = NULL;
 	char **arr;
 
-	arr = nmc_strsplit_set (line ? line : "", delim ? delim : " \t", 0);
+	arr0 = nm_utils_strsplit_set (line ?: "", delim ?: " \t");
+	if (!arr0)
+		arr = g_new0 (char *, 1);
+	else
+		arr = g_strdupv ((char **) arr0);
 
 	if (unquote) {
 		int i = 0;
@@ -613,7 +620,7 @@ nmc_string_to_arg_array (const char *line, const char *delim, gboolean unquote,
 		size_t l;
 		const char *quotes = "\"'";
 
-		while (arr && arr[i]) {
+		while (arr[i]) {
 			s = arr[i];
 			l = strlen (s);
 			if (l >= 2) {
@@ -628,7 +635,6 @@ nmc_string_to_arg_array (const char *line, const char *delim, gboolean unquote,
 
 	*argv = arr;
 	*argc = g_strv_length (arr);
-
 	return 0;
 }
 
@@ -998,6 +1004,7 @@ typedef struct {
 	const PrintDataCol *col;
 	const char *title;
 	bool title_to_free:1;
+	bool skip:1;
 	int width;
 } PrintDataHeaderCell;
 
@@ -1096,6 +1103,7 @@ _print_fill (const NmcConfig *nmc_config,
 
 		header_cell->col_idx = col_idx;
 		header_cell->col = col;
+		header_cell->skip = FALSE;
 
 		header_cell->title = nm_meta_abstract_info_get_name (info, TRUE);
 		if (   nmc_config->multiline_output
@@ -1130,10 +1138,11 @@ _print_fill (const NmcConfig *nmc_config,
 		for (i_col = 0; i_col < header_row->len; i_col++) {
 			char *to_free = NULL;
 			PrintDataCell *cell = &cells_line[i_col];
-			const PrintDataHeaderCell *header_cell;
+			PrintDataHeaderCell *header_cell;
 			const NMMetaAbstractInfo *info;
 			NMMetaAccessorGetOutFlags text_out_flags, color_out_flags;
 			gconstpointer value;
+			gboolean is_default;
 
 			header_cell = &g_array_index (header_row, PrintDataHeaderCell, i_col);
 			info = header_cell->col->selection_item->info;
@@ -1148,7 +1157,11 @@ _print_fill (const NmcConfig *nmc_config,
 			                                   text_get_type,
 			                                   text_get_flags,
 			                                   &text_out_flags,
+			                                   &is_default,
 			                                   (gpointer *) &to_free);
+
+			header_cell->skip = nmc_config->overview && is_default;
+
 			if (NM_FLAGS_HAS (text_out_flags, NM_META_ACCESSOR_GET_OUT_FLAGS_STRV)) {
 				if (value) {
 					if (nmc_config->multiline_output) {
@@ -1174,6 +1187,7 @@ _print_fill (const NmcConfig *nmc_config,
 			                                                      NM_META_ACCESSOR_GET_TYPE_TERMFORMAT,
 			                                                      NM_META_ACCESSOR_GET_FLAGS_NONE,
 			                                                      &color_out_flags,
+			                                                      NULL,
 			                                                      NULL),
 			                           &cell->term_color,
 			                           &cell->term_format);
@@ -1231,6 +1245,9 @@ _print_skip_column (const NmcConfig *nmc_config,
 	selection_item = header_cell->col->selection_item;
 	info = selection_item->info;
 
+	if (header_cell->skip)
+		return TRUE;
+
 	if (nmc_config->multiline_output) {
 		if (info->meta_type == &nm_meta_type_setting_info_editor) {
 			/* we skip the "name" entry for the setting in multiline output. */