X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fxscreensaver-text;h=1d0170d9fbfaea30c2099a07807eace017082cc2;hb=d6b0217f2417bd19187f0ebc389d6c5c2233b11c;hp=ff7c5734dd87ea14d0e2c06bd1818d5c4c034501;hpb=d1ae2829ff0fd2a96c16a0c8c5420efaa47d7b30;p=xscreensaver diff --git a/driver/xscreensaver-text b/driver/xscreensaver-text index ff7c5734..1d0170d9 100755 --- a/driver/xscreensaver-text +++ b/driver/xscreensaver-text @@ -1,5 +1,5 @@ #!/usr/bin/perl -w -# Copyright © 2005-2015 Jamie Zawinski +# Copyright © 2005-2016 Jamie Zawinski # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that @@ -37,7 +37,7 @@ use Text::Wrap qw(wrap); use bytes; my $progname = $0; $progname =~ s@.*/@@g; -my ($version) = ('$Revision: 1.38 $' =~ m/\s(\d[.\d]+)\s/s); +my ($version) = ('$Revision: 1.44 $' =~ m/\s(\d[.\d]+)\s/s); my $verbose = 0; my $http_proxy = undef; @@ -158,6 +158,7 @@ sub get_x11_prefs_1($) { my $got_any_p = 0; $body =~ s@\\\n@@gs; + $body =~ s@^[ \t]*#[^\n]*$@@gm; if ($body =~ m/^[.*]*textMode:[ \t]*([^\s]+)\s*$/im) { $text_mode = $1; @@ -277,6 +278,8 @@ sub which($) { sub output() { + binmode (STDOUT, ($latin1_p ? ':raw' : ':utf8')); + # Do some basic sanity checking (null text, null file names, etc.) # if (($text_mode eq 'literal' && $text_literal =~ m/^\s*$/i) || @@ -298,8 +301,9 @@ sub output() { $text_file =~ s@^~/@$ENV{HOME}/@s; # allow literal "~/" - if (open (my $in, '<', $text_file)) { + if (open (my $in, '<:raw', $text_file)) { print STDERR "$progname: reading $text_file\n" if ($verbose); + binmode (STDOUT, ':raw'); if (($wrap_columns && $wrap_columns > 0) || $truncate_lines) { # read it, then reformat it. @@ -473,8 +477,8 @@ sub reformat_html($$) { # Try to omit all tables, since they're impossible to read as text. # - 1 while (s/{{[^{}]*}}/ /gs); # {{ ... }} - 1 while (s/{\|.*?\|}/\n\n/gs); # {| ... |} + 1 while (s/\{\{[^{}]*}}/ /gs); # {{ ... }} + 1 while (s/\{\|.*?\|\}/\n\n/gs); # {| ... |} 1 while (s/\|-.*?\|/ /gs); # |- ... | (table cell) # Convert anchors to something more readable. @@ -659,16 +663,21 @@ sub reformat_text($) { sub set_proxy($) { my ($ua) = @_; - if (!defined($ENV{http_proxy}) && !defined($ENV{HTTP_PROXY})) { - my $proxy_data = `scutil --proxy 2>/dev/null`; - my ($server) = ($proxy_data =~ m/\bHTTPProxy\s*:\s*([^\s]+)/s); - my ($port) = ($proxy_data =~ m/\bHTTPPort\s*:\s*([^\s]+)/s); - if ($server) { + my $proxy_data = `scutil --proxy 2>/dev/null`; + foreach my $proto ('http', 'https') { + my ($server) = ($proxy_data =~ m/\b${proto}Proxy\s*:\s*([^\s]+)/si); + my ($port) = ($proxy_data =~ m/\b${proto}Port\s*:\s*([^\s]+)/si); + my ($enable) = ($proxy_data =~ m/\b${proto}Enable\s*:\s*([^\s]+)/si); + + if ($server && $enable) { # Note: this ignores the "ExceptionsList". - $ENV{http_proxy} = "http://" . $server . ($port ? ":$port" : "") . "/"; - print STDERR "$progname: MacOS proxy: $ENV{http_proxy}\n" - if ($verbose > 2) - } + my $proto2 = 'http'; + $ENV{"${proto}_proxy"} = ("${proto2}://" . $server . + ($port ? ":$port" : "") . "/"); + print STDERR "$progname: MacOS $proto proxy: " . + $ENV{"${proto}_proxy"} . "\n" + if ($verbose > 2); + } } $ua->env_proxy(); @@ -776,6 +785,8 @@ sub main() { $load_p = 0; } elsif (m/^--?text$/) { $text_mode = 'literal'; $text_literal = shift @ARGV || ''; + $text_literal =~ s@\\n@\n@gs; + $text_literal =~ s@\\\n@\n@gs; $load_p = 0; } elsif (m/^--?file$/) { $text_mode = 'file'; $text_file = shift @ARGV || '';