~ubuntu-branches/ubuntu/natty/luatex/natty

« back to all changes in this revision

Viewing changes to source/texk/web2c/luatexdir/lua/luastuff.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2009-12-25 09:47:05 UTC
  • mfrom: (1.1.9 upstream) (4.2.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091225094705-y33rpflo8t4u9nag
Tags: 0.50.0-1
* new upstream release
* disable fix-hurd-ftbfs patch, included upstream
* disable upstram-fixes, included upstream
* disable ubuntu_libpoppler-0.11, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* luastuff.c
2
2
   
3
 
   Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
 
3
   Copyright 2006-2009 Taco Hoekwater <taco@luatex.org>
4
4
 
5
5
   This file is part of LuaTeX.
6
6
 
17
17
   You should have received a copy of the GNU General Public License along
18
18
   with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
19
19
 
20
 
#include "luatex-api.h"
 
20
static const char _svn_version[] =
 
21
    "$Id: luastuff.c 3217 2009-12-03 16:52:01Z taco $ "
 
22
    "$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.50.0/source/texk/web2c/luatexdir/lua/luastuff.c $";
 
23
 
 
24
#include "lua/luatex-api.h"
21
25
#include <ptexlib.h>
22
26
 
23
 
static const char _svn_version[] =
24
 
    "$Id: luastuff.c 2321 2009-04-18 09:17:13Z hhenkel $ $URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.40.6/source/texk/web2c/luatexdir/lua/luastuff.c $";
25
 
 
26
27
lua_State *Luas = NULL;
27
28
 
28
29
extern char *startup_filename;
129
130
 
130
131
    do_openlibs(L);             /* does all the 'simple' libraries */
131
132
 
 
133
    luatex_md5_lua_open(L);
 
134
 
132
135
    open_oslibext(L, safer_option);
133
136
 
134
 
    lua_getglobal(L, "package");
135
 
    lua_pushstring(L, "");
136
 
    lua_setfield(L, -2, "cpath");
137
 
    lua_pop(L, 1);              /* pop the table */
138
 
 
139
137
    /* luasockets */
140
138
    /* socket and mime are a bit tricky to open because
141
139
     * they use a load-time  dependency that has to be 
170
168
 
171
169
    /* our own libraries */
172
170
    luaopen_ff(L);
173
 
    luaopen_pdf(L);
174
171
    luaopen_tex(L);
175
172
    luaopen_token(L);
176
173
    luaopen_node(L);
183
180
    luaopen_lang(L);
184
181
    luaopen_mplib(L);
185
182
 
 
183
    /* luaopen_pdf(L); */
 
184
    /* environment table at LUA_ENVIRONINDEX needs to load this way: */
 
185
    lua_pushcfunction(L, luaopen_pdf);
 
186
    lua_pushstring(L, "pdf");
 
187
    lua_call(L, 1, 0);
 
188
 
186
189
    /* luaopen_img(L); */
187
190
    lua_pushcfunction(L, luaopen_img);
188
191
    lua_pushstring(L, "img");
274
277
    return 1;
275
278
}
276
279
 
277
 
void luacall(int p, int nameptr)
 
280
/**********************************************************************/
 
281
 
 
282
static void luacall(int p, int nameptr)
278
283
{
279
284
    LoadS ls;
280
285
    int i, l;
324
329
    lua_active--;
325
330
}
326
331
 
 
332
void late_lua(PDF pdf, halfword p)
 
333
{
 
334
    (void) pdf;
 
335
    expand_macros_in_tokenlist(p);      /* sets def_ref */
 
336
    luacall(def_ref, late_lua_name(p));
 
337
    flush_list(def_ref);
 
338
}
 
339
 
 
340
/**********************************************************************/
 
341
 
327
342
void luatokencall(int p, int nameptr)
328
343
{
329
344
    LoadS ls;
369
384
    lua_active--;
370
385
}
371
386
 
372
 
 
373
 
 
374
 
void luatex_load_init(int s, LoadS * ls)
375
 
{
376
 
    ls->s = (const char *) &(str_pool[str_start[s]]);
377
 
    ls->size = str_start[s + 1] - str_start[s];
378
 
}
379
 
 
380
 
 
381
387
lua_State *luatex_error(lua_State * L, int is_fatal)
382
388
{
383
389
 
384
 
    str_number s;
385
390
    const char *luaerr;
386
391
    size_t len = 0;
387
392
    char *err = NULL;
394
399
        /* Normally a memory error from lua. 
395
400
           The pool may overflow during the maketexlstring(), but we 
396
401
           are crashing anyway so we may as well abort on the pool size */
397
 
        s = maketexlstring(err, len);
398
 
        lua_fatal_error(s);
 
402
        lua_fatal_error(err);
399
403
        /* never reached */
400
404
        xfree(err);
401
405
        lua_close(L);
402
406
        return (lua_State *) NULL;
403
407
    } else {
404
 
        s = maketexlstring(err, len);
405
 
        lua_norm_error(s);
406
 
        flush_str(s);
 
408
        lua_norm_error(err);
407
409
        xfree(err);
408
410
        return L;
409
411
    }