r55956 - /scripts/patchedit

potyl-guest at users.alioth.debian.org potyl-guest at users.alioth.debian.org
Sun Apr 11 15:18:30 UTC 2010


Author: potyl-guest
Date: Sun Apr 11 15:16:29 2010
New Revision: 55956

URL: http://svn.debian.org/wsvn/?sc=1&rev=55956
Log:
Refactor the patch parsing

Modified:
    scripts/patchedit

Modified: scripts/patchedit
URL: http://svn.debian.org/wsvn/scripts/patchedit?rev=55956&op=diff
==============================================================================
--- scripts/patchedit (original)
+++ scripts/patchedit Sun Apr 11 15:16:29 2010
@@ -256,24 +256,37 @@
 	my $key;
 	my $header_end = 0;
 	while (my $line = <$patch_fh>) {
-		if ($header_end or ($line !~ m/^([^\s]+) : \s+ (.+) $/xms)) {
-			# if the line begins with space it is the value that continues
-			if ((not $header_end) and ($line =~ m/^ /)) {
-				$patch_content{$key} .= $line;
-				next;
-			}
+		
+		if (! $header_end and $line =~ /^--- /) {
+			# Start of the patch body
 			$header_end = 1;
+		}
+
+		if ($header_end) {
+			# Slurping the patch
 			$patch_content{'_patch'} .= $line;
 			next;
 		}
 		
-		$key = $1;
-		my $value = $2;
-		
-		die 'key "_patch" not allowed'
-			if $key eq '_patch';
-		
-		$patch_content{$key} = $value;
+		my $value;
+		if (($key, $value) = $line =~ m/^(\S+) : \s+ (.+) $/xms) {
+			# New field start
+			die 'key "_patch" not allowed'
+				if $key eq '_patch';
+		
+			$patch_content{$key} = $value;
+			next;
+		}
+
+		if ($line =~ m/^ /) {
+			# Previous field not over
+			$patch_content{$key} .= $line;
+			next;
+		}
+		
+		# End of header but not yet the start of patch (before ---) 
+		$header_end = 1;
+		$patch_content{'_patch'} .= $line;
 	}
 	close($patch_fh);
 	




More information about the Pkg-perl-cvs-commits mailing list