Sfoglia il codice sorgente

+ Suppress output when not writing to a terminal.
+ Print full path when config file comes from the search path.

Christoph Berg 20 anni fa
parent
commit
20febc9757
3 ha cambiato i file con 34 aggiunte e 15 eliminazioni
  1. 7 2
      docs/Changelog
  2. 22 12
      modules/Pisg.pm
  3. 5 1
      pisg

+ 7 - 2
docs/Changelog

@@ -1,16 +1,21 @@
 pisg (0.68) - ??
    Christoph:
+   * Bug fixes:
      + ColorScheme 'none' will generate the color gradient again, the gradient
        is dropped with HiCell="".
      + Fix <user> parsing.
      + More smileys (SF #1264834).
-     + Fix English preposition (thanks, Barry Suridge).
-     + Add pointer to "compatibility" theme for XChat to FORMATS.
+     + Suppress output when not writing to a terminal.
+     + Print full path when config file comes from the search path.
+   * Parsers:
      + Strip nick modes in xchat format (SF #1304262).
+     + Add pointer to "compatibility" theme for XChat to FORMATS.
      + Add warning on silent option to eggdrop-pisg.tcl.
    Torbjörn:
+   * Features:
      + Generate stats in multiple languages in a single run.
    Language Updates:
+     + English: Fix preposition (thanks, Barry Suridge).
      + French: completed by Yoda.
      + Estonian: Hannes Tarien.
      + German: Michael Weyershäuser.

+ 22 - 12
modules/Pisg.pm

@@ -3,7 +3,7 @@ package Pisg;
 # Documentation(POD) for this module is found at the end of the file.
 
 # Copyright (C) 2001-2005  <Morten Brix Pedersen> - morten@wtf.dk
-# Copyright (C) 2003-2005  Christoph Berg <cb@df7cb.de>
+# Copyright (C) 2003-2006  Christoph Berg <cb@df7cb.de>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -57,15 +57,19 @@ sub run
     # Init the configuration file (aliases, ignores, channels, etc)
     my $r;
     if ($self->{use_configfile}) {
-        if ((open(CONFIG, $self->{cfg}->{configfile}) 
-            or open(CONFIG, $self->{search_path} . "/$self->{cfg}->{configfile}"))) {
-            $r = $self->init_config(\*CONFIG)
+        foreach my $c ($self->{cfg}->{configfile}, $self->{search_path} . "/$self->{cfg}->{configfile}") {
+            if (open(CONFIG, $c)) {
+                $self->{cfg}->{configfile} = $c;
+                print "Using config file: $self->{cfg}->{configfile}\n\n"
+                    unless ($self->{cfg}->{silent});
+                $r = $self->init_config(\*CONFIG);
+                last;
+            } else {
+                print STDERR "Warning: $c: $!\n\n" if -e $c;
+            }
         }
     }
 
-    print "Using config file: $self->{cfg}->{configfile}\n\n"
-        if ($r && !$self->{cfg}->{silent});
-
     # Get translations from langfile
     $self->get_language_templates();
 
@@ -395,14 +399,20 @@ sub init_config
             my $backup_cfg = $self->{cfg}->{configfile};
             $self->{cfg}->{configfile} = $include_cfg;
             my $r;
-            if ((open(INCLUDE, $self->{cfg}->{configfile}) 
-                or open(INCLUDE, $self->{search_path} . "/$self->{cfg}->{configfile}"))) {
-                $r = $self->init_config(\*INCLUDE);
-            } else {
-                print STDERR "Warning: $backup_cfg, line $.: $self->{cfg}->{configfile}: $!\n";
+            foreach my $c ($self->{cfg}->{configfile}, $self->{search_path} . "/$self->{cfg}->{configfile}") {
+                if (open(INCLUDE, $c)) {
+                    $self->{cfg}->{configfile} = $c;
+                    $r = $self->init_config(\*INCLUDE);
+                    last;
+                } else {
+                    print STDERR "Warning: $backup_cfg, line $.: $c: $!\n"
+                        if -e $c;
+                }
             }
             print "Included config file: $self->{cfg}->{configfile}\n\n"
                 if ($r && !$self->{cfg}->{silent});
+            print STDERR "Warning: $backup_cfg, line $.: $self->{cfg}->{configfile} not found\n"
+                if (!$r);
             $self->{cfg}->{configfile} = $backup_cfg;
         } elsif ($line =~ /<(\w+)?.*[^>]$/) {
             print STDERR "Warning: $self->{cfg}->{configfile}, line $.: Missing end on element <$1 (probably multi-line?)\n";

+ 5 - 1
pisg

@@ -6,7 +6,7 @@ use Getopt::Long;
 # pisg - Perl IRC Statistics Generator
 #
 # Copyright (C) 2001-2005  <Morten Brix Pedersen> - morten@wtf.dk
-# Copyright (C) 2003-2005  Christoph Berg <cb@df7cb.de>
+# Copyright (C) 2003-2006  Christoph Berg <cb@df7cb.de>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -35,6 +35,10 @@ sub main
         $script_dir = ".";
     }
 
+    if (!-t STDOUT) { # we are not writing to a terminal
+	push @ARGV, "--silent";
+    }
+
     my $cfg = get_cmdline_options($script_dir);
     unshift(@INC, $cfg->{modules_dir});