mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Search engine: development of hex search complete
src/search/glob.c: removed unneeded comment
This commit is contained in:
parent
9c38485130
commit
589f0b5bd8
@ -44,8 +44,6 @@
|
|||||||
|
|
||||||
/*** file scope functions ************************************************************************/
|
/*** file scope functions ************************************************************************/
|
||||||
|
|
||||||
//mc_search__regex_is_char_escaped (char *start, char *current)
|
|
||||||
|
|
||||||
static GString *
|
static GString *
|
||||||
mc_search__glob_translate_to_regex (gchar * str, gsize * len)
|
mc_search__glob_translate_to_regex (gchar * str, gsize * len)
|
||||||
{
|
{
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#include "../src/global.h"
|
#include "../src/global.h"
|
||||||
#include "../src/search/search.h"
|
#include "../src/search/search.h"
|
||||||
@ -44,12 +45,46 @@
|
|||||||
|
|
||||||
/*** file scope functions ************************************************************************/
|
/*** file scope functions ************************************************************************/
|
||||||
|
|
||||||
//mc_search__regex_is_char_escaped (char *start, char *current)
|
|
||||||
|
|
||||||
static GString *
|
static GString *
|
||||||
mc_search__hex_translate_to_regex (gchar * str, gsize * len)
|
mc_search__hex_translate_to_regex (gchar * str, gsize * len)
|
||||||
{
|
{
|
||||||
GString *buff = g_string_new ("");
|
GString *buff = g_string_new ("");
|
||||||
|
gchar *tmp_str = g_strndup (str, *len);
|
||||||
|
gchar *tmp_str2;
|
||||||
|
gsize loop = 0;
|
||||||
|
int val, ptr;
|
||||||
|
|
||||||
|
g_strchug (tmp_str); /* trim leadind whitespaces */
|
||||||
|
|
||||||
|
while (loop < *len) {
|
||||||
|
if (sscanf (tmp_str + loop, "%i%n", &val, &ptr)) {
|
||||||
|
if (val < -128 || val > 255) {
|
||||||
|
loop++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tmp_str2 = g_strdup_printf ("\\x%02X", (unsigned char) val);
|
||||||
|
g_string_append (buff, tmp_str2);
|
||||||
|
g_free (tmp_str2);
|
||||||
|
loop += ptr;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*(tmp_str + loop) == '"') {
|
||||||
|
loop++;
|
||||||
|
gsize loop2=0;
|
||||||
|
while (loop + loop2 < *len){
|
||||||
|
if (*(tmp_str + loop + loop2) == '"' &&
|
||||||
|
!mc_search__regex_is_char_escaped(tmp_str, tmp_str + loop + loop2 - 1))
|
||||||
|
break;
|
||||||
|
loop2++;
|
||||||
|
}
|
||||||
|
g_string_append_len(buff, tmp_str + loop, loop2 - 1);
|
||||||
|
loop+=loop2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
loop++;
|
||||||
|
}
|
||||||
|
*len = buff->len;
|
||||||
return buff;
|
return buff;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,9 +92,10 @@ mc_search__hex_translate_to_regex (gchar * str, gsize * len)
|
|||||||
|
|
||||||
void
|
void
|
||||||
mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t * mc_search,
|
mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t * mc_search,
|
||||||
mc_search_cond_t * mc_search_cond)
|
mc_search_cond_t * mc_search_cond)
|
||||||
{
|
{
|
||||||
GString *tmp = mc_search__hex_translate_to_regex (mc_search_cond->str->str, &mc_search_cond->len);
|
GString *tmp =
|
||||||
|
mc_search__hex_translate_to_regex (mc_search_cond->str->str, &mc_search_cond->len);
|
||||||
|
|
||||||
g_string_free (mc_search_cond->str, TRUE);
|
g_string_free (mc_search_cond->str, TRUE);
|
||||||
mc_search_cond->str = tmp;
|
mc_search_cond->str = tmp;
|
||||||
@ -72,7 +108,7 @@ mc_search__cond_struct_new_init_hex (const char *charset, mc_search_t * mc_searc
|
|||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
mc_search__run_hex (mc_search_t * mc_search, const void *user_data,
|
mc_search__run_hex (mc_search_t * mc_search, const void *user_data,
|
||||||
gsize start_search, gsize end_search, gsize * found_len)
|
gsize start_search, gsize end_search, gsize * found_len)
|
||||||
{
|
{
|
||||||
return mc_search__run_regex (mc_search, user_data, start_search, end_search, found_len);
|
return mc_search__run_regex (mc_search, user_data, start_search, end_search, found_len);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user