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: Mon, 25 Nov 2013 21:43:26 +0000 (UTC)	[thread overview]
Message-ID: <1385366639.49b8c6c96781d7d70662231b1a699701b3e4be15.yamakuzure@gentoo> (raw)

commit:     49b8c6c96781d7d70662231b1a699701b3e4be15
Author:     Sven Eden <yamakuzure <AT> gmx <DOT> net>
AuthorDate: Mon Nov 25 08:03:59 2013 +0000
Commit:     Sven Eden <sven.eden <AT> gmx <DOT> de>
CommitDate: Mon Nov 25 08:03:59 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/ufed.git;a=commit;h=49b8c6c9

Added error messages and reporting of those if the file parsing failes.

---
 Portage.pm | 13 +++++++------
 ufed.pl.in | 43 ++++++++++++++++++++++++++++++-------------
 2 files changed, 37 insertions(+), 19 deletions(-)

diff --git a/Portage.pm b/Portage.pm
index dc7b964..e9edaab 100644
--- a/Portage.pm
+++ b/Portage.pm
@@ -953,14 +953,14 @@ sub _read_sh {
 			for(;;) {
 				/\G$BLANK/gc;
 				last if ((pos || 0) == (length || 0));
-				/\G$IDENT/gc or die;
+				/\G$IDENT/gc or die "Empty file detected, no identifier found.";
 				my $name = $1;
 				/\G$BLANK/gc;
 				if($name ne 'source') {
-				/\G$ASSIG/gc or die;
+				/\G$ASSIG/gc or die "Bare keyword $name detected.";
 				/\G$BLANK/gc;
 				}
-				die if pos == length;
+				pos == length and die "Bumped into unexpected EOF after $name.";
 				my $value = '';
 				for(;;) {
 					if(/\G$UQVAL/gc || /\G$DQVAL/gc) {
@@ -989,17 +989,18 @@ sub _read_sh {
 					substr($_, pos, 0) = do {
 						local $/;
 						my $text = <$f>;
-						die if not defined $text;
+						defined $text or die "Error parsing $value";
 						$text;
 					};
 					pos = $pos;
-					close $f or die "Unable to open $value\n$!\n";
+					close $f or die "Unable to close $value\n$!\n";
 				} else {
 				$env{$name} = $value;
 				}
 			}
 		};
-		die "Parse error in $fname\n" if $@;
+		defined($@) and length($@) and
+			die "Parse error in $fname\n - Error: \"$@\"\n";
 	}
 	_merge_env(\%env);
 	return %env if wantarray;

diff --git a/ufed.pl.in b/ufed.pl.in
index be20b02..37f7957 100644
--- a/ufed.pl.in
+++ b/ufed.pl.in
@@ -213,31 +213,36 @@ sub save_flags {
 				my $line = substr($_, $linestart, pos()-$linestart);
 				$line !~ /[^ \t]/;
 			};
-			/\G$IDENT/gc or die;
+			/\G$IDENT/gc or die "No identifier found to start with.";
 			my $name = $1;
 			/\G$BLANK/gc;
 			if($name ne 'source') {
-			/\G$ASSIG/gc or die;
-			/\G$BLANK/gc;
+				/\G$ASSIG/gc or die "Identifier $name without assignement detected.";
+				/\G$BLANK/gc;
 			} else {
 				$sourcing = 1;
 			}
-			die if pos == length;
+			pos == length and die "Bumped into early EOF.";
 			if($name ne 'USE') {
-				/\G(?:$UQVAL|$SQVAL|$DQVAL)+/gc or die;
+				/\G(?:$UQVAL|$SQVAL|$DQVAL)+/gc or die "Blank assignement for $name detected.";
 			} else {
 				my $start = pos;
-				/\G(?:$BNUQV|$SQVAL|$BNDQV)+/gc or die;
+				m/\G(?:$BNUQV|$SQVAL|$BNDQV)+/gc or die "Empty USE assignement detected.";
 				my $end = pos;
+
 				# save whether user uses backslash-newline
 				my $bsnl = defined $1 || defined $2;
+
 				# start of the line is one past the last newline; also handles first line
 				my $linestart = 1+rindex $_, "\n", $start-1;
+
 				# everything on the current line before the USE flags, plus one for the "
 				my $line = substr($_, $linestart, $start-$linestart).' ';
+
 				# only indent if USE starts a line
 				my $blank = $flagatstartofline ? $line : "";
 				$blank =~ s/[^ \t]/ /g;
+
 				# word wrap
 				if(@flags != 0) {
 					my $length = 0;
@@ -251,10 +256,12 @@ sub save_flags {
 						}
 					}
 					my $blanklength = $blank ne '' ? $length : 0;
+
 					# new line, using backslash-newline if the user did that
 					my $nl = ($bsnl ? " \\\n" : "\n").$blank;
 					my $linelength = $bsnl ? 76 : 78;
 					my $flag = $flags[0];
+
 					if($blanklength != 0 || length $flag <= $linelength) {
 						$flags   = $flag;
 						$length += length $flag;
@@ -272,16 +279,22 @@ sub save_flags {
 						}
 					}
 				}
+
 				# replace the current USE flags with the modified ones
 				substr($_, $start, $end-$start) = "\"$flags\"";
+
 				# and have the next search start after our new flags
 				pos = $start + 2 + length $flags;
+
 				# and end this
 				undef $flags;
 				last;
 			}
 		}
-		if(defined $flags) { # if we didn't replace the flags, tack them after the last #USE= or at the end
+
+		if(defined $flags) {
+
+			# if we didn't replace the flags, tack them after the last #USE= or at the end
 			$flags = '';
 			if(@flags != 0) {
 				$flags = $flags[0];
@@ -297,21 +310,23 @@ sub save_flags {
 				}
 			}
 			substr($_, $ucs, $uce-$ucs) = "\nUSE=\"$flags\"\n";
-		} else { # if we replaced the flags, delete any further overrides
+		} else {
+
+			# if we replaced the flags, delete any further overrides
 			for(;;) {
 				my $start = pos;
 				/\G$BLANK/gc;
 				last if pos == length;
-				/\G$IDENT/gc or die;
+				/\G$IDENT/gc or die "Identifier detection failed.";
 				my $name = $1;
 				/\G$BLANK/gc;
 				if($name ne 'source') {
-				/\G$ASSIG/gc or die;
-				/\G$BLANK/gc;
+					/\G$ASSIG/gc or die "Identifier $name without assignement detected.";
+					/\G$BLANK/gc;
 				} else {
 					$sourcing = 1;
 				}
-				/\G(?:$UQVAL|$SQVAL|$DQVAL)+/gc or die;
+				m/\G(?:$UQVAL|$SQVAL|$DQVAL)+/gc or die "Empty assignement for $name detected.";
 				my $end = pos;
 				if($name eq 'USE') {
 					substr($_, $start, $end-$start) = '';
@@ -320,7 +335,9 @@ sub save_flags {
 			}
 		}
 	};
-	die "Parse error when writing make.conf - did you modify it while ufed was running?\n" if $@;
+	defined($@) and length($@) and die "\nParse error when writing make.conf"
+		. " - did you modify it while ufed was running?\n"
+		. " - Error: \"$@\"\n";
 
 	print STDERR <<EOF if $sourcing;
 Warning: source command found in $makeconf_name. Flags may


             reply	other threads:[~2013-11-25 21:43 UTC|newest]

Thread overview: 238+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-25 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-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-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=1385366639.49b8c6c96781d7d70662231b1a699701b3e4be15.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