From 8092fe3c0c75c5d78845103024a7446103e569c7 Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Thu, 28 Apr 2016 15:24:05 +0000
Subject: [PATCH] Cleanup cppcheck warning at input_complete.c
As other local functions use "text" as function parameter variable
to fix cppcheck warning:
[lib/widget/input_complete.c:569]: (error) Uninitialized variable: text
Signed-off-by: Andreas Mohr <and@gmx.li>
---
lib/widget/input_complete.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c
index 06f9b07..fa9c78f 100644
a
|
b
|
hostname_completion_function (const char *text, int state, input_complete_t flag |
538 | 538 | */ |
539 | 539 | |
540 | 540 | static char * |
541 | | command_completion_function (const char *_text, int state, input_complete_t flags) |
| 541 | command_completion_function (const char *text, int state, input_complete_t flags) |
542 | 542 | { |
543 | | char *text; |
| 543 | char *u_text; |
544 | 544 | static const char *path_end; |
545 | 545 | static gboolean isabsolute; |
546 | 546 | static int phase; |
… |
… |
command_completion_function (const char *_text, int state, input_complete_t flag |
565 | 565 | }; |
566 | 566 | char *p, *found; |
567 | 567 | |
568 | | /* cppcheck-suppress uninitvar */ |
569 | 568 | SHOW_C_CTX ("command_completion_function"); |
570 | 569 | |
571 | 570 | if (!(flags & INPUT_COMPLETE_COMMANDS)) |
572 | 571 | return 0; |
573 | 572 | |
574 | | text = strutils_shell_unescape (_text); |
| 573 | u_text = strutils_shell_unescape (text); |
575 | 574 | flags &= ~INPUT_COMPLETE_SHELL_ESC; |
576 | 575 | |
577 | 576 | if (state == 0) |
578 | 577 | { /* Initialize us a little bit */ |
579 | | isabsolute = strchr (text, PATH_SEP) != NULL; |
| 578 | isabsolute = strchr (u_text, PATH_SEP) != NULL; |
580 | 579 | if (!isabsolute) |
581 | 580 | { |
582 | 581 | words = bash_reserved; |
583 | 582 | phase = 0; |
584 | | text_len = strlen (text); |
| 583 | text_len = strlen (u_text); |
585 | 584 | |
586 | 585 | if (path == NULL) |
587 | 586 | { |
… |
… |
command_completion_function (const char *_text, int state, input_complete_t flag |
601 | 600 | |
602 | 601 | if (isabsolute) |
603 | 602 | { |
604 | | p = filename_completion_function (text, state, flags); |
| 603 | p = filename_completion_function (u_text, state, flags); |
605 | 604 | |
606 | 605 | if (p != NULL) |
607 | 606 | { |
… |
… |
command_completion_function (const char *_text, int state, input_complete_t flag |
611 | 610 | g_free (temp_p); |
612 | 611 | } |
613 | 612 | |
614 | | g_free (text); |
| 613 | g_free (u_text); |
615 | 614 | return p; |
616 | 615 | } |
617 | 616 | |
… |
… |
command_completion_function (const char *_text, int state, input_complete_t flag |
620 | 619 | { |
621 | 620 | case 0: /* Reserved words */ |
622 | 621 | for (; *words != NULL; words++) |
623 | | if (strncmp (*words, text, text_len) == 0) |
| 622 | if (strncmp (*words, u_text, text_len) == 0) |
624 | 623 | { |
625 | | g_free (text); |
| 624 | g_free (u_text); |
626 | 625 | return g_strdup (*(words++)); |
627 | 626 | } |
628 | 627 | phase++; |
629 | 628 | words = bash_builtins; |
630 | 629 | case 1: /* Builtin commands */ |
631 | 630 | for (; *words != NULL; words++) |
632 | | if (strncmp (*words, text, text_len) == 0) |
| 631 | if (strncmp (*words, u_text, text_len) == 0) |
633 | 632 | { |
634 | | g_free (text); |
| 633 | g_free (u_text); |
635 | 634 | return g_strdup (*(words++)); |
636 | 635 | } |
637 | 636 | phase++; |
… |
… |
command_completion_function (const char *_text, int state, input_complete_t flag |
649 | 648 | if (cur_path >= path_end) |
650 | 649 | break; |
651 | 650 | expanded = tilde_expand (*cur_path ? cur_path : "."); |
652 | | cur_word = mc_build_filename (expanded, text, (char *) NULL); |
| 651 | cur_word = mc_build_filename (expanded, u_text, (char *) NULL); |
653 | 652 | g_free (expanded); |
654 | 653 | canonicalize_pathname (cur_word); |
655 | 654 | cur_path = strchr (cur_path, 0) + 1; |
… |
… |
command_completion_function (const char *_text, int state, input_complete_t flag |
676 | 675 | } |
677 | 676 | } |
678 | 677 | |
679 | | g_free (text); |
| 678 | g_free (u_text); |
680 | 679 | return found; |
681 | 680 | } |
682 | 681 | |