Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-editors/nano/, app-editors/nano/files/
Date: Fri, 31 Jul 2020 08:38:19
Message-Id: 1596184687.628aa6e172bda140bb466a32e12508eec70e6766.polynomial-c@gentoo
1 commit: 628aa6e172bda140bb466a32e12508eec70e6766
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jul 31 08:31:28 2020 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Fri Jul 31 08:38:07 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=628aa6e1
7
8 app-editors/nano: Fixed build with USE="minimal" and USE="-spell"
9
10 Closes: https://bugs.gentoo.org/734856
11 Package-Manager: Portage-3.0.1, Repoman-2.3.23
12 Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
13
14 .../nano-4.9.3-disable-speller_build_fix.patch | 342 +++++++++++++++++++++
15 .../nano/files/nano-4.9.3-minimal_build_fix.patch | 46 +++
16 app-editors/nano/nano-4.9.3.ebuild | 5 +
17 3 files changed, 393 insertions(+)
18
19 diff --git a/app-editors/nano/files/nano-4.9.3-disable-speller_build_fix.patch b/app-editors/nano/files/nano-4.9.3-disable-speller_build_fix.patch
20 new file mode 100644
21 index 00000000000..978e24de805
22 --- /dev/null
23 +++ b/app-editors/nano/files/nano-4.9.3-disable-speller_build_fix.patch
24 @@ -0,0 +1,342 @@
25 +From 4b7f7a30c9ec593d68186b1dfef44d4e2bda735b Mon Sep 17 00:00:00 2001
26 +From: Benno Schulenberg <bensberg@×××××××.nl>
27 +Date: Mon, 22 Jun 2020 08:39:59 +0200
28 +Subject: [PATCH] build: fix compilation when configured with
29 + --disable-speller
30 +
31 +Move two functions that are used by the formatter too
32 +to between the proper #ifdef.
33 +
34 +Problem existed since commit 8089f5ad from a month ago.
35 +
36 +Backported to v4.9.3
37 +Signed-off-by: Lars Wendler <polynomial-c@g.o>
38 +---
39 + src/text.c | 302 ++++++++++++++++++++++++++---------------------------
40 + 1 file changed, 151 insertions(+), 151 deletions(-)
41 +
42 +diff --git a/src/text.c b/src/text.c
43 +index 93ad3704..c7690fd0 100644
44 +--- a/src/text.c
45 ++++ b/src/text.c
46 +@@ -2011,8 +2011,159 @@ void construct_argument_list(char ***arguments, char *command, char *filename)
47 + (*arguments)[count - 2] = filename;
48 + (*arguments)[count - 1] = NULL;
49 + }
50 ++
51 ++/* Open the specified file, and if that succeeds, remove the text of the marked
52 ++ * region or of the entire buffer and read the file contents into its place. */
53 ++bool replace_buffer(const char *filename, undo_type action, const char *operation)
54 ++{
55 ++ linestruct *was_cutbuffer = cutbuffer;
56 ++ int descriptor;
57 ++ FILE *stream;
58 ++
59 ++ descriptor = open_file(filename, FALSE, &stream);
60 ++
61 ++ if (descriptor < 0)
62 ++ return FALSE;
63 ++
64 ++ cutbuffer = NULL;
65 ++
66 ++#ifndef NANO_TINY
67 ++ add_undo(COUPLE_BEGIN, operation);
68 ++
69 ++ /* Cut either the marked region or the whole buffer. */
70 ++ add_undo(action, NULL);
71 ++#endif
72 ++ do_snip(FALSE, openfile->mark, openfile->mark == NULL, FALSE);
73 ++#ifndef NANO_TINY
74 ++ update_undo(action);
75 + #endif
76 +
77 ++ /* Discard what was cut. */
78 ++ free_lines(cutbuffer);
79 ++ cutbuffer = was_cutbuffer;
80 ++
81 ++ /* Insert the spell-checked file into the cleared area. */
82 ++ read_file(stream, descriptor, filename, TRUE);
83 ++
84 ++#ifndef NANO_TINY
85 ++ add_undo(COUPLE_END, operation);
86 ++#endif
87 ++ return TRUE;
88 ++}
89 ++
90 ++/* Execute the given program, with the given temp file as last argument. */
91 ++const char *treat(char *tempfile_name, char *theprogram, bool spelling)
92 ++{
93 ++ ssize_t lineno_save = openfile->current->lineno;
94 ++ size_t current_x_save = openfile->current_x;
95 ++ size_t pww_save = openfile->placewewant;
96 ++ bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
97 ++ struct stat fileinfo;
98 ++ long timestamp_sec, timestamp_nsec;
99 ++ static char **arguments = NULL;
100 ++ pid_t thepid;
101 ++ int program_status;
102 ++ bool replaced = FALSE;
103 ++
104 ++ /* Get the timestamp and the size of the temporary file. */
105 ++ stat(tempfile_name, &fileinfo);
106 ++ timestamp_sec = (long)fileinfo.st_mtim.tv_sec;
107 ++ timestamp_nsec = (long)fileinfo.st_mtim.tv_nsec;
108 ++
109 ++ /* If the number of bytes to check is zero, get out. */
110 ++ if (fileinfo.st_size == 0)
111 ++ return NULL;
112 ++
113 ++ /* Exit from curses mode to give the program control of the terminal. */
114 ++ endwin();
115 ++
116 ++ construct_argument_list(&arguments, theprogram, tempfile_name);
117 ++
118 ++ /* Fork a child process and run the given program in it. */
119 ++ if ((thepid = fork()) == 0) {
120 ++ execvp(arguments[0], arguments);
121 ++
122 ++ /* Terminate the child if the program is not found. */
123 ++ exit(9);
124 ++ } else if (thepid < 0)
125 ++ return _("Could not fork");
126 ++
127 ++ /* Block SIGWINCHes while waiting for the program to end,
128 ++ * so nano doesn't get pushed past the wait(). */
129 ++ block_sigwinch(TRUE);
130 ++ wait(&program_status);
131 ++ block_sigwinch(FALSE);
132 ++
133 ++ /* Restore the terminal state and reenter curses mode. */
134 ++ terminal_init();
135 ++ doupdate();
136 ++
137 ++ if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2) {
138 ++ statusline(ALERT, _("Error invoking '%s'"), arguments[0]);
139 ++ return NULL;
140 ++ } else if (WEXITSTATUS(program_status) != 0)
141 ++ statusline(ALERT, _("Program '%s' complained"), arguments[0]);
142 ++
143 ++ /* Stat the temporary file again. */
144 ++ stat(tempfile_name, &fileinfo);
145 ++
146 ++ /* When the temporary file wasn't touched, say so and leave. */
147 ++ if ((long)fileinfo.st_mtim.tv_sec == timestamp_sec &&
148 ++ (long)fileinfo.st_mtim.tv_nsec == timestamp_nsec) {
149 ++ statusbar(_("Nothing changed"));
150 ++ return NULL;
151 ++ }
152 ++
153 ++#ifndef NANO_TINY
154 ++ /* Replace the marked text (or entire text) with the corrected text. */
155 ++ if (spelling && openfile->mark) {
156 ++ ssize_t was_mark_lineno = openfile->mark->lineno;
157 ++ bool upright = mark_is_before_cursor();
158 ++
159 ++ replaced = replace_buffer(tempfile_name, CUT, "spelling correction");
160 ++
161 ++ /* Adjust the end point of the marked region for any change in
162 ++ * length of the region's last line. */
163 ++ if (upright)
164 ++ current_x_save = openfile->current_x;
165 ++ else
166 ++ openfile->mark_x = openfile->current_x;
167 ++
168 ++ /* Restore the mark. */
169 ++ openfile->mark = line_from_number(was_mark_lineno);
170 ++ } else
171 ++#endif
172 ++ {
173 ++ openfile->current = openfile->filetop;
174 ++ openfile->current_x = 0;
175 ++
176 ++ replaced = replace_buffer(tempfile_name, CUT_TO_EOF,
177 ++ /* TRANSLATORS: The next two go with Undid/Redid messages. */
178 ++ (spelling ? N_("spelling correction") : N_("formatting")));
179 ++ }
180 ++
181 ++ /* Go back to the old position. */
182 ++ goto_line_posx(lineno_save, current_x_save);
183 ++ if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
184 ++ openfile->current_x = strlen(openfile->current->data);
185 ++
186 ++#ifndef NANO_TINY
187 ++ if (replaced)
188 ++ update_undo(COUPLE_END);
189 ++#endif
190 ++
191 ++ openfile->placewewant = pww_save;
192 ++ adjust_viewport(STATIONARY);
193 ++
194 ++ if (spelling)
195 ++ statusbar(_("Finished checking spelling"));
196 ++ else
197 ++ statusbar(_("Buffer has been processed"));
198 ++
199 ++ return NULL;
200 ++}
201 ++#endif /* ENABLE_SPELLER || ENABLE_COLOR */
202 ++
203 + #ifdef ENABLE_SPELLER
204 + /* Let the user edit the misspelled word. Return FALSE if the user cancels. */
205 + bool fix_spello(const char *word)
206 +@@ -2307,157 +2458,6 @@ const char *do_int_speller(const char *tempfile_name)
207 + return NULL;
208 + }
209 +
210 +-/* Open the specified file, and if that succeeds, remove the text of the marked
211 +- * region or of the entire buffer and read the file contents into its place. */
212 +-bool replace_buffer(const char *filename, undo_type action, const char *operation)
213 +-{
214 +- linestruct *was_cutbuffer = cutbuffer;
215 +- int descriptor;
216 +- FILE *stream;
217 +-
218 +- descriptor = open_file(filename, FALSE, &stream);
219 +-
220 +- if (descriptor < 0)
221 +- return FALSE;
222 +-
223 +- cutbuffer = NULL;
224 +-
225 +-#ifndef NANO_TINY
226 +- add_undo(COUPLE_BEGIN, operation);
227 +-
228 +- /* Cut either the marked region or the whole buffer. */
229 +- add_undo(action, NULL);
230 +-#endif
231 +- do_snip(FALSE, openfile->mark, openfile->mark == NULL, FALSE);
232 +-#ifndef NANO_TINY
233 +- update_undo(action);
234 +-#endif
235 +-
236 +- /* Discard what was cut. */
237 +- free_lines(cutbuffer);
238 +- cutbuffer = was_cutbuffer;
239 +-
240 +- /* Insert the spell-checked file into the cleared area. */
241 +- read_file(stream, descriptor, filename, TRUE);
242 +-
243 +-#ifndef NANO_TINY
244 +- add_undo(COUPLE_END, operation);
245 +-#endif
246 +- return TRUE;
247 +-}
248 +-
249 +-/* Execute the given program, with the given temp file as last argument. */
250 +-const char *treat(char *tempfile_name, char *theprogram, bool spelling)
251 +-{
252 +- ssize_t lineno_save = openfile->current->lineno;
253 +- size_t current_x_save = openfile->current_x;
254 +- size_t pww_save = openfile->placewewant;
255 +- bool was_at_eol = (openfile->current->data[openfile->current_x] == '\0');
256 +- struct stat fileinfo;
257 +- long timestamp_sec, timestamp_nsec;
258 +- static char **arguments = NULL;
259 +- pid_t thepid;
260 +- int program_status;
261 +- bool replaced = FALSE;
262 +-
263 +- /* Get the timestamp and the size of the temporary file. */
264 +- stat(tempfile_name, &fileinfo);
265 +- timestamp_sec = (long)fileinfo.st_mtim.tv_sec;
266 +- timestamp_nsec = (long)fileinfo.st_mtim.tv_nsec;
267 +-
268 +- /* If the number of bytes to check is zero, get out. */
269 +- if (fileinfo.st_size == 0)
270 +- return NULL;
271 +-
272 +- /* Exit from curses mode to give the program control of the terminal. */
273 +- endwin();
274 +-
275 +- construct_argument_list(&arguments, theprogram, tempfile_name);
276 +-
277 +- /* Fork a child process and run the given program in it. */
278 +- if ((thepid = fork()) == 0) {
279 +- execvp(arguments[0], arguments);
280 +-
281 +- /* Terminate the child if the program is not found. */
282 +- exit(9);
283 +- } else if (thepid < 0)
284 +- return _("Could not fork");
285 +-
286 +- /* Block SIGWINCHes while waiting for the program to end,
287 +- * so nano doesn't get pushed past the wait(). */
288 +- block_sigwinch(TRUE);
289 +- wait(&program_status);
290 +- block_sigwinch(FALSE);
291 +-
292 +- /* Restore the terminal state and reenter curses mode. */
293 +- terminal_init();
294 +- doupdate();
295 +-
296 +- if (!WIFEXITED(program_status) || WEXITSTATUS(program_status) > 2) {
297 +- statusline(ALERT, _("Error invoking '%s'"), arguments[0]);
298 +- return NULL;
299 +- } else if (WEXITSTATUS(program_status) != 0)
300 +- statusline(ALERT, _("Program '%s' complained"), arguments[0]);
301 +-
302 +- /* Stat the temporary file again. */
303 +- stat(tempfile_name, &fileinfo);
304 +-
305 +- /* When the temporary file wasn't touched, say so and leave. */
306 +- if ((long)fileinfo.st_mtim.tv_sec == timestamp_sec &&
307 +- (long)fileinfo.st_mtim.tv_nsec == timestamp_nsec) {
308 +- statusbar(_("Nothing changed"));
309 +- return NULL;
310 +- }
311 +-
312 +-#ifndef NANO_TINY
313 +- /* Replace the marked text (or entire text) with the corrected text. */
314 +- if (spelling && openfile->mark) {
315 +- ssize_t was_mark_lineno = openfile->mark->lineno;
316 +- bool upright = mark_is_before_cursor();
317 +-
318 +- replaced = replace_buffer(tempfile_name, CUT, "spelling correction");
319 +-
320 +- /* Adjust the end point of the marked region for any change in
321 +- * length of the region's last line. */
322 +- if (upright)
323 +- current_x_save = openfile->current_x;
324 +- else
325 +- openfile->mark_x = openfile->current_x;
326 +-
327 +- /* Restore the mark. */
328 +- openfile->mark = line_from_number(was_mark_lineno);
329 +- } else
330 +-#endif
331 +- {
332 +- openfile->current = openfile->filetop;
333 +- openfile->current_x = 0;
334 +-
335 +- replaced = replace_buffer(tempfile_name, CUT_TO_EOF,
336 +- /* TRANSLATORS: The next two go with Undid/Redid messages. */
337 +- (spelling ? N_("spelling correction") : N_("formatting")));
338 +- }
339 +-
340 +- /* Go back to the old position. */
341 +- goto_line_posx(lineno_save, current_x_save);
342 +- if (was_at_eol || openfile->current_x > strlen(openfile->current->data))
343 +- openfile->current_x = strlen(openfile->current->data);
344 +-
345 +-#ifndef NANO_TINY
346 +- if (replaced)
347 +- update_undo(COUPLE_END);
348 +-#endif
349 +-
350 +- openfile->placewewant = pww_save;
351 +- adjust_viewport(STATIONARY);
352 +-
353 +- if (spelling)
354 +- statusbar(_("Finished checking spelling"));
355 +- else
356 +- statusbar(_("Buffer has been processed"));
357 +-
358 +- return NULL;
359 +-}
360 +-
361 + /* Spell check the current file. If an alternate spell checker is
362 + * specified, use it. Otherwise, use the internal spell checker. */
363 + void do_spell(void)
364 +--
365 +2.28.0
366 +
367
368 diff --git a/app-editors/nano/files/nano-4.9.3-minimal_build_fix.patch b/app-editors/nano/files/nano-4.9.3-minimal_build_fix.patch
369 new file mode 100644
370 index 00000000000..52112bab723
371 --- /dev/null
372 +++ b/app-editors/nano/files/nano-4.9.3-minimal_build_fix.patch
373 @@ -0,0 +1,46 @@
374 +From a98f48b4e82db7d30aa04925fb28344f5bce8c7c Mon Sep 17 00:00:00 2001
375 +From: Benno Schulenberg <bensberg@×××××××.nl>
376 +Date: Mon, 22 Jun 2020 14:00:23 +0200
377 +Subject: [PATCH] build: fix compilation for --enable-tiny --enable-color
378 + --enable-nanorc
379 +
380 +Backported to v4.9.3
381 +Signed-off-by: Lars Wendler <polynomial-c@g.o>
382 +---
383 + src/nano.c | 2 +-
384 + src/text.c | 4 ++--
385 + 2 files changed, 3 insertions(+), 3 deletions(-)
386 +
387 +diff --git a/src/nano.c b/src/nano.c
388 +index be80a073..3ac81ba4 100644
389 +--- a/src/nano.c
390 ++++ b/src/nano.c
391 +@@ -1079,7 +1079,7 @@ RETSIGTYPE do_continue(int signal)
392 + ungetch(KEY_FLUSH);
393 + }
394 +
395 +-#if !defined(NANO_TINY) || defined(ENABLE_SPELLER)
396 ++#if !defined(NANO_TINY) || defined(ENABLE_SPELLER) || defined(ENABLE_COLOR)
397 + /* Block or unblock the SIGWINCH signal, depending on the blockit parameter. */
398 + void block_sigwinch(bool blockit)
399 + {
400 +diff --git a/src/text.c b/src/text.c
401 +index c7690fd0..32727946 100644
402 +--- a/src/text.c
403 ++++ b/src/text.c
404 +@@ -2032,10 +2032,10 @@ bool replace_buffer(const char *filename, undo_type action, const char *operatio
405 +
406 + /* Cut either the marked region or the whole buffer. */
407 + add_undo(action, NULL);
408 +-#endif
409 + do_snip(FALSE, openfile->mark, openfile->mark == NULL, FALSE);
410 +-#ifndef NANO_TINY
411 + update_undo(action);
412 ++#else
413 ++ do_snip(FALSE, TRUE, FALSE, FALSE);
414 + #endif
415 +
416 + /* Discard what was cut. */
417 +--
418 +2.28.0
419 +
420
421 diff --git a/app-editors/nano/nano-4.9.3.ebuild b/app-editors/nano/nano-4.9.3.ebuild
422 index 076c22b9c60..bd791de7db4 100644
423 --- a/app-editors/nano/nano-4.9.3.ebuild
424 +++ b/app-editors/nano/nano-4.9.3.ebuild
425 @@ -32,6 +32,11 @@ BDEPEND="
426 nls? ( sys-devel/gettext )
427 virtual/pkgconfig
428 "
429 +PATCHES=(
430 + "${FILESDIR}/${P}-disable-speller_build_fix.patch"
431 + "${FILESDIR}/${P}-minimal_build_fix.patch" #734856
432 +)
433 +
434 src_prepare() {
435 default
436 if [[ ${PV} == "9999" ]] ; then