public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sven Eden" <sven.eden@gmx.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/ufed:master commit in: /
Date: Sat, 19 Jan 2013 21:43:35 +0000 (UTC)	[thread overview]
Message-ID: <1358493776.f6cc45aff1e8011bd496908ce3f2afc0c5ee2e46.yamakuzure@gentoo> (raw)

commit:     f6cc45aff1e8011bd496908ce3f2afc0c5ee2e46
Author:     Sven Eden <sven.eden <AT> gmx <DOT> de>
AuthorDate: Fri Jan 18 07:22:56 2013 +0000
Commit:     Sven Eden <sven.eden <AT> gmx <DOT> de>
CommitDate: Fri Jan 18 07:22:56 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=f6cc45af

The following changes are made:

1. Removed the "Local Flag: " prefix for flag descriptions
2. Added [x] prefix for all descriptions with the following meanings:
  g = global flag
  l = local flag, package not installed
  L = local flag, package is installed
  m = masked flag (package not installed if local)
  M = masked flag package is installed
3. Moved affected packages list of local flags to the front.

This is a preparation to add local/global and installed/uninstalled
filters.

The display, as it now is, is not pretty. I am not happy with the
static description line.

It is important to add a destinction between a globally masked flag,
and a locally masked flag. Further the prefix [x] is a) ugly and
b) must not scroll. It should be moved to the static left side,
getting its own column.

---
 ufed-curses-checklist.c |   57 +++++++++++++++++++++++++++++++++--------------
 ufed-curses.h           |    2 +
 ufed.pl.in              |   53 ++++++++++++++++++++++++++++++-------------
 3 files changed, 79 insertions(+), 33 deletions(-)

diff --git a/ufed-curses-checklist.c b/ufed-curses-checklist.c
index 8461ffb..176ceca 100644
--- a/ufed-curses-checklist.c
+++ b/ufed-curses-checklist.c
@@ -11,6 +11,19 @@
 
 #include "ufed-curses-help.h"
 
