Ticket #3598: mc-3598-0025-editor-syntax.c-cleanup-Wcast-qual-warning.patch

File mc-3598-0025-editor-syntax.c-cleanup-Wcast-qual-warning.patch, 3.4 KB (added by and, 8 years ago)
  • src/editor/syntax.c

    From f523232e1f584d0f7b7aa703172801e3c93605ee Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Fri, 19 Feb 2016 21:52:41 +0000
    Subject: [PATCH] editor/syntax.c: cleanup -Wcast-qual warnings
    
    syntax.c:266:14: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         for (p = (unsigned char *) text, q = p + strlen ((char *) p); p < q; p++, i++)
                  ^
    syntax.c:266:54: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         for (p = (unsigned char *) text, q = p + strlen ((char *) p); p < q; p++, i++)
                                                          ^
    syntax.c:298:39: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
                     if (j != 0 && strchr ((char *) p + 1, c) != NULL)       /* c exists further down, so it will get matched later */
                                           ^
    syntax.c:446:43: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
                 while (*(p = xx_strchr (edit, (unsigned char *) p + 1, c)) != '\0')
                                               ^
    syntax.c:547:39: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
             while (*(p = xx_strchr (edit, (unsigned char *) p + 1, c)) != '\0')
                                           ^
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/editor/syntax.c | 8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
    
    diff --git a/src/editor/syntax.c b/src/editor/syntax.c
    index 0e9bbee..6acfccb 100644
    a b compare_word_to_right (const WEdit * edit, off_t i, const char *text, 
    263263    if ((line_start != 0 && c != '\n') || (whole_left != NULL && strchr (whole_left, c) != NULL)) 
    264264        return -1; 
    265265 
    266     for (p = (unsigned char *) text, q = p + strlen ((char *) p); p < q; p++, i++) 
     266    for (p = (const unsigned char *) text, q = p + strlen ((const char *)p); p < q; p++, i++) 
    267267    { 
    268268        switch (*p) 
    269269        { 
    compare_word_to_right (const WEdit * edit, off_t i, const char *text, 
    295295                    if (*p == *text && p[1] == '\0')    /* handle eg '+' and @+@ keywords properly */ 
    296296                        break; 
    297297                } 
    298                 if (j != 0 && strchr ((char *) p + 1, c) != NULL)       /* c exists further down, so it will get matched later */ 
     298                if (j != 0 && strchr ((const char *) p + 1, c) != NULL)       /* c exists further down, so it will get matched later */ 
    299299                    break; 
    300300                if (c == '\n' || c == '\t' || c == ' ' || 
    301301                    (whole_right != NULL && strchr (whole_right, c) == NULL)) 
    apply_rules_going_right (WEdit * edit, off_t i) 
    443443        p = r->keyword_first_chars; 
    444444 
    445445        if (p != NULL) 
    446             while (*(p = xx_strchr (edit, (unsigned char *) p + 1, c)) != '\0') 
     446            while (*(p = xx_strchr (edit, (const unsigned char *) p + 1, c)) != '\0') 
    447447            { 
    448448                syntax_keyword_t *k; 
    449449                int count; 
    apply_rules_going_right (WEdit * edit, off_t i) 
    544544        r = CONTEXT_RULE (g_ptr_array_index (edit->rules, _rule.context)); 
    545545        p = r->keyword_first_chars; 
    546546 
    547         while (*(p = xx_strchr (edit, (unsigned char *) p + 1, c)) != '\0') 
     547        while (*(p = xx_strchr (edit, (const unsigned char *) p + 1, c)) != '\0') 
    548548        { 
    549549            syntax_keyword_t *k; 
    550550            int count;