[luatex] protect_glyph

luigi scarso luigi.scarso at gmail.com
Mon Jul 4 12:01:03 CEST 2011


On Mon, Jul 4, 2011 at 11:50 AM, Patrick Gundlach <patrick at gundla.ch> wrote:
> Hi,
>
> why is the function protect_glyph called "protect..."? What does it protect?
>
> Patrick
>
>
> (who is slightly embarrassed to ask this question)
>
>
(a little old trunk/source/texk/web2c/luatexdir/lua/lnodelib.c)

static int lua_nodelib_protect_glyphs(lua_State * L)
{
    int t = 0;
    halfword head = *(check_isnode(L, 1));
    while (head != null) {
        if (type(head) == glyph_node) {
            register int s = subtype(head);
            if (s <= 256) {
                t = 1;
                subtype(head) = (quarterword) (s == 1 ? 256 : 256 + s);
            }
        }
        head = vlink(head);
    }
    lua_pushboolean(L, t);
    lua_pushvalue(L, 1);
    return 2;
}

static int lua_nodelib_unprotect_glyphs(lua_State * L)
{
    int t = 0;
    halfword head = *(check_isnode(L, 1));
    while (head != null) {
        if (type(head) == glyph_node) {
            register int s = subtype(head);
            if (s > 256) {
                t = 1;
                subtype(head) = (quarterword) (s - 256);
            }
        }
        head = vlink(head);
    }
    lua_pushboolean(L, t);
    lua_pushvalue(L, 1);
    return 2;
}




-- 
luigi


More information about the luatex mailing list