]> git.draconx.ca Git - gentoo-fixes.git/blobdiff - sys-apps/man/files/man-1.6f-so-search-2.patch
sys-apps/man: Fix borken Gentoo man-1.6g-echo-escape.patch
[gentoo-fixes.git] / sys-apps / man / files / man-1.6f-so-search-2.patch
diff --git a/sys-apps/man/files/man-1.6f-so-search-2.patch b/sys-apps/man/files/man-1.6f-so-search-2.patch
new file mode 100644 (file)
index 0000000..ac42c8d
--- /dev/null
@@ -0,0 +1,34 @@
+improve the uncompressed .so search
+
+--- a/src/man.c
++++ b/src/man.c
+@@ -381,13 +381,23 @@ again:
+         }
+         /*
+          * Some people have compressed man pages, but uncompressed
+-         * .so files - we could glob for all possible extensions,
+-         * for now: only try .gz
++         * .so files - we should discover this list dynamically, but
++         * for now just hardcode it.
+          */
+-        else if (fp == NULL && get_expander(".gz") &&
+-                 strlen(name)+strlen(".gz") < BUFSIZE) {
+-             strcat(name, ".gz");
+-             fp = fopen (name, "r");
++        else if (fp == NULL) {
++#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
++             size_t i, name_len = strlen(name);
++             const char *extensions[] = { ".gz", ".bz2", ".lzma", ".xz", ".z", ".Z" };
++             for (i = 0; i < ARRAY_SIZE(extensions); ++i) {
++                  const char *comp = extensions[i];
++                  name[name_len] = '\0';
++                  if (get_expander(comp) && name_len+strlen(comp) < BUFSIZE) {
++                       strcat(name, comp);
++                       fp = fopen(name, "r");
++                       if (fp)
++                            break;
++                  }
++             }
+         }
+         if (fp == NULL) {