2025-10-06 16:08:28 +00:00
|
|
|
---
|
2025-10-10 10:29:33 +02:00
|
|
|
CMakeLists.txt | 6 ++++--
|
|
|
|
|
editorconfig_lua.c | 37 +++++++++++++++++++++++++++++++------
|
|
|
|
|
2 files changed, 35 insertions(+), 8 deletions(-)
|
2025-10-06 16:08:28 +00:00
|
|
|
|
|
|
|
|
Index: editorconfig-core-lua-0.3.0/CMakeLists.txt
|
|
|
|
|
===================================================================
|
|
|
|
|
--- editorconfig-core-lua-0.3.0.orig/CMakeLists.txt 2019-10-04 19:06:29.000000000 +0200
|
2025-10-10 10:29:33 +02:00
|
|
|
+++ editorconfig-core-lua-0.3.0/CMakeLists.txt 2025-10-10 11:39:03.526268594 +0200
|
|
|
|
|
@@ -24,7 +24,8 @@
|
|
|
|
|
# POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
-cmake_minimum_required(VERSION 3.0)
|
|
|
|
|
+cmake_minimum_required(VERSION 3.10)
|
|
|
|
|
+cmake_policy(SET CMP0074 NEW)
|
|
|
|
|
|
|
|
|
|
project(editorconfig-core-lua VERSION 0.3.0 LANGUAGES C)
|
|
|
|
|
|
|
|
|
|
@@ -35,7 +36,7 @@
|
2025-10-06 16:08:28 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
|
|
find_package(EditorConfig REQUIRED)
|
|
|
|
|
-set(Lua_FIND_VERSION 5.2) # minimum Lua version
|
|
|
|
|
+set(Lua_FIND_VERSION 5.1) # minimum Lua version
|
|
|
|
|
find_package(Lua REQUIRED)
|
|
|
|
|
|
|
|
|
|
set(CMAKE_C_STANDARD 99)
|
2025-10-10 10:29:33 +02:00
|
|
|
@@ -55,6 +56,7 @@
|
|
|
|
|
)
|
|
|
|
|
target_link_libraries(editorconfig_lua
|
|
|
|
|
${EDITORCONFIG_LIBRARIES}
|
|
|
|
|
+ ${LUA_LIBRARIES}
|
|
|
|
|
)
|
|
|
|
|
# Omit the lib<name>.so prefix from the DSO
|
|
|
|
|
set_target_properties(editorconfig_lua PROPERTIES
|
2025-10-06 16:08:28 +00:00
|
|
|
Index: editorconfig-core-lua-0.3.0/editorconfig_lua.c
|
|
|
|
|
===================================================================
|
|
|
|
|
--- editorconfig-core-lua-0.3.0.orig/editorconfig_lua.c 2019-10-04 19:06:29.000000000 +0200
|
2025-10-10 10:29:33 +02:00
|
|
|
+++ editorconfig-core-lua-0.3.0/editorconfig_lua.c 2025-10-10 11:38:53.210693172 +0200
|
2025-10-06 16:08:28 +00:00
|
|
|
@@ -6,10 +6,10 @@
|
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
- * this list of conditions and the following disclaimer.
|
|
|
|
|
+ * this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
- * this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
- * and/or other materials provided with the distribution.
|
|
|
|
|
+ * this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
+ * and/or other materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
2025-10-10 10:29:33 +02:00
|
|
|
@@ -36,6 +36,31 @@
|
2025-10-06 16:08:28 +00:00
|
|
|
#error "LEC_VERSION is not defined."
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
+#if LUA_VERSION_NUM < 502
|
|
|
|
|
+/*
|
|
|
|
|
+ * Lua 5.1 compatibility functions.
|
|
|
|
|
+ * Adapted from Lua 5.2.x source.
|
|
|
|
|
+ */
|
2025-10-10 10:29:33 +02:00
|
|
|
+void
|
2025-10-06 16:08:28 +00:00
|
|
|
+luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
|
|
|
|
|
+{
|
|
|
|
|
+ luaL_checkstack(L, nup, "too many upvalues");
|
|
|
|
|
+ for (; l->name; l++) {
|
|
|
|
|
+ int i;
|
|
|
|
|
+ for (i = 0; i < nup; i++)
|
|
|
|
|
+ lua_pushvalue(L, -nup);
|
|
|
|
|
+ lua_pushcclosure(L, l->func, nup);
|
|
|
|
|
+ lua_setfield(L, -(nup + 2), l->name);
|
|
|
|
|
+ }
|
|
|
|
|
+ lua_pop(L, nup);
|
|
|
|
|
+}
|
|
|
|
|
+
|
2025-10-10 10:29:33 +02:00
|
|
|
+#ifndef luaL_newlib
|
2025-10-06 16:08:28 +00:00
|
|
|
+#define luaL_newlib(L, l) (lua_newtable(L), luaL_setfuncs(L, l, 0))
|
|
|
|
|
+#endif
|
2025-10-10 10:29:33 +02:00
|
|
|
+#endif
|
|
|
|
|
+
|
2025-10-06 16:08:28 +00:00
|
|
|
+
|
|
|
|
|
/***
|
|
|
|
|
* Lua bindings to the EditorConfig C Core library.
|
|
|
|
|
* @module editorconfig
|
2025-10-10 10:29:33 +02:00
|
|
|
@@ -94,7 +119,7 @@
|
2025-10-06 16:08:28 +00:00
|
|
|
editorconfig_handle eh;
|
|
|
|
|
int name_value_count;
|
|
|
|
|
const char *name, *value;
|
|
|
|
|
- lua_Integer idx = 1;
|
|
|
|
|
+ lua_Number idx = 1; /* Use lua_Number for Lua 5.1 compatibility */
|
|
|
|
|
|
|
|
|
|
eh = open_ec_handle(L);
|
|
|
|
|
assert(eh != NULL);
|
2025-10-10 10:29:33 +02:00
|
|
|
@@ -108,7 +133,7 @@
|
2025-10-06 16:08:28 +00:00
|
|
|
lua_pushstring(L, name);
|
|
|
|
|
lua_pushstring(L, value);
|
|
|
|
|
lua_settable(L, 1);
|
|
|
|
|
- lua_pushinteger(L, idx);
|
|
|
|
|
+ lua_pushnumber(L, idx); /* Use lua_pushnumber for Lua 5.1 compatibility */
|
|
|
|
|
lua_pushstring(L, name);
|
|
|
|
|
lua_settable(L, 2);
|
|
|
|
|
idx += 1;
|
2025-10-10 10:29:33 +02:00
|
|
|
@@ -149,4 +174,4 @@
|
2025-10-06 16:08:28 +00:00
|
|
|
luaL_newlib(L, editorconfig_reg);
|
|
|
|
|
add_version(L);
|
|
|
|
|
return 1;
|
|
|
|
|
-}
|
|
|
|
|
+}
|
|
|
|
|
\ No newline at end of file
|