diff options
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua/ltexlib.c')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/lua/ltexlib.c | 219 |
1 files changed, 110 insertions, 109 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c index 785bf67f4e4..2813caee2bc 100644 --- a/Build/source/texk/web2c/luatexdir/lua/ltexlib.c +++ b/Build/source/texk/web2c/luatexdir/lua/ltexlib.c @@ -24,7 +24,7 @@ #include "tokens.h" static const char _svn_version[] = - "$Id: ltexlib.c 2321 2009-04-18 09:17:13Z hhenkel $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.2/source/texk/web2c/luatexdir/lua/ltexlib.c $"; + "$Id: ltexlib.c 2448 2009-06-08 07:43:50Z taco $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.3/source/texk/web2c/luatexdir/lua/ltexlib.c $"; extern halfword *check_isnode(lua_State * L, int ud); extern void lua_nodelib_push_fast(lua_State * L, halfword n); @@ -270,24 +270,23 @@ int dimen_to_number(lua_State * L, char *s) } -integer -get_item_index (lua_State *L, int i, integer base) +integer get_item_index(lua_State * L, int i, integer base) { size_t kk; integer k; int cur_cs; char *s; - if (lua_type(L, i) == LUA_TSTRING) { - s = (char *) lua_tolstring(L, i , &kk); + if (lua_type(L, i) == LUA_TSTRING) { + s = (char *) lua_tolstring(L, i, &kk); cur_cs = string_lookup(s, kk); - if (cur_cs==static_undefined_control_sequence || - is_undefined_cs(cur_cs)) { - k = -1; /* guarandeed invalid */ - } else { - k = (zget_equiv(cur_cs) - base); - } + if (cur_cs == static_undefined_control_sequence || + is_undefined_cs(cur_cs)) { + k = -1; /* guarandeed invalid */ + } else { + k = (zget_equiv(cur_cs) - base); + } } else { - k = (integer) luaL_checkinteger(L, i ); + k = (integer) luaL_checkinteger(L, i); } return k; } @@ -297,9 +296,9 @@ static int vsetdimen(lua_State * L, int is_global) { int i, j, err; integer k; - integer save_global_defs = int_par(param_global_defs_code); + integer save_global_defs = int_par(param_global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(param_global_defs_code) = 1; i = lua_gettop(L); j = 0; /* find the value */ @@ -311,7 +310,7 @@ static int vsetdimen(lua_State * L, int is_global) lua_error(L); } else j = (int) lua_tonumber(L, i); - k = get_item_index(L, (i-1), get_scaled_base()); + k = get_item_index(L, (i - 1), get_scaled_base()); check_index_range(k, "setdimen"); err = set_tex_dimen_register(k, j); int_par(param_global_defs_code) = save_global_defs; @@ -324,14 +323,14 @@ static int vsetdimen(lua_State * L, int is_global) static int setdimen(lua_State * L) { - int isglobal = 0; - int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; - } - return vsetdimen (L, isglobal); + int isglobal = 0; + int n = lua_gettop(L); + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; + } + return vsetdimen(L, isglobal); } static int getdimen(lua_State * L) @@ -350,13 +349,13 @@ static int vsetskip(lua_State * L, int is_global) int i, err; halfword *j; integer k; - integer save_global_defs = int_par(param_global_defs_code); + integer save_global_defs = int_par(param_global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(param_global_defs_code) = 1; i = lua_gettop(L); j = check_isnode(L, i); /* the value */ - k = get_item_index(L, (i-1), get_skip_base()); - check_index_range(k, "setskip"); /* the index */ + k = get_item_index(L, (i - 1), get_skip_base()); + check_index_range(k, "setskip"); /* the index */ err = set_tex_skip_register(k, *j); int_par(param_global_defs_code) = save_global_defs; if (err) { @@ -368,14 +367,14 @@ static int vsetskip(lua_State * L, int is_global) static int setskip(lua_State * L) { - int isglobal = 0; - int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; - } - return vsetskip (L, isglobal); + int isglobal = 0; + int n = lua_gettop(L); + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; + } + return vsetskip(L, isglobal); } int getskip(lua_State * L) @@ -395,12 +394,12 @@ static int vsetcount(lua_State * L, int is_global) { int i, j, err; integer k; - integer save_global_defs = int_par(param_global_defs_code); + integer save_global_defs = int_par(param_global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(param_global_defs_code) = 1; i = lua_gettop(L); j = (int) luaL_checkinteger(L, i); - k = get_item_index(L, (i-1), get_count_base()); + k = get_item_index(L, (i - 1), get_count_base()); check_index_range(k, "setcount"); err = set_tex_count_register(k, j); int_par(param_global_defs_code) = save_global_defs; @@ -415,12 +414,12 @@ static int setcount(lua_State * L) { int isglobal = 0; int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; } - return vsetcount (L, isglobal); + return vsetcount(L, isglobal); } static int getcount(lua_State * L) @@ -428,7 +427,7 @@ static int getcount(lua_State * L) int j; integer k; k = get_item_index(L, lua_gettop(L), get_count_base()); - check_index_range(k,"getcount"); + check_index_range(k, "getcount"); j = get_tex_count_register(k); lua_pushnumber(L, j); return 1; @@ -439,13 +438,13 @@ static int vsetattribute(lua_State * L, int is_global) { int i, j, err; integer k; - integer save_global_defs = int_par(param_global_defs_code); + integer save_global_defs = int_par(param_global_defs_code); if (is_global) int_par(param_global_defs_code) = 1; i = lua_gettop(L); j = (int) luaL_checkinteger(L, i); - k = get_item_index(L, (i-1), get_attribute_base()); - check_index_range(k,"setattribute"); + k = get_item_index(L, (i - 1), get_attribute_base()); + check_index_range(k, "setattribute"); err = set_tex_attribute_register(k, j); int_par(param_global_defs_code) = save_global_defs; if (err) { @@ -459,12 +458,12 @@ static int setattribute(lua_State * L) { int isglobal = 0; int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; } - return vsetattribute (L, isglobal); + return vsetattribute(L, isglobal); } static int getattribute(lua_State * L) @@ -472,7 +471,7 @@ static int getattribute(lua_State * L) int j; integer k; k = get_item_index(L, lua_gettop(L), get_attribute_base()); - check_index_range(k,"getattribute"); + check_index_range(k, "getattribute"); j = get_tex_attribute_register(k); lua_pushnumber(L, j); return 1; @@ -484,17 +483,17 @@ int vsettoks(lua_State * L, int is_global) size_t len; integer k; char *st; - integer save_global_defs = int_par(param_global_defs_code); + integer save_global_defs = int_par(param_global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(param_global_defs_code) = 1; i = lua_gettop(L); if (!lua_isstring(L, i)) { lua_pushstring(L, "unsupported value type"); lua_error(L); } st = (char *) lua_tolstring(L, i, &len); - k = get_item_index (L, (i-1), get_toks_base()); - check_index_range(k,"settoks"); + k = get_item_index(L, (i - 1), get_toks_base()); + check_index_range(k, "settoks"); j = maketexlstring(st, len); err = zset_tex_toks_register(k, j); int_par(param_global_defs_code) = save_global_defs; @@ -506,24 +505,24 @@ int vsettoks(lua_State * L, int is_global) return 0; } -static int settoks (lua_State * L) +static int settoks(lua_State * L) { int isglobal = 0; int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; } - return vsettoks (L, isglobal); + return vsettoks(L, isglobal); } static int gettoks(lua_State * L) { integer k; str_number t; - k = get_item_index (L, lua_gettop(L), get_toks_base()); - check_index_range(k,"gettoks"); + k = get_item_index(L, lua_gettop(L), get_toks_base()); + check_index_range(k, "gettoks"); t = get_tex_toks_register(k); lua_pushstring(L, makecstring(t)); flush_str(t); @@ -554,7 +553,7 @@ static int getbox(lua_State * L) { int k, t; k = get_box_id(L, -1); - check_index_range(k,"getbox"); + check_index_range(k, "getbox"); t = get_tex_box_register(k); nodelist_to_lua(L, t); return 1; @@ -563,11 +562,11 @@ static int getbox(lua_State * L) static int vsetbox(lua_State * L, int is_global) { int i, j, k, err; - integer save_global_defs = int_par(param_global_defs_code); + integer save_global_defs = int_par(param_global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(param_global_defs_code) = 1; k = get_box_id(L, -2); - check_index_range(k,"setbox"); + check_index_range(k, "setbox"); i = get_tex_box_register(k); if (lua_isboolean(L, -1)) { j = lua_toboolean(L, -1); @@ -591,12 +590,12 @@ static int setbox(lua_State * L) { int isglobal = 0; int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; } - return vsetbox (L, isglobal); + return vsetbox(L, isglobal); } static int getboxdim(lua_State * L, int whichdim) @@ -640,9 +639,9 @@ int getboxdp(lua_State * L) static int vsetboxdim(lua_State * L, int whichdim, int is_global) { int i, j, k, err; - integer save_global_defs = int_par(param_global_defs_code); + integer save_global_defs = int_par(param_global_defs_code); if (is_global) - int_par(param_global_defs_code) = 1; + int_par(param_global_defs_code) = 1; i = lua_gettop(L); if (!lua_isnumber(L, i)) { j = dimen_to_number(L, (char *) lua_tostring(L, i)); @@ -678,10 +677,10 @@ static int setboxwd(lua_State * L) { int isglobal = 0; int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; } return vsetboxdim(L, width_offset, isglobal); } @@ -690,10 +689,10 @@ static int setboxht(lua_State * L) { int isglobal = 0; int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; } return vsetboxdim(L, height_offset, isglobal); } @@ -702,10 +701,10 @@ static int setboxdp(lua_State * L) { int isglobal = 0; int n = lua_gettop(L); - if (n==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) - isglobal = 1; + if (n == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) + isglobal = 1; } return vsetboxdim(L, depth_offset, isglobal); } @@ -723,9 +722,9 @@ int settex(lua_State * L) st = (char *) lua_tolstring(L, (i - 1), &k); texstr = maketexlstring(st, k); if (is_primitive(texstr)) { - if (i==3 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) + if (i == 3 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) isglobal = 1; } cur_cs = string_lookup(st, k); @@ -733,8 +732,9 @@ int settex(lua_State * L) cur_cmd = zget_eq_type(cur_cs); if (is_int_assign(cur_cmd)) { if (lua_isnumber(L, i)) { - assign_internal_value((isglobal?4:0), zget_equiv(cur_cs), - lua_tonumber(L, i)); + assign_internal_value((isglobal ? 4 : 0), + zget_equiv(cur_cs), lua_tonumber(L, + i)); } else { lua_pushstring(L, "unsupported value type"); lua_error(L); @@ -748,9 +748,10 @@ int settex(lua_State * L) lua_error(L); } } else { - j = (int) lua_tonumber(L, i); + j = (int) lua_tonumber(L, i); } - assign_internal_value((isglobal?4:0), zget_equiv(cur_cs), j); + assign_internal_value((isglobal ? 4 : 0), zget_equiv(cur_cs), + j); } else { lua_pushstring(L, "unsupported tex internal assignment"); lua_error(L); @@ -934,37 +935,37 @@ int do_lastitem(lua_State * L, int cur_code) return retval; } -static int tex_setmathparm (lua_State *L) +static int tex_setmathparm(lua_State * L) { int i, j; scaled k; int n; int l = cur_level; n = lua_gettop(L); - - if ((n == 3) || (n == 4)) { - if (n==4 && lua_isstring(L,1)) { - char *s = (char *)lua_tostring(L,1); - if (strcmp(s,"global")==0) + + if ((n == 3) || (n == 4)) { + if (n == 4 && lua_isstring(L, 1)) { + char *s = (char *) lua_tostring(L, 1); + if (strcmp(s, "global") == 0) l = 1; - } - i = luaL_checkoption(L, (n-2), NULL, math_param_names); - j = luaL_checkoption(L, (n-1), NULL, math_style_names); - k = (scaled)lua_tonumber(L, n); - def_math_param (i,j,k, l); + } + i = luaL_checkoption(L, (n - 2), NULL, math_param_names); + j = luaL_checkoption(L, (n - 1), NULL, math_style_names); + k = (scaled) lua_tonumber(L, n); + def_math_param(i, j, k, l); } return 0; } -static int tex_getmathparm (lua_State *L) +static int tex_getmathparm(lua_State * L) { int i, j; scaled k; if ((lua_gettop(L) == 2)) { i = luaL_checkoption(L, 1, NULL, math_param_names); j = luaL_checkoption(L, 2, NULL, math_style_names); - k = get_math_param (i,j); - lua_pushnumber(L, k); + k = get_math_param(i, j); + lua_pushnumber(L, k); } return 1; } |