mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
(mc_search__hex_translate_to_regex): optimization and cleanup.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
efb4206883
commit
3ec8721f47
@ -51,34 +51,29 @@
|
||||
static GString *
|
||||
mc_search__hex_translate_to_regex (const GString * astr)
|
||||
{
|
||||
const char *str = astr->str;
|
||||
GString *buff;
|
||||
gchar *tmp_str;
|
||||
gsize tmp_str_len;
|
||||
gsize loop = 0;
|
||||
int val, ptr;
|
||||
|
||||
buff = g_string_sized_new (64);
|
||||
tmp_str = g_strndup (str, astr->len);
|
||||
tmp_str = g_strndup (astr->str, astr->len);
|
||||
g_strchug (tmp_str); /* trim leadind whitespaces */
|
||||
tmp_str_len = strlen (tmp_str);
|
||||
|
||||
while (loop < tmp_str_len)
|
||||
{
|
||||
int val, ptr;
|
||||
|
||||
if (sscanf (tmp_str + loop, "%i%n", &val, &ptr))
|
||||
{
|
||||
gchar *tmp_str2;
|
||||
|
||||
if (val < -128 || val > 255)
|
||||
{
|
||||
loop++;
|
||||
continue;
|
||||
else
|
||||
{
|
||||
g_string_append_printf (buff, "\\x%02X", (unsigned char) val);
|
||||
loop += ptr;
|
||||
}
|
||||
|
||||
tmp_str2 = g_strdup_printf ("\\x%02X", (unsigned char) val);
|
||||
g_string_append (buff, tmp_str2);
|
||||
g_free (tmp_str2);
|
||||
loop += ptr;
|
||||
}
|
||||
else if (*(tmp_str + loop) == '"')
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user