Ticket #3694: 3694-0008-mc_search__hex_translate_to_regex-rename-variables.patch

File 3694-0008-mc_search__hex_translate_to_regex-rename-variables.patch, 3.0 KB (added by mooffie, 7 years ago)
  • lib/search/hex.c

    From 5c8662cf6bbbb4fb72b90426e4f6935fea801ce6 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Mon, 26 Sep 2016 00:55:41 +0300
    Subject: [PATCH 8/8] (mc_search__hex_translate_to_regex): rename variables.
    
    Now that the string isn't duplicated there's nothing "temporary" about it.
    ---
     lib/search/hex.c | 30 +++++++++++++++---------------
     1 file changed, 15 insertions(+), 15 deletions(-)
    
    diff --git a/lib/search/hex.c b/lib/search/hex.c
    index a0a3c19..a3fa80b 100644
    a b mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err 
    5858                                   int *error_pos_ptr) 
    5959{ 
    6060    GString *buff; 
    61     const char *tmp_str; 
    62     gsize tmp_str_len; 
     61    const char *str; 
     62    gsize str_len; 
    6363    gsize loop = 0; 
    6464    mc_search_hex_parse_error_t error = MC_SEARCH_HEX_E_OK; 
    6565 
    6666    buff = g_string_sized_new (64); 
    67     tmp_str = astr->str; 
    68     tmp_str_len = astr->len; 
     67    str = astr->str; 
     68    str_len = astr->len; 
    6969 
    70     while (loop < tmp_str_len && error == MC_SEARCH_HEX_E_OK) 
     70    while (loop < str_len && error == MC_SEARCH_HEX_E_OK) 
    7171    { 
    7272        unsigned int val; 
    7373        int ptr; 
    7474 
    75         if (g_ascii_isspace (tmp_str[loop])) 
     75        if (g_ascii_isspace (str[loop])) 
    7676        { 
    7777            /* Eat-up whitespace between tokens. */ 
    78             while (g_ascii_isspace (tmp_str[loop])) 
     78            while (g_ascii_isspace (str[loop])) 
    7979                loop++; 
    8080        } 
    81         else if (tmp_str[loop] == '0' && (tmp_str[loop + 1] == 'x' || tmp_str[loop + 1] == 'X')) 
     81        else if (str[loop] == '0' && (str[loop + 1] == 'x' || str[loop + 1] == 'X')) 
    8282        { 
    8383            /* Skip 0x prefixes. */ 
    8484            loop += 2; 
    8585        } 
    8686        /* cppcheck-suppress invalidscanf */ 
    87         else if (sscanf (tmp_str + loop, "%x%n", &val, &ptr) == 1) 
     87        else if (sscanf (str + loop, "%x%n", &val, &ptr) == 1) 
    8888        { 
    8989            if (val > 255) 
    9090                error = MC_SEARCH_HEX_E_NUM_OUT_OF_RANGE; 
    mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err 
    9494                loop += ptr; 
    9595            } 
    9696        } 
    97         else if (tmp_str[loop] == '"') 
     97        else if (str[loop] == '"') 
    9898        { 
    9999            gsize loop2; 
    100100 
    101101            loop2 = loop + 1; 
    102102 
    103             while (loop2 < tmp_str_len) 
     103            while (loop2 < str_len) 
    104104            { 
    105                 if (tmp_str[loop2] == '"') 
     105                if (str[loop2] == '"') 
    106106                    break; 
    107                 if (tmp_str[loop2] == '\\' && loop2 + 1 < tmp_str_len) 
     107                if (str[loop2] == '\\' && loop2 + 1 < str_len) 
    108108                    loop2++; 
    109                 g_string_append_c (buff, tmp_str[loop2]); 
     109                g_string_append_c (buff, str[loop2]); 
    110110                loop2++; 
    111111            } 
    112112 
    113             if (tmp_str[loop2] == '\0') 
     113            if (str[loop2] == '\0') 
    114114                error = MC_SEARCH_HEX_E_UNMATCHED_QUOTES; 
    115115            else 
    116116                loop = loop2 + 1;