summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/lua/luainit.w
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lua/luainit.w')
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/luainit.w114
1 files changed, 93 insertions, 21 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lua/luainit.w b/Build/source/texk/web2c/luatexdir/lua/luainit.w
index e86f7f8d05b..60ec5cc5672 100644
--- a/Build/source/texk/web2c/luatexdir/lua/luainit.w
+++ b/Build/source/texk/web2c/luatexdir/lua/luainit.w
@@ -1,6 +1,6 @@
% luainit.w
%
-% Copyright 2006-2013 Taco Hoekwater <taco@@luatex.org>
+% Copyright 2006-2014 Taco Hoekwater <taco@@luatex.org>
%
% This file is part of LuaTeX.
%
@@ -19,8 +19,8 @@
@ @c
static const char _svn_version[] =
- "$Id: luainit.w 4524 2012-12-20 15:38:02Z taco $"
- "$URL: https://foundry.supelec.fr/svn/luatex/tags/beta-0.76.0/source/texk/web2c/luatexdir/lua/luainit.w $";
+ "$Id: luainit.w 4736 2014-01-08 09:50:31Z luigi $"
+ "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lua/luainit.w $";
#include "ptexlib.h"
@@ -49,14 +49,25 @@ and five environment variables:
@c
const_string LUATEX_IHELP[] = {
+#ifdef LuajitTeX
+ "Usage: luajittex --lua=FILE [OPTION]... [TEXNAME[.tex]] [COMMANDS]",
+ " or: luajittex --lua=FILE [OPTION]... \\FIRST-LINE",
+ " or: luajittex --lua=FILE [OPTION]... &FMT ARGS",
+ " Run LuajitTeX on TEXNAME, usually creating TEXNAME.pdf.",
+#else
"Usage: luatex --lua=FILE [OPTION]... [TEXNAME[.tex]] [COMMANDS]",
" or: luatex --lua=FILE [OPTION]... \\FIRST-LINE",
" or: luatex --lua=FILE [OPTION]... &FMT ARGS",
" Run LuaTeX on TEXNAME, usually creating TEXNAME.pdf.",
+#endif
" Any remaining COMMANDS are processed as luatex input, after TEXNAME is read.",
"",
" Alternatively, if the first non-option argument begins with a backslash,",
+#ifdef LuajitTeX
+ " luajittex interprets all non-option arguments as an input line.",
+#else
" luatex interprets all non-option arguments as an input line.",
+#endif
"",
" Alternatively, if the first non-option argument begins with a &, the",
" next word is taken as the FMT to read, overriding all else. Any",
@@ -103,6 +114,9 @@ const_string LUATEX_IHELP[] = {
"",
" --luaonly run a lua file, then exit",
" --luaconly byte-compile a lua file, then exit",
+#ifdef LuajitTeX
+ " --jiton turns the JIT compiler on (default off)",
+#endif
"",
"See the reference manual for more information about the startup process.",
NULL
@@ -169,6 +183,9 @@ static string user_progname = NULL;
char *startup_filename = NULL;
int lua_only = 0;
int lua_offset = 0;
+#ifdef LuajitTeX
+int luajiton = 0;
+#endif
int safer_option = 0;
int nosocket_option = 0;
@@ -187,6 +204,9 @@ static struct option long_options[]
= { {"fmt", 1, 0, 0},
{"lua", 1, 0, 0},
{"luaonly", 0, 0, 0},
+#ifdef LuajitTeX
+{"jiton", 0, 0, 0},
+#endif
{"safer", 0, &safer_option, 1},
{"nosocket", 0, &nosocket_option, 1},
{"help", 0, 0, 0},
@@ -262,6 +282,10 @@ static void parse_options(int ac, char **av)
startup_filename = optarg;
lua_offset = (optind - 1);
luainit = 1;
+#ifdef LuajitTeX
+ } else if (ARGUMENT_IS("jiton")) {
+ luajiton = 1;
+#endif
} else if (ARGUMENT_IS("kpathsea-debug")) {
kpathsea_debug |= atoi(optarg);
@@ -341,12 +365,21 @@ static void parse_options(int ac, char **av)
} else if (ARGUMENT_IS("version")) {
print_version_banner();
/* *INDENT-OFF* */
+#ifdef LuajitTeX
+ puts("\n\nExecute 'luajittex --credits' for credits and version details.\n\n"
+#else
puts("\n\nExecute 'luatex --credits' for credits and version details.\n\n"
+#endif
"There is NO warranty. Redistribution of this software is covered by\n"
"the terms of the GNU General Public License, version 2 or (at your option)\n"
"any later version. For more information about these matters, see the file\n"
"named COPYING and the LuaTeX source.\n\n"
- "Copyright 2013 Taco Hoekwater, the LuaTeX Team.\n");
+#ifdef LuajitTeX
+ "LuaTeX is Copyright 2014 Taco Hoekwater, the LuaTeX Team.\n"
+ "Libraries and JIT extensions by Luigi Scarso, the LuaTeX SwigLib team.\n");
+#else
+ "Copyright 2014 Taco Hoekwater, the LuaTeX Team.\n");
+#endif
/* *INDENT-ON* */
uexit(0);
} else if (ARGUMENT_IS("credits")) {
@@ -355,7 +388,11 @@ static void parse_options(int ac, char **av)
print_version_banner();
/* *INDENT-OFF* */
puts("\n\nThe LuaTeX team is Hans Hagen, Hartmut Henkel, Taco Hoekwater.\n"
+#ifdef LuajitTex
+ "LuajitTeX merges and builds upon (parts of) the code from these projects:\n\n"
+#else
"LuaTeX merges and builds upon (parts of) the code from these projects:\n\n"
+#endif
"tex by Donald Knuth\n"
"etex by Peter Breitenlohner, Phil Taylor and friends\n"
"omega by John Plaice and Yannis Haralambous\n"
@@ -366,11 +403,21 @@ static void parse_options(int ac, char **av)
" Luiz Henrique de Figueiredo\n"
"metapost by John Hobby, Taco Hoekwater and friends.\n"
"poppler by Derek Noonburg, Kristian H\\ogsberg (partial)\n"
+#ifdef LuajitTeX
+ "fontforge by George Williams (partial)\n"
+ "luajit by Mike Pall\n\n"
+#else
"fontforge by George Williams (partial)\n\n"
+#endif
"Some extensions to lua and additional lua libraries are used, as well as\n"
"libraries for graphic inclusion. More details can be found in the source.\n"
"Code development was sponsored by a grant from Colorado State University\n"
+#ifdef LuajitTeX
+ "via the 'oriental tex' project, the TeX User Groups, and donations.\n"
+ "The additional libraries and the LuaJIT extensions are provided by the LuaTeX SwigLib project.\n");
+#else
"via the 'oriental tex' project, the TeX User Groups, and donations.\n");
+#endif
/* *INDENT-ON* */
puts(versions);
uexit(0);
@@ -613,12 +660,24 @@ static int luatex_kpse_clua_find(lua_State * L)
const char *path_saved;
char *prefix, *postfix, *p, *total;
char *extensionless;
+ char *temp_name;
+ int j;
filename = luatex_kpse_find_aux(L, name, kpse_clua_format, "C");
if (filename == NULL)
return 1; /* library not found in this path */
extensionless = strdup(filename);
if (!extensionless) return 1; /* allocation failure */
- p = strstr(extensionless, name);
+ /* Fix Issue 850: replace '.' with LUA_DIRSEP */
+ temp_name = strdup(name);
+ for(j=0; ; j++){
+ if ((unsigned char)temp_name[j]=='\0') {
+ break;
+ }
+ if ((unsigned char)temp_name[j]=='.'){
+ temp_name[j]=LUA_DIRSEP[0];
+ }
+ }
+ p = strstr(extensionless, temp_name);
if (!p) return 1; /* this would be exceedingly weird */
*p = '\0';
prefix = strdup(extensionless);
@@ -648,6 +707,7 @@ static int luatex_kpse_clua_find(lua_State * L)
lua_pop(L,1); /* pop "package" */
free(extensionless);
free(total);
+ free(temp_name);
return 1;
}
}
@@ -661,7 +721,11 @@ functions defined above.
static void setup_lua_path(lua_State * L)
{
lua_getglobal(L, "package");
+#ifdef LuajitTeX
+ lua_getfield(L, -1, "loaders");
+#else
lua_getfield(L, -1, "searchers");
+#endif
lua_rawgeti(L, -1, 2); /* package.searchers[2] */
lua_loader_function = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushcfunction(L, luatex_kpse_lua_find);
@@ -752,29 +816,28 @@ void lua_initialize(int ac, char **av)
argc = ac;
argv = av;
+
if (luatex_svn < 0) {
- const char *fmt = "This is LuaTeX, Version %s-%s " WEB2CVERSION;
+#ifdef LuajitTeX
+ const char *fmt = "This is LuajitTeX, Version %s" WEB2CVERSION;
+#else
+ const char *fmt = "This is LuaTeX, Version %s" WEB2CVERSION;
+#endif
size_t len;
- char buf[16];
- sprintf(buf, "%d", luatex_date_info);
- len = strlen(fmt) + strlen(luatex_version_string) + strlen(buf) - 3;
-
- /* len is just enough, because of the placeholder chars in fmt
- that get replaced by the arguments. */
+ len = strlen(fmt) + strlen(luatex_version_string) ;
+
banner = xmalloc(len);
- sprintf(banner, fmt, luatex_version_string, buf);
+ sprintf(banner, fmt, luatex_version_string);
} else {
- const char *fmt = "This is LuaTeX, Version %s%s" WEB2CVERSION " (rev %d)";
- size_t len;
- char buf[18];
-#ifndef NATIVE_TEXLIVE_BUILD
- sprintf(buf, "-%d", luatex_date_info);
+#ifdef LuajitTeX
+ const char *fmt = "This is LuajitTeX, Version %s" WEB2CVERSION " (rev %d)";
#else
- buf[0] = 0; /* TL: skip datestamp provoking ever-changing binaries */
+ const char *fmt = "This is LuaTeX, Version %s" WEB2CVERSION " (rev %d)";
#endif
- len = strlen(fmt) + strlen(luatex_version_string) + strlen(buf) + 6;
+ size_t len;
+ len = strlen(fmt) + strlen(luatex_version_string) + 6;
banner = xmalloc(len);
- sprintf(banner, fmt, luatex_version_string, buf, luatex_svn);
+ sprintf(banner, fmt, luatex_version_string, luatex_svn);
}
ptexbanner = banner;
@@ -782,12 +845,21 @@ void lua_initialize(int ac, char **av)
/* be 'luac' */
if (argc >1) {
+#ifdef LuajitTeX
+ if (FILESTRCASEEQ(kpse_invocation_name, "texluajitc"))
+ exit(luac_main(ac, av));
+ if (STREQ(argv[1], "--luaconly") || STREQ(argv[1], "--luac")) {
+ strcpy(av[1], "luajittex");
+ exit(luac_main(--ac, ++av));
+ }
+#else
if (FILESTRCASEEQ(kpse_invocation_name, "texluac"))
exit(luac_main(ac, av));
if (STREQ(argv[1], "--luaconly") || STREQ(argv[1], "--luac")) {
strcpy(av[1], "luatex");
exit(luac_main(--ac, ++av));
}
+#endif
}
#if defined(WIN32) || defined(__MINGW32__) || defined(__CYGWIN__)
mk_suffixlist();