aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-01-10 08:38:15 +0000
committerRon Yorston <rmy@pobox.com>2019-01-10 08:38:15 +0000
commitf99a280743e877c14ee90a3f9e93a34ca3476a27 (patch)
tree60ca3d17596e190c8c7cbca587168946598bee8a /libbb/lineedit.c
parent40d5dd07ea1f290eaed30a03fd598e33a8eaf495 (diff)
parent6ca8e347fed8c24655df692f22694baf7c572770 (diff)
downloadbusybox-w32-f99a280743e877c14ee90a3f9e93a34ca3476a27.tar.gz
busybox-w32-f99a280743e877c14ee90a3f9e93a34ca3476a27.tar.bz2
busybox-w32-f99a280743e877c14ee90a3f9e93a34ca3476a27.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 11a77ec69..0b4e326d8 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1444,6 +1444,16 @@ void FAST_FUNC show_history(const line_input_t *st)
1444 printf("%4d %s\n", i, st->history[i]); 1444 printf("%4d %s\n", i, st->history[i]);
1445} 1445}
1446 1446
1447void FAST_FUNC free_line_input_t(line_input_t *n)
1448{
1449# if ENABLE_FEATURE_EDITING_SAVEHISTORY
1450 int i = n->cnt_history;
1451 while (i > 0)
1452 free(n->history[--i]);
1453#endif
1454 free(n);
1455}
1456
1447# if ENABLE_FEATURE_EDITING_SAVEHISTORY 1457# if ENABLE_FEATURE_EDITING_SAVEHISTORY
1448/* We try to ensure that concurrent additions to the history 1458/* We try to ensure that concurrent additions to the history
1449 * do not overwrite each other. 1459 * do not overwrite each other.
@@ -1453,14 +1463,6 @@ void FAST_FUNC show_history(const line_input_t *st)
1453 * than configured MAX_HISTORY lines. 1463 * than configured MAX_HISTORY lines.
1454 */ 1464 */
1455 1465
1456static void free_line_input_t(line_input_t *n)
1457{
1458 int i = n->cnt_history;
1459 while (i > 0)
1460 free(n->history[--i]);
1461 free(n);
1462}
1463
1464/* state->flags is already checked to be nonzero */ 1466/* state->flags is already checked to be nonzero */
1465static void load_history(line_input_t *st_parm) 1467static void load_history(line_input_t *st_parm)
1466{ 1468{
@@ -2380,6 +2382,18 @@ static int32_t reverse_i_search(int timeout)
2380} 2382}
2381#endif 2383#endif
2382 2384
2385#if ENABLE_FEATURE_EDITING_WINCH
2386static void sigaction2(int sig, struct sigaction *act)
2387{
2388 // Grr... gcc 8.1.1:
2389 // "passing argument 3 to restrict-qualified parameter aliases with argument 2"
2390 // dance around that...
2391 struct sigaction *oact FIX_ALIASING;
2392 oact = act;
2393 sigaction(sig, act, oact);
2394}
2395#endif
2396
2383/* maxsize must be >= 2. 2397/* maxsize must be >= 2.
2384 * Returns: 2398 * Returns:
2385 * -1 on read errors or EOF, or on bare Ctrl-D, 2399 * -1 on read errors or EOF, or on bare Ctrl-D,
@@ -2500,7 +2514,7 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2500 /* Install window resize handler (NB: after *all* init is complete) */ 2514 /* Install window resize handler (NB: after *all* init is complete) */
2501 S.SIGWINCH_handler.sa_handler = win_changed; 2515 S.SIGWINCH_handler.sa_handler = win_changed;
2502 S.SIGWINCH_handler.sa_flags = SA_RESTART; 2516 S.SIGWINCH_handler.sa_flags = SA_RESTART;
2503 sigaction(SIGWINCH, &S.SIGWINCH_handler, &S.SIGWINCH_handler); 2517 sigaction2(SIGWINCH, &S.SIGWINCH_handler);
2504#endif 2518#endif
2505 read_key_buffer[0] = 0; 2519 read_key_buffer[0] = 0;
2506 while (1) { 2520 while (1) {