-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3694-0006-mc_search__hex_translate_to_regex-clean-up-handling-.patch
57 lines (52 loc) · 1.7 KB
/
3694-0006-mc_search__hex_translate_to_regex-clean-up-handling-.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
From 7421a4c865e95afe0bc64453a6f92c01119f5038 Mon Sep 17 00:00:00 2001
From: Mooffie <mooffie@gmail.com>
Date: Mon, 26 Sep 2016 00:26:17 +0300
Subject: [PATCH 6/8] (mc_search__hex_translate_to_regex): clean up handling of
0x prefixes.
---
lib/search/hex.c | 20 ++++++--------------
1 file changed, 6 insertions(+), 14 deletions(-)
diff --git a/lib/search/hex.c b/lib/search/hex.c
index 1180016..14d0246 100644
--- a/lib/search/hex.c
+++ b/lib/search/hex.c
@@ -58,26 +58,13 @@ mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err
int *error_pos_ptr)
{
GString *buff;
- gchar *tmp_str, *tmp_str2;
+ gchar *tmp_str;
gsize tmp_str_len;
gsize loop = 0;
mc_search_hex_parse_error_t error = MC_SEARCH_HEX_E_OK;
buff = g_string_sized_new (64);
tmp_str = g_strndup (astr->str, astr->len);
- tmp_str2 = tmp_str;
-
- /* remove 0x prefices */
- while (TRUE)
- {
- tmp_str2 = strstr (tmp_str2, "0x");
- if (tmp_str2 == NULL)
- break;
-
- *tmp_str2++ = ' ';
- *tmp_str2++ = ' ';
- }
-
tmp_str_len = strlen (tmp_str);
while (loop < tmp_str_len && error == MC_SEARCH_HEX_E_OK)
@@ -91,6 +78,11 @@ mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err
while (g_ascii_isspace (tmp_str[loop]))
loop++;
}
+ else if (tmp_str[loop] == '0' && (tmp_str[loop + 1] == 'x' || tmp_str[loop + 1] == 'X'))
+ {
+ /* Skip 0x prefixes. */
+ loop += 2;
+ }
/* cppcheck-suppress invalidscanf */
else if (sscanf (tmp_str + loop, "%x%n", &val, &ptr) == 1)
{
--
2.9.3