git://git.camperquake.de
/
videosite.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
7480e9e
)
videosite-irssi: replace literal canary value by variable
author
Ralf Ertzinger
<ralf@skytale.net>
Thu, 2 May 2013 18:14:31 +0000
(20:14 +0200)
committer
Ralf Ertzinger
<ralf@skytale.net>
Thu, 2 May 2013 18:14:31 +0000
(20:14 +0200)
videosite-irssi.pl
patch
|
blob
|
history
diff --git
a/videosite-irssi.pl
b/videosite-irssi.pl
index
4d3f481
..
f5c6ef1
100644
(file)
--- a/
videosite-irssi.pl
+++ b/
videosite-irssi.pl
@@
-26,6
+26,14
@@
my %foreground_colors = (
);
#
);
#
+# This is a canary value used in the config system as the default
+# value. As irssi does not have a way to test if a setting exists
+# this is used instead. A config value is never expected to be set
+# to this value and be valid.
+#
+my $config_canary = "\1";
+
+#
# Initialize the config subsystem. Called by the core.
#
# Due to historic reasons this has to deal with a number of possible config sources:
# Initialize the config subsystem. Called by the core.
#
# Due to historic reasons this has to deal with a number of possible config sources:
@@
-140,10
+148,10
@@
sub config_get {
my $val;
my $val;
- Irssi::settings_add_str('videosite', $item,
"\1"
);
+ Irssi::settings_add_str('videosite', $item,
$config_canary
);
$val = Irssi::settings_get_str($item);
$val = Irssi::settings_get_str($item);
- return ($val ne
"\1"
)?$val:undef;
+ return ($val ne
$config_canary
)?$val:undef;
}
#
}
#
@@
-153,8
+161,8
@@
sub config_has {
my $path = shift;
my $item = join('.', 'videosite', @{$path});
my $path = shift;
my $item = join('.', 'videosite', @{$path});
- Irssi::settings_add_str('videosite', $item,
"\1"
);
- return Irssi::settings_get_str($item) ne
"\1"
;
+ Irssi::settings_add_str('videosite', $item,
$config_canary
);
+ return Irssi::settings_get_str($item) ne
$config_canary
;
}
#
}
#
@@
-165,7
+173,7
@@
sub config_set {
my $value = shift;
my $item = join('.', 'videosite', @{$path});
my $value = shift;
my $item = join('.', 'videosite', @{$path});
- Irssi::settings_add_str('videosite', $item,
"\1"
);
+ Irssi::settings_add_str('videosite', $item,
$config_canary
);
Irssi::settings_set_str($item, $value);
}
Irssi::settings_set_str($item, $value);
}
@@
-179,7
+187,7
@@
sub config_set {
sub config_del {
my $path = shift;
sub config_del {
my $path = shift;
- config_set($path,
"\1"
);
+ config_set($path,
$config_canary
);
}
#
}
#