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