summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luasocket/src/serial.c')
-rw-r--r--Build/source/texk/web2c/luatexdir/luasocket/src/serial.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c b/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c
index acee67181dd..f121bbf0a61 100644
--- a/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c
+++ b/Build/source/texk/web2c/luatexdir/luasocket/src/serial.c
@@ -2,7 +2,7 @@
* Serial stream
* LuaSocket toolkit
\*=========================================================================*/
-#include <string.h>
+#include <string.h>
#include "lua.h"
#include "lauxlib.h"
@@ -58,13 +58,6 @@ static luaL_Reg serial_methods[] = {
{NULL, NULL}
};
-/* our socket creation function */
-static luaL_Reg func[] = {
- {"serial", global_create},
- {NULL, NULL}
-};
-
-
/*-------------------------------------------------------------------------*\
* Initializes module
\*-------------------------------------------------------------------------*/
@@ -73,11 +66,7 @@ LUASOCKET_API int luaopen_socket_serial(lua_State *L) {
auxiliar_newclass(L, "serial{client}", serial_methods);
/* create class groups */
auxiliar_add2group(L, "serial{client}", "serial{any}");
- /* make sure the function ends up in the package table */
- luaL_openlib(L, "socket", func, 0);
- /* return the function instead of the 'socket' table */
- lua_pushstring(L, "serial");
- lua_gettable(L, -2);
+ lua_pushcfunction(L, global_create);
return 1;
}
@@ -119,7 +108,7 @@ static int meth_getfd(lua_State *L) {
/* this is very dangerous, but can be handy for those that are brave enough */
static int meth_setfd(lua_State *L) {
p_unix un = (p_unix) auxiliar_checkgroup(L, "serial{any}", 1);
- un->sock = (t_socket) luaL_checknumber(L, 2);
+ un->sock = (t_socket) luaL_checknumber(L, 2);
return 0;
}
@@ -130,7 +119,7 @@ static int meth_dirty(lua_State *L) {
}
/*-------------------------------------------------------------------------*\
-* Closes socket used by object
+* Closes socket used by object
\*-------------------------------------------------------------------------*/
static int meth_close(lua_State *L)
{
@@ -155,7 +144,7 @@ static int meth_settimeout(lua_State *L) {
/*-------------------------------------------------------------------------*\
-* Creates a serial object
+* Creates a serial object
\*-------------------------------------------------------------------------*/
static int global_create(lua_State *L) {
const char* path = luaL_checkstring(L, 1);
@@ -164,7 +153,7 @@ static int global_create(lua_State *L) {
p_unix un = (p_unix) lua_newuserdata(L, sizeof(t_unix));
/* open serial device */
-#ifdef __MINGW32__
+#if defined(_WIN32)
t_socket sock = open(path, O_RDWR);
#else
t_socket sock = open(path, O_NOCTTY|O_RDWR);
@@ -183,7 +172,7 @@ static int global_create(lua_State *L) {
/* initialize remaining structure fields */
socket_setnonblocking(&sock);
un->sock = sock;
- io_init(&un->io, (p_send) socket_write, (p_recv) socket_read,
+ io_init(&un->io, (p_send) socket_write, (p_recv) socket_read,
(p_error) socket_ioerror, &un->sock);
timeout_init(&un->tm, -1, -1);
buffer_init(&un->buf, &un->io, &un->tm);