From: Alexey Tourbin <at@altlinux.ru> To: devel@altlinux.ru Subject: [devel] польские файлы Date: Mon, 6 Oct 2003 19:38:24 +0400 Message-ID: <20031006153824.GC1726@julia.office.altlinux.ru> (raw) [-- Attachment #1: Type: text/plain, Size: 2415 bytes --] По поводу польских файлов предлагаю следующее. Алгоритм никакой, но на польских файлах срабатывает хорошо за счет non-ascii. Было бы интересно сделать обучающую машину, но на это может уйти много времени. --- /usr/lib/rpm/find-provides~ 2003-09-27 22:27:57 +0400 +++ /usr/lib/rpm/find-provides 2003-10-06 19:35:16 +0400 @@ -146,7 +146,7 @@ # Ignore symlinks for non-PAM scripts. [ ! -L "$f" ] || return 0 - if [ -z "${t##perl script text*}" -o -z "${t##Perl5 module source text}" ] || [ -z "${f%%*.p[lmh]}" -a -z "${t##*text*}" ]; then + if [ -z "${t##perl script text*}" -o -z "${f%%*.p[lmh]}" ]; then if [ -n "$FIND_PERL" ]; then [ -z "$LIST_PERL" ] && LIST_PERL="$f" || LIST_PERL="$LIST_PERL $f" --- /usr/lib/rpm/perl.req 2003-09-30 14:42:01 +0000 +++ RPM/SOURCES/rpm-perl.req 2003-10-06 15:28:05 +0000 @@ -276,9 +276,18 @@ sub process_file { process_line($_); } unless (close PIPE) { - $method ne 'relaxed' - and die "$fname: deparse failed.\n" - or warn "$fname: deparse failed.\n"; + if ($method eq 'relaxed') { + warn "$fname\: deparse failed, but I don't care\n"; + } elsif ($method eq 'strict') { + die "$fname\: deparse failed.\n"; + } else { + my $v = isPerl($fname); + if ($v > 0) { + die "$fname\: deparse failed. isPerl=$v\n"; + } else { + warn "$fname\: deparse failed, isPerl=$v, ok\n"; + } + } } } @@ -390,3 +399,56 @@ foreach my $k (keys %req) { } # nothing special? print "perl-base\n" unless %req; + +# auxiliary stuff +sub count($$) { + debug "$_[0] $_[1]"; +} + +sub isPerl { + my $fname = shift; + chomp $fname; + open(FILE, $fname) || die; + local $_ = join "" => <FILE>; + close FILE; + debug "processing $fname"; + my ($n, @n); + +# POSITIVE +# variables + @n = /[$%@]\w+/g; + count @n, "variables"; + $n += @n; +# comments + @n = /^\s*#/gm; + count @n, "comments"; + $n += @n; +# blocks + @n = /{$|^\s*}/gm; + count @n, "blocks"; + $n += @n; +# keywords + @n = /\b(unless|foreach|package|sub|use|strict)\b/gm; + count @n, "keywords"; + $n += @n; +# pod + @n = /^=(?:back|begin|cut|end|for|head|item|over|pod)/gm; + count @n, "pod sections"; + $n += @n; +# modules + @n = /^1;$/gm; + count @n, "`1;'"; + $n += @n; + +# NEGATIVE +# non-ascii characters + @n = /[^[:ascii:]]/g; + count @n, "non-ascii characters"; + $n -= @n; +# prolog + @n = /:-/g; + count @n, "prolog :- operators"; + $n -= @n; +# density + $n /= -s $fname; +} [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2003-10-06 15:38 UTC|newest] Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-10-06 15:38 Alexey Tourbin [this message] 2003-10-07 9:04 ` Alexander Bokovoy 2003-10-07 11:12 ` [devel] " Michael Shigorin 2003-10-07 11:53 ` Viktor S. Grishchenko 2003-10-07 11:56 ` Alexey Tourbin 2003-10-07 12:21 ` Michael Shigorin 2003-10-07 12:56 ` Andrey Orlov 2003-10-07 13:39 ` Alexey Tourbin 2003-10-07 22:40 ` Sergey V Turchin 2003-10-08 6:51 ` Andrey Orlov 2003-10-08 8:59 ` Alexander Bokovoy 2003-10-08 9:23 ` Dmitry V. Levin 2003-10-07 13:03 ` Alexey Tourbin 2003-10-07 11:54 ` Alexey Tourbin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20031006153824.GC1726@julia.office.altlinux.ru \ --to=at@altlinux.ru \ --cc=devel@altlinux.ru \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git