forked from pool/patch
This commit is contained in:
commit
eb1f8528c1
23
.gitattributes
vendored
Normal file
23
.gitattributes
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
## Default LFS
|
||||||
|
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bsp filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gem filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.jar filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.lzma filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.obscpio filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.oxt filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.pdf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.png filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.rpm filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tbz2 filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.ttf filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.txz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.whl filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.zst filter=lfs diff=lfs merge=lfs -text
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.osc
|
19
fail.test
Normal file
19
fail.test
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
$ mkdir d
|
||||||
|
$ cd d
|
||||||
|
|
||||||
|
$ mkdir sub
|
||||||
|
$ echo 1 > f
|
||||||
|
$ echo 2 > f.new
|
||||||
|
$ diff -Nu f f.new > f.diff
|
||||||
|
$ mv f.new f
|
||||||
|
$ echo 3 > f.new
|
||||||
|
$ diff -Nu f f.new >> f.diff
|
||||||
|
$ rm f.new
|
||||||
|
$ echo 1 > f
|
||||||
|
$ chmod a=r f
|
||||||
|
$ strace -o ../log patch -p0 --backup < f.diff
|
||||||
|
> patching file f
|
||||||
|
> patching file f
|
||||||
|
|
||||||
|
$ cd ..
|
||||||
|
$ rm -rf d
|
201
global-reject-file.diff
Normal file
201
global-reject-file.diff
Normal file
@ -0,0 +1,201 @@
|
|||||||
|
Index: patch-2.5.9/patch.man
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/patch.man
|
||||||
|
+++ patch-2.5.9/patch.man
|
||||||
|
@@ -520,6 +520,15 @@ file.
|
||||||
|
\fB\*=reject\-unified\fP
|
||||||
|
Produce unified reject files. The default is to produce context type reject files.
|
||||||
|
.TP
|
||||||
|
+.BI \*=global\-reject\-file= rejectfile
|
||||||
|
+Put all rejects into
|
||||||
|
+.I rejectfile
|
||||||
|
+instead of creating separate reject files for all files that have rejects. The
|
||||||
|
+.I rejectfile
|
||||||
|
+will contain headers that identify which file each reject refers to. Note that
|
||||||
|
+the global reject file is created even if \-\-dry\-run is specified (while
|
||||||
|
+non-global reject files will only be created without \-\-dry\-run).
|
||||||
|
+.TP
|
||||||
|
\fB\-R\fP or \fB\*=reverse\fP
|
||||||
|
Assume that this patch was created with the old and new files swapped.
|
||||||
|
(Yes, I'm afraid that does happen occasionally, human nature being what it
|
||||||
|
Index: patch-2.5.9/patch.c
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/patch.c
|
||||||
|
+++ patch-2.5.9/patch.c
|
||||||
|
@@ -67,6 +67,7 @@ static bool similar (char const *, size_
|
||||||
|
static bool spew_output (struct outstate *);
|
||||||
|
static char const *make_temp (char);
|
||||||
|
static int numeric_string (char const *, bool, char const *);
|
||||||
|
+static void reject_header (const char *filename);
|
||||||
|
static void abort_hunk (void);
|
||||||
|
static void cleanup (void);
|
||||||
|
static void get_some_switches (void);
|
||||||
|
@@ -98,6 +99,7 @@ static int Argc;
|
||||||
|
static char * const *Argv;
|
||||||
|
|
||||||
|
static FILE *rejfp; /* reject file pointer */
|
||||||
|
+static char *global_reject;
|
||||||
|
|
||||||
|
static char const *patchname;
|
||||||
|
static char *rejname;
|
||||||
|
@@ -172,6 +174,10 @@ main (int argc, char **argv)
|
||||||
|
/* Make sure we clean up in case of disaster. */
|
||||||
|
set_signals (false);
|
||||||
|
|
||||||
|
+ /* initialize global reject file */
|
||||||
|
+ if (global_reject)
|
||||||
|
+ init_reject ();
|
||||||
|
+
|
||||||
|
for (
|
||||||
|
open_patch_file (patchname);
|
||||||
|
there_is_another_patch();
|
||||||
|
@@ -208,8 +214,9 @@ main (int argc, char **argv)
|
||||||
|
init_output (TMPOUTNAME, exclusive, &outstate);
|
||||||
|
}
|
||||||
|
|
||||||
|
- /* initialize reject file */
|
||||||
|
- init_reject ();
|
||||||
|
+ /* initialize per-patch reject file */
|
||||||
|
+ if (!global_reject)
|
||||||
|
+ init_reject ();
|
||||||
|
|
||||||
|
/* find out where all the lines are */
|
||||||
|
if (!skip_rest_of_patch)
|
||||||
|
@@ -278,6 +285,8 @@ main (int argc, char **argv)
|
||||||
|
|
||||||
|
newwhere = pch_newfirst() + last_offset;
|
||||||
|
if (skip_rest_of_patch) {
|
||||||
|
+ if (!failed)
|
||||||
|
+ reject_header(outname);
|
||||||
|
abort_hunk();
|
||||||
|
failed++;
|
||||||
|
if (verbosity == VERBOSE)
|
||||||
|
@@ -292,6 +301,8 @@ main (int argc, char **argv)
|
||||||
|
say ("Patch attempted to create file %s, which already exists.\n",
|
||||||
|
quotearg (inname));
|
||||||
|
|
||||||
|
+ if (!failed)
|
||||||
|
+ reject_header(outname);
|
||||||
|
abort_hunk();
|
||||||
|
failed++;
|
||||||
|
if (verbosity != SILENT)
|
||||||
|
@@ -299,6 +310,8 @@ main (int argc, char **argv)
|
||||||
|
format_linenum (numbuf, newwhere));
|
||||||
|
}
|
||||||
|
else if (! apply_hunk (&outstate, where)) {
|
||||||
|
+ if (!failed)
|
||||||
|
+ reject_header(outname);
|
||||||
|
abort_hunk ();
|
||||||
|
failed++;
|
||||||
|
if (verbosity != SILENT)
|
||||||
|
@@ -332,7 +345,8 @@ main (int argc, char **argv)
|
||||||
|
fclose (outstate.ofp);
|
||||||
|
outstate.ofp = 0;
|
||||||
|
}
|
||||||
|
- fclose (rejfp);
|
||||||
|
+ if (!global_reject)
|
||||||
|
+ fclose (rejfp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -412,13 +426,13 @@ main (int argc, char **argv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (diff_type != ED_DIFF) {
|
||||||
|
- if (fclose (rejfp) != 0)
|
||||||
|
+ if (!global_reject && fclose (rejfp) != 0)
|
||||||
|
write_fatal ();
|
||||||
|
if (failed) {
|
||||||
|
somefailed = true;
|
||||||
|
say ("%d out of %d hunk%s %s", failed, hunk, "s" + (hunk == 1),
|
||||||
|
skip_rest_of_patch ? "ignored" : "FAILED");
|
||||||
|
- if (outname) {
|
||||||
|
+ if (!global_reject && outname) {
|
||||||
|
char *rej = rejname;
|
||||||
|
if (!rejname) {
|
||||||
|
rej = xmalloc (strlen (outname) + 5);
|
||||||
|
@@ -445,6 +459,20 @@ main (int argc, char **argv)
|
||||||
|
}
|
||||||
|
set_signals (true);
|
||||||
|
}
|
||||||
|
+ if (global_reject)
|
||||||
|
+ {
|
||||||
|
+ if (fclose (rejfp) != 0)
|
||||||
|
+ write_fatal ();
|
||||||
|
+ if (somefailed)
|
||||||
|
+ {
|
||||||
|
+ say (" -- saving rejects to file %s\n", quotearg (global_reject));
|
||||||
|
+ /*if (! dry_run)
|
||||||
|
+ {*/
|
||||||
|
+ move_file (TMPREJNAME, &TMPREJNAME_needs_removal,
|
||||||
|
+ global_reject, 0644, false);
|
||||||
|
+ /*}*/
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0))
|
||||||
|
write_fatal ();
|
||||||
|
cleanup ();
|
||||||
|
@@ -523,6 +551,7 @@ static struct option const longopts[] =
|
||||||
|
{"posix", no_argument, NULL, CHAR_MAX + 7},
|
||||||
|
{"quoting-style", required_argument, NULL, CHAR_MAX + 8},
|
||||||
|
{"unified-reject-files", no_argument, NULL, CHAR_MAX + 9},
|
||||||
|
+ {"global-reject-file", required_argument, NULL, CHAR_MAX + 10},
|
||||||
|
{NULL, no_argument, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -582,6 +611,7 @@ static char const *const option_help[] =
|
||||||
|
" --dry-run Do not actually change any files; just print what would happen.",
|
||||||
|
" --posix Conform to the POSIX standard.",
|
||||||
|
" --unified-reject-files Create unified reject files.",
|
||||||
|
+" --global-reject-file=file Put all rejects into one file.",
|
||||||
|
"",
|
||||||
|
" -d DIR --directory=DIR Change the working directory to DIR first.",
|
||||||
|
#if HAVE_SETMODE_DOS
|
||||||
|
@@ -784,6 +814,9 @@ get_some_switches (void)
|
||||||
|
case CHAR_MAX + 9:
|
||||||
|
unified_reject_files = true;
|
||||||
|
break;
|
||||||
|
+ case CHAR_MAX + 10:
|
||||||
|
+ global_reject = savestr (optarg);
|
||||||
|
+ break;
|
||||||
|
default:
|
||||||
|
usage (stderr, 2);
|
||||||
|
}
|
||||||
|
@@ -933,6 +966,37 @@ locate_hunk (LINENUM fuzz)
|
||||||
|
}
|
||||||
|
|
||||||
|
static char *
|
||||||
|
+format_timestamp (char timebuf[37], bool which)
|
||||||
|
+{
|
||||||
|
+ time_t ts = pch_timestamp(which);
|
||||||
|
+ if (ts != -1)
|
||||||
|
+ {
|
||||||
|
+ struct tm *tm = localtime(&ts);
|
||||||
|
+ strftime(timebuf, 37, "\t%Y-%m-%d %H:%M:%S.000000000 %z", tm);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ timebuf[0] = 0;
|
||||||
|
+ return timebuf;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+/* Write a header in a reject file that combines multiple hunks. */
|
||||||
|
+static void
|
||||||
|
+reject_header (const char *outname)
|
||||||
|
+{
|
||||||
|
+ char timebuf0[37], timebuf1[37];
|
||||||
|
+ if (!global_reject)
|
||||||
|
+ return;
|
||||||
|
+ if (diff_type == UNI_DIFF)
|
||||||
|
+ fprintf(rejfp, "--- %s.orig%s\n+++ %s%s\n",
|
||||||
|
+ outname, format_timestamp(timebuf0, reverse),
|
||||||
|
+ outname, format_timestamp(timebuf1, !reverse));
|
||||||
|
+ else
|
||||||
|
+ fprintf(rejfp, "*** %s.orig%s\n--- %s%s\n",
|
||||||
|
+ outname, format_timestamp(timebuf0, reverse),
|
||||||
|
+ outname, format_timestamp(timebuf1, !reverse));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static char *
|
||||||
|
format_linerange (char rangebuf[LINENUM_LENGTH_BOUND*2 + 2],
|
||||||
|
LINENUM first, LINENUM lines)
|
||||||
|
{
|
75
if_else_endif_comments.diff
Normal file
75
if_else_endif_comments.diff
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
Index: patch-2.5.9/patch.c
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/patch.c 2003-06-05 00:22:56.000000000 +0200
|
||||||
|
+++ patch-2.5.9/patch.c 2003-06-05 00:23:16.000000000 +0200
|
||||||
|
@@ -91,8 +91,8 @@ static LINENUM last_frozen_line;
|
||||||
|
static char const *do_defines; /* symbol to patch using ifdef, ifndef, etc. */
|
||||||
|
static char const if_defined[] = "\n#ifdef %s\n";
|
||||||
|
static char const not_defined[] = "\n#ifndef %s\n";
|
||||||
|
-static char const else_defined[] = "\n#else\n";
|
||||||
|
-static char const end_defined[] = "\n#endif\n";
|
||||||
|
+static char const else_defined[] = "\n#else /* %s */\n";
|
||||||
|
+static char const end_defined[] = "\n#endif /* %s */\n";
|
||||||
|
|
||||||
|
static int Argc;
|
||||||
|
static char * const *Argv;
|
||||||
|
@@ -1097,7 +1097,8 @@ apply_hunk (struct outstate *outstate, L
|
||||||
|
def_state = IN_IFNDEF;
|
||||||
|
}
|
||||||
|
else if (def_state == IN_IFDEF) {
|
||||||
|
- fprintf (fp, outstate->after_newline + else_defined);
|
||||||
|
+ fprintf (fp, outstate->after_newline + else_defined,
|
||||||
|
+ R_do_defines);
|
||||||
|
def_state = IN_ELSE;
|
||||||
|
}
|
||||||
|
if (ferror (fp))
|
||||||
|
@@ -1116,7 +1117,8 @@ apply_hunk (struct outstate *outstate, L
|
||||||
|
return false;
|
||||||
|
if (R_do_defines) {
|
||||||
|
if (def_state == IN_IFNDEF) {
|
||||||
|
- fprintf (fp, outstate->after_newline + else_defined);
|
||||||
|
+ fprintf (fp, outstate->after_newline + else_defined,
|
||||||
|
+ R_do_defines);
|
||||||
|
def_state = IN_ELSE;
|
||||||
|
}
|
||||||
|
else if (def_state == OUTSIDE) {
|
||||||
|
@@ -1164,7 +1166,8 @@ apply_hunk (struct outstate *outstate, L
|
||||||
|
while (pch_char (old) == '!');
|
||||||
|
|
||||||
|
if (R_do_defines) {
|
||||||
|
- fprintf (fp, outstate->after_newline + else_defined);
|
||||||
|
+ fprintf (fp, outstate->after_newline + else_defined,
|
||||||
|
+ R_do_defines);
|
||||||
|
if (ferror (fp))
|
||||||
|
write_fatal ();
|
||||||
|
def_state = IN_ELSE;
|
||||||
|
@@ -1183,7 +1186,8 @@ apply_hunk (struct outstate *outstate, L
|
||||||
|
old++;
|
||||||
|
new++;
|
||||||
|
if (R_do_defines && def_state != OUTSIDE) {
|
||||||
|
- fprintf (fp, outstate->after_newline + end_defined);
|
||||||
|
+ fprintf (fp, outstate->after_newline + end_defined,
|
||||||
|
+ R_do_defines);
|
||||||
|
if (ferror (fp))
|
||||||
|
write_fatal ();
|
||||||
|
outstate->after_newline = true;
|
||||||
|
@@ -1201,7 +1205,8 @@ apply_hunk (struct outstate *outstate, L
|
||||||
|
def_state = IN_IFDEF;
|
||||||
|
}
|
||||||
|
else if (def_state == IN_IFNDEF) {
|
||||||
|
- fprintf (fp, outstate->after_newline + else_defined);
|
||||||
|
+ fprintf (fp, outstate->after_newline + else_defined,
|
||||||
|
+ R_do_defines);
|
||||||
|
def_state = IN_ELSE;
|
||||||
|
}
|
||||||
|
if (ferror (fp))
|
||||||
|
@@ -1220,7 +1225,8 @@ apply_hunk (struct outstate *outstate, L
|
||||||
|
while (new <= pat_end && pch_char (new) == '+');
|
||||||
|
}
|
||||||
|
if (R_do_defines && def_state != OUTSIDE) {
|
||||||
|
- fprintf (fp, outstate->after_newline + end_defined);
|
||||||
|
+ fprintf (fp, outstate->after_newline + end_defined,
|
||||||
|
+ R_do_defines);
|
||||||
|
if (ferror (fp))
|
||||||
|
write_fatal ();
|
||||||
|
outstate->after_newline = true;
|
92
patch-2.5.9-cat_if_device.diff
Normal file
92
patch-2.5.9-cat_if_device.diff
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
Index: patch-2.5.9/patch.c
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/patch.c
|
||||||
|
+++ patch-2.5.9/patch.c
|
||||||
|
@@ -444,7 +444,7 @@ main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
move_file (TMPREJNAME, &TMPREJNAME_needs_removal,
|
||||||
|
rej, instat.st_mode, false);
|
||||||
|
- if (! inerrno
|
||||||
|
+ if (! inerrno && !s_is_chrblkfifosock(rej)
|
||||||
|
&& (chmod (rej, (instat.st_mode
|
||||||
|
& ~(S_IXUSR|S_IXGRP|S_IXOTH)))
|
||||||
|
!= 0))
|
||||||
|
Index: patch-2.5.9/util.c
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/util.c
|
||||||
|
+++ patch-2.5.9/util.c
|
||||||
|
@@ -65,6 +65,49 @@ static bool fid_search (const char *, co
|
||||||
|
FROM_NEEDS_REMOVAL must be nonnull if FROM is nonnull.
|
||||||
|
Back up TO if BACKUP is true. */
|
||||||
|
|
||||||
|
+int
|
||||||
|
+s_is_chrblkfifosock (const char *path)
|
||||||
|
+{
|
||||||
|
+ int r;
|
||||||
|
+ struct stat st;
|
||||||
|
+
|
||||||
|
+ r = stat(path, &st);
|
||||||
|
+ if (r < 0)
|
||||||
|
+ return r;
|
||||||
|
+
|
||||||
|
+ return (((st.st_mode & S_IFMT) == S_IFCHR) ||
|
||||||
|
+ ((st.st_mode & S_IFMT) == S_IFBLK) ||
|
||||||
|
+ ((st.st_mode & S_IFMT) == S_IFIFO) ||
|
||||||
|
+ ((st.st_mode & S_IFMT) == S_IFSOCK));
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void
|
||||||
|
+cat_file_to_dev (const char *from, const char *to)
|
||||||
|
+{
|
||||||
|
+ size_t i;
|
||||||
|
+ int fromfd, tofd;
|
||||||
|
+
|
||||||
|
+ fromfd = open(from, O_RDONLY);
|
||||||
|
+ if (fromfd < 0)
|
||||||
|
+ pfatal("could not open %s for reading", quotearg(from));
|
||||||
|
+
|
||||||
|
+ tofd = open(to, O_WRONLY | O_NONBLOCK);
|
||||||
|
+ if (tofd < 0)
|
||||||
|
+ pfatal("could not open %s for writing", quotearg(to));
|
||||||
|
+
|
||||||
|
+ while ((i = read (fromfd, buf, bufsize)) != 0)
|
||||||
|
+ {
|
||||||
|
+ if (i == (size_t) -1)
|
||||||
|
+ read_fatal ();
|
||||||
|
+ if (write (tofd, buf, i) != i)
|
||||||
|
+ write_fatal ();
|
||||||
|
+ }
|
||||||
|
+ if (close (fromfd) != 0)
|
||||||
|
+ read_fatal ();
|
||||||
|
+ if (close (tofd) != 0)
|
||||||
|
+ write_fatal ();
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
void
|
||||||
|
move_file (char const *from, int volatile *from_needs_removal,
|
||||||
|
char *to, mode_t mode, bool backup)
|
||||||
|
@@ -164,6 +207,15 @@ move_file (char const *from, int volatil
|
||||||
|
goto rename_succeeded;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ if (errno == EACCES && (s_is_chrblkfifosock(to) > 0))
|
||||||
|
+ {
|
||||||
|
+ cat_file_to_dev (from, to);
|
||||||
|
+ if (backup)
|
||||||
|
+ insert_fid (to);
|
||||||
|
+ unlink(from);
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
if (errno == EXDEV)
|
||||||
|
{
|
||||||
|
if (! backup)
|
||||||
|
Index: patch-2.5.9/util.h
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/util.h
|
||||||
|
+++ patch-2.5.9/util.h
|
||||||
|
@@ -57,3 +57,4 @@ void remove_prefix (char *, size_t);
|
||||||
|
void removedirs (char *);
|
||||||
|
void set_signals (bool);
|
||||||
|
void write_fatal (void) __attribute__ ((noreturn));
|
||||||
|
+int s_is_chrblkfifosock (const char *);
|
3
patch-2.5.9.tar.bz2
Normal file
3
patch-2.5.9.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:612a424b80bccf4638059742dc77676387c75a880723fc990a5d3a0ad0799de3
|
||||||
|
size 158619
|
11
patch-man-unified-reject.diff
Normal file
11
patch-man-unified-reject.diff
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
--- patch-2.5.9/patch.man
|
||||||
|
+++ patch-2.5.9/patch.man
|
||||||
|
@@ -517,7 +517,7 @@
|
||||||
|
.B \&.rej
|
||||||
|
file.
|
||||||
|
.TP
|
||||||
|
-\fB\*=reject\-unified\fP
|
||||||
|
+\fB\*=unified\-reject\-files\fP
|
||||||
|
Produce unified reject files. The default is to produce context type reject files.
|
||||||
|
.TP
|
||||||
|
.BI \*=global\-reject\-file= rejectfile
|
204
patch.changes
Normal file
204
patch.changes
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jan 25 21:30:47 CET 2006 - mls@suse.de
|
||||||
|
|
||||||
|
- converted neededforbuild to BuildRequires
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jan 12 07:52:31 CET 2006 - agruen@suse.de
|
||||||
|
|
||||||
|
- remember-backup-files.diff: Fix case where a patch modifies a
|
||||||
|
read-only file more than once while --backup is used (test case
|
||||||
|
in the patch header).
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Aug 18 18:09:59 CEST 2005 - mmj@suse.de
|
||||||
|
|
||||||
|
- --reject-unified is called --unified-reject-files [#105151]
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jun 29 13:50:06 CEST 2005 - mmj@suse.de
|
||||||
|
|
||||||
|
- Don't compile with -f-signed-char [#93883]
|
||||||
|
- Don't strip explicitly
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jan 4 21:11:54 CET 2005 - mmj@suse.de
|
||||||
|
|
||||||
|
- Add patch to make patch able to write reject files to devices,
|
||||||
|
named pipes and sockets [#45794]
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Sat Jan 25 02:30:00 CET 2004 - agruen@suse.de
|
||||||
|
|
||||||
|
- Add --reject-unified option to produce unified reject files:
|
||||||
|
Before, unified reject files were produced if the patch itself
|
||||||
|
was unified; this could sometimes have been annoying.
|
||||||
|
- If a patch with C function names (diff -p) has rejects, include
|
||||||
|
the function names in the reject files.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Sun Jan 11 11:17:55 CET 2004 - adrian@suse.de
|
||||||
|
|
||||||
|
- add %defattr
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Oct 7 15:03:22 CEST 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- remember-backup-files: Also include the file timestamps in the
|
||||||
|
hash table for non-POSIX-compliant systems that don't guarantee
|
||||||
|
that i_dev + i_ino uniquely identifies a file.
|
||||||
|
- #32031: Create --global-reject-file even if --dry-run is
|
||||||
|
specified. Add a missing '\n'.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jul 16 15:21:44 CEST 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- Replace trailing-cr-fix.diff with official upstream version that
|
||||||
|
fixes this bug differently.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Jun 30 13:30:33 CEST 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- trailing-cr-fix.diff: Fix a bug in carriage return detection
|
||||||
|
(DOS files) in the unified diff path.
|
||||||
|
- Disable patch that adds comments to C preprocessor style
|
||||||
|
merges, as specified by POSIX.1-2001.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jun 25 16:46:41 CEST 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- Fix bug introduced on June 5 that broke remember-backup-files.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Jun 24 17:35:09 CEST 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- smart-reject-file-format.diff: Work around a special case in
|
||||||
|
which patches are not terminated with a '^' in the internal
|
||||||
|
representation. The resulting error message was "internal error
|
||||||
|
in abort_hunk".
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jun 5 09:38:17 CEST 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- Temporary reject file logic: Ooops, now must only close the
|
||||||
|
temporary reject file after processing all patches, instead of
|
||||||
|
after each patch.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Jun 5 01:00:38 CEST 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- Upgrade to 2.5.9: Several fixes, obsoletes
|
||||||
|
rename-same-file.patch.
|
||||||
|
- Fix and adapt global-reject-file patch:
|
||||||
|
+ The global reject file included corrupted headers for each
|
||||||
|
rejected hunk, instead of one header for each file with
|
||||||
|
rejects.
|
||||||
|
+ Rename --global-reject to --global-reject-file.
|
||||||
|
+ Simplify temporary reject file logic.
|
||||||
|
+ Adapt to unified-reject-files patch (which has different
|
||||||
|
headers).
|
||||||
|
+ Add entry in man page.
|
||||||
|
- Fix a bug in smart-reject-file-format: Files that are created
|
||||||
|
are identified by `-0,0'; before the patch was generating
|
||||||
|
`-1,0' in reject files.
|
||||||
|
- Switch remember-backup-files.diff over to use gnulib's hash
|
||||||
|
tables instead of glibc's binary trees, requested from upstream
|
||||||
|
to ensure greater portability.
|
||||||
|
- Add /* SYM */ comment to #endif lines for patch -D SYM, too.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Apr 9 19:33:59 CEST 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- Fix another bug with hard links and backup file generation.
|
||||||
|
- Fix backup file generation if the same file appears in the
|
||||||
|
patch more than once.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Mar 26 14:00:55 CET 2003 - mmj@suse.de
|
||||||
|
|
||||||
|
- Update to 2.5.8:
|
||||||
|
· Bugfixes
|
||||||
|
· patch -D now outputs preprocessor lines without comments, as
|
||||||
|
required by POSIX 1003.1-2001
|
||||||
|
· File names in context patches may now contain spaces, so long
|
||||||
|
as the context patch headers use a tab to separate the file name
|
||||||
|
from the time stamp
|
||||||
|
· Perforce is now supported
|
||||||
|
· Patch lines beginning with "#" are comments and are ignored
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jan 15 16:50:57 CET 2003 - agruen@suse.de
|
||||||
|
|
||||||
|
- Fix a bug with hardlinks (see rename-same-file.patch)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Sep 17 17:34:28 CEST 2002 - ro@suse.de
|
||||||
|
|
||||||
|
- removed bogus self-provides
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Feb 6 12:05:34 CET 2002 - coolo@suse.de
|
||||||
|
|
||||||
|
- called suse_update_config
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Jun 25 12:46:18 CEST 2001 - uli@suse.de
|
||||||
|
|
||||||
|
- added patch adding "--global-reject" option by ak@suse.de
|
||||||
|
- bzipped tarball
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Mar 6 20:36:46 CET 2001 - bk@suse.de
|
||||||
|
|
||||||
|
- update to 2.5.4, added 2 patches from PLD and use buildroot
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Nov 8 17:41:23 CET 2000 - uli@suse.de
|
||||||
|
|
||||||
|
- now builds with -D_GNU_SOURCE, should avoid miscompilation that
|
||||||
|
breaks LFS support
|
||||||
|
- added fix for offset output by Alessandro Rubini
|
||||||
|
- added fix and enhancement for --ifdef by Pete Buechler
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Sun Feb 27 20:16:11 CET 2000 - @suse.de
|
||||||
|
|
||||||
|
- added missing CFLAGS quotes.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Sun Feb 27 19:07:58 CET 2000 - bk@suse.de
|
||||||
|
|
||||||
|
- added PPC fixes by Uli back again (-fsigned-char, CPPFLAGS)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Fri Feb 25 17:44:41 CET 2000 - schwab@suse.de
|
||||||
|
|
||||||
|
- Specfile cleanup, get rid of Makefile.Linux
|
||||||
|
- /usr/man -> /usr/share/man
|
||||||
|
- Add group tag.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Sep 13 17:23:57 CEST 1999 - bs@suse.de
|
||||||
|
|
||||||
|
- ran old prepare_spec on spec file to switch to new prepare_spec.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Aug 18 12:13:35 MEST 1999 - uli@suse.de
|
||||||
|
|
||||||
|
- fixed for PPC (-fsigned-char, CPPFLAGS)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Tue Mar 16 14:58:42 MET 1999 - ro@suse.de
|
||||||
|
|
||||||
|
- update to 2.5.3 using diff from jurix
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Jan 13 15:45:28 MET 1999 - bs@suse.de
|
||||||
|
|
||||||
|
- applied patch from Egbert Eich (problems with non existing files fixed)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Nov 5 00:19:13 MET 1998 - ro@suse.de
|
||||||
|
|
||||||
|
- use libc's basename() for glibc
|
||||||
|
|
189
patch.spec
Normal file
189
patch.spec
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
#
|
||||||
|
# spec file for package patch (Version 2.5.9)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||||
|
# This file and all modifications and additions to the pristine
|
||||||
|
# package are under the same license as the package itself.
|
||||||
|
#
|
||||||
|
# Please submit bugfixes or comments via http://bugs.opensuse.org
|
||||||
|
#
|
||||||
|
|
||||||
|
# norootforbuild
|
||||||
|
|
||||||
|
Name: patch
|
||||||
|
License: GPL
|
||||||
|
Group: Productivity/Text/Utilities
|
||||||
|
Autoreqprov: on
|
||||||
|
Version: 2.5.9
|
||||||
|
Release: 149
|
||||||
|
Summary: GNU patch
|
||||||
|
Source: ftp://prep.ai.mit.edu/pub/gnu/patch/%{name}-%{version}.tar.bz2
|
||||||
|
URL: http://www.gnu.org/software/patch/patch.html
|
||||||
|
Patch: trailing-cr-fix.diff
|
||||||
|
Patch1: remember-backup-files.diff
|
||||||
|
Patch2: unified-reject-files.diff
|
||||||
|
Patch3: global-reject-file.diff
|
||||||
|
Patch4: if_else_endif_comments.diff
|
||||||
|
Patch5: patch-2.5.9-cat_if_device.diff
|
||||||
|
Patch6: patch-man-unified-reject.diff
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
|
|
||||||
|
%description
|
||||||
|
The GNU patch program is used to apply diffs between original and
|
||||||
|
changed files (generated by the diff command) to the original files.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Authors:
|
||||||
|
--------
|
||||||
|
Larry Wall
|
||||||
|
Paul Eggert
|
||||||
|
|
||||||
|
%prep
|
||||||
|
%setup -q
|
||||||
|
%suse_update_config
|
||||||
|
%patch0 -p1
|
||||||
|
%patch1 -p1
|
||||||
|
%patch2 -p1
|
||||||
|
%patch3 -p1
|
||||||
|
%patch5 -p1
|
||||||
|
%patch6 -p1
|
||||||
|
|
||||||
|
%build
|
||||||
|
aclocal --acdir=m4
|
||||||
|
autoheader
|
||||||
|
autoconf
|
||||||
|
CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE -Wall -O2 -pipe" \
|
||||||
|
./configure \
|
||||||
|
%ifarch sparc sparc64
|
||||||
|
--disable-largefile \
|
||||||
|
%endif
|
||||||
|
--prefix=%{_prefix}
|
||||||
|
make CPPFLAGS=""
|
||||||
|
|
||||||
|
%install
|
||||||
|
make install \
|
||||||
|
bindir=$RPM_BUILD_ROOT%{_bindir} \
|
||||||
|
man1dir=$RPM_BUILD_ROOT%{_mandir}/man1
|
||||||
|
|
||||||
|
%files
|
||||||
|
%defattr(-,root,root)
|
||||||
|
%doc NEWS README
|
||||||
|
/usr/bin/patch
|
||||||
|
%doc %{_mandir}/man1/patch.1.gz
|
||||||
|
|
||||||
|
%changelog -n patch
|
||||||
|
* Wed Jan 25 2006 - mls@suse.de
|
||||||
|
- converted neededforbuild to BuildRequires
|
||||||
|
* Thu Jan 12 2006 - agruen@suse.de
|
||||||
|
- remember-backup-files.diff: Fix case where a patch modifies a
|
||||||
|
read-only file more than once while --backup is used (test case
|
||||||
|
in the patch header).
|
||||||
|
* Thu Aug 18 2005 - mmj@suse.de
|
||||||
|
- --reject-unified is called --unified-reject-files [#105151]
|
||||||
|
* Wed Jun 29 2005 - mmj@suse.de
|
||||||
|
- Don't compile with -f-signed-char [#93883]
|
||||||
|
- Don't strip explicitly
|
||||||
|
* Tue Jan 04 2005 - mmj@suse.de
|
||||||
|
- Add patch to make patch able to write reject files to devices,
|
||||||
|
named pipes and sockets [#45794]
|
||||||
|
* Sun Jan 25 2004 - agruen@suse.de
|
||||||
|
- Add --reject-unified option to produce unified reject files:
|
||||||
|
Before, unified reject files were produced if the patch itself
|
||||||
|
was unified; this could sometimes have been annoying.
|
||||||
|
- If a patch with C function names (diff -p) has rejects, include
|
||||||
|
the function names in the reject files.
|
||||||
|
* Sun Jan 11 2004 - adrian@suse.de
|
||||||
|
- add %%defattr
|
||||||
|
* Tue Oct 07 2003 - agruen@suse.de
|
||||||
|
- remember-backup-files: Also include the file timestamps in the
|
||||||
|
hash table for non-POSIX-compliant systems that don't guarantee
|
||||||
|
that i_dev + i_ino uniquely identifies a file.
|
||||||
|
- #32031: Create --global-reject-file even if --dry-run is
|
||||||
|
specified. Add a missing '\n'.
|
||||||
|
* Wed Jul 16 2003 - agruen@suse.de
|
||||||
|
- Replace trailing-cr-fix.diff with official upstream version that
|
||||||
|
fixes this bug differently.
|
||||||
|
* Mon Jun 30 2003 - agruen@suse.de
|
||||||
|
- trailing-cr-fix.diff: Fix a bug in carriage return detection
|
||||||
|
(DOS files) in the unified diff path.
|
||||||
|
- Disable patch that adds comments to C preprocessor style
|
||||||
|
merges, as specified by POSIX.1-2001.
|
||||||
|
* Wed Jun 25 2003 - agruen@suse.de
|
||||||
|
- Fix bug introduced on June 5 that broke remember-backup-files.
|
||||||
|
* Tue Jun 24 2003 - agruen@suse.de
|
||||||
|
- smart-reject-file-format.diff: Work around a special case in
|
||||||
|
which patches are not terminated with a '^' in the internal
|
||||||
|
representation. The resulting error message was "internal error
|
||||||
|
in abort_hunk".
|
||||||
|
* Thu Jun 05 2003 - agruen@suse.de
|
||||||
|
- Temporary reject file logic: Ooops, now must only close the
|
||||||
|
temporary reject file after processing all patches, instead of
|
||||||
|
after each patch.
|
||||||
|
* Thu Jun 05 2003 - agruen@suse.de
|
||||||
|
- Upgrade to 2.5.9: Several fixes, obsoletes
|
||||||
|
rename-same-file.patch.
|
||||||
|
- Fix and adapt global-reject-file patch:
|
||||||
|
+ The global reject file included corrupted headers for each
|
||||||
|
rejected hunk, instead of one header for each file with
|
||||||
|
rejects.
|
||||||
|
+ Rename --global-reject to --global-reject-file.
|
||||||
|
+ Simplify temporary reject file logic.
|
||||||
|
+ Adapt to unified-reject-files patch (which has different
|
||||||
|
headers).
|
||||||
|
+ Add entry in man page.
|
||||||
|
- Fix a bug in smart-reject-file-format: Files that are created
|
||||||
|
are identified by `-0,0'; before the patch was generating
|
||||||
|
`-1,0' in reject files.
|
||||||
|
- Switch remember-backup-files.diff over to use gnulib's hash
|
||||||
|
tables instead of glibc's binary trees, requested from upstream
|
||||||
|
to ensure greater portability.
|
||||||
|
- Add /* SYM */ comment to #endif lines for patch -D SYM, too.
|
||||||
|
* Wed Apr 09 2003 - agruen@suse.de
|
||||||
|
- Fix another bug with hard links and backup file generation.
|
||||||
|
- Fix backup file generation if the same file appears in the
|
||||||
|
patch more than once.
|
||||||
|
* Wed Mar 26 2003 - mmj@suse.de
|
||||||
|
- Update to 2.5.8:
|
||||||
|
· Bugfixes
|
||||||
|
· patch -D now outputs preprocessor lines without comments, as
|
||||||
|
required by POSIX 1003.1-2001
|
||||||
|
· File names in context patches may now contain spaces, so long
|
||||||
|
as the context patch headers use a tab to separate the file name
|
||||||
|
from the time stamp
|
||||||
|
· Perforce is now supported
|
||||||
|
· Patch lines beginning with "#" are comments and are ignored
|
||||||
|
* Wed Jan 15 2003 - agruen@suse.de
|
||||||
|
- Fix a bug with hardlinks (see rename-same-file.patch)
|
||||||
|
* Tue Sep 17 2002 - ro@suse.de
|
||||||
|
- removed bogus self-provides
|
||||||
|
* Wed Feb 06 2002 - coolo@suse.de
|
||||||
|
- called suse_update_config
|
||||||
|
* Mon Jun 25 2001 - uli@suse.de
|
||||||
|
- added patch adding "--global-reject" option by ak@suse.de
|
||||||
|
- bzipped tarball
|
||||||
|
* Tue Mar 06 2001 - bk@suse.de
|
||||||
|
- update to 2.5.4, added 2 patches from PLD and use buildroot
|
||||||
|
* Wed Nov 08 2000 - uli@suse.de
|
||||||
|
- now builds with -D_GNU_SOURCE, should avoid miscompilation that
|
||||||
|
breaks LFS support
|
||||||
|
- added fix for offset output by Alessandro Rubini
|
||||||
|
- added fix and enhancement for --ifdef by Pete Buechler
|
||||||
|
* Sun Feb 27 2000 - @suse.de
|
||||||
|
- added missing CFLAGS quotes.
|
||||||
|
* Sun Feb 27 2000 - bk@suse.de
|
||||||
|
- added PPC fixes by Uli back again (-fsigned-char, CPPFLAGS)
|
||||||
|
* Fri Feb 25 2000 - schwab@suse.de
|
||||||
|
- Specfile cleanup, get rid of Makefile.Linux
|
||||||
|
- /usr/man -> /usr/share/man
|
||||||
|
- Add group tag.
|
||||||
|
* Mon Sep 13 1999 - bs@suse.de
|
||||||
|
- ran old prepare_spec on spec file to switch to new prepare_spec.
|
||||||
|
* Wed Aug 18 1999 - uli@suse.de
|
||||||
|
- fixed for PPC (-fsigned-char, CPPFLAGS)
|
||||||
|
* Tue Mar 16 1999 - ro@suse.de
|
||||||
|
- update to 2.5.3 using diff from jurix
|
||||||
|
* Wed Jan 13 1999 - bs@suse.de
|
||||||
|
- applied patch from Egbert Eich (problems with non existing files fixed)
|
||||||
|
* Thu Nov 05 1998 - ro@suse.de
|
||||||
|
- use libc's basename() for glibc
|
1507
remember-backup-files.diff
Normal file
1507
remember-backup-files.diff
Normal file
File diff suppressed because it is too large
Load Diff
61
trailing-cr-fix.diff
Normal file
61
trailing-cr-fix.diff
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
From: "Paul Eggert" <eggert@twinsun.com>
|
||||||
|
Date: Wed, 2 Jul 2003 15:22:09 -0700
|
||||||
|
Subject: Re: patch bug with carriage returns
|
||||||
|
|
||||||
|
> From: Andreas Gruenbacher <agruen@suse.de>
|
||||||
|
> Date: Mon, 30 Jun 2003 13:43:33 +0200
|
||||||
|
|
||||||
|
> unified diffs with CRLF line endings are not recognized correctly
|
||||||
|
> anymore in 2.5.9. Here is a fix.
|
||||||
|
|
||||||
|
Thanks for the bug report. Unfortunately that fix doesn't handle the
|
||||||
|
case correctly where a Unix file contains a trailing CR in a header
|
||||||
|
line that is output by "diff -p" (trailing CR and all).
|
||||||
|
|
||||||
|
How about the following patch instead?
|
||||||
|
|
||||||
|
--- patch-2.5.9.orig/pch.c 2003/05/20 14:03:17 1.44
|
||||||
|
+++ patch-2.5.9/pch.c 2003/07/02 22:19:21 1.45
|
||||||
|
@@ -1,6 +1,6 @@
|
||||||
|
/* reading patches */
|
||||||
|
|
||||||
|
-/* $Id: pch.c,v 1.44 2003/05/20 14:03:17 eggert Exp $ */
|
||||||
|
+/* $Id: pch.c,v 1.45 2003/07/02 22:19:21 eggert Exp $ */
|
||||||
|
|
||||||
|
/* Copyright (C) 1986, 1987, 1988 Larry Wall
|
||||||
|
|
||||||
|
@@ -366,10 +366,16 @@ intuit_diff_type (void)
|
||||||
|
if (!stars_last_line && strnEQ(s, "*** ", 4))
|
||||||
|
name[OLD] = fetchname (s+4, strippath, &p_timestamp[OLD]);
|
||||||
|
else if (strnEQ(s, "+++ ", 4))
|
||||||
|
+ {
|
||||||
|
/* Swap with NEW below. */
|
||||||
|
name[OLD] = fetchname (s+4, strippath, &p_timestamp[OLD]);
|
||||||
|
+ p_strip_trailing_cr = strip_trailing_cr;
|
||||||
|
+ }
|
||||||
|
else if (strnEQ(s, "Index:", 6))
|
||||||
|
+ {
|
||||||
|
name[INDEX] = fetchname (s+6, strippath, (time_t *) 0);
|
||||||
|
+ p_strip_trailing_cr = strip_trailing_cr;
|
||||||
|
+ }
|
||||||
|
else if (strnEQ(s, "Prereq:", 7)) {
|
||||||
|
for (t = s + 7; ISSPACE ((unsigned char) *t); t++)
|
||||||
|
continue;
|
||||||
|
@@ -409,6 +415,7 @@ intuit_diff_type (void)
|
||||||
|
p_timestamp[NEW] = timestamp;
|
||||||
|
p_rfc934_nesting = (t - s) >> 1;
|
||||||
|
}
|
||||||
|
+ p_strip_trailing_cr = strip_trailing_cr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((diff_type == NO_DIFF || diff_type == ED_DIFF) &&
|
||||||
|
#--- patch-2.5.9.orig/pch.c 2003-06-30 13:28:39.000000000 +0200
|
||||||
|
#+++ patch-2.5.9/pch.c 2003-06-30 13:28:03.000000000 +0200
|
||||||
|
#@@ -440,6 +440,7 @@
|
||||||
|
# if (s[0] == '+' && s[1] == '0' && !ISDIGIT (s[2]))
|
||||||
|
# p_says_nonexistent[NEW] = 1 + ! p_timestamp[NEW];
|
||||||
|
# p_indent = indent;
|
||||||
|
#+ p_strip_trailing_cr = strip_trailing_cr;
|
||||||
|
# p_start = this_line;
|
||||||
|
# p_sline = p_input_line;
|
||||||
|
# retval = UNI_DIFF;
|
305
unified-reject-files.diff
Normal file
305
unified-reject-files.diff
Normal file
@ -0,0 +1,305 @@
|
|||||||
|
Generate unified diff style reject files. Also include the C function names
|
||||||
|
in reject files whenever possible.
|
||||||
|
|
||||||
|
$ cat > f.orig
|
||||||
|
< a() {
|
||||||
|
< 2
|
||||||
|
< 3
|
||||||
|
<
|
||||||
|
< 5
|
||||||
|
< 6
|
||||||
|
< }
|
||||||
|
|
||||||
|
$ sed -e 's/5/5a/' f.orig > f
|
||||||
|
$ diff -U2 -p f.orig f > f.diff
|
||||||
|
$ sed -e 's/5/5a/' -e 's/6/6x/' f.orig > f
|
||||||
|
$ ./patch -F0 -s --no-backup-if-mismatch f --reject-unified < f.diff
|
||||||
|
> 1 out of 1 hunk FAILED -- saving rejects to file f.rej
|
||||||
|
|
||||||
|
$ cat f.rej
|
||||||
|
> @@ -3,5 +3,5 @@ a() {
|
||||||
|
> 3
|
||||||
|
>
|
||||||
|
> -5
|
||||||
|
> +5a
|
||||||
|
> 6
|
||||||
|
> }
|
||||||
|
|
||||||
|
$ ./patch -F0 -s --no-backup-if-mismatch f < f.diff
|
||||||
|
> 1 out of 1 hunk FAILED -- saving rejects to file f.rej
|
||||||
|
|
||||||
|
$ cat f.rej
|
||||||
|
> *************** a() {
|
||||||
|
> *** 3,7 ****
|
||||||
|
> 3
|
||||||
|
>
|
||||||
|
> - 5
|
||||||
|
> 6
|
||||||
|
> }
|
||||||
|
> --- 3,7 ----
|
||||||
|
> 3
|
||||||
|
>
|
||||||
|
> + 5a
|
||||||
|
> 6
|
||||||
|
> }
|
||||||
|
|
||||||
|
$ diff -Nu -p /dev/null f.orig > f2.diff
|
||||||
|
$ ./patch -F0 -s --no-backup-if-mismatch f --reject-unified < f2.diff
|
||||||
|
> Patch attempted to create file f, which already exists.
|
||||||
|
> 1 out of 1 hunk FAILED -- saving rejects to file f.rej
|
||||||
|
|
||||||
|
$ cat f.rej
|
||||||
|
> @@ -0,0 +1,7 @@
|
||||||
|
> +a() {
|
||||||
|
> +2
|
||||||
|
> +3
|
||||||
|
> +
|
||||||
|
> +5
|
||||||
|
> +6
|
||||||
|
> +}
|
||||||
|
|
||||||
|
$ rm -f f f.orig f.rej f.diff f2.diff
|
||||||
|
|
||||||
|
Index: patch-2.5.9/pch.c
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/pch.c
|
||||||
|
+++ patch-2.5.9/pch.c
|
||||||
|
@@ -68,6 +68,7 @@ static LINENUM p_sline; /* and the lin
|
||||||
|
static LINENUM p_hunk_beg; /* line number of current hunk */
|
||||||
|
static LINENUM p_efake = -1; /* end of faked up lines--don't free */
|
||||||
|
static LINENUM p_bfake = -1; /* beg of faked up lines */
|
||||||
|
+static char *p_c_function; /* the C function a hunk is in */
|
||||||
|
|
||||||
|
enum nametype { OLD, NEW, INDEX, NONE };
|
||||||
|
|
||||||
|
@@ -888,6 +889,19 @@ another_hunk (enum diff difftype, bool r
|
||||||
|
next_intuit_at(line_beginning,p_input_line);
|
||||||
|
return chars_read == (size_t) -1 ? -1 : 0;
|
||||||
|
}
|
||||||
|
+ s = buf;
|
||||||
|
+ while (*s == '*')
|
||||||
|
+ s++;
|
||||||
|
+ if (*s == ' ')
|
||||||
|
+ {
|
||||||
|
+ p_c_function = s;
|
||||||
|
+ while (*s != '\n')
|
||||||
|
+ s++;
|
||||||
|
+ *s = '\0';
|
||||||
|
+ p_c_function = savestr (p_c_function);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ p_c_function = NULL;
|
||||||
|
p_hunk_beg = p_input_line + 1;
|
||||||
|
while (p_end < p_max) {
|
||||||
|
chars_read = get_line ();
|
||||||
|
@@ -1277,8 +1291,18 @@ another_hunk (enum diff difftype, bool r
|
||||||
|
else
|
||||||
|
p_repl_lines = 1;
|
||||||
|
if (*s == ' ') s++;
|
||||||
|
- if (*s != '@')
|
||||||
|
+ if (*s++ != '@')
|
||||||
|
malformed ();
|
||||||
|
+ if (*s++ == '@' && *s == ' ' && *s != '\0')
|
||||||
|
+ {
|
||||||
|
+ p_c_function = s;
|
||||||
|
+ while (*s != '\n')
|
||||||
|
+ s++;
|
||||||
|
+ *s = '\0';
|
||||||
|
+ p_c_function = savestr (p_c_function);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ p_c_function = NULL;
|
||||||
|
if (!p_ptrn_lines)
|
||||||
|
p_first++; /* do append rather than insert */
|
||||||
|
if (!p_repl_lines)
|
||||||
|
@@ -1884,6 +1908,12 @@ pch_hunk_beg (void)
|
||||||
|
return p_hunk_beg;
|
||||||
|
}
|
||||||
|
|
||||||
|
+char const *
|
||||||
|
+pch_c_function (void)
|
||||||
|
+{
|
||||||
|
+ return p_c_function;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* Is the newline-terminated line a valid `ed' command for patch
|
||||||
|
input? If so, return the command character; if not, return 0.
|
||||||
|
This accepts accepts just a subset of the valid commands, but it's
|
||||||
|
Index: patch-2.5.9/pch.h
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/pch.h
|
||||||
|
+++ patch-2.5.9/pch.h
|
||||||
|
@@ -25,6 +25,7 @@
|
||||||
|
LINENUM pch_end (void);
|
||||||
|
LINENUM pch_first (void);
|
||||||
|
LINENUM pch_hunk_beg (void);
|
||||||
|
+char const *pch_c_function (void);
|
||||||
|
LINENUM pch_newfirst (void);
|
||||||
|
LINENUM pch_prefix_context (void);
|
||||||
|
LINENUM pch_ptrn_lines (void);
|
||||||
|
Index: patch-2.5.9/patch.man
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/patch.man
|
||||||
|
+++ patch-2.5.9/patch.man
|
||||||
|
@@ -517,6 +517,9 @@ instead of the default
|
||||||
|
.B \&.rej
|
||||||
|
file.
|
||||||
|
.TP
|
||||||
|
+\fB\*=reject\-unified\fP
|
||||||
|
+Produce unified reject files. The default is to produce context type reject files.
|
||||||
|
+.TP
|
||||||
|
\fB\-R\fP or \fB\*=reverse\fP
|
||||||
|
Assume that this patch was created with the old and new files swapped.
|
||||||
|
(Yes, I'm afraid that does happen occasionally, human nature being what it
|
||||||
|
Index: patch-2.5.9/common.h
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/common.h
|
||||||
|
+++ patch-2.5.9/common.h
|
||||||
|
@@ -146,6 +146,7 @@ XTERN int invc;
|
||||||
|
XTERN struct stat instat;
|
||||||
|
XTERN bool dry_run;
|
||||||
|
XTERN bool posixly_correct;
|
||||||
|
+XTERN bool unified_reject_files;
|
||||||
|
|
||||||
|
XTERN char const *origprae;
|
||||||
|
XTERN char const *origbase;
|
||||||
|
Index: patch-2.5.9/patch.c
|
||||||
|
===================================================================
|
||||||
|
--- patch-2.5.9.orig/patch.c
|
||||||
|
+++ patch-2.5.9/patch.c
|
||||||
|
@@ -522,6 +522,7 @@ static struct option const longopts[] =
|
||||||
|
{"no-backup-if-mismatch", no_argument, NULL, CHAR_MAX + 6},
|
||||||
|
{"posix", no_argument, NULL, CHAR_MAX + 7},
|
||||||
|
{"quoting-style", required_argument, NULL, CHAR_MAX + 8},
|
||||||
|
+ {"unified-reject-files", no_argument, NULL, CHAR_MAX + 9},
|
||||||
|
{NULL, no_argument, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
@@ -580,6 +581,7 @@ static char const *const option_help[] =
|
||||||
|
" --verbose Output extra information about the work being done.",
|
||||||
|
" --dry-run Do not actually change any files; just print what would happen.",
|
||||||
|
" --posix Conform to the POSIX standard.",
|
||||||
|
+" --unified-reject-files Create unified reject files.",
|
||||||
|
"",
|
||||||
|
" -d DIR --directory=DIR Change the working directory to DIR first.",
|
||||||
|
#if HAVE_SETMODE_DOS
|
||||||
|
@@ -779,6 +781,9 @@ get_some_switches (void)
|
||||||
|
(enum quoting_style) i);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
+ case CHAR_MAX + 9:
|
||||||
|
+ unified_reject_files = true;
|
||||||
|
+ break;
|
||||||
|
default:
|
||||||
|
usage (stderr, 2);
|
||||||
|
}
|
||||||
|
@@ -927,6 +932,24 @@ locate_hunk (LINENUM fuzz)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+static char *
|
||||||
|
+format_linerange (char rangebuf[LINENUM_LENGTH_BOUND*2 + 2],
|
||||||
|
+ LINENUM first, LINENUM lines)
|
||||||
|
+{
|
||||||
|
+ if (lines == 1)
|
||||||
|
+ rangebuf = format_linenum (rangebuf, first);
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ char *rb;
|
||||||
|
+ rangebuf = format_linenum (rangebuf + LINENUM_LENGTH_BOUND + 1, lines);
|
||||||
|
+ rb = rangebuf-1;
|
||||||
|
+ rangebuf = format_linenum (rangebuf - LINENUM_LENGTH_BOUND - 1,
|
||||||
|
+ (lines > 0) ? first : 0);
|
||||||
|
+ *rb = ',';
|
||||||
|
+ }
|
||||||
|
+ return rangebuf;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/* We did not find the pattern, dump out the hunk so they can handle it. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
@@ -943,8 +966,83 @@ abort_hunk (void)
|
||||||
|
(int) NEW_CONTEXT_DIFF <= (int) diff_type ? " ****" : "";
|
||||||
|
char const *minuses =
|
||||||
|
(int) NEW_CONTEXT_DIFF <= (int) diff_type ? " ----" : " -----";
|
||||||
|
+ char const *function = pch_c_function();
|
||||||
|
+ if (function == NULL)
|
||||||
|
+ function = "";
|
||||||
|
+
|
||||||
|
+ if (unified_reject_files)
|
||||||
|
+ {
|
||||||
|
+ /* produce unified reject files */
|
||||||
|
+ char rangebuf0[LINENUM_LENGTH_BOUND*2 + 2];
|
||||||
|
+ char rangebuf1[LINENUM_LENGTH_BOUND*2 + 2];
|
||||||
|
+ LINENUM j;
|
||||||
|
+
|
||||||
|
+ /* Find the beginning of the remove and insert section. */
|
||||||
|
+ for (j = 0; j <= pat_end; j++)
|
||||||
|
+ if (pch_char (j) == '=')
|
||||||
|
+ break;
|
||||||
|
+ for (i = j+1; i <= pat_end; i++)
|
||||||
|
+ if (pch_char (i) == '^')
|
||||||
|
+ break;
|
||||||
|
+ if (pch_char (0) != '*' || j > pat_end || i > pat_end+1)
|
||||||
|
+ fatal ("internal error in abort_hunk");
|
||||||
|
+ i = 1; j++;
|
||||||
|
+
|
||||||
|
+ /* @@ -from,lines +to,lines @@ */
|
||||||
|
+ fprintf (rejfp, "@@ -%s +%s @@%s\n",
|
||||||
|
+ format_linerange (rangebuf0, oldfirst, pch_ptrn_lines()),
|
||||||
|
+ format_linerange (rangebuf1, newfirst, pch_repl_lines()),
|
||||||
|
+ function);
|
||||||
|
+
|
||||||
|
+ while ( (i <= pat_end && pch_char (i) != '=')
|
||||||
|
+ || (j <= pat_end && pch_char (j) != '^'))
|
||||||
|
+ {
|
||||||
|
+ if (i <= pat_end
|
||||||
|
+ && (pch_char (i) == '-' || pch_char (i) == '!'))
|
||||||
|
+ {
|
||||||
|
+ fputc('-', rejfp);
|
||||||
|
+ pch_write_line (i++, rejfp);
|
||||||
|
+ }
|
||||||
|
+ else if (j <= pat_end
|
||||||
|
+ && (pch_char (j) == '+' || pch_char (j) == '!'))
|
||||||
|
+ {
|
||||||
|
+ fputc('+', rejfp);
|
||||||
|
+ pch_write_line (j++, rejfp);
|
||||||
|
+ }
|
||||||
|
+ else if ((i <= pat_end
|
||||||
|
+ && (pch_char (i) == ' ' || pch_char (i) == '\n')) &&
|
||||||
|
+ (j > pat_end
|
||||||
|
+ || (pch_char (j) == ' ' || pch_char (j) == '\n')))
|
||||||
|
+ {
|
||||||
|
+ /* Unless j is already past the end, lines i and j
|
||||||
|
+ must be equal here. */
|
||||||
|
+
|
||||||
|
+ if (pch_char (i) == ' ')
|
||||||
|
+ fputc(' ', rejfp);
|
||||||
|
+ pch_write_line (i++, rejfp);
|
||||||
|
+ if (j <= pat_end)
|
||||||
|
+ j++;
|
||||||
|
+ }
|
||||||
|
+ else if ((j <= pat_end &&
|
||||||
|
+ (pch_char (j) == ' ' || pch_char (j) == '\n')) &&
|
||||||
|
+ (pch_char (i) == '='))
|
||||||
|
+ {
|
||||||
|
+ if (pch_char (j) == ' ')
|
||||||
|
+ fputc(' ', rejfp);
|
||||||
|
+ pch_write_line (j++, rejfp);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ fatal ("internal error in abort_hunk");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (ferror (rejfp))
|
||||||
|
+ write_fatal ();
|
||||||
|
+ return;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- fprintf(rejfp, "***************\n");
|
||||||
|
+ /* produce context type reject files */
|
||||||
|
+
|
||||||
|
+ fprintf(rejfp, "***************%s\n", function);
|
||||||
|
for (i=0; i<=pat_end; i++) {
|
||||||
|
char numbuf0[LINENUM_LENGTH_BOUND + 1];
|
||||||
|
char numbuf1[LINENUM_LENGTH_BOUND + 1];
|
Loading…
Reference in New Issue
Block a user