Brief about changes:
- add get_irssi_cache_dir()
- add get_irssi_runtime_dir()
- remove is_xdg_supported()
About the proposed implementation:
- use XDG only when the user has the XDG_CONFIG_HOME/irssi directory
- irssi_dir would equal XDG_DATA_HOME/irssi or ~/.irssi, depending on
whether XDG is enabled or not, respectively.
- if xdg is enabled, variables irssi_cache, irssi_runtime, would equal
their respective XDG paths.
- if xdg is *not* enabled, variables irssi_cache, irssi_runtime, would
equal irssi_dir
Notes for future code:
- functions that use the irssi config file would use get_irssi_config()
- functions that use the irssi data directory would use get_irssi_dir()
- functions that use the irssi cache directory would use
get_irssi_cache_dir()
- functions that use the irssi runtime directory would use
get_irssi_runtime_dir()
Stuff that are still missing for complete implementation:
- add checks to ensure the new referenced directories are present
- docs
- add is_xdg_supported() (C and Perl).
- use $XDG_CONFIG_HOME/irssi/ only when it is present.
- fallback mechanism added.
- scripts are run from $XDG_DATA_HOME/irssi/scripts/[autorun], if and
only if xdg is used.
- config file XDG support inspired from #511
- added support to try loading scripts from XDG_DATA_HOME, if not present try
loading from XDG_CONFIG_HOME, if not present try loading the usual way.
The g_strcmp0 fallback in particular was broken since it was used in a
few places as a GCompareFunc, and macros don't work that way.
Yes, that one was my fault, but nobody complained :D
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);