mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
basic: add helper function to print </==/>
This commit is contained in:
@@ -17,7 +17,7 @@ int verb_compare_versions(int argc, char *argv[], void *userdata) {
|
||||
r = strverscmp_improved(ASSERT_PTR(argv[1]), ASSERT_PTR(argv[2]));
|
||||
printf("%s %s %s\n",
|
||||
isempty(argv[1]) ? "''" : argv[1],
|
||||
r < 0 ? "<" : r > 0 ? ">" : "==",
|
||||
comparison_operator(r),
|
||||
isempty(argv[2]) ? "''" : argv[2]);
|
||||
|
||||
/* This matches the exit convention used by rpmdev-vercmp.
|
||||
|
||||
@@ -76,6 +76,10 @@ static inline const sd_char *yes_no(sd_bool b) {
|
||||
return b ? STR_C("yes") : STR_C("no");
|
||||
}
|
||||
|
||||
static inline const sd_char* comparison_operator(int result) {
|
||||
return result < 0 ? STR_C("<") : result > 0 ? STR_C(">") : STR_C("==");
|
||||
}
|
||||
|
||||
sd_int strverscmp_improved(const sd_char *a, const sd_char *b);
|
||||
|
||||
/* Like startswith(), but operates on arbitrary memory blocks */
|
||||
|
||||
@@ -835,7 +835,7 @@ static void test_strverscmp_improved_one(const char* a, const char *b, int expec
|
||||
|
||||
log_info("'%s' %s '%s'%s",
|
||||
strnull(a),
|
||||
r > 0 ? ">" : r < 0 ? "<" : "==",
|
||||
comparison_operator(r),
|
||||
strnull(b),
|
||||
r == expected ? "" : " !!!!!!!!!!!!!");
|
||||
assert_se(r == expected);
|
||||
|
||||
Reference in New Issue
Block a user