Package: lua-posix
Severity: normal
Tags: patch

Dear Maintainer,

lua-posix currently fails to build on hurd-i386. The attached patch fixes this 
issue. It also checks the return value of sysconf() on non-GNU systems.

WBR,
Cyril Roelandt.

-- System Information:
Debian Release: wheezy/sid
  APT prefers unreleased
  APT policy: (500, 'unreleased'), (500, 'unstable')
Architecture: hurd-i386 (i686-AT386)

Kernel: GNU-Mach 1.3.99/Hurd-0.3
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
--- lua-posix-5.1.19.orig/lposix.c	2012-06-06 16:53:00.000000000 +0000
+++ lua-posix-5.1.19/lposix.c	2012-06-06 17:55:49.000000000 +0000
@@ -8,6 +8,9 @@
 * Based on original by Claudio Terra for Lua 3.x.
 * With contributions by Roberto Ierusalimschy.
 */
+#ifdef __GNU__
+#define _GNU_SOURCE
+#endif
 
 #include <config.h>
 
@@ -543,7 +546,16 @@
 
 static int Pgetcwd(lua_State *L)		/** getcwd() */
 {
+#ifdef __GNU__
+	char *b = get_current_dir_name();
+	int error = !!(b==NULL);
+	if (!error)
+		lua_pushstring(L, b);
+	return error ? pusherror(L, ".") : 1;
+#else
 	long size = pathconf(".", _PC_PATH_MAX);
+	if (size == -1)
+		return pusherror(L, "pathconf");
 	void *ud;
 	lua_Alloc lalloc = lua_getallocf(L, &ud);
 	char *b, *ret;
@@ -554,6 +566,7 @@
 		lua_pushstring(L, b);
 	lalloc(ud, b, 0, 0);
 	return (ret == NULL) ? pusherror(L, ".") : 1;
+#endif
 }
 
 static int Pmkdir(lua_State *L)			/** mkdir(path) */

Reply via email to