Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1:/tmp/cvs-serv17610
Modified Files:
ChangeLog Services.pm
Log Message:
Added terminal width fix from patch #598402.
Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -r1.241 -r1.242
--- ChangeLog 14 Jan 2003 14:08:56 -0000 1.241
+++ ChangeLog 14 Jan 2003 20:28:24 -0000 1.242
@@ -1,3 +1,7 @@
+2003-01-14 Max Horn <[EMAIL PROTECTED]>
+
+ * Services.pm: Added terminal width fix from patch #598402.
+
2003-01-13 Finlay Dobbie <[EMAIL PROTECTED]>
* PkgVersion.pm (merge): Added warning to if we try to merge a
Index: Services.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Services.pm,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- Services.pm 12 Jan 2003 19:37:16 -0000 1.32
+++ Services.pm 14 Jan 2003 20:28:24 -0000 1.33
@@ -547,7 +547,8 @@
sub get_term_width {
# This function returns the width of the terminal window, or zero if STDOUT
# is not a terminal. Uses Term::ReadKey if it is available, greps the TERMCAP
-# env var if ReadKey is not installed returns 80 if neither are available.
+# env var if ReadKey is not installed, tries tput if neither are available,
+# and if nothing works just returns 80.
my ($width, $dummy);
use POSIX qw(isatty);
if (isatty(fileno STDOUT))
@@ -557,22 +558,25 @@
($width, $dummy, $dummy, $dummy) = &GetTerminalSize();
}
else {
- $width = $ENV{TERMCAP};
- if ((defined $width and $width !~ /^[0-9]+$/) or (not defined $width)) {
- $width = $ENV{COLUMNS};
- }
- if (defined $width) {
- $width =~ s/.*co#([0-9]+).*/$1/;
- }
- else {
- $width = 80;
+ $width =~ s/.*co#([0-9]+).*/$1/ if defined ($width = $ENV{TERMCAP});
+ unless (defined $width and $width =~ /^\d+$/) {
+ chomp($width = `tput cols`) # Only use tput if it won't spout an error.
+ if -t 1 and defined ($width = $ENV{TERM}) and $width ne "unknown";
+ unless ($? == 0 and defined $width and $width =~ /^\d+$/) {
+ $width = $ENV{COLUMNS};
+ unless (defined $width and $width =~ /^\d+$/) {
+ $width = 80;
+ }
+ }
}
}
}
else {
+ # Not a TTY
$width = 0;
}
if ($width !~ /^[0-9]+$/) {
+ # Shouldn't get here, but just in case...
$width = 80;
}
return $width;
-------------------------------------------------------
This SF.NET email is sponsored by: Take your first step towards giving
your online business a competitive advantage. Test-drive a Thawte SSL
certificate - our easy online guide will show you how. Click here to get
started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en
_______________________________________________
Fink-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-commits