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 |
58 | 58 | int *error_pos_ptr) |
59 | 59 | { |
60 | 60 | GString *buff; |
61 | | const char *tmp_str; |
62 | | gsize tmp_str_len; |
| 61 | const char *str; |
| 62 | gsize str_len; |
63 | 63 | gsize loop = 0; |
64 | 64 | mc_search_hex_parse_error_t error = MC_SEARCH_HEX_E_OK; |
65 | 65 | |
66 | 66 | 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; |
69 | 69 | |
70 | | while (loop < tmp_str_len && error == MC_SEARCH_HEX_E_OK) |
| 70 | while (loop < str_len && error == MC_SEARCH_HEX_E_OK) |
71 | 71 | { |
72 | 72 | unsigned int val; |
73 | 73 | int ptr; |
74 | 74 | |
75 | | if (g_ascii_isspace (tmp_str[loop])) |
| 75 | if (g_ascii_isspace (str[loop])) |
76 | 76 | { |
77 | 77 | /* Eat-up whitespace between tokens. */ |
78 | | while (g_ascii_isspace (tmp_str[loop])) |
| 78 | while (g_ascii_isspace (str[loop])) |
79 | 79 | loop++; |
80 | 80 | } |
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')) |
82 | 82 | { |
83 | 83 | /* Skip 0x prefixes. */ |
84 | 84 | loop += 2; |
85 | 85 | } |
86 | 86 | /* 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) |
88 | 88 | { |
89 | 89 | if (val > 255) |
90 | 90 | error = MC_SEARCH_HEX_E_NUM_OUT_OF_RANGE; |
… |
… |
mc_search__hex_translate_to_regex (const GString * astr, mc_search_hex_parse_err |
94 | 94 | loop += ptr; |
95 | 95 | } |
96 | 96 | } |
97 | | else if (tmp_str[loop] == '"') |
| 97 | else if (str[loop] == '"') |
98 | 98 | { |
99 | 99 | gsize loop2; |
100 | 100 | |
101 | 101 | loop2 = loop + 1; |
102 | 102 | |
103 | | while (loop2 < tmp_str_len) |
| 103 | while (loop2 < str_len) |
104 | 104 | { |
105 | | if (tmp_str[loop2] == '"') |
| 105 | if (str[loop2] == '"') |
106 | 106 | break; |
107 | | if (tmp_str[loop2] == '\\' && loop2 + 1 < tmp_str_len) |
| 107 | if (str[loop2] == '\\' && loop2 + 1 < str_len) |
108 | 108 | loop2++; |
109 | | g_string_append_c (buff, tmp_str[loop2]); |
| 109 | g_string_append_c (buff, str[loop2]); |
110 | 110 | loop2++; |
111 | 111 | } |
112 | 112 | |
113 | | if (tmp_str[loop2] == '\0') |
| 113 | if (str[loop2] == '\0') |
114 | 114 | error = MC_SEARCH_HEX_E_UNMATCHED_QUOTES; |
115 | 115 | else |
116 | 116 | loop = loop2 + 1; |