File: makehelp

package info (click to toggle)
blackened 1.8.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,916 kB
  • ctags: 3,389
  • sloc: ansic: 46,055; sh: 554; makefile: 270; perl: 46
file content (57 lines) | stat: -rwxr-xr-x 1,001 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl

# $Id: makehelp,v 1.5 1999/08/06 07:12:58 toast Exp $

sub mkhlp {
	local(@dir);
	local($loc) = $_[0];
	local($pre) = $_[1];
	local($last) = $_[2];
	local($entry);

	print STDERR "$loc/\n";

	if (opendir(DIR, "$loc")) {
		@dir = sort grep(!/^(\.|CVS$)/, readdir(DIR));
		closedir(DIR);

		print "$pre\?\n";
		foreach $entry (@dir) {
			print "\t$entry\n";
		}

		foreach $entry (@dir) {
			if (-f "$loc/$entry") {
				if (open(HLP, "< $loc/$entry ")) {
					$entry =~ tr/A-Z/a-z/;
					if ($last eq $entry) {
						print "$entry\n";
					} else {
						print $pre . $entry . "\n";
					}
					while (<HLP>) {
						if (!/^\!/) {
							chop;
							print "\t$_\n";
						}
					}
					close(HLP);
				} else {
					print STDERR "Can't read $loc/$entry\n";
				}
			} elsif (-d "$loc/$entry") {
				&mkhlp("$loc/$entry", "$pre$entry ", "$entry");
			}
		}

	} else {
		print STDERR "Can't read $loc/\n";
	}
}

if ($ARGV[0] eq "") {
	&mkhlp(".", "");
} else {
	&mkhlp($ARGV[0], "");
}