ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] польские файлы
@ 2003-10-06 15:38 Alexey Tourbin
  2003-10-07  9:04 ` Alexander Bokovoy
  0 siblings, 1 reply; 14+ messages in thread
From: Alexey Tourbin @ 2003-10-06 15:38 UTC (permalink / raw)
  To: devel

[-- 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 --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2003-10-08  9:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-06 15:38 [devel] польские файлы Alexey Tourbin
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

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