ksirc: Use Getopt::Std instead of deprecated getopts.pl library.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/86/head
Slávek Banko 2 months ago
parent 62b5b91d8b
commit f60724cc0c
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -55,8 +55,8 @@
# of ksirc when it started, and found it very flattering that someone # of ksirc when it started, and found it very flattering that someone
# would write 200k of C++ to interface with my 62k of perl :=) # would write 200k of C++ to interface with my 62k of perl :=)
$version='2.211'; $version='2.212';
$date='10 Mar 1998'; $date='21 Sep 2024';
$add_ons=''; $add_ons='';
$libdir=$ENV{"SIRCLIB"} || "."; $libdir=$ENV{"SIRCLIB"} || ".";
@ -68,12 +68,7 @@ $|=1;
$publicAway = 1; $publicAway = 1;
if (!eval "require 'getopts.pl';") { use Getopt::Std;
print "\n\n\
Your perl interpreter is *really* screwed up: the getopts.pl library is not
even there! Have you even bothered to run 'install'?\n";
exit;
}
if ($] >= 5 && (eval "use Socket;", $@ eq '')) { if ($] >= 5 && (eval "use Socket;", $@ eq '')) {
$sock6 = eval ("require Socket6;") and eval("use Socket6;"); $sock6 = eval ("require Socket6;") and eval("use Socket6;");
@ -96,22 +91,22 @@ if($@) {
} }
&Getopts('n:s:p:u:i:l:L:H:rqQR78S'); getopts('n:s:p:u:i:l:L:H:rqQR78S', \my %opts);
%set=("LOGFILE", "", "LOG", "off", "PRINTUH", "none", "PRINTCHAN", "off", %set=("LOGFILE", "", "LOG", "off", "PRINTUH", "none", "PRINTCHAN", "off",
"LOCALHOST", "", "CTCP", "noflood", "SENDAHEAD", 4096, "LOCALHOST", "", "CTCP", "noflood", "SENDAHEAD", 4096,
"USERINFO", "", "FINGER", "", "IRCNAME", "", "EIGHT_BIT", "on", "USERINFO", "", "FINGER", "", "IRCNAME", "", "EIGHT_BIT", "on",
"LOADPATH", join(":", @loadpath), "CTRL_T", "/next"); "LOADPATH", join(":", @loadpath), "CTRL_T", "/next");
$raw_mode=$opt_r || (!-t STDOUT); $raw_mode=$opts{r} || (!-t STDOUT);
$ansi=!$raw_mode && $ENV{"TERM"} =~ /^vt|^xterm|^ansi/i; $ansi=!$raw_mode && $ENV{"TERM"} =~ /^vt|^xterm|^ansi/i;
$server=$opt_s || $ARGV[1] || $ENV{"SIRCSERVER"} || $ENV{"IRCSERVER"} || $server=$opts{s} || $ARGV[1] || $ENV{"SIRCSERVER"} || $ENV{"IRCSERVER"} ||
"irc.primenet.com"; "irc.primenet.com";
$port0=$opt_p || $ENV{"SIRCPORT"} || $ENV{"IRCPORT"} || 6667; $port0=$opts{p} || $ENV{"SIRCPORT"} || $ENV{"IRCPORT"} || 6667;
$username=$opt_u || $ENV{"SIRCUSER"} || $ENV{"IRCUSER"} || (getpwuid($<))[0] || $username=$opts{u} || $ENV{"SIRCUSER"} || $ENV{"IRCUSER"} || (getpwuid($<))[0] ||
$ENV{"USER"} || "blah"; $ENV{"USER"} || "blah";
$set{"IRCNAME"}=$opt_i || $ENV{"SIRCNAME"} || $ENV{"IRCNAME"} || "sirc user"; $set{"IRCNAME"}=$opts{i} || $ENV{"SIRCNAME"} || $ENV{"IRCNAME"} || "sirc user";
$nick=$opt_n || $ARGV[0] || $ENV{"SIRCNICK"} || $ENV{"IRCNICK"} || $username; $nick=$opts{n} || $ARGV[0] || $ENV{"SIRCNICK"} || $ENV{"IRCNICK"} || $username;
$set{"FINGER"}=$ENV{"IRCFINGER"} || "keep your fingers to yourself"; $set{"FINGER"}=$ENV{"IRCFINGER"} || "keep your fingers to yourself";
$set{"USERINFO"}=$ENV{"USERINFO"} || "yep, I'm a user"; $set{"USERINFO"}=$ENV{"USERINFO"} || "yep, I'm a user";
if ($server =~ /^\[([^\]]+)\]:([0-9]*):?(.*)$/ if ($server =~ /^\[([^\]]+)\]:([0-9]*):?(.*)$/
@ -123,18 +118,18 @@ $port || ($port=$port0);
$server0=$server1=$server; $server0=$server1=$server;
$port0=$port1=$port; $port0=$port1=$port;
$pass0=$pass1=$pass; $pass0=$pass1=$pass;
$initfile=$opt_l || $ENV{"SIRCRCPL"} || $ENV{'HOME'}."/.sircrc.pl" $initfile=$opts{l} || $ENV{"SIRCRCPL"} || $ENV{'HOME'}."/.sircrc.pl"
if $opt_l || !$opt_q; if $opts{l} || !$opts{q};
$sysinit=$libdir."/sircrc.pl" if $libdir ne '.' && !$opt_Q; $sysinit=$libdir."/sircrc.pl" if $libdir ne '.' && !$opts{Q};
$rcfile=$opt_L || $ENV{"SIRCRC"} || $ENV{'HOME'}."/.sircrc" $rcfile=$opts{L} || $ENV{"SIRCRC"} || $ENV{'HOME'}."/.sircrc"
if $opt_L || !$opt_q; if $opts{L} || !$opts{q};
$sysrc=$libdir."/sircrc" if $libdir ne '.' && !$opt_Q; $sysrc=$libdir."/sircrc" if $libdir ne '.' && !$opts{Q};
$set{"LOGFILE"}=$logfile=$ENV{'HOME'}."/sirc.log"; $set{"LOGFILE"}=$logfile=$ENV{'HOME'}."/sirc.log";
$opt_8 || ($set{"EIGHT_BIT"}="off"); $opts{8} || ($set{"EIGHT_BIT"}="off");
$restrict=$opt_R; $restrict=$opts{R};
$set{"LOCALHOST"}=$opt_H || $ENV{"SIRCHOST"} || $ENV{"IRCHOST"} || $set{"LOCALHOST"}=$opts{H} || $ENV{"SIRCHOST"} || $ENV{"IRCHOST"} ||
$ENV{"LOCALHOST"} || ""; $ENV{"LOCALHOST"} || "";
$SSL=$opt_S; $SSL=$opts{S};
@ARGV=(); # ignore any more arguments @ARGV=(); # ignore any more arguments

Loading…
Cancel
Save