diff options
Diffstat (limited to 'recipes-devtools/patch/patch/global-reject-file.diff')
-rw-r--r-- | recipes-devtools/patch/patch/global-reject-file.diff | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/recipes-devtools/patch/patch/global-reject-file.diff b/recipes-devtools/patch/patch/global-reject-file.diff new file mode 100644 index 0000000..bb7ca79 --- /dev/null +++ b/recipes-devtools/patch/patch/global-reject-file.diff | |||
@@ -0,0 +1,203 @@ | |||
1 | Upstream-Status: Inappropriate [debian patch] | ||
2 | |||
3 | Index: patch-2.5.9/patch.man | ||
4 | =================================================================== | ||
5 | --- patch-2.5.9.orig/patch.man | ||
6 | +++ patch-2.5.9/patch.man | ||
7 | @@ -520,6 +520,15 @@ file. | ||
8 | \fB\*=reject\-unified\fP | ||
9 | Produce unified reject files. The default is to produce context type reject files. | ||
10 | .TP | ||
11 | +.BI \*=global\-reject\-file= rejectfile | ||
12 | +Put all rejects into | ||
13 | +.I rejectfile | ||
14 | +instead of creating separate reject files for all files that have rejects. The | ||
15 | +.I rejectfile | ||
16 | +will contain headers that identify which file each reject refers to. Note that | ||
17 | +the global reject file is created even if \-\-dry\-run is specified (while | ||
18 | +non-global reject files will only be created without \-\-dry\-run). | ||
19 | +.TP | ||
20 | \fB\-R\fP or \fB\*=reverse\fP | ||
21 | Assume that this patch was created with the old and new files swapped. | ||
22 | (Yes, I'm afraid that does happen occasionally, human nature being what it | ||
23 | Index: patch-2.5.9/patch.c | ||
24 | =================================================================== | ||
25 | --- patch-2.5.9.orig/patch.c | ||
26 | +++ patch-2.5.9/patch.c | ||
27 | @@ -67,6 +67,7 @@ static bool similar (char const *, size_ | ||
28 | static bool spew_output (struct outstate *); | ||
29 | static char const *make_temp (char); | ||
30 | static int numeric_string (char const *, bool, char const *); | ||
31 | +static void reject_header (const char *filename); | ||
32 | static void abort_hunk (void); | ||
33 | static void cleanup (void); | ||
34 | static void get_some_switches (void); | ||
35 | @@ -98,6 +99,7 @@ static int Argc; | ||
36 | static char * const *Argv; | ||
37 | |||
38 | static FILE *rejfp; /* reject file pointer */ | ||
39 | +static char *global_reject; | ||
40 | |||
41 | static char const *patchname; | ||
42 | static char *rejname; | ||
43 | @@ -172,6 +174,10 @@ main (int argc, char **argv) | ||
44 | /* Make sure we clean up in case of disaster. */ | ||
45 | set_signals (false); | ||
46 | |||
47 | + /* initialize global reject file */ | ||
48 | + if (global_reject) | ||
49 | + init_reject (); | ||
50 | + | ||
51 | for ( | ||
52 | open_patch_file (patchname); | ||
53 | there_is_another_patch(); | ||
54 | @@ -208,8 +214,9 @@ main (int argc, char **argv) | ||
55 | init_output (TMPOUTNAME, exclusive, &outstate); | ||
56 | } | ||
57 | |||
58 | - /* initialize reject file */ | ||
59 | - init_reject (); | ||
60 | + /* initialize per-patch reject file */ | ||
61 | + if (!global_reject) | ||
62 | + init_reject (); | ||
63 | |||
64 | /* find out where all the lines are */ | ||
65 | if (!skip_rest_of_patch) | ||
66 | @@ -278,6 +285,8 @@ main (int argc, char **argv) | ||
67 | |||
68 | newwhere = pch_newfirst() + last_offset; | ||
69 | if (skip_rest_of_patch) { | ||
70 | + if (!failed) | ||
71 | + reject_header(outname); | ||
72 | abort_hunk(); | ||
73 | failed++; | ||
74 | if (verbosity == VERBOSE) | ||
75 | @@ -292,6 +301,8 @@ main (int argc, char **argv) | ||
76 | say ("Patch attempted to create file %s, which already exists.\n", | ||
77 | quotearg (inname)); | ||
78 | |||
79 | + if (!failed) | ||
80 | + reject_header(outname); | ||
81 | abort_hunk(); | ||
82 | failed++; | ||
83 | if (verbosity != SILENT) | ||
84 | @@ -299,6 +310,8 @@ main (int argc, char **argv) | ||
85 | format_linenum (numbuf, newwhere)); | ||
86 | } | ||
87 | else if (! apply_hunk (&outstate, where)) { | ||
88 | + if (!failed) | ||
89 | + reject_header(outname); | ||
90 | abort_hunk (); | ||
91 | failed++; | ||
92 | if (verbosity != SILENT) | ||
93 | @@ -332,7 +345,8 @@ main (int argc, char **argv) | ||
94 | fclose (outstate.ofp); | ||
95 | outstate.ofp = 0; | ||
96 | } | ||
97 | - fclose (rejfp); | ||
98 | + if (!global_reject) | ||
99 | + fclose (rejfp); | ||
100 | continue; | ||
101 | } | ||
102 | |||
103 | @@ -412,13 +426,13 @@ main (int argc, char **argv) | ||
104 | } | ||
105 | } | ||
106 | if (diff_type != ED_DIFF) { | ||
107 | - if (fclose (rejfp) != 0) | ||
108 | + if (!global_reject && fclose (rejfp) != 0) | ||
109 | write_fatal (); | ||
110 | if (failed) { | ||
111 | somefailed = true; | ||
112 | say ("%d out of %d hunk%s %s", failed, hunk, "s" + (hunk == 1), | ||
113 | skip_rest_of_patch ? "ignored" : "FAILED"); | ||
114 | - if (outname) { | ||
115 | + if (!global_reject && outname) { | ||
116 | char *rej = rejname; | ||
117 | if (!rejname) { | ||
118 | rej = xmalloc (strlen (outname) + 5); | ||
119 | @@ -445,6 +459,20 @@ main (int argc, char **argv) | ||
120 | } | ||
121 | set_signals (true); | ||
122 | } | ||
123 | + if (global_reject) | ||
124 | + { | ||
125 | + if (fclose (rejfp) != 0) | ||
126 | + write_fatal (); | ||
127 | + if (somefailed) | ||
128 | + { | ||
129 | + say (" -- saving rejects to file %s\n", quotearg (global_reject)); | ||
130 | + /*if (! dry_run) | ||
131 | + {*/ | ||
132 | + move_file (TMPREJNAME, &TMPREJNAME_needs_removal, | ||
133 | + global_reject, 0644, false); | ||
134 | + /*}*/ | ||
135 | + } | ||
136 | + } | ||
137 | if (outstate.ofp && (ferror (outstate.ofp) || fclose (outstate.ofp) != 0)) | ||
138 | write_fatal (); | ||
139 | cleanup (); | ||
140 | @@ -523,6 +551,7 @@ static struct option const longopts[] = | ||
141 | {"posix", no_argument, NULL, CHAR_MAX + 7}, | ||
142 | {"quoting-style", required_argument, NULL, CHAR_MAX + 8}, | ||
143 | {"unified-reject-files", no_argument, NULL, CHAR_MAX + 9}, | ||
144 | + {"global-reject-file", required_argument, NULL, CHAR_MAX + 10}, | ||
145 | {NULL, no_argument, NULL, 0} | ||
146 | }; | ||
147 | |||
148 | @@ -582,6 +611,7 @@ static char const *const option_help[] = | ||
149 | " --dry-run Do not actually change any files; just print what would happen.", | ||
150 | " --posix Conform to the POSIX standard.", | ||
151 | " --unified-reject-files Create unified reject files.", | ||
152 | +" --global-reject-file=file Put all rejects into one file.", | ||
153 | "", | ||
154 | " -d DIR --directory=DIR Change the working directory to DIR first.", | ||
155 | #if HAVE_SETMODE_DOS | ||
156 | @@ -784,6 +814,9 @@ get_some_switches (void) | ||
157 | case CHAR_MAX + 9: | ||
158 | unified_reject_files = true; | ||
159 | break; | ||
160 | + case CHAR_MAX + 10: | ||
161 | + global_reject = savestr (optarg); | ||
162 | + break; | ||
163 | default: | ||
164 | usage (stderr, 2); | ||
165 | } | ||
166 | @@ -933,6 +966,37 @@ locate_hunk (LINENUM fuzz) | ||
167 | } | ||
168 | |||
169 | static char * | ||
170 | +format_timestamp (char timebuf[37], bool which) | ||
171 | +{ | ||
172 | + time_t ts = pch_timestamp(which); | ||
173 | + if (ts != -1) | ||
174 | + { | ||
175 | + struct tm *tm = localtime(&ts); | ||
176 | + strftime(timebuf, 37, "\t%Y-%m-%d %H:%M:%S.000000000 %z", tm); | ||
177 | + } | ||
178 | + else | ||
179 | + timebuf[0] = 0; | ||
180 | + return timebuf; | ||
181 | +} | ||
182 | + | ||
183 | +/* Write a header in a reject file that combines multiple hunks. */ | ||
184 | +static void | ||
185 | +reject_header (const char *outname) | ||
186 | +{ | ||
187 | + char timebuf0[37], timebuf1[37]; | ||
188 | + if (!global_reject) | ||
189 | + return; | ||
190 | + if (diff_type == UNI_DIFF) | ||
191 | + fprintf(rejfp, "--- %s.orig%s\n+++ %s%s\n", | ||
192 | + outname, format_timestamp(timebuf0, reverse), | ||
193 | + outname, format_timestamp(timebuf1, !reverse)); | ||
194 | + else | ||
195 | + fprintf(rejfp, "*** %s.orig%s\n--- %s%s\n", | ||
196 | + outname, format_timestamp(timebuf0, reverse), | ||
197 | + outname, format_timestamp(timebuf1, !reverse)); | ||
198 | +} | ||
199 | + | ||
200 | +static char * | ||
201 | format_linerange (char rangebuf[LINENUM_LENGTH_BOUND*2 + 2], | ||
202 | LINENUM first, LINENUM lines) | ||
203 | { | ||