Ticket #3598: mc-3598-0036-strutil-strutilutf8.c-cleanup-some-Wcast-qual-warnings.patch

File mc-3598-0036-strutil-strutilutf8.c-cleanup-some-Wcast-qual-warnings.patch, 2.9 KB (added by and, 8 years ago)
  • lib/strutil/strutilutf8.c

    From 4101b57d2b360c95113119da4221b7210c15eca8 Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sat, 20 Feb 2016 17:12:37 +0000
    Subject: [PATCH] strutil/strutilutf8.c: cleanup some -Wcast-qual warnings
    
    strutilutf8.c: In function 'str_utf8_vfs_convert_to':
    strutilutf8.c:430:39: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
             result = str_nconvert (coder, (char *) string, size, buffer);
                                           ^
    strutilutf8.c: In function 'str_utf8_search_first':
    strutilutf8.c:996:30: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         fold_text = (case_sen) ? (char *) text : g_utf8_casefold (text, -1);
                                  ^
    strutilutf8.c: In function 'str_utf8_search_last':
    strutilutf8.c:1040:30: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
         fold_text = (case_sen) ? (char *) text : g_utf8_casefold (text, -1);
                                  ^
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     lib/strutil/strutilutf8.c | 12 +++++-------
     1 file changed, 5 insertions(+), 7 deletions(-)
    
    diff --git a/lib/strutil/strutilutf8.c b/lib/strutil/strutilutf8.c
    index 8ec754d..aea7ecc 100644
    a b str_utf8_vfs_convert_to (GIConv coder, const char *string, int size, GString * b 
    427427    if (coder == str_cnv_not_convert) 
    428428        g_string_append_len (buffer, string, size); 
    429429    else 
    430         result = str_nconvert (coder, (char *) string, size, buffer); 
     430        result = str_nconvert (coder, string, size, buffer); 
    431431 
    432432    return result; 
    433433} 
    str_utf8_search_first (const char *text, const char *search, int case_sen) 
    993993    const char *result = NULL; 
    994994    const char *m; 
    995995 
    996     fold_text = (case_sen) ? (char *) text : g_utf8_casefold (text, -1); 
     996    fold_text = (case_sen) ? g_strdup (text) : g_utf8_casefold (text, -1); 
    997997    deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL); 
    998998 
    999999    match = deco_text; 
    str_utf8_search_first (const char *text, const char *search, int case_sen) 
    10201020    while (match != NULL && result == NULL); 
    10211021 
    10221022    g_free (deco_text); 
    1023     if (!case_sen) 
    1024         g_free (fold_text); 
     1023    g_free (fold_text); 
    10251024 
    10261025    return result; 
    10271026} 
    str_utf8_search_last (const char *text, const char *search, int case_sen) 
    10371036    const char *result = NULL; 
    10381037    const char *m; 
    10391038 
    1040     fold_text = (case_sen) ? (char *) text : g_utf8_casefold (text, -1); 
     1039    fold_text = (case_sen) ? g_strdup (text) : g_utf8_casefold (text, -1); 
    10411040    deco_text = g_utf8_normalize (fold_text, -1, G_NORMALIZE_ALL); 
    10421041 
    10431042    do 
    str_utf8_search_last (const char *text, const char *search, int case_sen) 
    10631062    while (match != NULL && result == NULL); 
    10641063 
    10651064    g_free (deco_text); 
    1066     if (!case_sen) 
    1067         g_free (fold_text); 
     1065    g_free (fold_text); 
    10681066 
    10691067    return result; 
    10701068}