1
1

Rename vfs_path_cmp() to vfs_path_equals()

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Этот коммит содержится в:
Slava Zanko 2013-01-28 16:20:42 +03:00 коммит произвёл Andrew Borodin
родитель 8454f12f8f
Коммит c984447f8e
9 изменённых файлов: 48 добавлений и 46 удалений

Просмотреть файл

@ -1532,20 +1532,20 @@ vfs_path_element_build_pretty_path_str (const vfs_path_element_t * element)
* @return integer value like to strcmp. * @return integer value like to strcmp.
*/ */
int gboolean
vfs_path_cmp (const vfs_path_t * vpath1, const vfs_path_t * vpath2) vfs_path_equal (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
{ {
char *path1; char *path1;
char *path2; char *path2;
int ret_val; gboolean ret_val;
if (vpath1 == NULL || vpath2 == NULL) if (vpath1 == NULL || vpath2 == NULL)
return -1; return FALSE;
path1 = vfs_path_to_str (vpath1); path1 = vfs_path_to_str (vpath1);
path2 = vfs_path_to_str (vpath2); path2 = vfs_path_to_str (vpath2);
ret_val = strcmp (path1, path2); ret_val = strcmp (path1, path2) == 0;
g_free (path1); g_free (path1);
g_free (path2); g_free (path2);
@ -1564,20 +1564,20 @@ vfs_path_cmp (const vfs_path_t * vpath1, const vfs_path_t * vpath2)
* @return integer value like to strcmp. * @return integer value like to strcmp.
*/ */
int gboolean
vfs_path_ncmp (const vfs_path_t * vpath1, const vfs_path_t * vpath2, size_t len) vfs_path_equal_len (const vfs_path_t * vpath1, const vfs_path_t * vpath2, size_t len)
{ {
char *path1; char *path1;
char *path2; char *path2;
int ret_val; gboolean ret_val;
if (vpath1 == NULL || vpath2 == NULL) if (vpath1 == NULL || vpath2 == NULL)
return -1; return FALSE;
path1 = vfs_path_to_str (vpath1); path1 = vfs_path_to_str (vpath1);
path2 = vfs_path_to_str (vpath2); path2 = vfs_path_to_str (vpath2);
ret_val = strncmp (path1, path2, len); ret_val = strncmp (path1, path2, len) == 0;
g_free (path1); g_free (path1);
g_free (path2); g_free (path2);

Просмотреть файл

@ -92,8 +92,8 @@ char *vfs_path_build_url_params_str (const vfs_path_element_t * element, gboolea
char *vfs_path_element_build_pretty_path_str (const vfs_path_element_t * element); char *vfs_path_element_build_pretty_path_str (const vfs_path_element_t * element);
size_t vfs_path_len (const vfs_path_t * vpath); size_t vfs_path_len (const vfs_path_t * vpath);
int vfs_path_cmp (const vfs_path_t * vpath1, const vfs_path_t * vpath2); gboolean vfs_path_equal (const vfs_path_t * vpath1, const vfs_path_t * vpath2);
int vfs_path_ncmp (const vfs_path_t * vpath1, const vfs_path_t * vpath2, size_t len); gboolean vfs_path_equal_len (const vfs_path_t * vpath1, const vfs_path_t * vpath2, size_t len);
vfs_path_t *vfs_path_to_absolute (const vfs_path_t * vpath); vfs_path_t *vfs_path_to_absolute (const vfs_path_t * vpath);
/*** inline functions ****************************************************************************/ /*** inline functions ****************************************************************************/

Просмотреть файл

@ -1663,7 +1663,7 @@ edit_save_as_cmd (WEdit * edit)
{ {
int rv; int rv;
if (vfs_path_cmp (edit->filename_vpath, exp_vpath) != 0) if (!vfs_path_equal (edit->filename_vpath, exp_vpath))
{ {
int file; int file;
struct stat sb; struct stat sb;

Просмотреть файл

@ -1044,7 +1044,7 @@ reread_cmd (void)
panel_update_flags_t flag = UP_ONLY_CURRENT; panel_update_flags_t flag = UP_ONLY_CURRENT;
if (get_current_type () == view_listing && get_other_type () == view_listing && if (get_current_type () == view_listing && get_other_type () == view_listing &&
vfs_path_cmp (current_panel->cwd_vpath, other_panel->cwd_vpath) == 0) vfs_path_equal (current_panel->cwd_vpath, other_panel->cwd_vpath))
flag = UP_OPTIMIZE; flag = UP_OPTIMIZE;
update_panels (UP_RELOAD | flag, UP_KEEPSEL); update_panels (UP_RELOAD | flag, UP_KEEPSEL);

Просмотреть файл

@ -4812,7 +4812,7 @@ do_cd (const vfs_path_t * new_dir_vpath, enum cd_enum exact)
size_t new_vpath_len; size_t new_vpath_len;
new_vpath_len = vfs_path_len (new_dir_vpath); new_vpath_len = vfs_path_len (new_dir_vpath);
if (vfs_path_ncmp (new_dir_vpath, panelized_panel.root_vpath, new_vpath_len) == 0) if (vfs_path_equal_len (new_dir_vpath, panelized_panel.root_vpath, new_vpath_len))
_new_dir_vpath = panelized_panel.root_vpath; _new_dir_vpath = panelized_panel.root_vpath;
} }

Просмотреть файл

@ -418,7 +418,7 @@ do_panelize_cd (struct WPanel *panel)
panel->count = panelized_panel.count; panel->count = panelized_panel.count;
panel->is_panelized = TRUE; panel->is_panelized = TRUE;
panelized_same = (vfs_path_cmp (panelized_panel.root_vpath, panel->cwd_vpath) == 0); panelized_same = (vfs_path_equal (panelized_panel.root_vpath, panel->cwd_vpath));
for (i = 0; i < panelized_panel.count; i++) for (i = 0; i < panelized_panel.count; i++)
{ {

Просмотреть файл

@ -314,13 +314,13 @@ show_tree (WTree * tree)
if (current->sublevel < tree->selected_ptr->sublevel) if (current->sublevel < tree->selected_ptr->sublevel)
{ {
if (vfs_path_cmp (current->name, tree->selected_ptr->name) == 0) if (vfs_path_equal (current->name, tree->selected_ptr->name))
i++; i++;
} }
else if (current->sublevel == tree->selected_ptr->sublevel) else if (current->sublevel == tree->selected_ptr->sublevel)
{ {
for (j = strlen (current_name) - 1; current_name[j] != PATH_SEP; j--); for (j = strlen (current_name) - 1; current_name[j] != PATH_SEP; j--);
if (vfs_path_ncmp (current->name, tree->selected_ptr->name, j) == 0) if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
i++; i++;
} }
else else
@ -328,8 +328,8 @@ show_tree (WTree * tree)
if (current->sublevel == tree->selected_ptr->sublevel + 1 if (current->sublevel == tree->selected_ptr->sublevel + 1
&& vfs_path_len (tree->selected_ptr->name) > 1) && vfs_path_len (tree->selected_ptr->name) > 1)
{ {
if (vfs_path_ncmp (current->name, tree->selected_ptr->name, if (vfs_path_equal_len (current->name, tree->selected_ptr->name,
vfs_path_len (tree->selected_ptr->name)) == 0) vfs_path_len (tree->selected_ptr->name)))
i++; i++;
} }
} }
@ -406,8 +406,8 @@ show_tree (WTree * tree)
{ {
if (current->sublevel < tree->selected_ptr->sublevel) if (current->sublevel < tree->selected_ptr->sublevel)
{ {
if (vfs_path_ncmp (current->name, tree->selected_ptr->name, if (vfs_path_equal_len (current->name, tree->selected_ptr->name,
vfs_path_len (current->name)) == 0) vfs_path_len (current->name)))
break; break;
} }
else if (current->sublevel == tree->selected_ptr->sublevel) else if (current->sublevel == tree->selected_ptr->sublevel)
@ -418,14 +418,14 @@ show_tree (WTree * tree)
for (j = strlen (current_name) - 1; current_name[j] != PATH_SEP; j--) for (j = strlen (current_name) - 1; current_name[j] != PATH_SEP; j--)
; ;
g_free (current_name); g_free (current_name);
if (vfs_path_ncmp (current->name, tree->selected_ptr->name, j) == 0) if (vfs_path_equal_len (current->name, tree->selected_ptr->name, j))
break; break;
} }
else if (current->sublevel == tree->selected_ptr->sublevel + 1 else if (current->sublevel == tree->selected_ptr->sublevel + 1
&& vfs_path_len (tree->selected_ptr->name) > 1) && vfs_path_len (tree->selected_ptr->name) > 1)
{ {
if (vfs_path_ncmp (current->name, tree->selected_ptr->name, if (vfs_path_equal_len (current->name, tree->selected_ptr->name,
vfs_path_len (tree->selected_ptr->name)) == 0) vfs_path_len (tree->selected_ptr->name)))
break; break;
} }
current = current->next; current = current->next;

Просмотреть файл

@ -727,7 +727,7 @@ tree_store_remove_entry (const vfs_path_t * name_vpath)
len = vfs_path_len (base->name); len = vfs_path_len (base->name);
current = base->next; current = base->next;
while (current != NULL && vfs_path_ncmp (current->name, base->name, len) == 0) while (current != NULL && vfs_path_equal_len (current->name, base->name, len))
{ {
char *current_name; char *current_name;
gboolean ok; gboolean ok;
@ -794,7 +794,7 @@ tree_store_mark_checked (const char *subname)
len = vfs_path_len (base->name); len = vfs_path_len (base->name);
base->mark = 0; base->mark = 0;
current = base->next; current = base->next;
while (current != NULL && vfs_path_ncmp (current->name, base->name, len) == 0) while (current != NULL && vfs_path_equal_len (current->name, base->name, len))
{ {
gboolean ok; gboolean ok;
@ -851,7 +851,7 @@ tree_store_start_check (const vfs_path_t * vpath)
len = vfs_path_len (ts.check_name); len = vfs_path_len (ts.check_name);
current = ts.check_start; current = ts.check_start;
while (current != NULL && vfs_path_ncmp (current->name, ts.check_name, len) == 0) while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len))
{ {
char *current_name; char *current_name;
gboolean ok; gboolean ok;
@ -887,7 +887,7 @@ tree_store_end_check (void)
len = vfs_path_len (ts.check_name); len = vfs_path_len (ts.check_name);
current = ts.check_start; current = ts.check_start;
while (current != NULL && vfs_path_ncmp (current->name, ts.check_name, len) == 0) while (current != NULL && vfs_path_equal_len (current->name, ts.check_name, len))
{ {
char *current_name; char *current_name;
gboolean ok; gboolean ok;

Просмотреть файл

@ -66,10 +66,10 @@ teardown (void)
#define path_cmp_one_check(input1, input2, etalon_condition) {\ #define path_cmp_one_check(input1, input2, etalon_condition) {\
vpath1 = vfs_path_from_str (input1);\ vpath1 = vfs_path_from_str (input1);\
vpath2 = vfs_path_from_str (input2);\ vpath2 = vfs_path_from_str (input2);\
result = vfs_path_cmp (vpath1, vpath2);\ result = vfs_path_equal (vpath1, vpath2);\
vfs_path_free (vpath1); \ vfs_path_free (vpath1); \
vfs_path_free (vpath2); \ vfs_path_free (vpath2); \
fail_unless ( result etalon_condition, "\ninput1: %s\ninput2: %s\nexpected: %d\nactual: %d\n",\ fail_unless ( result == etalon_condition, "\ninput1: %s\ninput2: %s\nexpected: %d\nactual: %d\n",\
input1, input2, #etalon_condition, result); \ input1, input2, #etalon_condition, result); \
} }
@ -80,16 +80,18 @@ START_TEST (test_path_compare)
vfs_path_t *vpath1, *vpath2; vfs_path_t *vpath1, *vpath2;
int result; int result;
path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", == 0); path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", TRUE);
#ifdef HAVE_CHARSET #ifdef HAVE_CHARSET
path_cmp_one_check ("/#enc:KOI8-R/тестовый/путь", "/тестовый/путь", <0); path_cmp_one_check ("/#enc:KOI8-R/тестовый/путь", "/тестовый/путь",
path_cmp_one_check ("/тестовый/путь", "/#enc:KOI8-R/тестовый/путь", >0); FALSE);
path_cmp_one_check ("/тестовый/путь", "/#enc:KOI8-R/тестовый/путь",
FALSE);
#endif #endif
path_cmp_one_check (NULL, "/тестовый/путь", -1); path_cmp_one_check (NULL, "/тестовый/путь", FALSE);
path_cmp_one_check ("/тестовый/путь", NULL, -1); path_cmp_one_check ("/тестовый/путь", NULL, FALSE);
path_cmp_one_check (NULL, NULL, -1); path_cmp_one_check (NULL, NULL, FALSE);
} }
/* *INDENT-OFF* */ /* *INDENT-OFF* */
END_TEST END_TEST
@ -101,10 +103,10 @@ END_TEST
#define path_cmp_one_check(input1, input2, len, etalon_condition) {\ #define path_cmp_one_check(input1, input2, len, etalon_condition) {\
vpath1 = vfs_path_from_str (input1);\ vpath1 = vfs_path_from_str (input1);\
vpath2 = vfs_path_from_str (input2);\ vpath2 = vfs_path_from_str (input2);\
result = vfs_path_ncmp (vpath1, vpath2, len);\ result = vfs_path_equal_len (vpath1, vpath2, len);\
vfs_path_free (vpath1); \ vfs_path_free (vpath1); \
vfs_path_free (vpath2); \ vfs_path_free (vpath2); \
fail_unless ( result etalon_condition, "\ninput1: %s\ninput2: %s\nexpected: %d\nactual: %d\n",\ fail_unless ( result == etalon_condition, "\ninput1: %s\ninput2: %s\nexpected: %d\nactual: %d\n",\
input1, input2, #etalon_condition, result); \ input1, input2, #etalon_condition, result); \
} }
@ -115,17 +117,17 @@ START_TEST (test_path_compare_len)
vfs_path_t *vpath1, *vpath2; vfs_path_t *vpath1, *vpath2;
int result; int result;
path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", 10, == 0); path_cmp_one_check ("/тестовый/путь", "/тестовый/путь", 10, TRUE);
path_cmp_one_check ("/тест/овый/путь", "/тестовый/путь", 10, <0); path_cmp_one_check ("/тест/овый/путь", "/тестовый/путь", 10, FALSE);
path_cmp_one_check ("/тестовый/путь", "/тест/овый/путь", 10, >0); path_cmp_one_check ("/тестовый/путь", "/тест/овый/путь", 10, FALSE);
path_cmp_one_check ("/тест/овый/путь", "/тестовый/путь", 9, == 0); path_cmp_one_check ("/тест/овый/путь", "/тестовый/путь", 9, TRUE);
path_cmp_one_check (NULL, "/тестовый/путь", 0, <0); path_cmp_one_check (NULL, "/тестовый/путь", 0, FALSE);
path_cmp_one_check ("/тестовый/путь", NULL, 0, <0); path_cmp_one_check ("/тестовый/путь", NULL, 0, FALSE);
path_cmp_one_check (NULL, NULL, 0, <0); path_cmp_one_check (NULL, NULL, 0, FALSE);
} }
/* *INDENT-OFF* */ /* *INDENT-OFF* */
END_TEST END_TEST