3194N/AWhen looking for lua shared objects, dynamically adjust the pathnames to
3194N/Ainclude "64/", when running a 64-bit lua executable.
3194N/AThe lua maintainers are not interested in this patch.
3194N/A+** Return 1 if template is a shared object (has an extension of ".so"),
3194N/A+issharedobj(const char *template) {
3194N/A+ ext = template + strlen(template) - 3;
3194N/A+ return strcmp(ext, ".so") == 0;
3194N/A+** Return 1 if this is a 64-bit executable, otherwise 0.
3194N/A+ return sizeof(void *) == 8;
3194N/A static const char *searchpath (lua_State *L, const char *name,
3194N/A luaL_Buffer msg; /* to build error message */
3194N/A if (*sep != '\0') /* non-empty separator? */
3194N/A name = luaL_gsub(L, name, sep, dirsep); /* replace it by 'dirsep' */
3194N/A+ name64 = calloc(strlen(name) + 4, 1);
3194N/A while ((path = pushnexttemplate(L, path)) != NULL) {
3194N/A- const char *filename = luaL_gsub(L, lua_tostring(L, -1),
3194N/A+ const char *item = lua_tostring(L, -1);
3194N/A+ if (is64bit() && issharedobj(item)) {
3194N/A+ if (strstr(item, LUA_PATH_MARK))
3194N/A+ filename = (char *)luaL_gsub(L, item, LUA_PATH_MARK, name);
3194N/A+ * There's nothing to substitute, so we have to go digging through the
3194N/A+ * path to find where to put the 64-bit directory. Search for "/" in
3194N/A+ * the template element until we can't find any more, replace that with
3194N/A+ * "?", and replace that with "/64/".
3194N/A+ for (p1 = s; p1; p1 = strstr(p1 + 1, "/"))
3194N/A+ * We didn't find any slashes; that either means there aren't any, or
3194N/A+ * item is in the root directory.
3194N/A+ s = calloc(strlen(item) + 3, 1);
3194N/A+ filename = (char *)luaL_gsub(L, s, LUA_PATH_MARK, "/64/");
3194N/A+ filename = (char *)luaL_gsub(L, item, LUA_PATH_MARK, name);
3194N/A lua_remove(L, -2); /* remove path template */
3194N/A- if (readable(filename)) /* does file exist and is readable? */
3194N/A+ if (readable(filename)) { /* does file exist and is readable? */
3194N/A return filename; /* return that file name */
3194N/A lua_pushfstring(L, "\n\tno file " LUA_QS, filename);
3194N/A lua_remove(L, -2); /* remove file name */
3194N/A luaL_addvalue(&msg); /* concatenate error msg. entry */
3194N/A luaL_pushresult(&msg); /* create error message */
3194N/A return NULL; /* not found */
3194N/A static int ll_searchpath (lua_State *L) {
3194N/A const char *f = searchpath(L, luaL_checkstring(L, 1),