[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-patch] [PATCH] Add --ignorecr option to ignore trailing carriage re
From: |
Simon Derr |
Subject: |
[bug-patch] [PATCH] Add --ignorecr option to ignore trailing carriage returns |
Date: |
Thu, 2 Jul 2009 15:01:18 +0200 (CEST) |
User-agent: |
Alpine 2.00 (DEB 1167 2008-08-23) |
Hello,
The attached patch adds the -w and --ignorecr options to patch.
When used with -l this option will ignore trailing carriage returns.
This can be useful when dealing with dos/unix and text editors (or
users) that arbitrarily add/remove carriage returns.
I don't know whether this should be included in GNU patch but I happened
to need that feature, so I thought I'd make it public.
Regards,
Simon
diff -ur patch-2.5.9/common.h mod/common.h
--- patch-2.5.9/common.h 2003-05-19 08:57:36.000000000 +0200
+++ mod/common.h 2009-07-02 14:29:48.000000000 +0200
@@ -171,6 +171,7 @@
XTERN bool skip_rest_of_patch;
XTERN int strippath;
XTERN bool canonicalize;
+XTERN bool ignorecr;
XTERN int patch_get;
XTERN bool set_time;
XTERN bool set_utc;
diff -ur patch-2.5.9/patch.c mod/patch.c
--- patch-2.5.9/patch.c 2003-05-20 15:55:03.000000000 +0200
+++ mod/patch.c 2009-07-02 14:33:24.000000000 +0200
@@ -482,7 +482,7 @@
skip_rest_of_patch = false;
}
-static char const shortopts[] = "bB:cd:D:eEfF:g:i:lnNo:p:r:RstTuvV:x:Y:z:Z";
+static char const shortopts[] = "bB:cd:D:eEfF:g:i:lnNo:p:r:RstTuvV:wx:Y:z:Z";
static struct option const longopts[] =
{
{"backup", no_argument, NULL, 'b'},
@@ -510,6 +510,7 @@
{"unified", no_argument, NULL, 'u'},
{"version", no_argument, NULL, 'v'},
{"version-control", required_argument, NULL, 'V'},
+ {"ignorecr", no_argument, NULL, 'w'},
{"debug", required_argument, NULL, 'x'},
{"basename-prefix", required_argument, NULL, 'Y'},
{"suffix", required_argument, NULL, 'z'},
@@ -726,6 +727,9 @@
version_control = optarg;
version_control_context = "--version-control or -V option";
break;
+ case 'w':
+ ignorecr = 1;
+ break;
#if DEBUGGING
case 'x':
debug = numeric_string (optarg, true, "debugging option");
@@ -1274,6 +1278,11 @@
alen -= alen && a[alen - 1] == '\n';
blen -= blen && b[blen - 1] == '\n';
+ if (ignorecr) {
+ alen -= alen && a[alen - 1] == '\r';
+ blen -= blen && b[blen - 1] == '\r';
+ }
+
for (;;)
{
if (!blen || (*b == ' ' || *b == '\t'))
diff -ur patch-2.5.9/patch.man mod/patch.man
--- patch-2.5.9/patch.man 2002-05-25 12:36:44.000000000 +0200
+++ mod/patch.man 2009-07-02 14:46:22.000000000 +0200
@@ -653,6 +653,9 @@
\fB\*=verbose\fP
Output extra information about the work being done.
.TP
+\fB\-w\fP or \fB\*=ignorecr\fP
+When used with -l, also ignore carriage returns at the end of lines.
+.TP
\fB\-x\fP \fInum\fP or \fB\*=debug=\fP\fInum\fP
Set internal debugging flags of interest only to
.B patch
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [bug-patch] [PATCH] Add --ignorecr option to ignore trailing carriage returns,
Simon Derr <=