Date: Thu, 22 May 2014 12:40:53 GMT From: GreenDog <fiziologus@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/190105: [UPD] devel/luafilesystem to 1.6.2 Message-ID: <201405221240.s4MCer0K006545@cgiserv.freebsd.org> Resent-Message-ID: <201405221250.s4MCo1Uu076167@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 190105 >Category: ports >Synopsis: [UPD] devel/luafilesystem to 1.6.2 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: maintainer-update >Submitter-Id: current-users >Arrival-Date: Thu May 22 12:50:01 UTC 2014 >Closed-Date: >Last-Modified: >Originator: GreenDog >Release: >Organization: >Environment: >Description: [devel/luafilesystem] Update to 1.6.2 (via patch) Staging Now luafilesystem support both lua-5.1 and lua-5.2 >How-To-Repeat: >Fix: Patch attached with submission follows: diff -ruN luafilesystem.orig/Makefile luafilesystem/Makefile --- luafilesystem.orig/Makefile 2014-02-21 17:36:12.000000000 +0400 +++ luafilesystem/Makefile 2014-05-22 16:22:31.000000000 +0400 @@ -2,8 +2,9 @@ # $FreeBSD: head/devel/luafilesystem/Makefile 345404 2014-02-21 13:36:12Z ehaupt $ PORTNAME= luafilesystem -PORTVERSION= 1.5.0 +PORTVERSION= 1.6.2 CATEGORIES= devel +DISTVERSION= 1.5.0 MASTER_SITES= GH PKGNAMEPREFIX= ${LUA_PKGNAMEPREFIX} @@ -12,12 +13,12 @@ LICENSE= MIT -USE_LUA= 5.1 +USES= lua:51+ USE_GITHUB= yes GH_ACCOUNT= keplerproject GH_PROGECT= ${PORTNAME} -GH_TAGNAME= v${PORTVERSION} +GH_TAGNAME= v1.5.0 GH_COMMIT= 8ff2013 ALL_TARGET= lib @@ -25,10 +26,6 @@ PLIST_FILES= %%LUA_MODLIBDIR%%/lfs.so PORTDOCS= * -MAKE_ARGS+= INCS="-I${LOCALBASE}/include/${LUA_SUBDIR}" - -NO_STAGE= yes - OPTIONS_DEFINE= DOCS .include <bsd.port.options.mk> @@ -36,13 +33,14 @@ post-patch: ${REINPLACE_CMD} -e \ "s|%%PREFIX%%|${PREFIX}| ; \ - s|%%MODLIBDIR%%|${LUA_MODLIBDIR}| ; \ + s|%%MODLIBDIR%%|${STAGEDIR}${LUA_MODLIBDIR}| ; \ s|%%INCDIR%%|${LUA_INCDIR}|" ${WRKSRC}/config + ${CP} ${FILESDIR}/doc.css ${WRKSRC}/doc/us post-install: .if ${PORT_OPTIONS:MDOCS} - ${MKDIR} ${DOCSDIR} && \ - ${CP} ${WRKSRC}/doc/us/* ${DOCSDIR} + ${MKDIR} ${STAGEDIR}${DOCSDIR} && \ + ${CP} ${WRKSRC}/doc/us/* ${STAGEDIR}${DOCSDIR} .endif .include <bsd.port.mk> diff -ruN luafilesystem.orig/files/doc.css luafilesystem/files/doc.css --- luafilesystem.orig/files/doc.css 1970-01-01 03:00:00.000000000 +0300 +++ luafilesystem/files/doc.css 2014-05-22 16:22:31.000000000 +0400 @@ -0,0 +1,212 @@ +body { + margin-left: 1em; + margin-right: 1em; + font-family: arial, helvetica, geneva, sans-serif; + background-color:#ffffff; margin:0px; +} + +code { + font-family: "Andale Mono", monospace; +} + +tt { + font-family: "Andale Mono", monospace; +} + +body, td, th { font-size: 11pt; } + +h1, h2, h3, h4 { margin-left: 0em; } + +textarea, pre, tt { font-size:10pt; } +body, td, th { color:#000000; } +small { font-size:0.85em; } +h1 { font-size:1.5em; } +h2 { font-size:1.25em; } +h3 { font-size:1.15em; } +h4 { font-size:1.06em; } + +a:link { font-weight:bold; color: #004080; text-decoration: none; } +a:visited { font-weight:bold; color: #006699; text-decoration: none; } +a:link:hover { text-decoration:underline; } +hr { color:#cccccc } +img { border-width: 0px; } + +h3 { padding-top: 1em; } + +p { margin-left: 1em; } + +p.name { + font-family: "Andale Mono", monospace; + padding-top: 1em; + margin-left: 0em; +} + +blockquote { margin-left: 3em; } + +.example { + background-color: rgb(245, 245, 245); + border-top-width: 1px; + border-right-width: 1px; + border-bottom-width: 1px; + border-left-width: 1px; + border-top-style: solid; + border-right-style: solid; + border-bottom-style: solid; + border-left-style: solid; + border-top-color: silver; + border-right-color: silver; + border-bottom-color: silver; + border-left-color: silver; + padding: 1em; + margin-left: 1em; + margin-right: 1em; + font-family: "Andale Mono", monospace; + font-size: smaller; +} + +hr { + margin-left: 0em; + background: #00007f; + border: 0px; + height: 1px; +} + +ul { list-style-type: disc; } + +table.index { border: 1px #00007f; } +table.index td { text-align: left; vertical-align: top; } +table.index ul { padding-top: 0em; margin-top: 0em; } + +table { + border: 1px solid black; + border-collapse: collapse; + margin-left: auto; + margin-right: auto; +} + +th { + border: 1px solid black; + padding: 0.5em; +} + +td { + border: 1px solid black; + padding: 0.5em; +} +div.header, div.footer { margin-left: 0em; } + +#container { + margin-left: 1em; + margin-right: 1em; + background-color: #f0f0f0; +} + +#product { + text-align: center; + border-bottom: 1px solid #cccccc; + background-color: #ffffff; +} + +#product big { + font-size: 2em; +} + +#product_logo { +} + +#product_name { +} + +#product_description { +} + +#main { + background-color: #f0f0f0; + border-left: 2px solid #cccccc; +} + +#navigation { + float: left; + width: 12em; + margin: 0; + vertical-align: top; + background-color: #f0f0f0; + overflow:visible; +} + +#navigation h1 { + background-color:#e7e7e7; + font-size:1.1em; + color:#000000; + text-align:left; + margin:0px; + padding:0.2em; + border-top:1px solid #dddddd; + border-bottom:1px solid #dddddd; +} + +#navigation ul { + font-size:1em; + list-style-type: none; + padding: 0; + margin: 1px; +} + +#navigation li { + text-indent: -1em; + margin: 0em 0em 0em 0.5em; + display: block; + padding: 3px 0px 0px 12px; +} + +#navigation li li a { + padding: 0px 3px 0px -1em; +} + +#content { + margin-left: 12em; + padding: 1em; + border-left: 2px solid #cccccc; + border-right: 2px solid #cccccc; + background-color: #ffffff; +} + +#about { + clear: both; + margin: 0; + padding: 5px; + border-top: 2px solid #cccccc; + background-color: #ffffff; +} + +@media print { + body { + font: 10pt "Times New Roman", "TimeNR", Times, serif; + } + a { + font-weight:bold; color: #004080; text-decoration: underline; + } + #main { + background-color: #ffffff; border-left: 0px; + } + #container { + margin-left: 2%; margin-right: 2%; background-color: #ffffff; + } + #content { + margin-left: 0px; padding: 1em; border-left: 0px; border-right: 0px; background-color: #ffffff; + } + #navigation { + display: none; + } + #product_logo { + display: none; + } + #about img { + display: none; + } + .example { + font-family: "Andale Mono", monospace; + font-size: 8pt; + page-break-inside: avoid; + } +} diff -ruN luafilesystem.orig/files/patch-doc__us__examples.html luafilesystem/files/patch-doc__us__examples.html --- luafilesystem.orig/files/patch-doc__us__examples.html 1970-01-01 03:00:00.000000000 +0300 +++ luafilesystem/files/patch-doc__us__examples.html 2014-05-22 16:22:31.000000000 +0400 @@ -0,0 +1,22 @@ +--- doc/us/examples.html 2009-10-21 00:54:35.000000000 +0400 ++++ ../luafilesystem-master/doc/us/examples.html 2012-10-04 18:25:54.000000000 +0400 +@@ -47,8 +47,8 @@ + <li><strong>Examples</strong></li> + <li><a href="http://luaforge.net/projects/luafilesystem/">Project</a> + <ul> +- <li><a href="http://luaforge.net/tracker/?group_id=66">Bug Tracker</a></li> +- <li><a href="http://luaforge.net/scm/?group_id=66">CVS</a></li> ++ <li><a href="https://github.com/keplerproject/luafilesystem/issues">Bug Tracker</a></li> ++ <li><a href="https://github.com/keplerproject/luafilesystem">CVS</a></li> + </ul> + </li> + <li><a href="license.html">License</a></li> +@@ -65,7 +65,7 @@ + attributes for each file inside it.</p> + + <pre class="example"> +-require"lfs" ++local lfs = require"lfs" + + function attrdir (path) + for file in lfs.dir(path) do diff -ruN luafilesystem.orig/files/patch-doc__us__index.html luafilesystem/files/patch-doc__us__index.html --- luafilesystem.orig/files/patch-doc__us__index.html 1970-01-01 03:00:00.000000000 +0300 +++ luafilesystem/files/patch-doc__us__index.html 2014-05-22 16:22:31.000000000 +0400 @@ -0,0 +1,54 @@ +--- doc/us/index.html 2009-10-21 00:54:35.000000000 +0400 ++++ ../luafilesystem-master/doc/us/index.html 2012-10-04 18:25:54.000000000 +0400 +@@ -47,8 +47,8 @@ + <li><a href="examples.html">Examples</a></li> + <li><a href="http://luaforge.net/projects/luafilesystem/">Project</a> + <ul> +- <li><a href="http://luaforge.net/tracker/?group_id=66">Bug Tracker</a></li> +- <li><a href="http://luaforge.net/scm/?group_id=66">CVS</a></li> ++ <li><a href="https://github.com/keplerproject/luafilesystem/issues">Bug Tracker</a></li> ++ <li><a href="https://github.com/keplerproject/luafilesystem">CVS</a></li> + </ul> + </li> + <li><a href="license.html">License</a></li> +@@ -71,7 +71,8 @@ + + <h2><a name="status"></a>Status</h2> + +-<p>Current version is 1.5.0. It was developed for Lua 5.1.</p> ++<p>Current version is 1.6.2. It was developed for Lua 5.1 but also ++ works with Lua 5.2.</p> + + <h2><a name="download"></a>Download</h2> + +@@ -82,10 +83,30 @@ + <h2><a name="history"></a>History</h2> + + <dl class="history"> ++ <dt><strong>Version 1.6.2</strong> [??/Oct/2012]</dt> ++ <dd><ul> ++ <li>Full Lua 5.2 compatibility (with Lua 5.1 fallbacks)</li> ++ </ul></dd> ++ ++ <dt><strong>Version 1.6.1</strong> [01/Oct/2012]</dt> ++ <dd><ul> ++ <li>fix build for Lua 5.2</li> ++ </ul></dd> ++ ++ <dt><strong>Version 1.6.0</strong> [26/Sep/2012]</dt> ++ <dd><ul> ++ <li>getcwd fix for Android</li> ++ <li>support for Lua 5.2</li> ++ <li>add lfs.link</li> ++ <li>other bug fixes</li> ++ </ul></dd> ++ + <dt><strong>Version 1.5.0</strong> [20/Oct/2009]</dt> ++ <dd><ul> + <li>Added explicit next and close methods to second return value of lfs.dir + (the directory object), for explicit iteration or explicit closing.</li> + <li>Added directory locking via lfs.lock_dir function (see the <a href="manual.html">manual</a>).</li> ++ </ul></dd> + <dt><strong>Version 1.4.2</strong> [03/Feb/2009]</dt> + <dd> + <ul> diff -ruN luafilesystem.orig/files/patch-doc__us__license.html luafilesystem/files/patch-doc__us__license.html --- luafilesystem.orig/files/patch-doc__us__license.html 1970-01-01 03:00:00.000000000 +0300 +++ luafilesystem/files/patch-doc__us__license.html 2014-05-22 16:22:31.000000000 +0400 @@ -0,0 +1,13 @@ +--- doc/us/license.html 2009-10-21 00:54:35.000000000 +0400 ++++ ../luafilesystem-master/doc/us/license.html 2012-10-04 18:25:54.000000000 +0400 +@@ -47,8 +47,8 @@ + <li><a href="examples.html">Examples</a></li> + <li><a href="http://luaforge.net/projects/luafilesystem/">Project</a> + <ul> +- <li><a href="http://luaforge.net/tracker/?group_id=66">Bug Tracker</a></li> +- <li><a href="http://luaforge.net/scm/?group_id=66">CVS</a></li> ++ <li><a href="https://github.com/keplerproject/luafilesystem/issues/">Bug Tracker</a></li> ++ <li><a href="https://github.com/keplerproject/luafilesystem">CVS</a></li> + </ul> + </li> + <li><strong>License</strong></li> diff -ruN luafilesystem.orig/files/patch-doc__us__manual.html luafilesystem/files/patch-doc__us__manual.html --- luafilesystem.orig/files/patch-doc__us__manual.html 1970-01-01 03:00:00.000000000 +0300 +++ luafilesystem/files/patch-doc__us__manual.html 2014-05-22 16:22:31.000000000 +0400 @@ -0,0 +1,56 @@ +--- doc/us/manual.html 2009-10-21 00:54:35.000000000 +0400 ++++ ../luafilesystem-master/doc/us/manual.html 2012-10-04 18:25:54.000000000 +0400 +@@ -45,8 +45,8 @@ + <li><a href="examples.html">Examples</a></li> + <li><a href="http://luaforge.net/projects/luafilesystem/">Project</a> + <ul> +- <li><a href="http://luaforge.net/tracker/?group_id=66">Bug Tracker</a></li> +- <li><a href="http://luaforge.net/scm/?group_id=66">CVS</a></li> ++ <li><a href="https://github.com/keplerproject/luafilesystem/issues">Bug Tracker</a></li> ++ <li><a href="https://github.com/keplerproject/luafilesystem">CVS</a></li> + </ul> + </li> + <li><a href="license.html">License</a></li> +@@ -174,7 +174,7 @@ + + <dt><a name="chdir"></a><strong><code>lfs.lock_dir(path, [seconds_stale])</code></strong></dt> + <dd>Creates a lockfile (called lockfile.lfs) in <code>path</code> if it does not +- exist and returns the lock. If the lock already exists checks it ++ exist and returns the lock. If the lock already exists checks if + it's stale, using the second parameter (default for the second + parameter is <code>INT_MAX</code>, which in practice means the lock will never + be stale. To free the the lock call <code>lock:free()</code>. <br/> +@@ -206,6 +206,13 @@ + Returns <code>true</code> if the operation was successful; in + case of error, it returns <code>nil</code> plus an error string. + </dd> ++ ++ <dt><a name="link"></a><strong><code>lfs.link (old, new[, symlink])</code></strong></dt> ++ <dd>Creates a link. The first argument is the object to link to ++ and the second is the name of the link. If the optional third ++ argument is true, the link will by a symbolic link (by default, a ++ hard link is created). ++ </dd> + + <dt><a name="mkdir"></a><strong><code>lfs.mkdir (dirname)</code></strong></dt> + <dd>Creates a new directory. The argument is the name of the new +@@ -221,15 +228,15 @@ + + <dt><a name="setmode"></a><strong><code>lfs.setmode (file, mode)</code></strong></dt> + <dd>Sets the writing mode for a file. The mode string can be either <code>binary</code> or <code>text</code>. +- Returns the previous mode string for the file. This function is only available in Windows, so you may want to make sure that +- <code>lfs.setmode</code> exists before using it. ++ Returns the previous mode string for the file. On non-Windows platforms, where the two modes are identical, ++ setting the mode has no effect, and the mode is always returned as <code>binary</code>. + </dd> + + <dt><a name="symlinkattributes"></a><strong><code>lfs.symlinkattributes (filepath [, aname])</code></strong></dt> + <dd>Identical to <a href="#attributes">lfs.attributes</a> except that + it obtains information about the link itself (not the file it refers to). +- This function is not available in Windows so you may want to make sure that +- <code>lfs.symlinkattributes</code> exists before using it. ++ On Windows this function does not yet support links, and is identical to ++ <code>lfs.attributes</code>. + </dd> + + <dt><a name="touch"></a><strong><code>lfs.touch (filepath [, atime [, mtime]])</code></strong></dt> diff -ruN luafilesystem.orig/files/patch-src__lfs.c luafilesystem/files/patch-src__lfs.c --- luafilesystem.orig/files/patch-src__lfs.c 1970-01-01 03:00:00.000000000 +0300 +++ luafilesystem/files/patch-src__lfs.c 2014-05-22 16:22:31.000000000 +0400 @@ -0,0 +1,388 @@ +--- src/lfs.c 2009-10-21 00:54:35.000000000 +0400 ++++ ../luafilesystem-master/src/lfs.c 2012-10-04 18:25:54.000000000 +0400 +@@ -56,11 +56,19 @@ + #include <utime.h> + #endif + +-#include "lua.h" +-#include "lauxlib.h" +-#include "lualib.h" ++#include <lua.h> ++#include <lauxlib.h> ++#include <lualib.h> ++ + #include "lfs.h" + ++#define LFS_VERSION "1.6.2" ++#define LFS_LIBNAME "lfs" ++ ++#if LUA_VERSION_NUM < 502 ++# define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l)) ++#endif ++ + /* Define 'strerror' for systems that do not implement it */ + #ifdef NO_STRERROR + #define strerror(_) "System unable to describe the error" +@@ -72,15 +80,22 @@ + #define getcwd_error "Function 'getcwd' not provided by system" + #else + #define getcwd_error strerror(errno) ++ #ifdef _WIN32 ++ /* MAX_PATH seems to be 260. Seems kind of small. Is there a better one? */ ++ #define LFS_MAXPATHLEN MAX_PATH ++ #else ++ /* For MAXPATHLEN: */ ++ #include <sys/param.h> ++ #define LFS_MAXPATHLEN MAXPATHLEN ++ #endif + #endif + + #define DIR_METATABLE "directory metatable" +-#define MAX_DIR_LENGTH 1023 + typedef struct dir_data { + int closed; + #ifdef _WIN32 + long hFile; +- char pattern[MAX_DIR_LENGTH+1]; ++ char pattern[MAX_PATH+1]; + #else + DIR *dir; + #endif +@@ -97,17 +112,40 @@ + #define STAT_STRUCT struct _stati64 + #endif + #define STAT_FUNC _stati64 ++#define LSTAT_FUNC STAT_FUNC + #else + #define _O_TEXT 0 + #define _O_BINARY 0 +-#define lfs_setmode(L,file,m) ((void)((void)file,m), \ +- luaL_error(L, LUA_QL("setmode") " not supported on this platform"), -1) ++#define lfs_setmode(L,file,m) ((void)L, (void)file, (void)m, 0) + #define STAT_STRUCT struct stat + #define STAT_FUNC stat + #define LSTAT_FUNC lstat + #endif + + /* ++** Utility functions ++*/ ++static int pusherror(lua_State *L, const char *info) ++{ ++ lua_pushnil(L); ++ if (info==NULL) ++ lua_pushstring(L, strerror(errno)); ++ else ++ lua_pushfstring(L, "%s: %s", info, strerror(errno)); ++ lua_pushinteger(L, errno); ++ return 3; ++} ++ ++static int pushresult(lua_State *L, int i, const char *info) ++{ ++ if (i==-1) ++ return pusherror(L, info); ++ lua_pushinteger(L, i); ++ return 1; ++} ++ ++ ++/* + ** This function changes the working (current) directory + */ + static int change_dir (lua_State *L) { +@@ -130,14 +168,15 @@ + */ + static int get_dir (lua_State *L) { + char *path; +- if ((path = getcwd(NULL, 0)) == NULL) { ++ /* Passing (NULL, 0) is not guaranteed to work. Use a temp buffer and size instead. */ ++ char buf[LFS_MAXPATHLEN]; ++ if ((path = getcwd(buf, LFS_MAXPATHLEN)) == NULL) { + lua_pushnil(L); + lua_pushstring(L, getcwd_error); + return 2; + } + else { + lua_pushstring(L, path); +- free(path); + return 1; + } + } +@@ -281,10 +320,9 @@ + } + #endif + +-#ifdef _WIN32 + static int lfs_g_setmode (lua_State *L, FILE *f, int arg) { +- static const int mode[] = {_O_TEXT, _O_BINARY}; +- static const char *const modenames[] = {"text", "binary", NULL}; ++ static const int mode[] = {_O_BINARY, _O_TEXT}; ++ static const char *const modenames[] = {"binary", "text", NULL}; + int op = luaL_checkoption(L, arg, NULL, modenames); + int res = lfs_setmode(L, f, mode[op]); + if (res != -1) { +@@ -307,13 +345,6 @@ + return 3; + } + } +-#else +-static int lfs_g_setmode (lua_State *L, FILE *f, int arg) { +- lua_pushboolean(L, 0); +- lua_pushliteral(L, "setmode not supported on this platform"); +- return 2; +-} +-#endif + + static int lfs_f_setmode(lua_State *L) { + return lfs_g_setmode(L, check_file(L, 1, "setmode"), 2); +@@ -363,14 +394,35 @@ + } + + ++/* ++** Creates a link. ++** @param #1 Object to link to. ++** @param #2 Name of link. ++** @param #3 True if link is symbolic (optional). ++*/ ++static int make_link(lua_State *L) ++{ ++#ifndef _WIN32 ++ const char *oldpath = luaL_checkstring(L, 1); ++ const char *newpath = luaL_checkstring(L, 2); ++ return pushresult(L, ++ (lua_toboolean(L,3) ? symlink : link)(oldpath, newpath), NULL); ++#else ++ pusherror(L, "make_link is not supported on Windows"); ++#endif ++} ++ ++ ++/* ++** Creates a directory. ++** @param #1 Directory path. ++*/ + static int make_dir (lua_State *L) { + const char *path = luaL_checkstring (L, 1); + int fail; + #ifdef _WIN32 +- int oldmask = umask (0); + fail = _mkdir (path); + #else +- mode_t oldmask = umask( (mode_t)0 ); + fail = mkdir (path, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | + S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH ); + #endif +@@ -379,7 +431,6 @@ + lua_pushfstring (L, "%s", strerror(errno)); + return 2; + } +- umask (oldmask); + lua_pushboolean (L, 1); + return 1; + } +@@ -413,12 +464,13 @@ + struct dirent *entry; + #endif + dir_data *d = (dir_data *)luaL_checkudata (L, 1, DIR_METATABLE); +- luaL_argcheck (L, !d->closed, 1, "closed directory"); ++ luaL_argcheck (L, d->closed == 0, 1, "closed directory"); + #ifdef _WIN32 + if (d->hFile == 0L) { /* first entry */ + if ((d->hFile = _findfirst (d->pattern, &c_file)) == -1L) { + lua_pushnil (L); + lua_pushstring (L, strerror (errno)); ++ d->closed = 1; + return 2; + } else { + lua_pushstring (L, c_file.name); +@@ -457,14 +509,13 @@ + #ifdef _WIN32 + if (!d->closed && d->hFile) { + _findclose (d->hFile); +- d->closed = 1; + } + #else + if (!d->closed && d->dir) { + closedir (d->dir); +- d->closed = 1; + } + #endif ++ d->closed = 1; + return 0; + } + +@@ -477,18 +528,16 @@ + dir_data *d; + lua_pushcfunction (L, dir_iter); + d = (dir_data *) lua_newuserdata (L, sizeof(dir_data)); ++ luaL_getmetatable (L, DIR_METATABLE); ++ lua_setmetatable (L, -2); + d->closed = 0; + #ifdef _WIN32 + d->hFile = 0L; +- luaL_getmetatable (L, DIR_METATABLE); +- lua_setmetatable (L, -2); +- if (strlen(path) > MAX_DIR_LENGTH) ++ if (strlen(path) > MAX_PATH-2) + luaL_error (L, "path too long: %s", path); + else + sprintf (d->pattern, "%s/*", path); + #else +- luaL_getmetatable (L, DIR_METATABLE); +- lua_setmetatable (L, -2); + d->dir = opendir (path); + if (d->dir == NULL) + luaL_error (L, "cannot open %s: %s", path, strerror (errno)); +@@ -502,19 +551,18 @@ + */ + static int dir_create_meta (lua_State *L) { + luaL_newmetatable (L, DIR_METATABLE); +- /* set its __gc field */ +- lua_pushstring (L, "__index"); ++ ++ /* Method table */ + lua_newtable(L); +- lua_pushstring (L, "next"); + lua_pushcfunction (L, dir_iter); +- lua_settable(L, -3); +- lua_pushstring (L, "close"); ++ lua_setfield(L, -2, "next"); + lua_pushcfunction (L, dir_close); +- lua_settable(L, -3); +- lua_settable (L, -3); +- lua_pushstring (L, "__gc"); ++ lua_setfield(L, -2, "close"); ++ ++ /* Metamethods */ ++ lua_setfield(L, -2, "__index"); + lua_pushcfunction (L, dir_close); +- lua_settable (L, -3); ++ lua_setfield (L, -2, "__gc"); + return 1; + } + +@@ -523,10 +571,13 @@ + */ + static int lock_create_meta (lua_State *L) { + luaL_newmetatable (L, LOCK_METATABLE); +- /* set its __gc field */ ++ ++ /* Method table */ + lua_newtable(L); + lua_pushcfunction(L, lfs_unlock_dir); + lua_setfield(L, -2, "free"); ++ ++ /* Metamethods */ + lua_setfield(L, -2, "__index"); + lua_pushcfunction(L, lfs_unlock_dir); + lua_setfield(L, -2, "__gc"); +@@ -669,6 +720,46 @@ + #endif + } + ++ /* ++** Convert the inode protection mode to a permission list. ++*/ ++ ++#ifdef _WIN32 ++static const char *perm2string (unsigned short mode) { ++ static char perms[10] = "---------\0"; ++ int i; ++ for (i=0;i<9;i++) perms[i]='-'; ++ if (mode & _S_IREAD) ++ { perms[0] = 'r'; perms[3] = 'r'; perms[6] = 'r'; } ++ if (mode & _S_IWRITE) ++ { perms[1] = 'w'; perms[4] = 'w'; perms[7] = 'w'; } ++ if (mode & _S_IEXEC) ++ { perms[2] = 'x'; perms[5] = 'x'; perms[8] = 'x'; } ++ return perms; ++} ++#else ++static const char *perm2string (mode_t mode) { ++ static char perms[10] = "---------\0"; ++ int i; ++ for (i=0;i<9;i++) perms[i]='-'; ++ if (mode & S_IRUSR) perms[0] = 'r'; ++ if (mode & S_IWUSR) perms[1] = 'w'; ++ if (mode & S_IXUSR) perms[2] = 'x'; ++ if (mode & S_IRGRP) perms[3] = 'r'; ++ if (mode & S_IWGRP) perms[4] = 'w'; ++ if (mode & S_IXGRP) perms[5] = 'x'; ++ if (mode & S_IROTH) perms[6] = 'r'; ++ if (mode & S_IWOTH) perms[7] = 'w'; ++ if (mode & S_IXOTH) perms[8] = 'x'; ++ return perms; ++} ++#endif ++ ++/* permssions string */ ++static void push_st_perm (lua_State *L, STAT_STRUCT *info) { ++ lua_pushstring (L, perm2string (info->st_mode)); ++} ++ + typedef void (*_push_function) (lua_State *L, STAT_STRUCT *info); + + struct _stat_members { +@@ -688,6 +779,7 @@ + { "modification", push_st_mtime }, + { "change", push_st_ctime }, + { "size", push_st_size }, ++ { "permissions", push_st_perm }, + #ifndef _WIN32 + { "blocks", push_st_blocks }, + { "blksize", push_st_blksize }, +@@ -747,17 +839,9 @@ + /* + ** Get symbolic link information using lstat. + */ +-#ifndef _WIN32 + static int link_info (lua_State *L) { + return _file_info_ (L, LSTAT_FUNC); + } +-#else +-static int link_info (lua_State *L) { +- lua_pushboolean(L, 0); +- lua_pushliteral(L, "symlinkattributes not supported on this platform"); +- return 2; +-} +-#endif + + + /* +@@ -765,13 +849,13 @@ + */ + static void set_info (lua_State *L) { + lua_pushliteral (L, "_COPYRIGHT"); +- lua_pushliteral (L, "Copyright (C) 2003-2009 Kepler Project"); ++ lua_pushliteral (L, "Copyright (C) 2003-2012 Kepler Project"); + lua_settable (L, -3); + lua_pushliteral (L, "_DESCRIPTION"); + lua_pushliteral (L, "LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution"); + lua_settable (L, -3); + lua_pushliteral (L, "_VERSION"); +- lua_pushliteral (L, "LuaFileSystem 1.5.0"); ++ lua_pushliteral (L, "LuaFileSystem "LFS_VERSION); + lua_settable (L, -3); + } + +@@ -781,6 +865,7 @@ + {"chdir", change_dir}, + {"currentdir", get_dir}, + {"dir", dir_iter_factory}, ++ {"link", make_link}, + {"lock", file_lock}, + {"mkdir", make_dir}, + {"rmdir", remove_dir}, +@@ -795,7 +880,9 @@ + int luaopen_lfs (lua_State *L) { + dir_create_meta (L); + lock_create_meta (L); +- luaL_register (L, "lfs", fslib); ++ luaL_newlib (L, fslib); ++ lua_pushvalue(L, -1); ++ lua_setglobal(L, LFS_LIBNAME); + set_info (L); + return 1; + } diff -ruN luafilesystem.orig/files/patch-src__lfs.h luafilesystem/files/patch-src__lfs.h --- luafilesystem.orig/files/patch-src__lfs.h 1970-01-01 03:00:00.000000000 +0300 +++ luafilesystem/files/patch-src__lfs.h 2014-05-22 16:22:31.000000000 +0400 @@ -0,0 +1,12 @@ +--- src/lfs.h.orig 2009-10-21 00:54:35.000000000 +0400 ++++ src/lfs.h 2014-05-19 14:31:08.000000000 +0400 +@@ -13,5 +13,9 @@ + #define chdir_error strerror(errno) + #endif + ++// Fix for Lua-5.2 ++#if LUA_VERSION_NUM == 502 ++# define luaL_reg luaL_Reg ++#endif + + int luaopen_lfs (lua_State *L); >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405221240.s4MCer0K006545>