acheck-0.5.1+nmu1/0000755000000000000000000000000012225330460010472 5ustar acheck-0.5.1+nmu1/FileType.pm0000644000000000000000000000410607710515063012561 0ustar package ACheck::FileType; use strict; use Exporter; use locale; use File::Spec::Functions qw(rel2abs splitpath splitdir); use ACheck::Common; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw( file_type ); my %FILE_TYPES = ( # filetypes '\.wml(\.\w+)?$' => "wml", '\.po(\.\w+)?$' => "po", '\.te?xt(\.\w+)?$' => "text" ); # file_type # # find file type # # input: # filename # array reference of file lines # return: # file type sub file_type ($$) { my $filename = shift || "-"; # filename my $lines = shift; # array of lines debug 1; debug 2, "filename: ".($filename || "STDIN")."\n"; my $type; # file type my $file = ""; # file name my $dir = ""; # directory my @dirs = (""); # path unless ($filename eq "-") { $filename = rel2abs($filename) unless $filename eq "-"; (undef, $dir, $file) = splitpath($filename); @dirs = splitdir($dir); } # # file name tests # if ($dirs[-1] eq "debian" && $file eq "control" ) { $type = "debian-control"; } if ($type) { debug 3, "filetype: $type\n"; return $type; } # # file extension tests # foreach (keys %FILE_TYPES) { next unless $file =~ /$_/; $type = $FILE_TYPES{$_}; last; } if ($type) { debug 3, "filetype: $type\n"; return $type; } # # content tests # if ($$lines[0] =~ /^--- \w+/ && # unified diff tests $$lines[1] =~ /^\+\+\+ \w+/ && $$lines[2] =~ /^@@ / ) { $type = "udiff-wml" if $$lines[0] =~ /^\-\-\- \w+\.wml\b/; $type = "udiff-wml" if $$lines[1] =~ /^\+\+\+ \w+\.wml\b/; $type ||= "udiff"; } elsif ($$lines[0] =~ /^#use wml\b/) { $type = "wml"; } else { # otherwise try to guess from file lines my $i; for ($i = 0; $i < @{ $lines }; $i++) { last unless $$lines[$i] =~ /^#/; } if ($i == @{ $lines }) { } elsif ($$lines[$i ] =~ /^msgid ""$/ && $$lines[$i+1] =~ /^msgstr "/ ) { $type = "po"; } elsif ($$lines[$i ] =~ /^Description: /) { $type = "ddts"; } } $type ||= "text"; # default to text debug 3, "filetype: $type\n"; return $type; } 1; acheck-0.5.1+nmu1/debian/0000755000000000000000000000000012225330460011714 5ustar acheck-0.5.1+nmu1/debian/dirs0000644000000000000000000000003707704572577012627 0ustar usr/bin usr/share/perl5/ACheck acheck-0.5.1+nmu1/debian/compat0000644000000000000000000000000212225274014013114 0ustar 3 acheck-0.5.1+nmu1/debian/copyright0000644000000000000000000000141007704572144013660 0ustar This is the Debian package of acheck. Copyright (c) 2001-2003 Nicolas Bertolissio This is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License with your Debian GNU/Linux system, in /usr/share/common-licenses/GPL. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. acheck-0.5.1+nmu1/debian/control0000644000000000000000000000141512225330044013316 0ustar Source: acheck Section: text Priority: optional Maintainer: Nicolas Bertolissio Build-Depends: debhelper (>> 3.0.0), perl, gettext Standards-Version: 3.6.2 Package: acheck Architecture: all Depends: ${misc:Depends}, perl, acheck-rules, libterm-size-perl, libconfig-general-perl Recommends: libtext-aspell-perl, liblocale-gettext-perl Suggests: libterm-readline-gnu-perl | libterm-readline-perl-perl Description: Check common localisation mistakes acheck, any text file checker, is a tool designed to help both translators and reviewers checking and fixing common localisation mistakes according to file format. Rules can be defined to add new checks. . If you install the Aspell Perl module as recommended, Aspell can be invoked to check word spelling. acheck-0.5.1+nmu1/debian/rules0000755000000000000000000000345312225274503013006 0ustar #!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. # export DH_VERBOSE=1 package := acheck manpages := 1 5 languages := fr configure: configure-stamp configure-stamp: dh_testdir touch configure-stamp build: configure-stamp build-stamp build-stamp: dh_testdir set -ex;\ for i in $(manpages); do\ pod2man --section=$$i man/$(package).$$i.pod > man/$(package).$$i;\ for lang in $(languages); do\ if test -e man/$(package).$$lang.$$i.pod; then\ pod2man --section=$$i man/$(package).$$lang.$$i.pod > man/$(package).$$lang.$$i;\ fi\ done \ done $(MAKE) -C po all touch build-stamp clean: dh_testdir dh_testroot set -ex; find man -name \*.[1-9] | xargs rm -f; $(MAKE) -C po $@ dh_clean build-stamp configure-stamp install: build dh_testdir dh_testroot dh_clean -k dh_installdirs set -ex; install -m 0755 $(package) debian/$(package)/usr/bin set -ex; install -m 0644 *.pm debian/$(package)/usr/share/perl5/ACheck/ $(MAKE) -C po DESTDIR=`pwd`/debian/$(package) install # Build architecture-independent files here. binary-indep: build install dh_testdir dh_testroot # dh_installdebconf dh_installdocs -n misc/* # dh_installexamples # dh_installmenu # dh_installlogrotate # dh_installemacsen # dh_installpam # dh_installmime # dh_installinit # dh_installcron dh_installman man/*[1-9] # dh_installinfo # dh_undocumented dh_installchangelogs # dh_link # dh_strip dh_compress dh_fixperms # dh_makeshlibs dh_installdeb # dh_perl # dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb # Build architecture-dependent files here. binary-arch: build install # We have nothing to do by default. binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install configure acheck-0.5.1+nmu1/debian/changelog0000644000000000000000000002314612225306374013603 0ustar acheck (0.5.1+nmu1) unstable; urgency=low * Non-maintainer upload. * Fix POD files to be compatible with perl 5.18. (closes: bug#723774) * debian/compat: added, set to 3. * debian/rules: remove DH_COMPAT=3. * debian/control: + Add ${misc:Depends} to Depends. Patch by Benjamin Kerensa. (closes: bug#692725) + Replace Build-Depends-Indep by Build-Depends, for the clean target. -- Bill Allombert Wed, 09 Oct 2013 17:40:05 +0200 acheck (0.5.1) unstable; urgency=low * Fix FTBFS with new make version (closes: bug#352795) -- Nicolas Bertolissio Sun, 19 Feb 2006 21:59:48 +0100 acheck (0.5) unstable; urgency=low * add Swedish po-template translation (closes: bug#332220) * Standard-Version 3.6.2 -- Nicolas Bertolissio Sun, 9 Oct 2005 18:14:07 +0200 acheck (0.4) unstable; urgency=low * add pause after warning if aspell cannot be used in interactive mode thanks to Martin Quinson for reporting this bug * make menu easier to translated * fix missing i18n for hint comment output * add Polish localisation thanks to Arkadiusz Lipiec for providing it * Standards-version: 3.6.1 * change maintainer's address to Debian's one -- Nicolas Bertolissio Sun, 5 Oct 2003 13:17:22 +0200 acheck (0.3) unstable; urgency=low * improve `debian/rules' * use `perl' in `Depends' as there is no compiled module thanks to Denis Barbier for reporting this bug * recommend `libtext-aspell-perl' installation in package description * add missing dependency on `libconfig-general-perl' * use `File::Copy' to move files * use `IO::File' to read from / write to files * use `File::Spec::Functions' to deal with filenames and directories * split file type search to new `ACheck::FileType' package - add `debian-control' file type - find `wml' and `po' according to file contents if file extension tests failed - add `te?xt' file extension test - add double extension to file extension tests * add internationalisation * add French localisation * improve French manpage -- Nicolas Bertolissio Sat, 26 Jul 2003 20:48:47 +0200 acheck (0.2) unstable; urgency=low * use `${perl:Depends}' to calculate perl dependency * fix missing warning if aspell module missing thanks to Denis Barbier for reporting this bug * fix `--rules' option to rules settting * add `--type' option for filetype setting * entering Debian archive (closes: bug#202252) * clean `debian/' directory - remove empty `README.Debian' - add `Build-Depends-Indep: perl - improve description - clean `rules' - Recommends aspell perl module (instead of suggests) thanks to Denis Barbier for all these -- Nicolas Bertolissio Wed, 23 Jul 2003 01:57:36 +0200 acheck (0.1) unstable; urgency=low * make source tree clearer: - move manpages sources to man/ - move files for /usr/share/doc/acheck/ to misc/ * rewrite the all thing * change package name * use aspell * new rule format - allow include - allow loops * Standards-version: 3.6.0 - recode changelog to utf8 * allow input from STDIN and output to STDOUT thanks to Christian Couder for requesting these features -- Nicolas Bertolissio Sun, 20 Jul 2003 14:14:04 +0200 l10n-check (0.5.4) unstable; urgency=low * fix masked variable declaration -- Nicolas Bertolissio Sat, 12 Jul 2003 00:50:59 +0200 l10n-check (0.5.3) unstable; urgency=low * fix add of ispell output when adding word to the dictionnary thanks to Denis Barbier for his patch -- Nicolas Bertolissio Thu, 10 Jul 2003 23:32:27 +0200 l10n-check (0.5.2) unstable; urgency=low * fix troubles with .po files thanks to Denis Barbier for his patch -- Nicolas Bertolissio Mon, 7 Jul 2003 15:35:10 +0200 l10n-check (0.5.1) unstable; urgency=low * fix some more troubles with comments -- Nicolas Bertolissio Tue, 8 Apr 2003 11:24:52 +0200 l10n-check (0.5) unstable; urgency=low * remove `/usr/doc' symlink * fix comment trouble with ddts thanks to Daniel Déchelotte for his patch -- Nicolas Bertolissio Mon, 7 Apr 2003 21:05:58 +0200 l10n-check (0.4) unstable; urgency=low * use Term::ReadLine to edit, so it choose the best readline available * add `E' command to edit whole line -- Nicolas Bertolissio Mon, 10 Feb 2003 15:32:59 +0100 l10n-check (0.3.3) unstable; urgency=low * fix typo in version setting thanks to Thomas Poindessous for his patch -- Nicolas Bertolissio Tue, 29 Oct 2002 15:30:47 +0100 l10n-check (0.3.2) unstable; urgency=low * fix some typo. thanks to Benoît Sibaud for his patch * change maintainer's address -- Nicolas Bertolissio Tue, 29 Oct 2002 15:29:34 +0100 l10n-check (0.3.1) unstable; urgency=low * fix `FILE_TYPE' rev extension * remove short option for `--rules' (due conflict with `--review') * add bash completion file * add note in `README.Debian' -- Nicolas Bertolissio Fri, 22 Feb 2002 00:26:11 +0100 l10n-check (0.3) unstable; urgency=low * use locale so `\w' should match correctly * use Getopt::Long module to parse options * use constants for constant values * capitalize first letter of glogal variables * use default values so configuration file is optional * add prototype in subs declarations * fix typo in changelog * remove remaining pod documentation * close file in `file_type' * split manpage, configuration is now in l10n-check(5) and rules definition in l10n-check-rules(5) in l10n-check-rules package * set `$Spell_all' to `yes' * fix manpages * add French manpages * add `X' and `N' commands -- Nicolas Bertolissio Sun, 17 Feb 2002 07:57:47 +0100 l10n-check (0.2.12) unstable; urgency=low * fix unitialized value when parsing po header * allow on-line comments after each value -- Nicolas Bertolissio Tue, 12 Feb 2002 19:24:58 +0100 l10n-check (0.2.11) unstable; urgency=low * to pass lintian tests: - change field `Build-Depends:' into `Build-Depends-Indep:' - fix copyright file - add manpage * remove pod documentation from the script as there is a manpage -- Nicolas Bertolissio Wed, 6 Feb 2002 21:55:06 +0100 l10n-check (0.2.10) unstable; urgency=low * don't skip begining of template and ddts files thanks to Denis Barbier for reporting this bug -- Nicolas Bertolissio Mon, 4 Feb 2002 08:32:43 +0100 l10n-check (0.2.9) unstable; urgency=low * add quotes for emacs highlighting mode * don't check spelling of directories * don't check spelling of po file headers * set package section to `text' thanks to Martin Quinson for all these patches -- Nicolas Bertolissio Sun, 3 Feb 2002 23:22:56 +0100 l10n-check (0.2.8) unstable; urgency=low * add template file type -- Nicolas Bertolissio Sat, 2 Feb 2002 22:53:12 +0100 l10n-check (0.2.7) unstable; urgency=low * Initial Debian Package Release * override `$rules_dir' to `/usr/share/l10n-check/rules', for easy transition to Debian package, to be changed. -- Nicolas Bertolissio Sat, 2 Feb 2002 16:23:07 +0100 l10n-check (0.2.6) unstable; urgency=low * add missing parentheses -- Nicolas Bertolissio Fri, 1 Feb 2002 09:41:00 +0100 l10n-check (0.2.5) unstable; urgency=low * add facility to accept a word for session or to put it in personal dictionary when spelling * add facility to personalize comment in review mode when providing manual correction * update doc for better presentation * bug fix: define empty `$choice' when replacing with an empty string -- Nicolas Bertolissio Thu, 31 Jan 2002 20:08:00 +0100 l10n-check (0.2.4) unstable; urgency=low * add documentation in pod format * add po format * use a hash table for file types * bug fix: add space for nice presentation * bug fix: add debug message -- Nicolas Bertolissio Sat, 26 Jan 2002 14:38:00 +0100 l10n-check (0.2.3) unstable; urgency=low * add letter next to the text to choose (easier for long lines) * remove old comment * bug fix: match regexp for comments -- Nicolas Bertolissio Mon, 21 Jan 2002 22:08:00 +0100 l10n-check (0.2.2) unstable; urgency=low * bug fix: add square brackets in regexp searching for words * bug fix: add `' if no hint found -- Nicolas Bertolissio Mon, 21 Jan 2002 09:20:00 +0100 l10n-check (0.2.1) unstable; urgency=low * add `$word_regex' config variable to define words for ispell * bug fix: keep only 25 choices in choose menu * bug fix: re-parse line only if a change has been made when checking rules * bug fix: set next match after last word if no change has been made when checkin spelling -- Nicolas Bertolissio Sun, 20 Jan 2002 17:32:00 +0100 l10n-check (0.2) unstable; urgency=low * add options: - add facility to add review comments - add ispell check - add license * bug fix: add normal text color before changing color -- Nicolas Bertolissio Sat, 19 Jan 2002 20:13:00 +0100 l10n-check (0.1) unstable; urgency=low * Initial Release -- Nicolas Bertolissio Sat, 19 Jan 2002 02:24:00 +0100 acheck-0.5.1+nmu1/Parser.pm0000644000000000000000000002176312225275657012315 0ustar package ACheck::Parser; use strict; use locale; use Exporter; use File::Spec::Functions; use ACheck::Common; use constant LAST_PARSED_LIST => "LAST_PARSED_LIST"; # special name use constant RULES_DIR => "/usr/share/acheck/rules"; # rules directory use constant RULES_E => "rules"; # rules files extension use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw( load_ruleset ); my @fields; # parsed fields my @values; # parsed values my @lines; # corresponding line (for error message output) my %lists; # list of rule lists name => hashref my %rules; # list of rules name => hashref my %valids; # list of valids name => hashref my %comments; # list of comments name => hashref my @LIST_FIELDS = qw( type name list rule comment spell ); my @LIST_REGEX = qw( test ); my @RULE_FIELDS = qw( type name valid hint fix ); my @RULE_REGEX = qw( regex ); my @VALID_FIELDS = qw( name ); my @VALID_REGEX = qw( pre in post ); my @COMMENT_FIELDS = qw( name start_offset stop_offset ); my @COMMENT_REGEX = qw( start skip stop ); my @END_FIELDS = qw( end_list end_rule end_comment end_valid ); my @FIELDS = (@LIST_FIELDS, @RULE_FIELDS, @VALID_FIELDS, @COMMENT_FIELDS, @LIST_REGEX, @RULE_REGEX, @VALID_REGEX, @COMMENT_REGEX, @END_FIELDS); my %LIST_VALID = ( 'type' => [qw( loop until while )], 'spell' => [qw( yes no )] ); my %RULE_VALID = ( 'type' => [qw( fix autofix warning error nop )] ); sub shift_0() { my $f = shift @fields; my $v = shift @values; my $l = shift @lines; return ($f, $v, $l); } sub get_0() { my $f = $fields[0]; my $v = $values[0]; my $l = $lines[0]; return ($f, $v, $l); } sub valid($$$%) { my $f = shift; my $v = shift; my $l = shift; my %V = @_; foreach (keys %V) { next unless $f =~ /^$_$/i; foreach (@{ $V{$_} }) { return unless $v =~ /^$_$/; } suicide __("%s: value not valid\n"), $l; } } sub escape_regex($) { $_ = shift; s/(\$\D)/\\$1/g; # `$' prevent use of variables but `$1', `$2', ... s/\(\?{/(\\?{/g; # `(?{' prevent arbitrary code execution s/\(\?\?{/(\\?\\?{/g; # `(??{' prevent arbitrary code execution return $_; } sub parse_comment() { my $comment = {}; # new hashref my $f; # field my $v; # value my $l; # line shift_0; $comment->{'type'} = "comment"; while (@fields) { ($f, $v, $l) = get_0; if ($f =~ /^(comment)|(valid)|(rule)|(list)$/i) { return $comment; } elsif ($f =~ /^end_comment$/i) { shift_0; return $comment; } elsif ($f =~ /^end_/i) { return $comment; } elsif (grep /^$f$/i, @COMMENT_REGEX) { shift_0; $comment->{$f} = escape_regex $v; } elsif (grep /^$f$/i, @COMMENT_FIELDS) { shift_0; $comment->{$f} = $v; } else { suicide __("%s: syntax error\n"), $l; } } return $comment; } sub parse_valid() { my $valid = {}; # new hashref my $f; # field my $v; # value my $l; # line shift_0; while (@fields) { ($f, $v, $l) = get_0; if ($f =~ /^(comment)|(valid)|(rule)|(list)$/i) { return $valid; } elsif ($f =~ /^end_valid$/i) { shift_0; return $valid; } elsif ($f =~ /^end_/i) { return $valid; } elsif (grep /^$f$/i, @VALID_REGEX) { shift_0; $valid->{$f} = escape_regex $v; } elsif (grep /^$f$/i, @VALID_FIELDS) { shift_0; $valid->{$f} = $v; } else { suicide __("%s: syntax error\n"), $l; } } return $valid; } sub parse_rule() { my $rule = {}; # new hashref my $f; # field my $v; # value my $l; # line shift_0; while (@fields) { ($f, $v, $l) = get_0; if ($f =~ /^(comment)|(rule)|(list)$/i) { return $rule; } elsif ($f =~ /^end_rule$/i) { shift_0; return $rule; } elsif ($f =~ /^end_/i) { return $rule; } elsif ($f =~ /^valid$/i && $v) { shift_0; push @{ $rule->{'valid'} }, $v; } elsif ($f =~ /^valid$/i) { $v = parse_valid; $valids{$v->{'name'} || ''} = $v; push @{ $rule->{'valid'} }, $v->{'name'} || $v; } elsif (grep /^$f$/i, @RULE_REGEX) { valid $f, $v, $l, %RULE_VALID; shift_0; $rule->{$f} = escape_regex $v; } elsif (grep /^$f$/i, @RULE_FIELDS) { valid $f, $v, $l, %RULE_VALID; shift_0; if ($f =~ /^fix$/) { push @{ $rule->{$f} }, escape_regex $v; } elsif ($f =~ /^hint$/) { push @{ $rule->{$f} }, $v; } else { $rule->{$f} = $v; } } else { suicide __("%s: syntax error\n"), $l; } } return $rule; } sub parse_list(); sub parse_list() { my $list = {}; # new hashref my $f; # field my $v; # value my $l; # line shift_0; while (@fields) { ($f, $v, $l) = get_0; if ($f =~ /^list$/i && $v) { shift_0; push @{ $list->{'rules'} }, $v; } elsif ($f =~ /^list$/i) { $v = parse_list; $lists{$v->{'name'} || ''} = $v; push @{ $list->{'rules'} }, $v->{'name'} || $v; } elsif ($f =~ /^end_list$/i) { shift_0; return $list; } elsif ($f =~ /^comment$/i && $v) { shift_0; push @{ $list->{'rules'} }, $v; } elsif ($f =~ /^comment$/i) { $v = parse_comment; $comments{$v->{'name'} || ''} = $v; push @{ $list->{'rules'} }, $v->{'name'} || $v; } elsif ($f =~ /^rule$/i && $v) { shift_0; push @{ $list->{'rules'} }, $v; } elsif ($f =~ /^rule$/i) { $v = parse_rule; $rules{$v->{'name'} || ''} = $v; push @{ $list->{'rules'} }, $v->{'name'} || $v; } elsif (grep /^$f$/i, @LIST_REGEX) { valid $f, $v, $l, %LIST_VALID; shift_0; $list->{$f} = escape_regex $v; } elsif (grep /^$f$/i, @LIST_FIELDS) { valid $f, $v, $l, %LIST_VALID; ($f =~ /^name$/i) && ($v eq LAST_PARSED_LIST) && (suicide __("%s: name %s\nreserved word\n"), $l, LAST_PARSED_LIST); shift_0; $list->{$f} = $v; } else { suicide __("%s: syntax error\n"), $l; } } return $list; } sub parse() { my $f; # field my $v; # value my $l; # line while (@fields) { ($f, $v, $l) = get_0; if ($f =~ /^list$/i ) { $v = parse_list; $lists{LAST_PARSED_LIST} = $v; $lists{$v->{'name'} || ''} = $v; } elsif ($f =~ /^rule$/i) { $v = parse_rule; $rules{$v->{'name'} || ''} = $v; } elsif ($f =~ /^valid$/i) { $v = parse_valid; $valids{$v->{'name'} || ''} = $v; } elsif ($f =~ /^comment$/i) { $v = parse_comment; $comments{$v->{'name'} || ''} = $v; } elsif ($f =~ /^end_(list)|(rule)|(comment)|(valid)$/i ) { shift_0; } else { suicide __("%s: syntax error\n"), $l; } } foreach (values %rules) { next unless exists $_->{'valid'}; for (my $i = 0; $i < @{ $_->{'valid'} }; $i++) { next if ref $_->{'valid'}[$i]; $_->{'valid'}[$i] = $valids{$_->{'valid'}[$i]} || suicide __("unable to resolve %s\nundefined name as `valid' rule\n"), $_->{'valid'}[$i]; } } foreach (values %lists) { next unless exists $_->{'rules'}; for (my $i = 0; $i < @{ $_->{'rules'} }; $i++) { next if ref $_->{'rules'}[$i]; my $many; $many = ($rules{$_->{'rules'}[$i]} && $lists {$_->{'rules'}[$i]}) || 0; $many |= ($rules{$_->{'rules'}[$i]} && $comments{$_->{'rules'}[$i]}) || 0; $many |= ($lists{$_->{'rules'}[$i]} && $comments{$_->{'rules'}[$i]}) || 0; $many && suicide __("unable to resolve %s\nname defined more than once as `rule', `list' and `comment'\n"), $_->{'rules'}[$i]; $_->{'rules'}[$i] = $rules {$_->{'rules'}[$i]} || $lists {$_->{'rules'}[$i]} || $comments{$_->{'rules'}[$i]} || suicide __("unable to resolve %s\nundefined name as `rule', `list' or `comment'\n"), $_->{'rules'}[$i]; } } my $r; $r->[0] = $lists{'root'} || $lists{''} || $lists{LAST_PARSED_LIST}; return $r; } sub load_one_rulefile($$); sub load_one_rulefile($$) { my $ruleset = shift; # set my $filetype = shift; # type debug 1, "ruleset: `$ruleset'\n". "filetype: `$filetype'\n"; my $filename = catfile(RULES_DIR, $ruleset, "$filetype.".RULES_E); my @file; # file lines my $longline; # temp value for multiline parsing my $l = 0; # line counter my $handle; # file handle $handle = new IO::File($filename, '<') or suicide __("Cannot read `%s': %s\n"), $filename, $!; @file = $handle -> getlines; $handle -> close; chomp @file; while (@file) { $_ = shift @file; $l++; if (/^#include\s+(\S+)/) { load_one_rulefile($ruleset, $1); next; } s/(?). This file is optional unless you don't want to use default values. Lines beginning with a number sign (`B<#>') and empty lines will be ignored. Spaces at the beginning and the end of a line will also be ignored as well as tabulators. If you need spaces at the end or the beginning of a value you can use apostrophes (`B<">'). An option line starts with it's name followed by a value. An equal sign is optional. A comment starts with the number sign, there can be any number of spaces and/or tab stops in front of the #. Some possible examples: # this line is ignored option value option = value # this is a comment option "value ending with space " You have to escape number signs with a backslash (`B<\>') to use it in a value. Default values are provided into square brackets, they should be suitable for most installations. =head1 SPELLING Define if you want to use ispell for checking spelling and how to use it. =over 4 =item I use Aspell for spelling if set to `B' [yes] =item I Language dictionary to use with Aspell, use default if empty [empty] =item I regular expression to define characters allowed to write a word, pattern matches according locale [\w] =item I<$review_mode> set to `B' if you want review comments to be added in the output file after parsed line, otherwise just fix error [no] =back =head1 COLORS Set text colors for clear presentation. The recognized colors (all of which should be fairly intuitive) are: B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, B, and B. Case is not significant. Underline and underscore are equivalent, as are clear and reset, so use whichever is the most intuitive to you. The I alone sets the foreground color, and I sets the background color. Note that not all colors are supported by all terminal types, and some terminals may not support any of these sequences. Dark, blink, and concealed in particular are frequently not implemented. =over 4 =item I color used to highlight errors, this should highlight space characters [bold on_red] =item I color used to highlight suggestions, this should highlight space characters [bold on_green] =item I color used to display the error line header [bold red] =item I color used to display the suggestion line header [bold green] =item I color used for comments and hints [cyan] =back =head1 OTHERS =over 4 =item I extension for backup files [bak] =item I comment string for review [>> ] =item I verbosity level [0] =back Verbosity Levels: =over 4 =item I<0> quiet, normal only warnings and errors =item I<1> debug names of subroutines =item I<2> debug verbose names and arguments of subroutines =item I<3> .. I<5> debug very verbose output parsing and checking details =back =head1 SEE ALSO acheck(1), acheck-rules(5) =head1 AUTHOR Nicolas Bertolissio =cut acheck-0.5.1+nmu1/man/acheck.fr.1.pod0000644000000000000000000001061112225273645013746 0ustar #!/usr/bin/perl -w =encoding ISO8859-1 =head1 NOM acheck - Correction des erreurs courantes de traduction =head1 SYNOPSIS acheck [OPTIONS] [FICHIER_D'ENTRE] =head1 DESCRIPTION Ce programme analyse un fichier en vrifiant des rgles de syntaxe et ventuellement en demandant Aspell de vrifier l'orthographe des mots. Il suggre des corrections et gnre un fichier corrig en fonction, ajoutant des commentaires de relecture si vous le dsirez. Il essaye de trouver le type de fichier en fonction de son extension ou de ses premires lignes et charge les rgles correspondantes. Il affiche les lignes au fur et mesure de l'analyse. Quand une erreur est trouve, un menu est affich. Pressez simplement Entre si vous ne voulez rien modifier. Si un choix vous convient, entrez la lettre correspondante. Si vous voulez corriger mais qu'aucun choix n'est correct, entrez un espace, il vous demandera alors un texte pour remplacer celui qui est surlign. Il remplacera le texte surlign par votre choix et reprendra l'analyse. Voici toutes les commandes disponiblesE: =over 4 =item I, ignorer. Ignore l'erreur. =item I, rafficher. Raffiche la dernire ligne, les suggestions et commentaires. =item I, diter. dite le texte surlign. =item I, diter la ligne. dite la ligne entire. =item I, ajouter le commentaire. Ajouter le commentaire affich en tant que commentaire de relecture. Ceci peut tre utilis si vous voulez que le traducteur voit l'avertissement ou l'erreur mais que vous n'avez pas de correction apporter. =item I, ligne suivante. Continuer la ligne suivante en sautant le reste de la ligne courante. =item I, quitter sans changement. Quitter sans sauvegarder les modifications, le script vous demande alors confirmation, vous devez tapez EBE (oui) pour sortir sinon l'analyse reprend sur l'erreur actuelle. =item I, ajouter au dictionnaire. Ajoute le mot surlign votre dictionnaire personnel, avec les majuscules telles qu'elles sont. =item I, ajouter en minuscules au dictionnaire. Ajoute le mot surlign votre dictionnaire personnel, en minuscules. =item I, ignorer le mot. Ignore le mot surlign, comme I. =item I, ignorer toujours. Ignore le mot surlign et l'ajoute votre dictionnaire de session. =back =head1 OPTIONS Niveau de bavardageE: =over 4 =item I<-q>, I<--quiet> silencieuxE; =item I<-v> verbeux, commence au niveau I<$Debug + 1>, plus il y en a, plus il est bavard (voir plus bas)E; =item I<--verbose n> utiliser le niveau I (voir plus bas). =back FichiersE: =over 4 =item I<-i>, I<--input> nom du fichier d'entre, utiliser EI<->E pour lire depuis l'entre standardE; =item I<-o>, I<--output> nom du fichier de sortie, utiliser EI<->E pour crire sur la sortie standard. Si aucun nom de fichier de sortie n'est fourni, le fichier d'entre est sauvegard avec l'extension EIE et son nom est utilis. =back Vrification de l'orthographeE: =over 4 =item I<-s>, I<--spell> vrifier l'orthographe avec AspellE; =item I<-d langue>, I<--dict langue> utiliser Aspell avec le dictionnaire IE; =item I<-n>, I<--nospell> ne pas vrifier l'orthographe. =back ModeE: =over 4 =item I<-r>, I<--review> mode relecture, ajoute des commentaires sur des lignes commenant par I<$Comment> aprs les lignes analysesE; =item I<-t>, I<--trans> mode traduction, ne pas ajouter de commentaire, ne faire que les corrections. =back AutreE: =over 4 =item I<--rules jeu_de_rgles> utiliser I comme jeu de rglesE; =item I<--type type_de_fichier> utiliser I quelque soit le type de fichierE; =item I<--dump> affiche le jeu de rgles, pour le dbogageE; =item I<-V>, I<--version> afficher le numro de version. =item I<-h>, I<--help> afficher un court message d'utilisationE; =back =head2 Niveaux de bavardage =over 4 =item I<0> silencieux, normal seulement les avertissements et les erreursE; =item I<1> dbogage noms des procduresE; =item I<2> dbogage bavard noms et arguments des procduresE; =item I<3> .. I<5> dbogage trs bavard dtails des analyses et des vrifications. =back =head1 VOIR AUSSI acheck(5), acheck-rules(5) =head1 AUTEUR Nicolas Bertolissio =cut acheck-0.5.1+nmu1/man/acheck.1.pod0000644000000000000000000000715012225273304013334 0ustar #!/usr/bin/perl -w =head1 NAME acheck - Check common localization mistakes =head1 SYNOPSIS acheck [OPTIONS] [INPUT_FILE] =head1 DESCRIPTION This program parses a file checking for syntax rules and optionally asking Aspell for checking word spelling. It makes fix suggestions and outputs a corrected file accordingly adding review comments if requested. It tries to find the file type according to the extension or the first lines and loads rules accordingly. It displays lines when they are parse. When an error is found, a menu is displayed. Just press Enter if you don't want to change anything. If a choice suits you, enter the corresponding number. If you want to fix it but no choice is correct, enter a space, then you will be asked for a string to replace the highlighted text. The script will replace the highlighted text with your choice and parse it again for new errors. Here are all the available commands: =over 4 =item I, ignore. Ignore. =item I, redraw. Rewrite the last line, suggestions and hints. =item I, edit. Edit the highlighted text. =item I, edit line. Edit the whole line. =item I, add hint. Add the displayed hint as review comment. Use this if you want the translator to see the corresponding warning or error but you have no correction. =item I, next line. Skip the rest of this line. =item I, exit and discard all changes. Quit without saving modifications, the script ask you for confirmation, you have to enter `B' to exit otherwise parsing starts again at the current mistake. =item I, add in dictionary. Add the highlighted word to you personal dictionary, capitalized as it is. =item I, add lowercase in dictionary. Lowercase the highlighted word to add it to your personal dictionary. =item I, ignore word. Ignore the highlighted word, same as I. =item I, ignore all. Ignore the highlighted word and add it to your session dictionary. =back =head1 OPTIONS Verbosity level: =over 4 =item I<-q>, I<--quiet> quiet mode. =item I<-v> verbose, start at level I<$Debug + 1>, add more for more verbosity (see below). =item I<--verbose n> set verbosity level to I (see below). =back Files: =over 4 =item I<-i>, I<--input> input filename, can be 'I<->' to read data from standard input. =item I<-o>, I<--output> output filename, can be 'I<->' to write data to standard ouput. If no output filename is provided, input file is backed up with `I' extension and input filename is used. =back Spell check: =over 4 =item I<-s>, I<--spell> check spelling with Aspell. =item I<-d language>, I<--dict language> use I dictionary for Aspell. =item I<-n>, I<--nospell> don't check spelling. =back Mode: =over 4 =item I<-r>, I<--review> review mode, add comments on lines beginning with I<$Comment> after parsed line. =item I<-t>, I<--trans> translator mode, don't add comments, just fix errors. =back others: =over 4 =item I<--rules ruleset> use I rules set. =item I<--type filetype> use I whatever the file type is. =item I<--dump> Dump the rules to check and exit, use this for debugging purposes. =item I<-V>, I<--version> print version and exit. =item I<-h>, I<--help> print a short usage message and exit. =back =head2 Verbosity Level =over 4 =item I<0> quiet, normal only warnings and errors =item I<1> debug names of subroutines =item I<2> debug verbose names and arguments of subroutines =item I<3> .. I<5> debug very verbose output parsing and checking details =back =head1 SEE ALSO acheck(5), acheck-rules(5) =head1 AUTHOR Nicolas Bertolissio =cut acheck-0.5.1+nmu1/man/acheck.fr.5.pod0000644000000000000000000001054612225273747013764 0ustar #!/usr/bin/perl -w =encoding ISO8859-1 =head1 NOM .acheck - Fichier de configuration d'acheck =head1 DESCRIPTION Il s'agit du fichier de configuration pour acheck. S'il existe, il doit tre situ dans votre rpertoire personnel (F<$HOME>). Ce fichier est optionnel moins que vous ne souhaitiez pas utiliser les valeurs par dfaut. Les lignes commenant par un dise (EB<#>E) et les lignes vides sont ignores. Les espaces au dbut et la fin d'une ligne sont aussi ignors ainsi que les tabulations. Si vous avez besoin d'espaces la fin ou au dbut d'une valeur, vous pouvez utilisez des guillemets anglo-saxons (EB<">E). Une ligne d'option dbute par le nom de l'option suivi par sa valeur. Le signe gal est optionnel. Un commentaire commence par un dise, il peut y avoir des espaces ou des tabulations devant le dise. Quelques exemplesE: # cette ligne est ignore option valeur option = valeur # ceci est un commentaire option "valeur avec espaces la fin " Vous devez protger le caractre dise avec une barre oblique inverse (EB<\>E) si vous voulez l'utiliser dans une valeur. Les valeurs par dfaut sont fournies entre crochets, elles devraient convenir pour la plupart des configurations. =head1 ORTHOGRAPHE Dfinit si vous voulez utiliser ispell pour vrifier l'orthographe et comme l'utiliser. =over 4 =item I utiliser aspell pour vrifier l'orthographe si EBE (oui) [yes]E; =item I dictionnaire utiliser avec ispell, utiliser celui par dfaut si vide [vide]E; =item I expression rationnelle dfinissant les caractres autoriss pour former un mot, le motif correspond selon la locale [\w]E; =item I<$Review_mode> positionnez cette valeur EBE (oui) si vous voulez ajouter des commentaires de relecture aprs les lignes analyses dans le fichier corrig, sinon le script corrige uniquement les erreurs [no]. =back =head1 COULEURS Dfinit les couleurs du texte pour une meilleure prsentation. Les couleurs reconnues sontE: B et B (normal), B (sombre), B (gras), B et B (soulign), B (clignotant), B (invers), B (cach), B (noir), B (rouge), B (vert), B (jaune), B (bleu), B (mangenta), B (cyan), B (blanc), B (sur noir), B (sur rouge), B (sur vert), B (sur jaune), B (sur bleu), B (sur magenta), B (sur cyan), et B (sur blanc). La casse n'est pas significative. B et B sont quivalents, de mme que B et B, utilisez celui qui vous semble le plus intuitif. Les I seules dfinissent la couleur des caractres, et les I dfinissent la couleur du fond. Notez que toutes les couleurs ne sont pas supportes par tous les types de terminaux, et certains terminaux peuvent ne supporter aucune de ces squences. B, B et B en particulier sont souvent manquantes. =over 4 =item I couleur utilise pour surligner les erreurs, elle devrait colorer les caractres d'espacement [bold on_red]E; =item I couleur utilise pour surligner les suggestions, elle devrait colorer les caractres d'espacement [bold on_green]E; =item I couleur utilise pour afficher l'en-tte des lignes errones [bold red]E; =item I couleur utilise pour afficher l'en-tte des lignes de suggestion [bold green]E; =item I couleur utilise pour les commentaires [cyan]. =back =head1 AUTRES =over 4 =item I extension pour les fichiers de sauvegarde [bak]E; =item I chane de commentaire pour la relecture [>>E]E; =item I niveau de bavardage [0]. =back Niveaux de bavardageE: =over 4 =item I<0> silencieux, normal seulement les avertissements et les erreursE; =item I<1> dbogage noms des procduresE; =item I<2> dbogage bavard noms et arguments des procduresE; =item I<3> .. I<5> dbogage trs bavard dtails des analyses et des vrifications. =back =head1 VOIR AUSSI acheck(1), acheck-rules(5) =head1 AUTEUR Nicolas Bertolissio =cut acheck-0.5.1+nmu1/po/0000755000000000000000000000000012225330460011110 5ustar acheck-0.5.1+nmu1/po/acheck.pot0000644000000000000000000001011007720214701013046 0ustar # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR 2001-2003 Nicolas Bertolissio # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: Nicolas Bertolissio \n" "POT-Creation-Date: 2003-08-18 20:24+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" #: ../acheck:123 #, c-format msgid "`%s': unknow offset\n" msgstr "" #: ../acheck:150 msgid "comment: no stop regex\n" msgstr "" #: ../acheck:389 msgid "" "Edit current line\n" "Add hint\n" "Skip the rest of the line\n" "Exit and discard all changes\n" "Add in dictionnary\n" "Add lowercase in dictionnary\n" "Ignore\n" "Ignore all\n" msgstr "" #: ../acheck:433 msgid "Enter correction to replace the highlighted part:\n" msgstr "" #: ../acheck:436 ../acheck:457 msgid "Enter explanation, use displayed hint if empty:\n" msgstr "" #: ../acheck:454 msgid "Modify the line:\n" msgstr "" #: ../acheck:502 msgid "Exit and discard all changes! type `yes' to confirm: " msgstr "" #: ../acheck:504 msgid "yes" msgstr "" #: ../acheck:596 ../acheck:649 ../acheck:680 ../acheck:728 #, c-format msgid "%s: %s" msgstr "" #: ../acheck:826 #, c-format msgid "`%s': unknown operation\n" msgstr "" #: ../acheck:843 #, c-format msgid "spelling for `%s'" msgstr "" #: ../acheck:951 #, c-format msgid "%s: spelling for `%s'" msgstr "" #: ../acheck:1041 ../Parser.pm:374 #, c-format msgid "Cannot read `%s': %s\n" msgstr "" #: ../acheck:1046 msgid "Empty file\n" msgstr "" #: ../acheck:1066 #, c-format msgid "Cannot backup `%s': %s\n" msgstr "" #: ../acheck:1067 #, c-format msgid "Cannot write to `%s': %s\n" msgstr "" #: ../acheck:1083 #, c-format msgid "%s version %s\n" msgstr "" #: ../acheck:1098 #, c-format msgid "" "Usage: %s [OPTIONS] [INPUT_FILE]\n" "\n" "options:\n" " -q, --quiet quiet mode\n" " -v verbose, add more for more verbosity\n" " --verbose set verbosity to n\n" " --rules use rules set \n" " --type set filetype to \n" " -i, --input input filename\n" " -o, --output output filename\n" " -s, --spell check spelling with aspell\n" " -d, --dict use dictionary\n" " -n, --nospell don't check spelling\n" " -r, --review add comments (for reviewers)\n" " -t, --trans don't add comments (for translators)\n" " --dump dump the rules and exit (for debugging)\n" " -V, --version print version and exit\n" " -h, --help print this message and exit\n" "\n" "If input filename is '-' or not provided, data are read from STDIN\n" "If output filename is not provided, input filename is used, '-' write to " "STDOUT\n" "\n" "%s version %s\n" msgstr "" #: ../acheck:1163 ../acheck:1167 msgid "Aspell Perl module not found, spelling check cancelled." msgstr "" #: ../acheck:1164 msgid "Press 'Enter' to continue" msgstr "" #: ../acheck:1171 #, c-format msgid "Aspell: unable to use `%s'.\n" msgstr "" #: ../Common.pm:92 msgid "ERROR " msgstr "" #: ../Common.pm:110 msgid "WARNING " msgstr "" #: ../Parser.pm:118 #, c-format msgid "%s: value not valid\n" msgstr "" #: ../Parser.pm:159 ../Parser.pm:191 ../Parser.pm:238 ../Parser.pm:293 #: ../Parser.pm:324 #, c-format msgid "%s: syntax error\n" msgstr "" #: ../Parser.pm:289 #, c-format msgid "" "%s: name %s\n" "reserved word\n" msgstr "" #: ../Parser.pm:333 #, c-format msgid "" "unable to resolve %s\n" "undefined name as `valid' rule\n" msgstr "" #: ../Parser.pm:346 #, c-format msgid "" "unable to resolve %s\n" "name defined more than once as `rule', `list' and `comment'\n" msgstr "" #: ../Parser.pm:350 #, c-format msgid "" "unable to resolve %s\n" "undefined name as `rule', `list' or `comment'\n" msgstr "" #: ../Parser.pm:418 #, c-format msgid "%s/%s:%s: `%s', unknown field name\n" msgstr "" acheck-0.5.1+nmu1/po/pl.po0000644000000000000000000001507307737774432012120 0ustar # Polish translation of Acheck. # Copyright (C) YEAR 2001-2003 Nicolas Bertolissio # This file is distributed under the same license as the PACKAGE package. # Arkadiusz Lipiec , 2003. # msgid "" msgstr "" "Project-Id-Version: acheck\n" "Report-Msgid-Bugs-To: Nicolas Bertolissio \n" "POT-Creation-Date: 2003-08-18 20:24+0200\n" "PO-Revision-Date: 2003-09-29 20:40+0100\n" "Last-Translator: Arkadiusz Lipiec \n" "Language-Team: Polish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #: ../acheck:123 #, c-format msgid "`%s': unknow offset\n" msgstr "\"%s\": nieznane przesunięcie\n" #: ../acheck:150 msgid "comment: no stop regex\n" msgstr "komentarz: brak zatrzymującego wyrażenia regularnego\n" #: ../acheck:389 msgid "" "Edit current line\n" "Add hint\n" "Skip the rest of the line\n" "Exit and discard all changes\n" "Add in dictionnary\n" "Add lowercase in dictionnary\n" "Ignore\n" "Ignore all\n" msgstr "" "Edycja bieżącego wiersza\n" "Dodanie podpowiedzi\n" "Pominięcie reszty wiersza\n" "Zakończenie i porzucenie wszystkich zmian\n" "Dodanie w słowniku\n" "Dodanie małej litery w słowniku\n" "Zignorowanie\n" "Zignorowanie wszystkiego\n" #: ../acheck:433 msgid "Enter correction to replace the highlighted part:\n" msgstr "Podaj poprawkę aby zastąpić podświetloną część:\n" #: ../acheck:436 ../acheck:457 msgid "Enter explanation, use displayed hint if empty:\n" msgstr "Podaj wyjaśnienie, użyj wyświetlonej podpowiedzi jeśli puste:\n" #: ../acheck:454 msgid "Modify the line:\n" msgstr "Zmodyfikuj wiersz:\n" #: ../acheck:502 msgid "Exit and discard all changes! type `yes' to confirm: " msgstr "Zakończ i porzuć wszystkie zmiany! wpisz \"tak\" aby potwierdzić: " #: ../acheck:504 msgid "yes" msgstr "tak" #: ../acheck:596 ../acheck:649 ../acheck:680 ../acheck:728 #, c-format msgid "%s: %s" msgstr "%s: %s" #: ../acheck:826 #, c-format msgid "`%s': unknown operation\n" msgstr "\"%s\": nieznana operacja\n" #: ../acheck:843 #, c-format msgid "spelling for `%s'" msgstr "pisownia dla \"%s\"" #: ../acheck:951 #, c-format msgid "%s: spelling for `%s'" msgstr "%s: pisowania dla \"%s\"" #: ../acheck:1041 ../Parser.pm:374 #, c-format msgid "Cannot read `%s': %s\n" msgstr "Nie można odczytać \"%s\": %s\n" #: ../acheck:1046 msgid "Empty file\n" msgstr "Puste pole\n" #: ../acheck:1066 #, c-format msgid "Cannot backup `%s': %s\n" msgstr "Nie można zarchiwizować \"%s\": %s\n" #: ../acheck:1067 #, c-format msgid "Cannot write to `%s': %s\n" msgstr "Nie moÂżna zapisaĂŚ \"%s\": %s\n" #: ../acheck:1083 #, c-format msgid "%s version %s\n" msgstr "%s wersja %s\n" #: ../acheck:1098 #, c-format msgid "" "Usage: %s [OPTIONS] [INPUT_FILE]\n" "\n" "options:\n" " -q, --quiet quiet mode\n" " -v verbose, add more for more verbosity\n" " --verbose set verbosity to n\n" " --rules use rules set \n" " --type set filetype to \n" " -i, --input input filename\n" " -o, --output output filename\n" " -s, --spell check spelling with aspell\n" " -d, --dict use dictionary\n" " -n, --nospell don't check spelling\n" " -r, --review add comments (for reviewers)\n" " -t, --trans don't add comments (for translators)\n" " --dump dump the rules and exit (for debugging)\n" " -V, --version print version and exit\n" " -h, --help print this message and exit\n" "\n" "If input filename is '-' or not provided, data are read from STDIN\n" "If output filename is not provided, input filename is used, '-' write to " "STDOUT\n" "\n" "%s version %s\n" msgstr "" "Użycie: %s [OPCJE] [PLIK_WEJŚCIOWY]\n" "\n" "opcje:\n" " -q, --quiet tryb cichy\n" " -v tryb informacyjny, więcej informacji\n" " --verbose ustawia informacyjność na n\n" " --rules używa zbioru \n" " --type ustawia typ pliku na \n" " -i, --input nazwa pliku wejściowego\n" " -o, --output nazwa pliku wyjściowego\n" " -s, --spell sprawdza pisownię z aspellem\n" " -d, --disc ustawia dla słownika\n" " -n, --nospell nie sprawdza pisowni\n" " -r, --review dodaje komentarze (dla korektorów)\n" " -t, --trans nie dodaje komentarzy (dla tłumaczy)\n" " --dump zrzuca zasady i kończy (do debugowania)\n" " -V, --version wypisuje wersje i kończy\n" " -h, --help wypisuje ten komunikat i kończy\n" "\n" "Jeśli podany plik wejściowy to \"-\", wczytywane są dane ze\n" "standardowego wejścia STDIN. Jeśli nie podano nazwy pliku wyjściowego\n" "wówczas używana jest nazwa pliku wejściowego, używane jest \"-\"\n" "jako wyjście standardowe STDOUT\n" "\n" "%s wersja %s\n" #: ../acheck:1163 ../acheck:1167 msgid "Aspell Perl module not found, spelling check cancelled." msgstr "Nie znaleziono modułu perla do aspella, anulowano sprawdzanie pisowni." #: ../acheck:1164 msgid "Press 'Enter' to continue" msgstr "Naciśnij \"Enter\" aby kontynuować" #: ../acheck:1171 #, c-format msgid "Aspell: unable to use `%s'.\n" msgstr "Aspell: nie można użyć \"%s\".\n" #: ../Common.pm:92 msgid "ERROR " msgstr "BŁĄD " #: ../Common.pm:110 msgid "WARNING " msgstr "OSTRZEŻENIE " #: ../Parser.pm:118 #, c-format msgid "%s: value not valid\n" msgstr "%s: wartość nie jest poprawna\n" #: ../Parser.pm:159 ../Parser.pm:191 ../Parser.pm:238 ../Parser.pm:293 #: ../Parser.pm:324 #, c-format msgid "%s: syntax error\n" msgstr "%: błąd składni\n" #: ../Parser.pm:289 #, c-format msgid "" "%s: name %s\n" "reserved word\n" msgstr "" "%s: nazwa %s\n" "zarezerwowane słowo\n" #: ../Parser.pm:333 #, c-format msgid "" "unable to resolve %s\n" "undefined name as `valid' rule\n" msgstr "" "Nie można odnaleźć nazwy %s\n" "niezdefiniowana nazwa jako zasada \"poprawna\"\n" #: ../Parser.pm:346 #, c-format msgid "" "unable to resolve %s\n" "name defined more than once as `rule', `list' and `comment'\n" msgstr "" "Nie można odnaleźć nazwy %s\n" "nazwa zdefiniowana więcej niż raz jako \"zasada\", \"lista\" i \"komentarz" "\"\n" #: ../Parser.pm:350 #, c-format msgid "" "unable to resolve %s\n" "undefined name as `rule', `list' or `comment'\n" msgstr "" "nie można odnaleźć nazwy %s\n" "niezdefiniowana nazwa jako \"zasada\", \"lista\" lub \"komentarz\"\n" #: ../Parser.pm:418 #, c-format msgid "%s/%s:%s: `%s', unknown field name\n" msgstr "%s/%s:%s: \"%s\", nieznana nazwa pola\n" acheck-0.5.1+nmu1/po/Makefile0000644000000000000000000000134607737637010012571 0ustar XGETTEXT = xgettext MSGFMT = msgfmt MSGMERGE = msgmerge LOCALEDIR = "usr/share/locale" .SUFFIXES: .po .mo .pot %.mo: %.po $(MSGFMT) -o $@ $< %.pox: %.po acheck.pot $(MSGMERGE) -o $@ $^ LANG = $(basename $(shell ls *.po)) MO = $(addsuffix .mo,$(LANG)) POX = $(addsuffix .pox,$(LANG)) all: $(MO) update: $(POX) acheck.pot: ../acheck ../*.pm $(XGETTEXT)\ --copyright-holder="2001-2003 Nicolas Bertolissio"\ --msgid-bugs-address="Nicolas Bertolissio "\ --keyword=__\ --output=$@\ ../acheck ../*.pm install: $(MO) for i in $(MO) ; do \ t=$(DESTDIR)/$(LOCALEDIR)/`basename $$i .mo`/LC_MESSAGES ;\ install -d $$t ;\ install -m 644 $$i $$t/acheck.mo ;\ done clean: $(RM) $(MO) *~ ddtc.pot *.pox acheck-0.5.1+nmu1/po/fr.po0000644000000000000000000001530007737776627012115 0ustar # acheck fr.po # Copyright (C) YEAR 2001-2003 Nicolas Bertolissio # This file is distributed under the same license as the acheck package. # Nicolas Bertolissio , 2003. # msgid "" msgstr "" "Project-Id-Version: acheck 0.3\n" "Report-Msgid-Bugs-To: Nicolas Bertolissio \n" "POT-Creation-Date: 2003-08-18 20:24+0200\n" "PO-Revision-Date: 2003-08-18 15:20+0200\n" "Last-Translator: Nicolas Bertolissio \n" "Language-Team: French translators \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-15\n" "Content-Transfer-Encoding: 8bit\n" #: ../acheck:123 #, c-format msgid "`%s': unknow offset\n" msgstr "%s: dcalage inconnu\n" #: ../acheck:150 msgid "comment: no stop regex\n" msgstr "comment: pas d'expression rationnelle pour stop\n" #: ../acheck:389 msgid "" "Edit current line\n" "Add hint\n" "Skip the rest of the line\n" "Exit and discard all changes\n" "Add in dictionnary\n" "Add lowercase in dictionnary\n" "Ignore\n" "Ignore all\n" msgstr "" "diter la ligne actuelle\n" "Ajouter le commentaire\n" "Ignorer le reste de la ligne\n" "Quitter en annulant toutes les modifications\n" "Ajouter au dictionnaire\n" "Ajouter en minuscules au dictionnaire\n" "Ignorer\n" "Ignorer toujours\n" #: ../acheck:433 msgid "Enter correction to replace the highlighted part:\n" msgstr "Saisissez la correction pour remplacer la partie surligne:\n" #: ../acheck:436 ../acheck:457 msgid "Enter explanation, use displayed hint if empty:\n" msgstr "" "Saisissez une explication, le commentaire affich sera utilis dfaut:\n" #: ../acheck:454 msgid "Modify the line:\n" msgstr "Modifiez la ligne:\n" #: ../acheck:502 msgid "Exit and discard all changes! type `yes' to confirm: " msgstr "" "Quitter en annulant toutes les modifications! Tapez oui pour " "confirmer: " #: ../acheck:504 msgid "yes" msgstr "oui" #: ../acheck:596 ../acheck:649 ../acheck:680 ../acheck:728 #, c-format msgid "%s: %s" msgstr "%s: %s" #: ../acheck:826 #, c-format msgid "`%s': unknown operation\n" msgstr "%s: opration inconnue\n" #: ../acheck:843 #, c-format msgid "spelling for `%s'" msgstr "orthographe de %s" #: ../acheck:951 #, c-format msgid "%s: spelling for `%s'" msgstr "%s: orthographe de %s" #: ../acheck:1041 ../Parser.pm:374 #, c-format msgid "Cannot read `%s': %s\n" msgstr "Impossible de lire %s: %s\n" #: ../acheck:1046 msgid "Empty file\n" msgstr "Fichier vide\n" #: ../acheck:1066 #, c-format msgid "Cannot backup `%s': %s\n" msgstr "Impossible de sauvegarder %s: %s\n" #: ../acheck:1067 #, c-format msgid "Cannot write to `%s': %s\n" msgstr "Impossible d'crire dans %s: %s\n" #: ../acheck:1083 #, c-format msgid "%s version %s\n" msgstr "%s version %s\n" #: ../acheck:1098 #, c-format msgid "" "Usage: %s [OPTIONS] [INPUT_FILE]\n" "\n" "options:\n" " -q, --quiet quiet mode\n" " -v verbose, add more for more verbosity\n" " --verbose set verbosity to n\n" " --rules use rules set \n" " --type set filetype to \n" " -i, --input input filename\n" " -o, --output output filename\n" " -s, --spell check spelling with aspell\n" " -d, --dict use dictionary\n" " -n, --nospell don't check spelling\n" " -r, --review add comments (for reviewers)\n" " -t, --trans don't add comments (for translators)\n" " --dump dump the rules and exit (for debugging)\n" " -V, --version print version and exit\n" " -h, --help print this message and exit\n" "\n" "If input filename is '-' or not provided, data are read from STDIN\n" "If output filename is not provided, input filename is used, '-' write to " "STDOUT\n" "\n" "%s version %s\n" msgstr "" "Usage: %s [OPTIONS] [FICHIER_D'ENTRE]\n" "\n" "options:\n" " -q, --quiet mode silencieux\n" " -v bavard, rpter pour augmenter le bavardage\n" " --verbose niveau de bavardage n\n" " --rules slection du jeu de rgles \n" " --type slection du type de fichier \n" " -i, --input nom du fichier d'entre\n" " -o, --output nom du fichier de sortie\n" " -s, --spell correction orthographique avec Aspell\n" " -d, --dict utilisation du dictionnaire \n" " -n, --nospell pas de correction orthographique\n" " -r, --review ajout de commentaires (pour les relecteurs)\n" " -t, --trans pas d'ajout de commentaires (pour les " "traducteurs)\n" " --dump afficher les rgles et quitter (pour le dbogage)\n" " -V, --version afficher la version et quitter\n" " -h, --help afficher ce message et quitter\n" "\n" "Si le nom du fichier d'entre est - ou n'est pas donn, les donnes sont " "lues depuis l'entre standard.\n" "Si le nom du fichier de sortie n'est pas donne, celui d'entre est utilis, " "- permet d'crire sur la sortie standard.\n" "\n" "%s version %s\n" #: ../acheck:1163 ../acheck:1167 msgid "Aspell Perl module not found, spelling check cancelled." msgstr "Module Perl pour Aspell non trouv, correction orthographique annule." #: ../acheck:1164 msgid "Press 'Enter' to continue" msgstr "Pressez Entre pour continuer" #: ../acheck:1171 #, c-format msgid "Aspell: unable to use `%s'.\n" msgstr "Aspell: impossible d'utiliser %s.\n" #: ../Common.pm:92 msgid "ERROR " msgstr "ERREUR " #: ../Common.pm:110 msgid "WARNING " msgstr "ATTENTION " #: ../Parser.pm:118 #, c-format msgid "%s: value not valid\n" msgstr "%s: value invalide\n" #: ../Parser.pm:159 ../Parser.pm:191 ../Parser.pm:238 ../Parser.pm:293 #: ../Parser.pm:324 #, c-format msgid "%s: syntax error\n" msgstr "%s: erreur de syntaxe\n" #: ../Parser.pm:289 #, c-format msgid "" "%s: name %s\n" "reserved word\n" msgstr "" "%s: nom %s\n" "mot rserv\n" #: ../Parser.pm:333 #, c-format msgid "" "unable to resolve %s\n" "undefined name as `valid' rule\n" msgstr "" "impossible de rsoudre %s\n" "nom de rgle valid indfini\n" #: ../Parser.pm:346 #, c-format msgid "" "unable to resolve %s\n" "name defined more than once as `rule', `list' and `comment'\n" msgstr "" "impossible de rsoudre %s\n" "nom de rule , list ou comment dfini plusieurs fois\n" #: ../Parser.pm:350 #, c-format msgid "" "unable to resolve %s\n" "undefined name as `rule', `list' or `comment'\n" msgstr "" "impossible de rsoudre %s\n" "nom de rule , list ou comment indfini\n" #: ../Parser.pm:418 #, c-format msgid "%s/%s:%s: `%s', unknown field name\n" msgstr "%s/%s:%s: %s, nom de champ inconnu\n" acheck-0.5.1+nmu1/po/sv.po0000644000000000000000000001435510322237771012117 0ustar # Swedish translation of acheck. # Copyright (C) 2005 2001-2003 Nicolas Bertolissio # This file is distributed under the same license as the acheck package. # Daniel Nylander , 2005. # # msgid "" msgstr "" "Project-Id-Version: acheck 0.4\n" "Report-Msgid-Bugs-To: Nicolas Bertolissio \n" "POT-Creation-Date: 2003-08-18 20:24+0200\n" "PO-Revision-Date: 2005-10-06 08:57+0200\n" "Last-Translator: Daniel Nylander \n" "Language-Team: Swedish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit" #: ../acheck:123 #, c-format msgid "`%s': unknow offset\n" msgstr "`%s': oknd offset\n" #: ../acheck:150 msgid "comment: no stop regex\n" msgstr "kommentar: inget stoppregex\n" #: ../acheck:389 msgid "" "Edit current line\n" "Add hint\n" "Skip the rest of the line\n" "Exit and discard all changes\n" "Add in dictionnary\n" "Add lowercase in dictionnary\n" "Ignore\n" "Ignore all\n" msgstr "" "ndra nuvarande rad\n" "Lgg till tips\n" "Hoppa ver resten av raderna\n" "Avsluta och kasta alla ndringar\n" "Lgg till i ordbok\n" "Lgg till gemener i ordbok\n" "Ignorera\n" "Ignorera alla\n" #: ../acheck:433 msgid "Enter correction to replace the highlighted part:\n" msgstr "Ange rttning att byta ut mot framhvd del:\n" #: ../acheck:436 ../acheck:457 msgid "Enter explanation, use displayed hint if empty:\n" msgstr "Ange frklarning, anvnd visat tips om tom:\n" #: ../acheck:454 msgid "Modify the line:\n" msgstr "Modifiera raden:\n" #: ../acheck:502 msgid "Exit and discard all changes! type `yes' to confirm: " msgstr "Avsluta och kasta alla ndringar! skriv 'ja' fr att gra detta: " #: ../acheck:504 msgid "yes" msgstr "ja" #: ../acheck:596 ../acheck:649 ../acheck:680 ../acheck:728 #, c-format msgid "%s: %s" msgstr "%s: %s" #: ../acheck:826 #, c-format msgid "`%s': unknown operation\n" msgstr "`%s': oknd operation\n" #: ../acheck:843 #, c-format msgid "spelling for `%s'" msgstr "stavning fr '%s'" #: ../acheck:951 #, c-format msgid "%s: spelling for `%s'" msgstr "%s: stavning fr `%s'" #: ../acheck:1041 ../Parser.pm:374 #, c-format msgid "Cannot read `%s': %s\n" msgstr "Kan inte lsa `%s': %s\n" #: ../acheck:1046 msgid "Empty file\n" msgstr "Tom fil\n" #: ../acheck:1066 #, c-format msgid "Cannot backup `%s': %s\n" msgstr "Kan inte skerhetskopiera `%s': %s\n" #: ../acheck:1067 #, c-format msgid "Cannot write to `%s': %s\n" msgstr "Kan inte skriva till `%s': %s\n" #: ../acheck:1083 #, c-format msgid "%s version %s\n" msgstr "%s version %s\n" #: ../acheck:1098 #, c-format msgid "" "Usage: %s [OPTIONS] [INPUT_FILE]\n" "\n" "options:\n" " -q, --quiet quiet mode\n" " -v verbose, add more for more verbosity\n" " --verbose set verbosity to n\n" " --rules use rules set \n" " --type set filetype to \n" " -i, --input input filename\n" " -o, --output output filename\n" " -s, --spell check spelling with aspell\n" " -d, --dict use dictionary\n" " -n, --nospell don't check spelling\n" " -r, --review add comments (for reviewers)\n" " -t, --trans don't add comments (for translators)\n" " --dump dump the rules and exit (for debugging)\n" " -V, --version print version and exit\n" " -h, --help print this message and exit\n" "\n" "If input filename is '-' or not provided, data are read from STDIN\n" "If output filename is not provided, input filename is used, '-' write to " "STDOUT\n" "\n" "%s version %s\n" msgstr "" "Anvndning: %s [OPTIONS] [INPUT_FILE]\n" "\n" "options:\n" " -q, --quiet tyst lge\n" " -v informativt, lgg till fler fr mer information\n" " --verbose stt information till n\n" " --rules anvnd regeluppsttning \n" " --type stt filtyp till \n" " -i, --input mata in filenamn\n" " -o, --output utgng filnamn\n" " -s, --spell kontrollera stavning med aspell\n" " -d, --dict anvnd ordbok\n" " -n, --nospell kontrollera inte stavning\n" " -r, --review lgg till kommentar (fr granskare)\n" " -t, --trans lgg inte till kommentarer (fr versttare)\n" " --dump dumpa reglerna och avsluta (fr avlusning)\n" " -V, --version skriv ut version och avsluta\n" " -h, --help skriv ut detta meddelande och avsluta\n" "\n" "Om ingngsfilnamn r '-' eller inte medskickat, data blir lst frn STDIN\n" "Om utgngsfilnamn inte skickas med anvnds ingngsfilnamnet, '-' skriv till " "STDOUT\n" "\n" "%s version %s\n" #: ../acheck:1163 ../acheck:1167 msgid "Aspell Perl module not found, spelling check cancelled." msgstr "Aspell Perl-modul hittades inte, stavningskontroll avbruten." #: ../acheck:1164 msgid "Press 'Enter' to continue" msgstr "Tryck 'Enter' fr att fortstta" #: ../acheck:1171 #, c-format msgid "Aspell: unable to use `%s'.\n" msgstr "Aspell: kan inte anvnda `%s'.\n" #: ../Common.pm:92 msgid "ERROR " msgstr "FEL" #: ../Common.pm:110 msgid "WARNING " msgstr "VARNING" #: ../Parser.pm:118 #, c-format msgid "%s: value not valid\n" msgstr "%s: vrde inte giltigt\n" #: ../Parser.pm:159 ../Parser.pm:191 ../Parser.pm:238 ../Parser.pm:293 #: ../Parser.pm:324 #, c-format msgid "%s: syntax error\n" msgstr "%s: syntaxfel\n" #: ../Parser.pm:289 #, c-format msgid "" "%s: name %s\n" "reserved word\n" msgstr "" "%s: namn %s\n" "reserverade ord\n" #: ../Parser.pm:333 #, c-format msgid "" "unable to resolve %s\n" "undefined name as `valid' rule\n" msgstr "" "kunde inte sl upp %s\n" "odefinierat namn som 'giltig' regel\n" #: ../Parser.pm:346 #, c-format msgid "" "unable to resolve %s\n" "name defined more than once as `rule', `list' and `comment'\n" msgstr "" "kunde inte sl upp %s\n" "namn definierat mer n en gng som 'regel' 'lista' och 'kommentar'\n" #: ../Parser.pm:350 #, c-format msgid "" "unable to resolve %s\n" "undefined name as `rule', `list' or `comment'\n" msgstr "" "kunde inte sl upp %s\n" "odefinierat namn som 'regel', 'lista' eller 'kommentar'\n" #: ../Parser.pm:418 #, c-format msgid "%s/%s:%s: `%s', unknown field name\n" msgstr "%s/%s:%s: `%s', oknt fltnamn\n" acheck-0.5.1+nmu1/acheck0000755000000000000000000007023107720214673011654 0ustar #!/usr/bin/perl -w use strict; use locale; use Getopt::Long; use Config::General; use File::Copy; use File::Spec::Functions; use IO::File; use Term::ReadLine; use Term::ANSIColor; use Term::Size; use Data::Dumper; use ACheck::Common; use ACheck::Parser; use ACheck::FileType; # Constants setting # use constant VERSION => "0.4"; # script version number use constant CONFFILE => ".acheck"; # Config file name # Global variables # my $Rules; # rules structure my @Rules_stack = (-1); # rules stack my @Rules_success = ( 0); # number of success test per stack level my @Rules_loop = ( 0); # loop counter my @Lines_orig; # original file my @Lines_current = (""); # current line and added comments my @Lines_fixed = (""); # fixed file and comments my $Lines_whole; # whole current line eval "use Text::Aspell;"; my $Aspell = not $@; # true if Aspell module found my $Speller; $Speller = Text::Aspell->new if $Aspell; # spell checker my $Term = new Term::ReadLine (''); # terminal my $Comment_in = 0; # next line is comments my $Comment_skip = 0; # small comment found # Configuration # my %conf = ( bak_ext => 'bak', comment => '>> ', check_spelling => 1, word_letters => '\w', review_mode => 0, display_menu => 1, debug => 0, rules_set => '', comment_color => 'cyan', error_color => 'bold on_red', fix_color => 'bold on_green', error_head_color => 'bold red', fix_head_color => 'bold green' ); if (-e catfile($ENV{HOME}, CONFFILE)) { my $config = new Config::General ( -ConfigFile => catfile($ENV{HOME}, CONFFILE), -AllowMultiOptions => 'no', -LowerCaseNames => 'yes', -UseApacheInclude => 'no', -MergeDuplicateOptions => 'yes', -AutoTrue => 'yes', -DefaultConfig => \%conf ); %conf = $config -> getall; } my $Bak_e = $conf{'bak_ext'}; # backup files extension my $Comment = $conf{'comment'}; # comment string my $Check_spelling = $conf{'check_spelling'}; # use ispell if "yes" my $Dictionary = $conf{'dictionary'}; # aspell dictionary my $Word_letters = $conf{'word_letters'}; # letters regex my $Review_mode = $conf{'review_mode'}; # review mode if "yes" my $Display_menu = $conf{'display_menu'}; # display menu if "yes" my $Rules_set = $conf{'rules_set'}; # rules set my $NC = color( 'clear' ); # color for normal text my $CC = $NC.color($conf{ 'comment_color'}); # comment text color my $EC = $NC.color($conf{ 'error_color'}); # highlighted error text color my $FC = $NC.color($conf{ 'fix_color'}); # highlighted fix text color my $EL = $NC.color($conf{'error_head_color'}); # error letter color my $FL = $NC.color($conf{ 'fix_head_color'}); # fix letter color set_debug($conf{'debug'}); # debug level # get_offset # # split a string at the given offset # # input: # string # offset # output: # part before the offset # part after sub get_offset($$) { my $string = shift; my $offset = shift; my $len = length $string; if ($offset =~ /^s$/i) { $len = 0; } elsif ($offset =~ /^s\+(\d+)$/i) { $len = $1 < $len ? $1 : $len; } elsif ($offset =~ /^e$/i) { } elsif ($offset =~ /^e\-(\d+)$/i) { $len = $1 < $len ? -$1 : -$len; } else { suicide __("`%s': unknow offset\n"), $offset; } return substr($string, 0, $len), substr($string, $len ); } # line_next # # save fixed line and get next one # # output: # false if end of file sub line_next() { debug 1; my $stop; my $first; my $offset; if ($Comment_skip) { $Lines_fixed[-1] .= (defined $Lines_current[0]) ? shift @Lines_current : ""; $Lines_fixed[-1] .= (defined $Lines_orig [0]) ? shift @Lines_orig : ""; # skipped part unshift @Lines_current, (defined $Lines_orig [0]) ? shift @Lines_orig : ""; # rest of the line $Comment_skip--; return 1; } if ($Comment_in) { $stop = (defined $Lines_orig[0]) ? shift @Lines_orig : suicide __("comment: no stop regex\n"); $offset = (defined $Lines_orig[0]) ? shift @Lines_orig : "e"; $Lines_fixed[-1] .= (defined $Lines_current[0]) ? shift @Lines_current : ""; unshift @Lines_current, (defined $Lines_orig [0]) ? shift @Lines_orig : ""; $first = 1; } while ($Comment_in) { if ($Lines_current[0] =~ /$stop/) { my $a; my $b; $Lines_fixed [-1] .= (defined $`) ? $` : ""; $Lines_current[ 0] = (defined $') ? $' : ""; ($a, $b) = get_offset($&, $offset); $Lines_fixed [-1] .= $a; $Lines_current[ 0] = $b.$Lines_current[0]; $Comment_in--; return 1; } else { if ($first) { $Lines_fixed[-1] .= (defined $Lines_current[0]) ? shift @Lines_current : ""; push @Lines_fixed, map { $_ = $Comment.$_ } @Lines_current if $Review_mode; $first = 0; } else { $Lines_fixed[-1] .= (defined $Lines_current[0]) ? shift @Lines_current : ""; } debug 0, $Lines_fixed[-1]."\n"; @Lines_current = (shift @Lines_orig); push @Lines_fixed, ""; } } $Lines_fixed[-1] .= (defined $Lines_current[0]) ? shift @Lines_current : ""; push @Lines_fixed, map { $_ = $Comment.$_ } @Lines_current if $Review_mode; push @Lines_fixed, ""; $Lines_whole = shift @Lines_orig ; @Lines_current = ($Lines_whole); debug 0, ($Lines_current[0] || "")."\n"; return defined $Lines_whole; } # stack_add # # add one stack level # # output: # next stack sub stack_add() { push @Rules_stack, -1; # add one stack level push @Rules_success, 0; # add one success level return @Rules_stack; } # stack_remove # # remove one stack level # # output: # next stack sub stack_remove() { pop @Rules_stack; # remove one stack level pop @Rules_success; return @Rules_stack; } # rule_get # # get a rule # # input: # rule stack # output: # rule reference sub rule_get(@) { debug 5; my $rule = $Rules->[shift @_]; $rule = $rule->{'rules'}[shift @_] while @_; return $rule; } # rule_current # # get current rule # # output: # rule reference sub rule_current() { debug 5; return rule_get(@Rules_stack); } # rule_first # # set first rule of present stack level # # output: # rule stack sub rule_first() { debug 1; $Rules_stack[@Rules_stack-1] = 0; # first rule return @Rules_stack; } # rule_next # # set next rule of present stack level # # output: # false if end of stack level # new rule stack otherwise sub rule_next() { debug 1; $Rules_stack[@Rules_stack-1]++; # next rule at this stack level debug 3, (rule_current ? (rule_current->{'regex'} || rule_current->{'name'} || "") : "END OF LEVEL")."\n"; return (defined rule_current) ? @Rules_stack : undef; } # rule_last # # set last rule of present stack level # # output: # rule stack sub rule_last() { debug 1; $Rules_stack[@Rules_stack-1] = @{ rule_get(@Rules_stack[0,@Rules_stack-2])->{'rules'} }; # first rule return @Rules_stack; } # rule_print # # print current rule for debugging sub rule_print() { my @s=@Rules_stack; my @r; unless (rule_current) { debug 0, "END OF LEVEL\n"; return; } while (@Rules_stack) { unshift @r, rule_current->{'name'} || rule_current->{'regex'} || rule_current->{'skip'} || rule_current->{'test'} || rule_current->{'type'} || ""; stack_remove; } debug 0, join(":", @r)."\n"; @Rules_stack=@s; } # next_to_check # # set next rule to check # # output: # false if end of ruleset # new rule stack otherwise sub next_to_check() { debug 1; while (1) { return 0 unless @Rules_stack; # false if we removed the first stack level at previous pass rule_next unless defined rule_current->{'test'}; rule_print if get_debug == 9; until (rule_current) { return 0 unless stack_remove; # back one level rule_print if get_debug == 9; } while (defined (my $test = rule_current->{'test'})) { if (rule_current->{'type'} =~ /^until$/) { # until unless ($Lines_whole =~ /$test/) { stack_add; } } elsif (rule_current->{'type'} =~ /^while$/) { # while if ($Lines_whole =~ /$test/) { stack_add; } } elsif (rule_current->{'type'} =~ /^loop$/) { if (($test == 0) || ($Rules_loop[-1] < $test)) { $Rules_loop[-1]++; stack_add; } } rule_next; rule_print if get_debug == 9; } if (not (defined rule_current)) { # we reached the end of this stack level return 0 unless stack_remove; # back one level } elsif (rule_current->{'rules'}) { # there are sub-rules stack_add; # add one stack level rule_next; rule_print if get_debug == 9; } else { last; } } return @Rules_stack; } # menu # # print menu # # input: # available command letters # number of corrections [ optionnal ] sub menu($;$) { my $l_com = shift; my $l_max = shift || 0; my %command = ( ' '=> undef, ' ' => undef); { my @l = qw(E H N X a l i I); my @m = split(/\n/, __("Edit current line\nAdd hint\nSkip the rest of the line\nExit and discard all changes\nAdd in dictionnary\nAdd lowercase in dictionnary\nIgnore\nIgnore all\n")); # _r_Replace\n_Replace all $command{shift @l} = shift @m while @l; } my $letters = ""; foreach (sort keys %command) { next unless $l_com =~ /$_/; $letters .= $_; next unless defined $command{$_}; print ($EL.$_.$CC." $command{$_}".$NC."\n") if $Display_menu; } my $prompt = $letters; $prompt =~ s/\W//g; $prompt .= " 0" if $l_max; $prompt .= "-".($l_max-1) if $l_max && $l_max-1; my $l = "_"; until ($l =~ /^[$letters]?$/) { $l = $Term -> readline("$prompt\: "); chomp $l; last if ($l =~ /^\d+$/) && (0 <= $l) && ($l < $l_max); } return $l; } # command_edit # # edit error # # input: # string before the match # match string # string after the match # hint array reference # return: # correction sub command_edit($$) { my $match = shift; my $hint = shift; my $fix = $Term -> readline(__("Enter correction to replace the highlighted part:\n"), $match); if ($Review_mode) { push @Lines_current, ($Term -> readline(__("Enter explanation, use displayed hint if empty:\n"))) || @{ $hint }; } return $fix; } # command_line # # edit the current line # # input: # hint array reference # return: # true sub command_line($) { my $hint = shift; $Lines_current[0] = $Term -> readline(__("Modify the line:\n"), $Lines_current[0]); if ($Review_mode) { push @Lines_current, $Term -> readline(__("Enter explanation, use displayed hint if empty:\n")) || @{ $hint }; } return 1; } # command_hint # # add hints # # input: # hint array reference # return: # true sub command_hint($) { my $hint = shift; push @Lines_current, @{ $hint }; return 1; } # command_next # # go for next line # # return: # true sub command_next() { $Rules_success[0]++; return 1; } # command_exit # # print exit and discard message and wait for right answer # # return: # false unless exit sub command_exit() { my $l; $l = $Term -> readline(__("Exit and discard all changes! type `yes' to confirm: ")); chomp $l; exit if $l eq __("yes"); } # command_nop # # nothing # # return: # true sub command_nop() { return 1; } # make_fix # # prepare menu for fixing # # input: # string before error # matched error # string after error # array reference of fixes # array reference of hints sub make_fix($$$$$) { my $before = shift; my $match = shift; my $after = shift; my $fix = shift; my $hint = shift; my $bef; # beginning of the line to display my $aft; # end of the line to display my $line_nb; # number of displayable fixes my $line_len; # number of colomns of the terminal my $head_len; # line header length my $bef_len; # length before the fix my $fix_len; # max fix length my $aft_len; # length after the fix my $wish_len; # length required my $half_len; # egal displayable lenght around fix ($line_len, $line_nb) = Term::Size::chars *STDOUT{IO}; $line_len ||= 80; $line_nb ||= 25; $line_nb -= ($Display_menu ? 3 : 0); $line_nb -= 4; $line_nb = min(scalar @{ $fix }, max($line_nb, 10)); $bef = $Lines_fixed[-1].$before; $aft = $after; $head_len = length($line_nb) + 1; $bef_len = length($bef); $fix_len = max_length($match, @{ $fix }); $aft_len = length($aft); $wish_len = $head_len + $bef_len + $fix_len + $aft_len; $half_len = ($line_len-$head_len-$fix_len)/2; if ($wish_len > $line_len) { if ($bef_len < $half_len) { $aft = substr($aft, 0, $line_len-$head_len-$bef_len-$fix_len ); } elsif ($aft_len < $half_len) { $bef = substr($bef, -($line_len-$head_len -$fix_len-$aft_len)); } else { $bef = substr($bef, -$half_len); $aft = substr($aft, 0, $half_len); } } $bef_len = length $bef; $aft_len = length $aft; my $done = 0; until ($done) { print $EL." "x($head_len-1).">$NC"; # error line print "$bef$EC$match$NC$aft\n"; my $l = 0; # fixes foreach (@{ $fix }) { last unless $l < $line_nb+1; my $head = $FL." "x($head_len-length($l)-1).$l.">".$NC; print $head; if ($bef_len > $head_len+1) { print " "x($bef_len-$head_len).$head."$FC$_$NC$aft\n"; } else { print " "x $bef_len ."$FC$_$NC$aft\n"; } $l++ } print " "x$head_len." $CC$_$NC\n" foreach @{ $hint }; # hints $hint->[0] = sprintf(__("%s: %s"), $match, $hint->[0]); my $m = menu(" ENX", $l); if ($m eq " ") { } elsif ($m eq "") { $done = command_nop; } elsif ($m eq " ") { $match = command_edit($match, $hint); $Lines_current[0] = $before.$match.$after; $done = command_nop; } elsif ($m eq "E") { $done = command_line($hint); } elsif ($m eq "N") { $done = command_next; } elsif ($m eq "X") { $done = command_exit; } elsif ((0 <= $m) && ($m < $l)) { $Lines_current[0] = $before.$fix->[$m].$after; $done = command_hint($hint); } } } # make_autofix # # prepare menu for autofixing # # input: # string before error # matched error # string after error # array reference of fixes # array reference of hints sub make_autofix($$$$$) { my $before = shift; my $match = shift; my $after = shift; my $fix = shift; my $hint = shift; $fix = $fix->[0]; # use first fix print "$EL >$NC"; # error line print $Lines_fixed[-1]; print "$before$EC$match$NC$after\n"; print "$FL >$NC"; # fix print $Lines_fixed[-1]; print "$before$FC$fix$NC$after\n"; print "$CC$_$NC\n" foreach @{ $hint }; # hint $hint->[0] = sprintf(__("%s: %s"), $match, $hint->[0]); $Lines_current[0] = $before.$fix.$after; command_hint($hint); } # make_warning # # prepare menu for warning # # input: # string before error # matched error # string after error # array reference of fixes # array reference of hints sub make_warning($$$$$) { my $before = shift; my $match = shift; my $after = shift; my $fix = shift; my $hint = shift; my $done = 0; until ($done) { print "$EL >$NC"; # error line print $Lines_fixed[-1]; print "$before$EC$match$NC$after\n"; print "$CC$_$NC\n" foreach @{ $hint }; # hint $hint->[0] = sprintf(__("%s: %s"), $match, $hint->[0]); my $m = menu(" EHNX"); if ($m eq " ") { } elsif ($m eq "") { $done = command_nop; } elsif ($m eq " ") { $match = command_edit($match, $hint); $Lines_current[0] = $before.$match.$after; $done = command_nop; } elsif ($m eq "E") { $done = command_line($hint); } elsif ($m eq "H") { $done = command_hint($hint); } elsif ($m eq "N") { $done = command_next; } elsif ($m eq "X") { $done = command_exit; } } } # make_error # # prepare menu for error # # input: # string before error # matched error # string after error # array reference of fixes # array reference of hints sub make_error($$$$$) { my $before = shift; my $match = shift; my $after = shift; my $fix = shift; my $hint = shift; my $done = 0; until ($done) { print "$EL >$NC"; # error line print $Lines_fixed[-1]; print "$before$EC$match$NC$after\n"; print "$CC$_$NC\n" foreach @{ $hint }; # hint $hint->[0] = sprintf(__("%s: %s"), $match, $hint->[0]); my $m = menu(" EHNX"); if ($m eq " ") { } elsif ($m eq " ") { $match = command_edit($match, $hint); $Lines_current[0] = $before.$match.$after; $done = command_nop; } elsif ($m eq "") { $done = command_nop; } elsif ($m eq "E") { $done = command_line($hint); } elsif ($m eq "H") { $done = command_hint($hint); } elsif ($m eq "N") { $done = command_next; } elsif ($m eq "X") { $done = command_exit; } } } # parse # # main parsing sub # sub parse() { debug 1; my $done; until ($done) { next_to_check; my $rule = rule_current; my $type = $rule->{'type'}; if ($type =~ /^comment$/i) { my $start = $rule->{'start'}; my $skip = $rule->{'skip' }; if ($skip && $Lines_current[0] =~ /$skip/ ) { $Lines_current[0] = (defined $`) ? $` : ""; unshift @Lines_orig, (defined $') ? $' : ""; unshift @Lines_orig, (defined $&) ? $& : ""; $Comment_skip++; } if ($start && $Lines_current[0] =~ /$start/) { my $a; my $b; $Lines_current[0] = (defined $`) ? $` : ""; unshift @Lines_orig, (defined $') ? $' : ""; ($a, $b) = get_offset($&, $rule->{'start_offset'} || "s"); $Lines_current[0] .= $a; $Lines_orig [0] = $b.$Lines_orig[0]; unshift @Lines_orig, ($rule->{'stop_offset'} || "e"); unshift @Lines_orig, ($rule->{'stop' } ); $Comment_in++; } next; } elsif ($type =~ /^nop$/) { $done = 1; debug 3, "nop\n"; next; } my $regex = $rule->{'regex'}; my @fix = $rule->{'fix' } ? @{ $rule->{'fix' } } : (); my @hint = $rule->{'hint' } ? @{ $rule->{'hint' } } : (); my @valid = $rule->{'valid'} ? @{ $rule->{'valid'} } : (); if ($Lines_current[0] =~ /$regex/) { my $before = (defined $`) ? $` : ""; my $match = (defined $&) ? $& : ""; my $after = (defined $') ? $' : ""; @fix = map { eval "\"$_\"" } @fix; # group substitution ##### FIXME security? FIXME ##### my $ok; foreach (@valid) { $ok = 1; $ok &= ($before =~ $_->{'pre' }) if defined $_->{'pre' }; $ok &= ($match =~ $_->{'in' }) if defined $_->{'in' }; $ok &= ($after =~ $_->{'post'}) if defined $_->{'post'}; last if $ok; } next if $ok; if ($type =~ /^fix$/ ) { make_fix ($before, $match, $after, \@fix, \@hint); } elsif ($type =~ /^autofix$/) { make_autofix($before, $match, $after, \@fix, \@hint); } elsif ($type =~ /^warning$/) { make_warning($before, $match, $after, \@fix, \@hint); } elsif ($type =~ /^error$/ ) { make_error ($before, $match, $after, \@fix, \@hint); } else { suicide __("`%s': unknown operation\n"), $type; } } } } # aspell_fix # # fix using aspell module # # input: # mispelled word sub aspell_fix($) { my $word = shift; my @suggestions = ($Speller->suggest($word)); my $hint = [(sprintf __("spelling for `%s'"), $word)]; my $bef; # beginning of the line to display my $aft; # end of the line to display my $line_nb; # number of displayable fixes my $line_len; # number of colomns of the terminal my $head_len; # line header length my $bef_len; # length before the fix my $fix_len; # max fix length my $aft_len; # length after the fix my $wish_len; # length required my $half_len; # egal displayable lenght around fix ($line_len, $line_nb) = Term::Size::chars; $line_len ||= 80; $line_nb ||= 25; $line_nb -= ($Display_menu ? 8 : 0); $line_nb -= 4; $line_nb = min(scalar @suggestions, max($line_nb, 10)); $bef = $Lines_fixed[-1].$Lines_current[0]; $aft = $Lines_current[1]; $head_len = length($line_nb) + 1; $bef_len = length($bef); $fix_len = max_length($word, @suggestions); $aft_len = length($aft); $wish_len = $head_len + $bef_len + $fix_len + $aft_len; $half_len = ($line_len-$head_len-$fix_len)/2; if ($wish_len > $line_len) { if ($bef_len < $half_len) { $aft = substr($aft, 0, $line_len-$head_len-$bef_len-$fix_len ); } elsif ($aft_len < $half_len) { $bef = substr($bef, -($line_len-$head_len -$fix_len-$aft_len)); } else { $bef = substr($bef, -$half_len); $aft = substr($aft, 0, $half_len); } } $bef_len = length $bef; $aft_len = length $aft; print $EL." "x($head_len-1).">$NC"; # error line print "$bef$EC$word"." "x($fix_len-length($word))."$NC$aft\n"; my $l = 0; # fixes foreach (@suggestions) { last unless $l < $line_nb+1; my $head = $FL." "x($head_len-length($l)-1).$l.">".$NC; print $head; if ($bef_len > $head_len+1) { print " "x($bef_len-$head_len).$head."$FC$_"." "x($fix_len-length($_))."$NC\n"; } else { print " "x $bef_len ."$FC$_"." "x($fix_len-length($_))."$NC\n"; } $l++ } my $done = 0; until ($done) { my $m = menu(" aliIrRENX", $l); if ($m eq " ") { } elsif ($m eq "") { $Lines_current[0] .= $word; $done = command_nop; } elsif ($m eq " ") { # edit word $word = command_edit($word, $hint); $Lines_current[1] = $word.$Lines_current[1]; # change must be checked $done = command_nop; } elsif ($m eq "a") { # add $Speller->add_to_personal($word); $Speller->save_all_word_lists; $Lines_current[0] .= $word; $done = command_nop; } elsif ($m eq "l") { # add lowercase $Speller->add_to_personal(lc $word); $Speller->save_all_word_lists; $Lines_current[0] .= $word; $done = command_nop; } elsif ($m eq "i") { # ignore $Lines_current[0] .= $word; $done = command_nop; } elsif ($m eq "I") { # ignore all $Speller->add_to_session($word); $Lines_current[0] .= $word; $done = command_nop; # } elsif ($m eq "r") { # replace # $Lines_current[0] .= $word; # $done = command_nop; # } elsif ($m eq "R") { # replace all # $Lines_current[0] .= $word; # $done = command_nop; } elsif ($m eq "E") { $Lines_current[0] .= $word.$Lines_current[1]; # prepare for edition $done = command_line($hint); $Lines_current[1] = $Lines_current[0]; # all line must be re-checked $Lines_current[0] = ""; } elsif ($m eq "N") { $Lines_current[0] .= $word.$Lines_current[1]; $Lines_current[1] = ""; $done = command_next; } elsif ($m eq "X") { $done = command_exit; } elsif ((0 <= $m) && ($m < $l)) { $Lines_current[0] .= $suggestions[$m]; $hint = [(sprintf __("%s: spelling for `%s'"),$suggestions[$m] ,$word)]; $done = command_hint($hint); } } } # spell # # main spell-checking sub # sub spell() { debug 1; my @stack = @Rules_stack; while (@stack) { my $rule = rule_get(@stack); if (defined $rule->{'test'}) { last unless defined $rule->{'spell'}; return if $rule->{'spell'} =~ /^no$/i; last; } else { pop @stack; next; } } unshift @Lines_current, ""; while (1) { my $found = $Lines_current[1] =~ /[$Word_letters]+/i; my $before = (defined $`) ? $` : ""; my $match = (defined $&) ? $& : ""; my $after = (defined $') ? $' : ""; unless ($found) { $Lines_current[0] .= $Lines_current[1]; $Lines_current[1] = ""; last; } $Lines_current[0] .= $before; $Lines_current[1] = $after; $found = $Speller->check($match); if ($found) { $Lines_current[0] .= $match; } elsif (defined $found) { aspell_fix($match); } else { ##### FIXME skip on error FIXME ##### $Lines_current[0] .= $match; } } my $l = shift @Lines_current; shift @Lines_current; unshift @Lines_current, $l; } # parse_file # # parse a loaded file # sub parse_file() { debug 1; while (line_next) { parse; spell if $Check_spelling && $Aspell; } shift @Lines_fixed; # remove first item which was line #0 and so is empty pop @Lines_fixed; # remove last item which was prepared for next line and so is empty } # load_file # # load a file # # input: # filename sub load_file($) { debug 3; my $file = shift; debug 1; debug 2, "filename $file\n"; my $handle = *STDIN; unless ($file eq "-") { $handle = new IO::File($file, '<') or suicide __("Cannot read `%s': %s\n"), $file, $!; } @Lines_orig = $handle -> getlines; chomp @Lines_orig; @Lines_orig or suicide __("Empty file\n"); } # write_file # # write a file # # input: # filename sub write_file($) { debug 3; my $file = shift; debug 1; debug 2, "filename $file\n"; my $handle = *STDOUT; unless ($file eq "-") { (-e $file) && (move($file, "$file.$Bak_e") or suicide __("Cannot backup `%s': %s\n"), $file, $!); $handle = new IO::File($file, '>') or suicide __("Cannot write to `%s': %s\n"); } $handle -> print(join("\n", @Lines_fixed)."\n"); } # print_version # # Print version # sub print_version () { debug 1; my $me = $0; # get command name with path $me =~ s/.*\/([^\/]*)$/$1/; # keep script name debug 0, __("%s version %s\n"), $me, VERSION; exit; } # print_help # # Print help message # sub print_help () { debug 1; my $me = $0; # get command name with path $me =~ s/.*\/([^\/]*)$/$1/; # keep script name debug 0, __("Usage: %s [OPTIONS] [INPUT_FILE]\n\noptions:\n -q, --quiet quiet mode\n -v verbose, add more for more verbosity\n --verbose set verbosity to n\n --rules use rules set \n --type set filetype to \n -i, --input input filename\n -o, --output output filename\n -s, --spell check spelling with aspell\n -d, --dict use dictionary\n -n, --nospell don't check spelling\n -r, --review add comments (for reviewers)\n -t, --trans don't add comments (for translators)\n --dump dump the rules and exit (for debugging)\n -V, --version print version and exit\n -h, --help print this message and exit\n\nIf input filename is '-' or not provided, data are read from STDIN\nIf output filename is not provided, input filename is used, '-' write to STDOUT\n\n%s version %s\n"), $me, $me, VERSION; exit; } # main # # Parse command line # { debug 1; my $dump; # flag for --dump option my $filetype; my $input_file; my $output_file; Getopt::Long::Configure qw(permute bundling); # set standard gnu options (for potato perl) Getopt::Long::GetOptions ( 'verbose=i' => sub { set_debug $_[1] }, # verbose 'v+' => sub { inc_debug }, # incremental 'quiet|q' => sub { set_debug 0 }, # quiet 'version|V' => sub { print_version; exit 0 }, # version 'help|h' => sub { print_help; exit 0 }, # help 'input|i=s' => \$input_file, # input filename 'output|o=s' => \$output_file, # output filename 'rules=s' => \$Rules_set, # rules set 'type=s' => \$filetype, # file type 'spell|s' => sub { $Check_spelling = 1 }, # use aspell 'nospell|n' => sub { $Check_spelling = 0 }, # short no 'dict|d=s' => \$Dictionary, # dictionary 'review|r' => sub { $Review_mode = 1 }, # review mode 'trans|t' => sub { $Review_mode = 0 }, # translation mode 'dump' => sub { $dump = 1 } # dump and exit ); $input_file ||= shift @ARGV if @ARGV; $input_file ||= "-"; $output_file ||= $input_file; debug 5, "Configuration dump:\n". "bak_e ". $Bak_e."\n". "comment ". $Comment."\n". "rules set ".($Rules_set || "")."\n"; debug 4, "debug ". get_debug."\n"; debug 5, "check spelling ".($Check_spelling ? "yes" : "no" )."\n". "aspell ".($Aspell ? "" : "not")."found\n". "dictionary ".($Dictionary || "")."\n". "word letters ". $Word_letters."\n". "review mode ".($Review_mode ? "yes" : "no")."\n". $CC."comments color".$NC."\n". $EC."error text".$NC."\n". $FC."fix text".$NC."\n". $EL."error head color".$NC."\n". $FL."fix head color".$NC."\n". "version ". VERSION."\n"; debug 4, "input file ". $input_file."\n". "output file ". $output_file."\n"; debug 5, "file type ". $filetype."\n" if $filetype; debug 4, "arguments ".join(" ", @ARGV)."\n" if @ARGV; if (not ($Aspell) && $Check_spelling) { $Check_spelling = 0; if ((-t) && (-t STDOUT)) { print $EC.__("Aspell Perl module not found, spelling check cancelled.")."$NC\n"; print $CC.__("Press 'Enter' to continue")."$NC\n"; menu(" "); } else { warning __("Aspell Perl module not found, spelling check cancelled."); } } if ($Aspell && $Dictionary) { suicide(__("Aspell: unable to use `%s'.\n"), $Dictionary) unless $Speller -> set_option('lang', $Dictionary); } load_file $input_file; $filetype ||= file_type($input_file, \@Lines_orig); # get file type if not provided $Rules = load_ruleset($Rules_set, $filetype); if ($dump) { print Dumper($Rules); exit 0; } parse_file; write_file $output_file; } acheck-0.5.1+nmu1/misc/0000755000000000000000000000000007704572310011435 5ustar acheck-0.5.1+nmu1/misc/bash_completion0000644000000000000000000000060707704572310014531 0ustar # This is a completion rule, it parses the usage message for commands and # options through a one-line perl command _acheck() { COMPREPLY=() cur=${COMP_WORDS[COMP_CWORD]} # current word COMPREPLY=( $( compgen -W '-q -v -s -n -d -r -t -V -h --quiet --verbose --rules --spell --nospell --dict --review --trans --dump --version --help' -- $cur ) ) return 0 } complete -F _acheck acheck acheck-0.5.1+nmu1/Common.pm0000644000000000000000000000461307710514263012274 0ustar package ACheck::Common; use strict; use Exporter; use vars qw(@ISA @EXPORT); @ISA = qw(Exporter); @EXPORT = qw( set_debug get_debug inc_debug dec_debug debug warning suicide min max max_length __ ); my $debug; # debug level BEGIN { eval 'use Locale::gettext'; if ($@) { *gettext = sub { shift }; *textdomain = sub { "" }; *LC_MESSAGES = sub { 5 }; } eval { require POSIX; import POSIX qw(setlocale); }; if ($@) { *setlocale = sub { 1 }; } } no strict; setlocale(LC_MESSAGES, ""); use strict; textdomain("acheck"); sub __($) { gettext(shift); } # set debug level sub inc_debug() { $debug++ if $debug < 9 }; # increase debug level sub dec_debug() { $debug-- if $debug > 0 }; # decrease debug level sub set_debug($) { $debug = $_[0] > 9 ? 9 : $_[0] < 0 ? 0 : shift; # set debug level }; # get debug level sub get_debug() { return $debug }; # get debug level # write debug messages sub debug ($;$@) { return unless $debug >= shift; # debug level my $text = shift || ""; $text = sprintf ($text, @_) if @_; chomp $text; my $line = (caller(0))[2]; # get calling line my $sub = (caller(1))[3] || ''; # get calling sub name foreach (split("\n", $text)) { print "debug ($sub\:$line) " unless $debug < 3; print "$_\n"; } } # write error message and die sub suicide (@) { my $text = shift || ""; $text = sprintf ($text, @_) if @_; chomp $text; my $line = (caller(0))[2]; # get calling line my $sub = (caller(1))[3] || ''; # get calling sub name foreach (split("\n", $text)) { $debug < 3 ? print __("ERROR ") : print "suicide ($sub\:$line) "; print "$_\n"; } exit -1; } # write warning message sub warning (@) { my $text = shift || ""; $text = sprintf ($text, @_) if @_; chomp $text; my $line = (caller(0))[2]; # get calling line my $sub = (caller(1))[3] || ''; # get calling sub name foreach (split("\n", $text)) { $debug < 3 ? print __("WARNING ") : print "warning ($sub\:$line) "; print "$_\n"; } } # return min value sub min(@) { my $min = shift; $min = ($min < $_) ? $min : $_ foreach (@_); return $min; } # return max value sub max(@) { my $max = shift; $max = ($max > $_) ? $max : $_ foreach (@_); return $max; } # return longest value sub max_length(@) { my $max = length shift; $max = ($max > length($_)) ? $max : length($_) foreach (@_); return $max; } 1;