diff options
author | dequis <dx@dxzone.com.ar> | 2015-04-11 15:09:49 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-04-11 15:09:53 -0300 |
commit | 9890daca797b31d34d97d953c512378aabe3d51f (patch) | |
tree | 902f884cdf223229e440d9b05651e225b876ad39 /src/common.h | |
parent | ef0877f4849a73ba43e886a9faafb321d3559e43 (diff) | |
download | irssi-9890daca797b31d34d97d953c512378aabe3d51f.zip |
Handle nulls properly in the g_strcmp0() for glib<2.16
I wrote some tests to compare the behavior but I don't know where to put
them, so i'm including them here:
assert(g_strcmp0("a", "b") == -1);
assert(g_strcmp0(NULL, "a") == -1);
assert(g_strcmp0("a", NULL) == 1);
assert(g_strcmp0("b", "a") == 1);
assert(g_strcmp0("a", "a") == 0);
assert(g_strcmp0(NULL, NULL) == 0);
Diffstat (limited to 'src/common.h')
-rw-r--r-- | src/common.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/common.h b/src/common.h index 23d091a1..1b99753b 100644 --- a/src/common.h +++ b/src/common.h @@ -53,7 +53,7 @@ #endif #if !GLIB_CHECK_VERSION(2,16,0) -#define g_strcmp0(str1, str2) strcmp(str1, str2) +#define g_strcmp0(a, b) (!a ? -(a != b) : (!b ? (a != b) : strcmp(a, b))) #endif #ifdef USE_GC |