aboutsummaryrefslogtreecommitdiff
Upstream status: This patch was taken from leptonica upstream.

Backported to ghostscripts bundled leptonica.

From f04da7c816feb1d5f689c34f3d0e7e3621edf1f5 Mon Sep 17 00:00:00 2001
From: Samuel Thibault <samuel.thibault@ens-lyon.org>
Date: Wed, 1 Feb 2023 19:35:43 +0100
Subject: [PATCH] Fix GNU/Hurd build

There is no PATH_MAX limitation on GNU/Hurd, and realpath() can be
safely be used with its second parameter set to NULL (as required by
posix since its version 2001).
---
 src/sarray1.c | 29 +++++++++++++++++++++++------
 1 file changed, 23 insertions(+), 6 deletions(-)

--- a/src/sarray1.c	2023-06-13 12:31:13.393672916 +0200
+++ a/src/sarray1.c	2023-06-13 12:34:13.574237149 +0200
@@ -1953,7 +1953,11 @@
 SARRAY *
 getFilenamesInDirectory(const char  *dirname)
 {
+#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
+char           *dir;
+#else
 char            dir[PATH_MAX + 1];
+#endif
 char           *realdir, *stat_path, *ignore;
 size_t          size;
 SARRAY         *safiles;
@@ -1976,17 +1980,28 @@
             * If the file or directory exists, realpath returns its path;
               else it returns NULL.
             * If the second arg to realpath is passed in, the canonical path
-              is returned there.  Use a buffer of sufficient size.  If the
-              second arg is NULL, the path is malloc'd and returned if the
-              file or directory exists.
-           We pass in a buffer for the second arg, and check that the canonical
-           directory path was made.  The existence of the directory is checked
-           later, after its actual path is returned by genPathname().  */
+              is returned there.  Use a buffer of sufficient size.
+              We pass in a buffer for the second arg, and check that the
+              canonical directory path was made.  The existence of the
+              directory is checked later, after its actual path is returned by
+              genPathname().
+              With GNU libc or Posix 2001, if the second arg is NULL, the path
+              is malloc'd and returned if the file or directory exists.
+           */
+#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
+    dir = realpath(dirname, NULL);
+    if (dir == NULL)
+        return (SARRAY *)ERROR_PTR("dir not made", __func__, NULL);
+#else
     dir[0] = '\0';  /* init empty in case realpath() fails to write it */
     ignore = realpath(dirname, dir);
     if (dir[0] == '\0')
         return (SARRAY *)ERROR_PTR("dir not made", procName, NULL);
+#endif
     realdir = genPathname(dir, NULL);
+#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
+    LEPT_FREE(dir);
+#endif
     if ((pdir = opendir(realdir)) == NULL) {
         LEPT_FREE(realdir);
         return (SARRAY *)ERROR_PTR("pdir not opened", procName, NULL);
@@ -1998,10 +2013,12 @@
         stat_ret = fstatat(dfd, pdirentry->d_name, &st, 0);
 #else
         size = strlen(realdir) + strlen(pdirentry->d_name) + 2;
+#if _POSIX_VERSION < 200112 && !defined(__GLIBC__)
         if (size > PATH_MAX) {
             L_ERROR("size = %zu too large; skipping\n", procName, size);
             continue;
         }
+#endif
         stat_path = (char *)LEPT_CALLOC(size, 1);
         snprintf(stat_path, size, "%s/%s", realdir, pdirentry->d_name);
         stat_ret = stat(stat_path, &st);
?id=2f5368d678aad334149b280e9dab90ec1635104b'>import: minetest: Fix typos....* guix/import/minetest.scm (elaborate-contentdb-name): Fix ‘ambiguous’ and ‘thes’ typos. * tests/minetest.scm: Likewise for all tests. Tobias Geerinckx-Rice 2021-09-18import: minetest: Strip "v" prefixes from the version number....This fixes one of the issues noted at <https://issues.guix.gnu.org/50425#4>. * guix/import/minetest.scm (release-version): New procedure. (%minetest->guix-package): Call new procedure instead of release-title. * tests/minetest.scm (make-package-sexp): Allow overriding the version number. (make-releases-json): Allow overriding the release title. ("conventional version number") ("v-prefixed version number") ("dates as version number"): New tests. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Maxime Devos 2021-09-18import: minetest: Delete duplicate dependencies....This fixes one of the issues noted in <https://issues.guix.gnu.org/50425#4>. * guix/import/minetest.scm (import-dependencies): Call 'delete-duplicates' on the resulting list. * tests/minetest.scm ("minetest->guix-package, multiple dependencies implemented by one mod"): New test. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Maxime Devos 2021-09-18tests/minetest: Fix 'test-package*' indenting....* tests/minetest.scm (Local Variables)[test-package*]: Set scheme-indent-function property to 1. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Maxime Devos 2021-08-20guix: Add ContentDB importer....* guix/import/contentdb.scm: New file. * guix/scripts/import/contentdb.scm: New file. * tests/contentdb.scm: New file. * Makefile.am (MODULES, SCM_TESTS): Register them. * po/guix/POTFILES.in: Likewise. * doc/guix.texi (Invoking guix import): Document it. Signed-off-by: Leo Prikler <leo.prikler@student.tugraz.at> Maxime Devos