summaryrefslogtreecommitdiff
path: root/appl/lib/man.b
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2007-06-07 15:33:50 +0000
committerCharles.Forsyth <devnull@localhost>2007-06-07 15:33:50 +0000
commit7d5a2526f46cd3474fb96a684f7b87e9e78128b0 (patch)
treef7ece6cb7cd1d30674d303f39b838a5cc1ec0376 /appl/lib/man.b
parent5f2c52f9f523ee1b46383d4df8544ecf79bad85c (diff)
20070607-1632
Diffstat (limited to 'appl/lib/man.b')
-rw-r--r--appl/lib/man.b25
1 files changed, 14 insertions, 11 deletions
diff --git a/appl/lib/man.b b/appl/lib/man.b
index bbd7e15e..2a9e5a6c 100644
--- a/appl/lib/man.b
+++ b/appl/lib/man.b
@@ -11,11 +11,6 @@ PATHDEPTH: con 1;
indices: list of (string, list of (string, string));
-init()
-{
- sys = load Sys Sys->PATH;
-}
-
loadsections(scanlist: list of string): string
{
sys = load Sys Sys->PATH;
@@ -33,10 +28,10 @@ loadsections(scanlist: list of string): string
indexpaths = filepat->expand(MANPATH + "[0-9]*/INDEX");
if (indexpaths == nil)
- return sys->sprint("cannot find man pages");
+ return "cannot find man pages";
} else {
for (; scanlist != nil; scanlist = tl scanlist)
- indexpaths = MANPATH + string hd scanlist + "/INDEX" :: indexpaths;
+ indexpaths = MANPATH + trimdot(hd scanlist) + "/INDEX" :: indexpaths;
indexpaths = sortuniq(indexpaths);
}
@@ -51,7 +46,7 @@ loadsections(scanlist: list of string): string
for (sl := sections; sl != nil; sl = tl sl) {
section := hd sl;
- path := MANPATH + string section + "/INDEX";
+ path := MANPATH + section + "/INDEX";
iob := bufio->open(path, Sys->OREAD);
if (iob == nil)
continue;
@@ -71,6 +66,14 @@ loadsections(scanlist: list of string): string
return nil;
}
+trimdot(s: string): string
+{
+ for(i := 0; i < len s; i++)
+ if(s[i] == '.')
+ return s[0: i];
+ return s;
+}
+
getfiles(sections: list of string, keys: list of string): list of (int, string, string)
{
ixl: list of (string, list of (string, string));
@@ -79,7 +82,7 @@ getfiles(sections: list of string, keys: list of string): list of (int, string,
ixl = indices;
else {
for (; sections != nil; sections = tl sections) {
- section := hd sections;
+ section := trimdot(hd sections);
for (il := indices; il != nil; il = tl il) {
(s, mapl) := hd il;
if (s == section) {
@@ -95,13 +98,13 @@ getfiles(sections: list of string, keys: list of string): list of (int, string,
for ((s, mapl) := hd ixl; mapl != nil; mapl = tl mapl) {
(kw, file) := hd mapl;
if (hd keyl == kw) {
- p := MANPATH + s + "/" + file;
+ p := MANPATH + trimdot(s) + "/" + file;
paths = (int s, kw, p) :: paths;
}
}
# allow files not in the index
if(paths == nil || (hd paths).t0 != int s || (hd paths).t1 != hd keyl){
- p := MANPATH + string s + "/" + hd keyl;
+ p := MANPATH + string int s + "/" + hd keyl;
if(sys->stat(p).t0 != -1)
paths = (int s, hd keyl, p) :: paths;
}