Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# lua
Lua Ru 5.3.4 Русификация Lua, русские переменные, имена функций и операторы

https://тхаб.рф/wiki/Учебник_по_LuaRu - Учебник в процессе перовода!! по LuaRu
https://тхаб.рф/wiki/Учебник_по_LuaRu - Учебник в процессе перевода!! по LuaRu

http://plana.mybb.ru/viewtopic.php?id=576 Обсуждение LuaRu

исправленный файлы lctype.h и llex.c
исправленные файлы lctype.h и llex.c

== Русские синонимы англоязычных ключевых слов ==
(в скобках не реализованные варианты)
Expand All @@ -18,7 +18,7 @@ do - начало (делать ?)

else - иначе

elseif - иначеесли
elseif - иначеесли (либо)

end - всё (конец ?)

Expand All @@ -28,7 +28,7 @@ for - для

function - функция

goto - идина (перейти_к, выполнить_с ?)
goto - идина (посыл, перейти_к, выполнить_с ?)

if - если

Expand Down
77 changes: 39 additions & 38 deletions lbaselib.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,15 +356,15 @@ static int luaB_load (lua_State *L) {
size_t l;
const char *s = lua_tolstring(L, 1, &l);
const char *mode = luaL_optstring(L, 3, "bt");
int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */
if (s != NULL) { /* loading a string? */
int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' индекс или 0 если не 'env' */
if (s != NULL) { /* грузить строку? */
const char *chunkname = luaL_optstring(L, 2, s);
status = luaL_loadbufferx(L, s, l, chunkname, mode);
}
else { /* loading from a reader function */
else { /* загрузка из функции чтения */
const char *chunkname = luaL_optstring(L, 2, "=(load)");
luaL_checktype(L, 1, LUA_TFUNCTION);
lua_settop(L, RESERVEDSLOT); /* create reserved slot */
lua_settop(L, RESERVEDSLOT); /* создать резервный слот */
status = lua_load(L, generic_reader, NULL, chunkname, mode);
}
return load_aux(L, status, env);
Expand All @@ -374,7 +374,7 @@ static int luaB_load (lua_State *L) {


static int dofilecont (lua_State *L, int d1, lua_KContext d2) {
(void)d1; (void)d2; /* only to match 'lua_Kfunction' prototype */
(void)d1; (void)d2; /* только для соответствия прототипу 'lua_Kfunction' */
return lua_gettop(L) - 1;
}

Expand All @@ -390,14 +390,14 @@ static int luaB_dofile (lua_State *L) {


static int luaB_assert (lua_State *L) {
if (lua_toboolean(L, 1)) /* condition is true? */
return lua_gettop(L); /* return all arguments */
if (lua_toboolean(L, 1)) /* условие верно? */
return lua_gettop(L); /* вернуть все аргументы */
else { /* error */
luaL_checkany(L, 1); /* there must be a condition */
lua_remove(L, 1); /* remove it */
lua_pushliteral(L, "assertion failed!"); /* default message */
luaL_checkany(L, 1); /* должно быть условие */
lua_remove(L, 1); /* убери это */
lua_pushliteral(L, "не подтвердилось!"); /* сообщение по умолчанию */
lua_settop(L, 1); /* leave only message (default if no other one) */
return luaB_error(L); /* call 'error' */
return luaB_error(L); /* вызов 'error' */
}
}

Expand All @@ -412,24 +412,24 @@ static int luaB_select (lua_State *L) {
lua_Integer i = luaL_checkinteger(L, 1);
if (i < 0) i = n + i;
else if (i > n) i = n;
luaL_argcheck(L, 1 <= i, 1, "index out of range");
luaL_argcheck(L, 1 <= i, 1, "индекс вне диапазона");
return n - (int)i;
}
}


/*
** Continuation function for 'pcall' and 'xpcall'. Both functions
** already pushed a 'true' before doing the call, so in case of success
** 'finishpcall' only has to return everything in the stack minus
** 'extra' values (where 'extra' is exactly the number of items to be
** ignored).
** Функция продолжения для «pcall» и «xpcall». Обе функции
** уже толкают «истину» перед тем, как вызвать, поэтому в случае успеха
** 'finishpcall' должен только вернуть все в стек минус
** «дополнительные» значения (где «extra» - это точное количество элементов,
** которые должны игнорироваться).
*/
static int finishpcall (lua_State *L, int status, lua_KContext extra) {
if (status != LUA_OK && status != LUA_YIELD) { /* error? */
lua_pushboolean(L, 0); /* first result (false) */
lua_pushvalue(L, -2); /* error message */
return 2; /* return false, msg */
lua_pushboolean(L, 0); /* первый результат (false) */
lua_pushvalue(L, -2); /* сообщение об ошибке */
return 2; /* вернуть false, msg */
}
else
return lua_gettop(L) - (int)extra; /* return all results */
Expand All @@ -447,17 +447,17 @@ static int luaB_pcall (lua_State *L) {


/*
** Do a protected call with error handling. After 'lua_rotate', the
** stack will have <f, err, true, f, [args...]>; so, the function passes
** 2 to 'finishpcall' to skip the 2 first values when returning results.
** Защищенный вызов с обработкой ошибок. После 'lua_rotate'
** стек будет иметь <f, err, true, f, [args...]>; поэтому функция проходит
** 2 до 'finishpcall', чтобы пропустить 2 первых значения при возврате результатов.
*/
static int luaB_xpcall (lua_State *L) {
int status;
int n = lua_gettop(L);
luaL_checktype(L, 2, LUA_TFUNCTION); /* check error function */
lua_pushboolean(L, 1); /* first result */
lua_pushvalue(L, 1); /* function */
lua_rotate(L, 3, 2); /* move them below function's arguments */
luaL_checktype(L, 2, LUA_TFUNCTION); /* функция проверки ошибок */
lua_pushboolean(L, 1); /* первый результат */
lua_pushvalue(L, 1); /* функция */
lua_rotate(L, 3, 2); /* переместить их ниже аргументов функции */
status = lua_pcallk(L, n - 2, LUA_MULTRET, 2, 2, finishpcall);
return finishpcall(L, status, 2);
}
Expand Down Expand Up @@ -496,19 +496,20 @@ static const luaL_Reg base_funcs[] = {
/* placeholders */
{LUA_GNAME, NULL},
{"_VERSION", NULL},
/* add russian synonyms */
/* добавить русские синонимы */
// {"assert", luaB_assert},
// {"collectgarbage", luaB_collectgarbage},
// {"dofile", luaB_dofile},
// {"error", luaB_error},
// {"getmetatable", luaB_getmetatable},
// {"ipairs", luaB_ipairs},
{"���������_����", luaB_loadfile},
{"���������", luaB_load},
{"�����", luaB_next},
// {"pairs", luaB_pairs},
/* ищем самые короткие аналогии */
{"влить файл", luaB_loadfile},
{"влить", luaB_load},
{"сел", luaB_next}, /* по аналогии "встал-сел" вместо "for-next" */
// {"пары", luaB_pairs},
// {"pcall", luaB_pcall},
{"������", luaB_print},
{"печать", luaB_print},
// {"rawequal", luaB_rawequal},
// {"rawlen", luaB_rawlen},
// {"rawget", luaB_rawget},
Expand All @@ -517,23 +518,23 @@ static const luaL_Reg base_funcs[] = {
// {"setmetatable", luaB_setmetatable},
// {"tonumber", luaB_tonumber},
// {"tostring", luaB_tostring},
{"���", luaB_type},
{"тип", luaB_type},
// {"xpcall", luaB_xpcall},
// /* placeholders */
// {LUA_GNAME, NULL},
{"_������", NULL},
{"нуль", NULL},
{NULL, NULL}
};


LUAMOD_API int luaopen_base (lua_State *L) {
/* open lib into global table */
/* открыть lib в глобальную таблицу */
lua_pushglobaltable(L);
luaL_setfuncs(L, base_funcs, 0);
/* set global _G */
/* задать глобал _G */
lua_pushvalue(L, -1);
lua_setfield(L, -2, LUA_GNAME);
/* set global _VERSION */
/* задать глобал _VERSION */
lua_pushliteral(L, LUA_VERSION);
lua_setfield(L, -2, "_VERSION");
return 1;
Expand Down