+#define DEBUG_EXIT 1
+
+#if defined(DEBUG_EXIT)
+#  define ERROR_EXIT(code, fmt, ...) { \
+	fprintf(stderr, "ERROR in %s:%d (%s): \n -> ", \
+		__FILE__, __LINE__, __FUNCTION__); \
+	fprintf(stderr, fmt, __VA_ARGS__); \
+	exit(code); \
+}
+#else
+#  define ERROR_EXIT(code, ...) { exit(code); }
+#endif // DEBUG_EXIT
+
 /* internal types */
 struct flag {
 	struct item item;
@@ -54,9 +67,9 @@ static char *getline(FILE *fp) {
 
 	size = LINE_MAX;
 	result = malloc(size);
-	if(result==NULL)
-		exit(-1);
-	if(fgets(result, size, fp)==NULL)
+	if(result == NULL)
+		ERROR_EXIT(-1, "Can not allocate %lu bytes\n", sizeof(char) * size);
+	if(fgets(result, size, fp) == NULL)
 		return NULL;
 	{
 		char *p = strchr(result, '\n');
@@ -68,8 +81,8 @@ static char *getline(FILE *fp) {
 	}
 	for(;;) {
 		result = realloc(result, size+size/2);
-		if(result==NULL)
-			exit(-1);
+		if(result == NULL)
+			ERROR_EXIT(-1, "Can not reallocate %lu bytes\n", (size_t)(sizeof(char) * size * 1.5));
 		if(fgets(result+size, size/2, fp)==NULL)
 			return NULL;
 		{
@@ -91,7 +104,7 @@ static void read_flags(void) {
 	int y=0;
 
 	if(input==NULL)
-		exit(-1);
+		ERROR_EXIT(-1, "fdopen failed with error %d\n", errno);
 	atexit(&free_flags);
 	for(;;) {
 		struct {
@@ -107,10 +120,10 @@ static void read_flags(void) {
 				&on.start,    &on.end,
 				&state.start, &state.end,
 				&ndescr)!=1)
-			exit(-1);
+			ERROR_EXIT(-1, "sscanf failed on line\n\"%s\"\n", line);
 		flag = malloc(sizeof *flag + ndescr * sizeof *flag->descr);
 		if(flag==NULL)
-			exit(-1);
+			ERROR_EXIT(-1, "Can not allocate %lu bytes\n", sizeof *flag + ndescr * sizeof *flag->descr);
 		flag->item.top = y;
 
 		line[name.end] = '\0';
@@ -120,19 +133,14 @@ static void read_flags(void) {
 
 		/* check and save current flag setting from configuration */
 		line[on.end] = '\0';
-		flag->item.isMasked = false;
 		if(!strcmp(&line[on.start], "on"))
 			flag->on = '+';
 		else if(!strcmp(&line[on.start], "off"))
 			flag->on = '-';
 		else if(!strcmp(&line[on.start], "def"))
 			flag->on = ' ';
-		else if(!strcmp(&line[on.start], "msk")) {
-			flag->on = 'm';
-			flag->item.isMasked = true;
-		}
 		else
-			exit(-1);
+			ERROR_EXIT(-1, "flag->on can not be determined with \"%s\"\n", &line[on.start]);
 
 		/* record first not masked y if not done, yet */
 		if (firstNormalY < 0 && !flag->item.isMasked)
@@ -141,14 +149,29 @@ static void read_flags(void) {
 		/* check and set flag state */
 		line[state.end] = '\0';
 		if(state.end-state.start != 4)
-			exit(-1);
+			ERROR_EXIT(-1, "state.end - state.start is %d (must be 4)\n", state.end - state.start);
 		flag->state = &line[state.start];
 
 		/* check and set flag item height */
 		flag->item.height = ndescr;
-		{ int i; for(i=0; i<ndescr; i++) {
+
+		/* read description(s) and determine flag status */
+		flag->item.isMasked    = false;
+		flag->item.isGlobal    = false;
+		flag->item.isInstalled = false;
+		for (int i = 0; i < ndescr; ++i) {
 			flag->descr[i] = getline(input);
-		} }
+			if ('g' == flag->descr[i][1])
+				flag->item.isGlobal = true;
+			else if ('L' == flag->descr[i][1])
+				flag->item.isInstalled = true;
+			else if ('M' == flag->descr[i][1]) {
+				flag->item.isMasked = true;
+				flag->item.isInstalled = true;
+			}
+			else if ('m' == flag->descr[i][1])
+				flag->item.isMasked = true;
+		}
 
 		y += ndescr;
 

diff --git a/ufed-curses.h b/ufed-curses.h
index 03bb62a..81ee779 100644
--- a/ufed-curses.h
+++ b/ufed-curses.h
@@ -16,6 +16,8 @@ struct item {
 	struct item *prev, *next;
 	int top, height;
 	bool isMasked;
+	bool isGlobal;
+	bool isInstalled;
 };
 
 struct key {

diff --git a/ufed.pl.in b/ufed.pl.in
index bdcfb91..9b1263e 100644
--- a/ufed.pl.in
+++ b/ufed.pl.in
@@ -40,17 +40,22 @@ for(@Portage::archs) {
 	delete $Portage::all_flags{$_};
 	delete $use_descriptions{$_};
 }
-for(keys %Portage::use_masked_flags) {
+for my $flag (keys %Portage::use_masked_flags) {
 	my $masked = 1;
-	for(values %{$Portage::use_masked_flags{$_}}) {
-		last if not($masked &&= $_);
+	for my $mask (values %{$Portage::use_masked_flags{$flag}}) {
+		last if not($masked &&= $mask);
 	}
 	if($masked) {
-		@{$masked_descriptions{$_}} = @{$use_descriptions{$_}}
-			if (defined($use_descriptions{$_}));
-		delete $Portage::default_flags{$_};
-		delete $Portage::all_flags{$_};
-		delete $use_descriptions{$_};
+		if (defined($use_descriptions{$flag})) {
+			@{$masked_descriptions{$flag}} = @{$use_descriptions{$flag}};
+			for (my $i = 0; $i < scalar @{$masked_descriptions{$flag}}; ++$i) {
+				$masked_descriptions{$flag}->[$i] =~ s/^\[[lg]\]/[m]/ ;
+				$masked_descriptions{$flag}->[$i] =~ s/^\[L\]/[M]/ ;
+			}
+		}
+		delete $use_descriptions{$flag};
+		delete $Portage::default_flags{$flag};
+		delete $Portage::all_flags{$flag};
 	}
 }
 
@@ -101,7 +106,9 @@ sub flags_dialog {
 
 	# Write masked flags first so they sort at the beginning of the list
 	for my $flag (sort { uc $a cmp uc $b } keys %masked_descriptions) {
-		$outTxt .= sprintf ("(%s) msk (%s%s) %d\n", $flag,
+		$outTxt .= sprintf ("(%s) %s (%s%s) %d\n", $flag,
+					defined($Portage::make_conf_flags{$flag})
+						? $Portage::make_conf_flags{$flag} ? 'on' : 'off' : 'def',
 					exists($Portage::make_defaults_flags{$flag})
 						? $Portage::make_defaults_flags{$flag} ? '+' : '-' : ' ',
 					exists($Portage::make_conf_flags{$flag})
@@ -114,7 +121,7 @@ sub flags_dialog {
 	for my $flag (sort { uc $a cmp uc $b } keys %use_descriptions) {
 		$outTxt .= sprintf ("%s %s (%s%s) %d\n", $flag,
 					defined($Portage::make_conf_flags{$flag})
-						? $Portage::make_conf_flags{$flag} ? ' on ' : ' off ' : ' def ',
+						? $Portage::make_conf_flags{$flag} ? 'on' : 'off' : 'def',
 					exists($Portage::make_defaults_flags{$flag})
 						? $Portage::make_defaults_flags{$flag} ? '+' : '-' : ' ',
 					exists($Portage::make_conf_flags{$flag})
@@ -172,12 +179,26 @@ sub read_use_descs {
 			$_use_local_descriptions{$flag}{$desc}{$pkg} = 1;
 		}
 	}
-	local $"=", ";
-	for(sort keys %_use_descriptions)
-	{ @{$use_descriptions{$_}} = sort keys %{$_use_descriptions{$_}} }
-	for(sort keys %_use_local_descriptions) {
-		for my $desc(sort keys %{$_use_local_descriptions{$_}})
-		{ push @{$use_descriptions{$_}}, "Local flag: $desc (@{[sort keys %{$_use_local_descriptions{$_}{$desc}}]})" }
+	# Record all global flags first, their description is printed first
+	# in the ncurses interface as well.
+	for my $key (sort keys %_use_descriptions) {
+		for my $desc (sort keys %{$_use_descriptions{$key}}) {
+			push @{$use_descriptions{$key}}, "[g] " . $desc;
+		}
+	}
+
+	# Add local flags
+	for my $key (sort keys %_use_local_descriptions) {
+		for my $desc (sort keys %{$_use_local_descriptions{$key}}) {
+			my $flagPrefix = "l";
+			my @pkgs = ();
+			for my $pkg (sort keys %{$_use_local_descriptions{$key}{$desc}}) {
+				$flagPrefix = "L" if (Portage::have_package($pkg));
+				push @pkgs, $pkg;
+			}
+			local $"=", ";
+			push @{$use_descriptions{$key}}, sprintf("[%s] (%s) %s", $flagPrefix, "@pkgs", $desc);
+		}
 	}
 	return;
 }


             reply	other threads:[~2013-01-19 21:43 UTC|newest]

Thread overview: 238+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-19 21:43 Sven Eden [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-11-07 14:25 [gentoo-commits] proj/ufed:master commit in: / Sven Eden
2020-05-02  8:38 Ulrich Müller
2019-09-27  6:42 Sven Eden
2019-09-27  6:39 Sven Eden
2019-09-24 17:57 Sven Eden
2019-09-24 17:56 Sven Eden
2019-04-07 15:17 David Seifert
2019-04-07 13:56 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2019-04-07 13:19 David Seifert
2015-02-12 15:47 Sven Eden
2015-02-11  9:03 Sven Eden
2014-11-10  9:59 Sven Eden
2014-10-28 11:43 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-26 10:26 Sven Eden
2014-02-25  8:18 Sven Eden
2014-02-25  8:18 Sven Eden
2014-02-25  8:18 Sven Eden
2014-02-25  8:18 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-11-25 21:43 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-20  8:30 Sven Eden
2013-09-11  7:09 Sven Eden
2013-09-11  6:31 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-11  6:04 Sven Eden
2013-09-10 12:37 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-09-10  6:36 Sven Eden
2013-07-22  9:34 Sven Eden
2013-07-22  6:09 Sven Eden
2013-07-22  6:09 Sven Eden
2013-04-09  7:22 Sven Eden
2013-04-09  7:22 Sven Eden
2013-04-09  7:22 Sven Eden
2013-04-08  7:18 Sven Eden
2013-04-03 13:39 Sven Eden
2013-03-05 16:53 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-03-05 16:49 Sven Eden
2013-02-21 10:02 Sven Eden
2013-02-19 15:16 Sven Eden
2013-02-19 13:34 Sven Eden
2013-02-18  7:22 Sven Eden
2013-02-15  8:36 Sven Eden
2013-02-15  8:36 Sven Eden
2013-02-15  8:36 Sven Eden
2013-02-14  8:35 Sven Eden
2013-02-14  8:35 Sven Eden
2013-02-14  8:35 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-13  9:23 Sven Eden
2013-02-12 10:51 Sven Eden
2013-02-12 10:51 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-12  9:01 Sven Eden
2013-02-06  9:09 Sven Eden
2013-02-06  9:09 Sven Eden
2013-02-05 18:06 Paul Varner
2013-02-05 13:53 Sven Eden
2013-02-05 13:53 Sven Eden
2013-02-05 11:24 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-03 14:32 Sven Eden
2013-02-02 20:49 Sven Eden
2013-02-02 10:11 Sven Eden
2013-02-02  9:47 Sven Eden
2013-02-02  9:47 Sven Eden
2013-02-02  9:47 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 21:12 Sven Eden
2013-02-01 16:04 Sven Eden
2013-02-01 15:55 Sven Eden
2013-02-01 15:26 Sven Eden
2013-02-01 14:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-02-01 10:49 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-24 10:15 Sven Eden
2013-01-23 14:44 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-23 12:05 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-19 21:43 Sven Eden
2013-01-16 13:43 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-16 12:56 Sven Eden
2013-01-08 11:02 Sven Eden
2013-01-02  8:47 Sven Eden
2013-01-02  8:01 Sven Eden
2013-01-02  8:01 Sven Eden
2012-11-20 17:31 Paul Varner
2012-11-20 17:25 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:13 Paul Varner
2012-10-23 16:01 Paul Varner
2012-10-22 20:42 Paul Varner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358493776.f6cc45aff1e8011bd496908ce3f2afc0c5ee2e46.yamakuzure@gentoo \
    --to=sven.eden@gmx.de \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox