r55992 - /scripts/patchedit
jozef-guest at users.alioth.debian.org
jozef-guest at users.alioth.debian.org
Mon Apr 12 07:49:51 UTC 2010
Author: jozef-guest
Date: Mon Apr 12 07:49:46 2010
New Revision: 55992
URL: http://svn.debian.org/wsvn/?sc=1&rev=55992
Log:
Detect dpatch files (can't be handled yet)
Modified:
scripts/patchedit
Modified: scripts/patchedit
URL: http://svn.debian.org/wsvn/scripts/patchedit?rev=55992&op=diff
==============================================================================
--- scripts/patchedit (original)
+++ scripts/patchedit Mon Apr 12 07:49:46 2010
@@ -253,10 +253,39 @@
my %patch_content;
open(my $patch_fh, '<', $patch) or die 'failed to open "'.$patch.'" - '.$!;
+
+ # Peek at the first line and see if we are dealing with a normal patch or with
+ # dpatch. We assume that if the file starts with a shebang (#!) that we are
+ # dealing with dpatch.
+ my $use_classic = 1;
+ my $line = <$patch_fh>;
+ if ($line =~ /^#!/) {
+ $use_classic = 0;
+ }
+
+ # Rewind the file handle back to the beeking.
+ seek $patch_fh, 0, 0;
+
+ my $patch_content;
+ if ($use_classic) {
+ $patch_content = _read_patch_classic($patch_fh);
+ }
+ else {
+ die "Dpatch is not yet supported";
+ }
+ close($patch_fh);
+
+ return $patch_content;
+}
+
+sub _read_patch_classic {
+ my ($patch_fh) = @_;
+
+ my %patch_content;
my $key = '';
my $header_end = 0;
while (my $line = <$patch_fh>) {
-
+
if (! $header_end and $line =~ /^--- /) {
# Start of the patch body
$header_end = 1;
@@ -289,7 +318,6 @@
$header_end = 1;
$patch_content{'_patch'} .= $line;
}
- close($patch_fh);
# remove the first empty line (will be added automaticaly)
$patch_content{'_patch'} =~ s/\A\s+//xms;
More information about the Pkg-perl-cvs-commits
mailing list