SHA256
1
0
forked from pool/man
man/man-db-2.5.1-globbing.dif

32 lines
1.1 KiB
Plaintext
Raw Normal View History

--- src/globbing.c
+++ src/globbing.c 2007-09-19 13:35:04.128822519 +0200
@@ -340,13 +340,22 @@ char **look_for_file (const char *unesc_
/* allow lookups like "3x foo" to match "../man3/foo.3x" */
if ((layout & LAYOUT_GNU) && CTYPE (isdigit, *sec) && sec[1] != '\0') {
- path = appendstr (path, hier, cat ? "/cat" : "/man", "\t",
- NULL);
- *strrchr (path, '\t') = *sec;
- pattern = end_pattern (appendstr (pattern, name, NULL), sec);
+ off_t nptr, nsec;
- status = match_in_directory (path, pattern, !match_case,
- &gbuf);
+ path = appendstr (path, hier, cat ? "/cat" : "/man", NULL);
+ nptr = strlen(path);
+ path = appendstr (path, sec, NULL);
+ nsec = nptr + strlen(sec);
+
+ while (nsec > nptr) {
+ *(path + nsec--) = '\0';
+ if (pattern)
+ *pattern = '\0';
+ pattern = end_pattern (appendstr (pattern, name, NULL), sec);
+ status = match_in_directory (path, pattern, !match_case, &gbuf);
+ if ((status == 0) && (gbuf.gl_pathc != 0))
+ break;
+ }
}
/* AIX glob.h doesn't define GLOB_NOMATCH and the manpage is vague