[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Quilt-dev] merging with upstream and adding new files
From: |
Andreas Gruenbacher |
Subject: |
Re: [Quilt-dev] merging with upstream and adding new files |
Date: |
Sun, 12 Jun 2005 22:41:05 +0200 |
User-agent: |
KMail/1.7.1 |
On Sunday 12 June 2005 21:40, Jean Delvare wrote:
> > if (/^@@ -(\d+)(?:,(\d+)) \+(\d+)(?:,(\d+)) @@/) {
> > my ($ln, $n, $lr) = ($2 || 1, $3, $4 || 1);
>
> I'm a bit confused by this regular expression. Why are you using the
> "?:" construct?
The 2nd and 4th parentheses are not counted with (?:...); they are used for
grouping only.
> Also, how could $2 or $4 be undefined? To me, the following is equivalent
and more efficient:
>
> if (/^@@ -\d+,(\d+) \+(\d+),(\d+) @@/) {
> my ($ln, $n, $lr) = ($1, $2, $3);
>
> But I am certainly missing something...
The line ranges can be of the form \d+ or \d+,\d+. Example:
diff -U0 <(echo 'a') <(echo 'b'; echo 'c')
[...]
@@ -1 +1,2 @@
-a
+b
+c
My first version got the 0 case wrong though.
> Also, I think that the name $n is somewhat error prone, as it works with
> $lr, not $ln (which themselves aren't exactly explicit variable names).
;)
> > print "Removing trailing whitespace from line(s) ",
> > join(', ', (keys %lines)), " of $file\n";
>
> Sorting the keys would be more user friendly. Also, I am not sure that
> using a hash for this is good. Since you're adding the line numbers in
> order, and need them in the same order, a simple list and push+shift
> should work, and should be more efficient. Unless unified diffs are
> allowed not have their changes in random order?
Lists are somewhat simpler here, yes.
> I am also wondering if a forced pop followed by a push when a refresh
> strips whitespace wouldn't be just as efficient, and cheaper (as far as
> code goes)?
I'd rather not. The script has a fair chance of doing the right thing when
refreshing a patch that is not on top. With pop+push this would get nasty.
-- Andreas.
- Re: [Quilt-dev] merging with upstream and adding new files, Jean Delvare, 2005/06/02
- Re: [Quilt-dev] merging with upstream and adding new files, jerome lacoste, 2005/06/02
- Re: [Quilt-dev] merging with upstream and adding new files, Jean Delvare, 2005/06/03
- Re: [Quilt-dev] merging with upstream and adding new files, jerome lacoste, 2005/06/12
- Re: [Quilt-dev] merging with upstream and adding new files, Andreas Gruenbacher, 2005/06/12
- Re: [Quilt-dev] merging with upstream and adding new files, Jean Delvare, 2005/06/12
- Re: [Quilt-dev] merging with upstream and adding new files, Andreas Gruenbacher, 2005/06/12
- Re: [Quilt-dev] merging with upstream and adding new files, Jean Delvare, 2005/06/12
- Re: [Quilt-dev] merging with upstream and adding new files,
Andreas Gruenbacher <=
- Re: [Quilt-dev] merging with upstream and adding new files, Jean Delvare, 2005/06/12
- Re: [Quilt-dev] merging with upstream and adding new files, Andreas Gruenbacher, 2005/06/12