Skip to content

Commit

Permalink
test-lib: replace repeated code logic with an existing helper
Browse files Browse the repository at this point in the history
This patch replaces the code, that changes the path separators,
with the already existing function `change_path_separators()`

Signed-off-by: Mohit Marathe <[email protected]>
  • Loading branch information
mohit-marathe committed Mar 18, 2024
1 parent 0157b1d commit 8a730b6
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions t/unit-tests/test-lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ static const char *make_relative(const char *location)
prefix_len = len - needle_len;
if (prefix[prefix_len + 1] == '/') {
/* Oh, we're not Windows */
for (size_t i = 0; i < needle_len; i++)
if (needle[i] == '\\')
needle[i] = '/';
change_path_separators(&needle[0]);
need_bs_to_fs = 0;
} else {
need_bs_to_fs = 1;
Expand Down Expand Up @@ -88,9 +86,8 @@ static const char *make_relative(const char *location)

/* convert backslashes to forward slashes */
strlcpy(buf, location + prefix_len, sizeof(buf));
for (p = buf; *p; p++)
if (*p == '\\')
*p = '/';
p = buf;
change_path_separators(p);
return buf;
}

Expand Down

0 comments on commit 8a730b6

Please sign in to comment.