summaryrefslogtreecommitdiff
path: root/src/file-data.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file-data.c')
-rw-r--r--src/file-data.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/file-data.c b/src/file-data.c
index 53a6f85..911a5e9 100644
--- a/src/file-data.c
+++ b/src/file-data.c
@@ -147,9 +147,9 @@ int
find_path_in_file_data_array (GPtrArray *array,
const char *path)
{
- int path_l;
- int left, right, p, cmp = -1;
- FileData *fd;
+ int path_l;
+ int left;
+ int right;
if (path == NULL)
return -1;
@@ -158,16 +158,23 @@ find_path_in_file_data_array (GPtrArray *array,
left = 0;
right = array->len;
while (left < right) {
+ FileData *fd;
+ int p;
+ int cmp;
+
p = left + ((right - left) / 2);
fd = (FileData *) g_ptr_array_index (array, p);
-
cmp = strcmp (path, fd->original_path);
if (cmp != 0) {
/* consider '/path/to/dir' and '/path/to/dir/' the same path */
+ int original_path_l;
+
+ original_path_l = strlen (fd->original_path);
- int original_path_l = strlen (fd->original_path);
if ((path_l == original_path_l - 1) && (fd->original_path[original_path_l - 1] == '/')) {
- int cmp2 = strncmp (path, fd->original_path, original_path_l - 1);
+ int cmp2;
+
+ cmp2 = strncmp (path, fd->original_path, original_path_l - 1);
if (cmp2 == 0)
cmp = cmp2;
}