Ticket #3598: mc-3598-0013-widget-input_complete.c-cleanup-Wcast-qual-warning.patch

File mc-3598-0013-widget-input_complete.c-cleanup-Wcast-qual-warning.patch, 2.3 KB (added by and, 8 years ago)
  • lib/widget/input_complete.c

    From a40fa7b34502bc66d06daaf712deacb47559ba11 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 20 Feb 2016 10:46:35 +0000
    Subject: [PATCH] widget/input_complete.c: cleanup -Wcast-qual warning
    
    input_complete.c:688:21: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         return strcmp (*(char **) a, *(char **) b);
                         ^
    input_complete.c:688:35: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         return strcmp (*(char **) a, *(char **) b);
                                       ^
    input_complete.c:810:9: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         p = (char *) text;
             ^
    input_complete.c:811:9: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         q = (char *) text + lc_start;
             ^
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     lib/widget/input_complete.c | 10 +++++-----
     1 file changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/lib/widget/input_complete.c b/lib/widget/input_complete.c
    index ccd4b81..1ad9df6 100644
    a b command_completion_function (const char *_text, int state, input_complete_t flag 
    685685static int 
    686686match_compare (const void *a, const void *b) 
    687687{ 
    688     return strcmp (*(char **) a, *(char **) b); 
     688    return strcmp (*(char *const *) a, *(char *const *) b); 
    689689} 
    690690 
    691691/* --------------------------------------------------------------------------------------------- */ 
    completion_matches (const char *text, CompletionFunction entry_function, input_c 
    799799static gboolean 
    800800check_is_cd (const char *text, int lc_start, input_complete_t flags) 
    801801{ 
    802     char *p, *q; 
     802    const char *p, *q; 
    803803 
    804804    SHOW_C_CTX ("check_is_cd"); 
    805805 
    check_is_cd (const char *text, int lc_start, input_complete_t flags) 
    807807        return FALSE; 
    808808 
    809809    /* Skip initial spaces */ 
    810     p = (char *) text; 
    811     q = (char *) text + lc_start; 
     810    p = text; 
     811    q = text + lc_start; 
    812812    while (p < q && p[0] != '\0' && str_isspace (p)) 
    813         str_next_char (&p); 
     813        str_cnext_char (&p); 
    814814 
    815815    /* Check if the command is "cd" and the cursor is after it */ 
    816816    return (p[0] == 'c' && p[1] == 'd' && str_isspace (p + 2) && p + 2 < q);