Ticket #3694: 3964-0009-mc_search__hex_translate_to_regex-remove-explicit-ha.patch

File 3964-0009-mc_search__hex_translate_to_regex-remove-explicit-ha.patch, 1.2 KB (added by mooffie, 8 years ago)
  • lib/search/hex.c

    From 7c960063f4751ab5dc16dc4697f7de51ff8e3fb3 Mon Sep 17 00:00:00 2001
    From: Mooffie <mooffie@gmail.com>
    Date: Wed, 2 Nov 2016 22:03:57 +0200
    Subject: [PATCH] (mc_search__hex_translate_to_regex): remove explicit handling
     of 0x prefixes.
    
    scanf("%x") knows to eat up this prefix[1][2], so we don't need to do this
    ourselves.
    
    [1] K&R's "The C Programming Language" documents "%x" as "hexadecimal
        integer (with or without leading 0x or 0X)"
    [2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/scanf.html
    ---
     lib/search/hex.c | 5 -----
     1 file changed, 5 deletions(-)
    
    diff --git a/lib/search/hex.c b/lib/search/hex.c
    index a3fa80b..91caadf 100644
    a b mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err 
    7878            while (g_ascii_isspace (str[loop])) 
    7979                loop++; 
    8080        } 
    81         else if (str[loop] == '0' && (str[loop + 1] == 'x' || str[loop + 1] == 'X')) 
    82         { 
    83             /* Skip 0x prefixes. */ 
    84             loop += 2; 
    85         } 
    8681        /* cppcheck-suppress invalidscanf */ 
    8782        else if (sscanf (str + loop, "%x%n", &val, &ptr) == 1) 
    8883        {