summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-01-27 14:32:55 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2016-01-27 14:32:55 +0000
commit89b29626b49977810c7a8f59d83e51a223227f89 (patch)
tree95eae48bd19cfdcf4a1bc43c3937049a1d0b9245 /Build
parent2e8cab52576c48c7338f064da518f7f197af72b3 (diff)
web2c/luatexdir: sync with the upstream
git-svn-id: svn://tug.org/texlive/trunk@39495 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/luatexdir/font/writet3.w16
-rw-r--r--Build/source/texk/web2c/luatexdir/lua/lpdflib.c57
-rw-r--r--Build/source/texk/web2c/luatexdir/luapeg/lpeg.c213
-rw-r--r--Build/source/texk/web2c/luatexdir/luapeg/lpeg.h78
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdfgen.w2
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftables.h4
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdftypes.h1
-rw-r--r--Build/source/texk/web2c/luatexdir/tex/textoken.w1
8 files changed, 218 insertions, 154 deletions
diff --git a/Build/source/texk/web2c/luatexdir/font/writet3.w b/Build/source/texk/web2c/luatexdir/font/writet3.w
index 005d2795fc3..c7cc79a722f 100644
--- a/Build/source/texk/web2c/luatexdir/font/writet3.w
+++ b/Build/source/texk/web2c/luatexdir/font/writet3.w
@@ -91,7 +91,8 @@ static boolean writepk(PDF pdf, internal_font_number f)
char *name;
chardesc cd;
boolean is_null_glyph, check_preamble;
- int dpi;
+ int dpi = 0;
+ int newdpi = 0;
int callback_id = 0;
int file_opened = 0;
xfree(t3_buffer);
@@ -100,11 +101,17 @@ static boolean writepk(PDF pdf, internal_font_number f)
callback_id = callback_defined(find_pk_file_callback);
+ if (pdf->pk_fixed_dpi) {
+ newdpi = pdf->pk_resolution;
+ } else {
+ newdpi = dpi;
+ }
+
if (callback_id > 0) {
/* <base>.dpi/<fontname>.<tdpi>pk */
dpi = round((float) pdf->pk_resolution * (((float) font_size(f)) / (float) font_dsize(f)));
cur_file_name = font_name(f);
- run_callback(callback_id, "Sd->S", cur_file_name, (int) dpi, &name);
+ run_callback(callback_id, "Sd->S", cur_file_name, (int) newdpi, &name);
if (name == NULL || strlen(name) == 0) {
formatted_warning("type 3","font %s at %i not found", cur_file_name, (int) dpi);
return false;
@@ -171,7 +178,10 @@ static boolean writepk(PDF pdf, internal_font_number f)
pdf_printf(pdf, " 0 %i %i %i %i d1\n", (int) llx, (int) lly, (int) urx, (int) ury);
if (is_null_glyph)
goto end_stream;
- pdf_printf(pdf, "q\n%i 0 0 %i %i %i cm\nBI\n", (int) cd.cwidth, (int) cd.cheight, (int) llx, (int) lly);
+ pdf_printf(pdf, "q\n%i 0 0 %i %i %i cm\nBI\n",
+ (int) (dpi * cd.cwidth / newdpi),
+ (int) (dpi * cd.cheight / newdpi),
+ (int) llx, (int) lly);
pdf_printf(pdf, "/W %i\n/H %i\n", (int) cd.cwidth, (int) cd.cheight);
pdf_puts(pdf, "/IM true\n/BPC 1\n/D [1 0]\nID ");
cw = (cd.cwidth + 7) / 8;
diff --git a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
index 334571b215d..cb7aa5aba35 100644
--- a/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
+++ b/Build/source/texk/web2c/luatexdir/lua/lpdflib.c
@@ -800,9 +800,8 @@ static int l_get_objcompresslevel(lua_State * L)
static int l_set_compresslevel(lua_State * L)
{
- int c ;
if (lua_type(L, 1) == LUA_TNUMBER) {
- c = (int) lua_tointeger(L, 1);
+ int c = (int) lua_tointeger(L, 1);
if (c<0)
c = 0 ;
else if (c>9)
@@ -814,9 +813,8 @@ static int l_set_compresslevel(lua_State * L)
static int l_set_objcompresslevel(lua_State * L)
{
- int c ;
if (lua_type(L, 1) == LUA_TNUMBER) {
- c = (int) lua_tointeger(L, 1);
+ int c = (int) lua_tointeger(L, 1);
if (c<0)
c = 0 ;
else if (c>9)
@@ -834,19 +832,44 @@ static int l_get_decimal_digits(lua_State * L)
return 1 ;
}
-
static int l_set_decimal_digits(lua_State * L)
{
- int c ;
if (lua_type(L, 1) == LUA_TNUMBER) {
- c = (int) lua_tointeger(L, 1);
- if (c<0)
+ int c = (int) lua_tointeger(L, 1);
+ if (c<0) {
c = 0 ;
+ }
set_pdf_decimal_digits(c);
}
return 0 ;
}
+/* pk */
+
+static int l_get_pk_resolution(lua_State * L)
+{
+ lua_pushinteger(L, (pdf_pk_resolution));
+ lua_pushinteger(L, (pdf_pk_fixed_dpi));
+ return 2 ;
+}
+
+static int l_set_pk_resolution(lua_State * L)
+{
+ if (lua_type(L, 1) == LUA_TNUMBER) {
+ int c = (int) lua_tointeger(L, 1);
+ if (c < 72) {
+ c = 72 ;
+ } else if (c > 8000) {
+ c = 8000 ;
+ }
+ set_pdf_pk_resolution(c);
+ }
+ if (lua_type(L, 2) == LUA_TNUMBER) {
+ set_pdf_pk_fixed_dpi(lua_tointeger(L, 1));
+ }
+ return 0 ;
+}
+
/* pdf stuff */
static int getpdffontname(lua_State * L)
@@ -867,9 +890,9 @@ static int getpdffontname(lua_State * L)
static int getpdffontobjnum(lua_State * L)
{
- int c, ff ;
if (lua_type(L, 1) == LUA_TNUMBER) {
- c = (int) lua_tointeger(L, 1);
+ int ff;
+ int c = (int) lua_tointeger(L, 1);
pdf_check_vf(c);
if (!font_used(c))
pdf_init_font(static_pdf,c);
@@ -883,9 +906,8 @@ static int getpdffontobjnum(lua_State * L)
static int getpdffontsize(lua_State * L)
{
- int c;
if (lua_type(L, 1) == LUA_TNUMBER) {
- c = (int) lua_tointeger(L, 1);
+ int c = (int) lua_tointeger(L, 1);
lua_pushinteger(L, (font_size(c)));
} else {
lua_pushnil(L);
@@ -895,9 +917,8 @@ static int getpdffontsize(lua_State * L)
static int getpdfpageref(lua_State * L)
{
- int c ;
if (lua_type(L, 1) == LUA_TNUMBER) {
- c = (int) lua_tointeger(L, 1);
+ int c = (int) lua_tointeger(L, 1);
lua_pushinteger(L, (pdf_get_obj(static_pdf, obj_type_page, c, false)));
} else {
lua_pushnil(L);
@@ -907,9 +928,8 @@ static int getpdfpageref(lua_State * L)
static int getpdfxformname(lua_State * L)
{
- int c ;
if (lua_type(L, 1) == LUA_TNUMBER) {
- c = (int) lua_tointeger(L, 1);
+ int c = (int) lua_tointeger(L, 1);
check_obj_type(static_pdf, obj_type_xform, c);
lua_pushinteger(L, (obj_info(static_pdf, c)));
} else {
@@ -933,9 +953,8 @@ static int getpdfminorversion(lua_State * L)
static int setpdfminorversion(lua_State * L)
{
- int c ;
if (lua_type(L, 1) == LUA_TNUMBER) {
- c = (int) lua_tointeger(L, 1);
+ int c = (int) lua_tointeger(L, 1);
if ((c >= 0) && (c <= 9)) {
static_pdf->minor_version = c;
set_pdf_minor_version(c);
@@ -1115,6 +1134,8 @@ static const struct luaL_Reg pdflib[] = {
{ "setobjcompresslevel", l_set_objcompresslevel },
{ "getdecimaldigits", l_get_decimal_digits },
{ "setdecimaldigits", l_set_decimal_digits },
+ { "getpkresolution", l_get_pk_resolution },
+ { "setpkresolution", l_set_pk_resolution },
/* moved from tex table */
{ "fontname", getpdffontname },
{ "fontobjnum", getpdffontobjnum },
diff --git a/Build/source/texk/web2c/luatexdir/luapeg/lpeg.c b/Build/source/texk/web2c/luatexdir/luapeg/lpeg.c
index 12c7ea42d36..30f54522de5 100644
--- a/Build/source/texk/web2c/luatexdir/luapeg/lpeg.c
+++ b/Build/source/texk/web2c/luatexdir/luapeg/lpeg.c
@@ -1,20 +1,18 @@
-
#include "lpeg.h"
-
/*
-** $Id: lpprint.c,v 1.7 2013/04/12 16:29:49 roberto Exp $
+** $Id: lpprint.c,v 1.9 2015/06/15 16:09:57 roberto Exp $
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
-/* #include <ctype.h>*/
-/* #include <limits.h>*/
-/* #include <stdio.h>*/
+/* #include <ctype.h> */
+/* #include <limits.h> */
+/* #include <stdio.h> */
-/* #include "lptypes.h"*/
-/* #include "lpprint.h"*/
-/* #include "lpcode.h"*/
+/* #include "lptypes.h" */
+/* #include "lpprint.h" */
+/* #include "lpcode.h" */
#if defined(LPEG_DEBUG)
@@ -56,7 +54,7 @@ static void printjmp (const Instruction *op, const Instruction *p) {
}
-static void printinst (const Instruction *op, const Instruction *p) {
+void printinst (const Instruction *op, const Instruction *p) {
const char *const names[] = {
"any", "char", "set",
"testany", "testchar", "testset",
@@ -225,10 +223,10 @@ void printtree (TTree *tree, int ident) {
void printktable (lua_State *L, int idx) {
int n, i;
- lua_getfenv(L, idx);
+ lua_getuservalue(L, idx);
if (lua_isnil(L, -1)) /* no ktable? */
return;
- n = lua_objlen(L, -1);
+ n = lua_rawlen(L, -1);
printf("[");
for (i = 1; i <= n; i++) {
printf("%d = ", i);
@@ -246,27 +244,28 @@ void printktable (lua_State *L, int idx) {
/* }====================================================== */
#endif
+
/*
-** $Id: lpvm.c,v 1.5 2013/04/12 16:29:49 roberto Exp $
+** $Id: lpvm.c,v 1.6 2015/09/28 17:01:25 roberto Exp $
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
-/* #include <limits.h>*/
-/* #include <string.h>*/
+/* #include <limits.h> */
+/* #include <string.h> */
-/* #include "lua.h"*/
-/* #include "lauxlib.h"*/
+/* #include "lua.h" */
+/* #include "lauxlib.h" */
-/* #include "lpcap.h"*/
-/* #include "lptypes.h"*/
-/* #include "lpvm.h"*/
-/* #include "lpprint.h"*/
+/* #include "lpcap.h" */
+/* #include "lptypes.h" */
+/* #include "lpvm.h" */
+/* #include "lpprint.h" */
/* initial size for call/backtrack stack */
#if !defined(INITBACK)
-#define INITBACK 100
+#define INITBACK MAXBACK
#endif
@@ -318,7 +317,7 @@ static Stack *doublestack (lua_State *L, Stack **stacklimit, int ptop) {
max = lua_tointeger(L, -1); /* maximum allowed size */
lua_pop(L, 1);
if (n >= max) /* already at maximum size? */
- luaL_error(L, "too many pending calls/choices");
+ luaL_error(L, "backtrack stack overflow (current limit is %d)", max);
newn = 2 * n; /* new size */
if (newn > max) newn = max;
newstack = (Stack *)lua_newuserdata(L, newn * sizeof(Stack));
@@ -602,18 +601,18 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
/*
-** $Id: lpcode.c,v 1.21 2014/12/12 17:01:29 roberto Exp $
+** $Id: lpcode.c,v 1.23 2015/06/12 18:36:47 roberto Exp $
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
-/* #include <limits.h>*/
+/* #include <limits.h> */
-/* #include "lua.h"*/
-/* #include "lauxlib.h"*/
+/* #include "lua.h" */
+/* #include "lauxlib.h" */
-/* #include "lptypes.h"*/
-/* #include "lpcode.h"*/
+/* #include "lptypes.h" */
+/* #include "lpcode.h" */
/* signals a "no-instruction */
@@ -1034,11 +1033,11 @@ typedef struct CompileState {
/*
-** code generation is recursive; 'opt' indicates that the code is
-** being generated under a 'IChoice' operator jumping to its end
-** (that is, the match is "optional").
-** 'tt' points to a previous test protecting this code. 'fl' is
-** the follow set of the pattern.
+** code generation is recursive; 'opt' indicates that the code is being
+** generated as the last thing inside an optional pattern (so, if that
+** code is optional too, it can reuse the 'IChoice' already in place for
+** the outer pattern). 'tt' points to a previous test protecting this
+** code (or NOINST). 'fl' is the follow set of the pattern.
*/
static void codegen (CompileState *compst, TTree *tree, int opt, int tt,
const Charset *fl);
@@ -1241,13 +1240,13 @@ static void codebehind (CompileState *compst, TTree *tree) {
/*
** Choice; optimizations:
-** - when p1 is headfail
-** - when first(p1) and first(p2) are disjoint; than
+** - when p1 is headfail or
+** when first(p1) and first(p2) are disjoint, than
** a character not in first(p1) cannot go to p1, and a character
** in first(p1) cannot go to p2 (at it is not in first(p2)).
** (The optimization is not valid if p1 accepts the empty string,
** as then there is no character at all...)
-** - when p2 is empty and opt is true; a IPartialCommit can resuse
+** - when p2 is empty and opt is true; a IPartialCommit can reuse
** the Choice already active in the stack.
*/
static void codechoice (CompileState *compst, TTree *p1, TTree *p2, int opt,
@@ -1274,7 +1273,7 @@ static void codechoice (CompileState *compst, TTree *p1, TTree *p2, int opt,
}
else {
/* <p1 / p2> ==
- test(fail(p1)) -> L1; choice L1; <p1>; commit L2; L1: <p2>; L2: */
+ test(first(p1)) -> L1; choice L1; <p1>; commit L2; L1: <p2>; L2: */
int pcommit;
int test = codetestset(compst, &cs1, e1);
int pchoice = addoffsetinst(compst, IChoice);
@@ -1362,7 +1361,7 @@ static void coderep (CompileState *compst, TTree *tree, int opt,
/* L1: test (fail(p1)) -> L2; <p>; jmp L1; L2: */
int jmp;
int test = codetestset(compst, &st, 0);
- codegen(compst, tree, opt, test, fullset);
+ codegen(compst, tree, 0, test, fullset);
jmp = addoffsetinst(compst, IJmp);
jumptohere(compst, test);
jumptothere(compst, jmp, test);
@@ -1587,16 +1586,18 @@ Instruction *compile (lua_State *L, Pattern *p) {
/* }====================================================== */
+
+
/*
-** $Id: lpcap.c,v 1.5 2014/12/12 16:58:47 roberto Exp $
+** $Id: lpcap.c,v 1.6 2015/06/15 16:09:57 roberto Exp $
** Copyright 2007, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
-/* #include "lua.h"*/
-/* #include "lauxlib.h"*/
+/* #include "lua.h" */
+/* #include "lauxlib.h" */
-/* #include "lpcap.h"*/
-/* #include "lptypes.h"*/
+/* #include "lpcap.h" */
+/* #include "lptypes.h" */
#define captype(cap) ((cap)->kind)
@@ -1715,7 +1716,7 @@ static Capture *findback (CapState *cs, Capture *cap) {
continue; /* opening an enclosing capture: skip and get previous */
if (captype(cap) == Cgroup) {
getfromktable(cs, cap->idx); /* get group name */
- if (lua_equal(L, -2, -1)) { /* right group? */
+ if (lp_equal(L, -2, -1)) { /* right group? */
lua_pop(L, 2); /* remove reference name and group name */
return cap;
}
@@ -2125,23 +2126,23 @@ int getcaptures (lua_State *L, const char *s, const char *r, int ptop) {
/*
-** $Id: lptree.c,v 1.15 2015/03/04 17:23:00 roberto Exp $
+** $Id: lptree.c,v 1.21 2015/09/28 17:01:25 roberto Exp $
** Copyright 2013, Lua.org & PUC-Rio (see 'lpeg.html' for license)
*/
-/* #include <ctype.h>*/
-/* #include <limits.h>*/
-/* #include <string.h>*/
+/* #include <ctype.h> */
+/* #include <limits.h> */
+/* #include <string.h> */
-/* #include "lua.h"*/
-/* #include "lauxlib.h"*/
+/* #include "lua.h" */
+/* #include "lauxlib.h" */
-/* #include "lptypes.h"*/
-/* #include "lpcap.h"*/
-/* #include "lpcode.h"*/
-/* #include "lpprint.h"*/
-/* #include "lptree.h"*/
+/* #include "lptypes.h" */
+/* #include "lpcap.h" */
+/* #include "lpcode.h" */
+/* #include "lpprint.h" */
+/* #include "lptree.h" */
/* number of siblings for each tree */
@@ -2272,7 +2273,7 @@ static void finalfix (lua_State *L, int postable, TTree *g, TTree *t) {
*/
static void newktable (lua_State *L, int n) {
lua_createtable(L, n, 0); /* create a fresh table */
- lua_setfenv(L, -2); /* set it as 'ktable' for pattern */
+ lua_setuservalue(L, -2); /* set it as 'ktable' for pattern */
}
@@ -2287,8 +2288,8 @@ static int addtoktable (lua_State *L, int idx) {
return 0;
else {
int n;
- lua_getfenv(L, -1); /* get ktable from pattern */
- n = lua_objlen(L, -1);
+ lua_getuservalue(L, -1); /* get ktable from pattern */
+ n = lua_rawlen(L, -1);
if (n >= USHRT_MAX)
luaL_error(L, "too many Lua values in pattern");
lua_pushvalue(L, idx); /* element to be added */
@@ -2307,7 +2308,7 @@ static int addtoktable (lua_State *L, int idx) {
*/
static int ktablelen (lua_State *L, int idx) {
if (!lua_istable(L, idx)) return 0;
- else return lua_objlen(L, idx);
+ else return lua_rawlen(L, idx);
}
@@ -2370,18 +2371,18 @@ static void correctkeys (TTree *tree, int n) {
*/
static void joinktables (lua_State *L, int p1, TTree *t2, int p2) {
int n1, n2;
- lua_getfenv(L, p1); /* get ktables */
- lua_getfenv(L, p2);
+ lua_getuservalue(L, p1); /* get ktables */
+ lua_getuservalue(L, p2);
n1 = ktablelen(L, -2);
n2 = ktablelen(L, -1);
if (n1 == 0 && n2 == 0) /* are both tables empty? */
lua_pop(L, 2); /* nothing to be done; pop tables */
- else if (n2 == 0 || lua_equal(L, -2, -1)) { /* 2nd table empty or equal? */
+ else if (n2 == 0 || lp_equal(L, -2, -1)) { /* 2nd table empty or equal? */
lua_pop(L, 1); /* pop 2nd table */
- lua_setfenv(L, -2); /* set 1st ktable into new pattern */
+ lua_setuservalue(L, -2); /* set 1st ktable into new pattern */
}
else if (n1 == 0) { /* first table is empty? */
- lua_setfenv(L, -3); /* set 2nd table into new pattern */
+ lua_setuservalue(L, -3); /* set 2nd table into new pattern */
lua_pop(L, 1); /* pop 1st table */
}
else {
@@ -2389,7 +2390,7 @@ static void joinktables (lua_State *L, int p1, TTree *t2, int p2) {
/* stack: new p; ktable p1; ktable p2; new ktable */
concattable(L, -3, -1); /* from p1 into new ktable */
concattable(L, -2, -1); /* from p2 into new ktable */
- lua_setfenv(L, -4); /* new ktable becomes 'p' environment */
+ lua_setuservalue(L, -4); /* new ktable becomes 'p' environment */
lua_pop(L, 2); /* pop other ktables */
correctkeys(t2, n1); /* correction for indices from p2 */
}
@@ -2400,8 +2401,8 @@ static void joinktables (lua_State *L, int p1, TTree *t2, int p2) {
** copy 'ktable' of element 'idx' to new tree (on top of stack)
*/
static void copyktable (lua_State *L, int idx) {
- lua_getfenv(L, idx);
- lua_setfenv(L, -2);
+ lua_getuservalue(L, idx);
+ lua_setuservalue(L, -2);
}
@@ -2412,8 +2413,8 @@ static void copyktable (lua_State *L, int idx) {
*/
static void mergektable (lua_State *L, int idx, TTree *stree) {
int n;
- lua_getfenv(L, -1); /* get ktables */
- lua_getfenv(L, idx);
+ lua_getuservalue(L, -1); /* get ktables */
+ lua_getuservalue(L, idx);
n = concattable(L, -1, -2);
lua_pop(L, 2); /* remove both ktables */
correctkeys(stree, n);
@@ -2464,7 +2465,7 @@ static Pattern *getpattern (lua_State *L, int idx) {
static int getsize (lua_State *L, int idx) {
- return (lua_objlen(L, idx) - sizeof(Pattern)) / sizeof(TTree) + 1;
+ return (lua_rawlen(L, idx) - sizeof(Pattern)) / sizeof(TTree) + 1;
}
@@ -2477,12 +2478,16 @@ static TTree *gettree (lua_State *L, int idx, int *len) {
/*
-** create a pattern
+** create a pattern. Set its uservalue (the 'ktable') equal to its
+** metatable. (It could be any empty sequence; the metatable is at
+** hand here, so we use it.)
*/
static TTree *newtree (lua_State *L, int len) {
size_t size = (len - 1) * sizeof(TTree) + sizeof(Pattern);
Pattern *p = (Pattern *)lua_newuserdata(L, size);
luaL_getmetatable(L, PATTERN_T);
+ lua_pushvalue(L, -1);
+ lua_setuservalue(L, -3);
lua_setmetatable(L, -2);
p->code = NULL; p->codesize = 0;
return p->tree;
@@ -2803,7 +2808,7 @@ static int lp_behind (lua_State *L) {
TTree *tree;
TTree *tree1 = getpatt(L, 1, NULL);
int n = fixedlen(tree1);
- luaL_argcheck(L, n > 0, 1, "pattern may not have fixed length");
+ luaL_argcheck(L, n >= 0, 1, "pattern may not have fixed length");
luaL_argcheck(L, !hascaptures(tree1), 1, "pattern have captures");
luaL_argcheck(L, n <= MAXBEHIND, 1, "pattern too long to look behind");
tree = newroot1sib(L, TBehind);
@@ -2900,10 +2905,8 @@ static int lp_tablecapture (lua_State *L) {
static int lp_groupcapture (lua_State *L) {
if (lua_isnoneornil(L, 2))
return capture_aux(L, Cgroup, 0);
- else {
- luaL_checkstring(L, 2);
+ else
return capture_aux(L, Cgroup, 2);
- }
}
@@ -2934,7 +2937,7 @@ static int lp_argcapture (lua_State *L) {
static int lp_backref (lua_State *L) {
- luaL_checkstring(L, 1);
+ luaL_checkany(L, 1);
newemptycapkey(L, Cbackref, 1);
return 1;
}
@@ -3032,7 +3035,7 @@ static int collectrules (lua_State *L, int arg, int *totalsize) {
lua_pushnil(L); /* prepare to traverse grammar table */
while (lua_next(L, arg) != 0) {
if (lua_tonumber(L, -2) == 1 ||
- lua_equal(L, -2, postab + 1)) { /* initial rule? */
+ lp_equal(L, -2, postab + 1)) { /* initial rule? */
lua_pop(L, 1); /* remove value (keep key for lua_next) */
continue;
}
@@ -3109,36 +3112,40 @@ static int verifyerror (lua_State *L, int *passed, int npassed) {
/*
** Check whether a rule can be left recursive; raise an error in that
-** case; otherwise return 1 iff pattern is nullable. Assume ktable at
-** the top of the stack.
+** case; otherwise return 1 iff pattern is nullable.
+** The return value is used to check sequences, where the second pattern
+** is only relevant if the first is nullable.
+** Parameter 'nb' works as an accumulator, to allow tail calls in
+** choices. ('nb' true makes function returns true.)
+** Assume ktable at the top of the stack.
*/
static int verifyrule (lua_State *L, TTree *tree, int *passed, int npassed,
- int nullable) {
+ int nb) {
tailcall:
switch (tree->tag) {
case TChar: case TSet: case TAny:
case TFalse:
- return nullable; /* cannot pass from here */
+ return nb; /* cannot pass from here */
case TTrue:
case TBehind: /* look-behind cannot have calls */
return 1;
case TNot: case TAnd: case TRep:
/* return verifyrule(L, sib1(tree), passed, npassed, 1); */
- tree = sib1(tree); nullable = 1; goto tailcall;
+ tree = sib1(tree); nb = 1; goto tailcall;
case TCapture: case TRunTime:
- /* return verifyrule(L, sib1(tree), passed, npassed); */
+ /* return verifyrule(L, sib1(tree), passed, npassed, nb); */
tree = sib1(tree); goto tailcall;
case TCall:
- /* return verifyrule(L, sib2(tree), passed, npassed); */
+ /* return verifyrule(L, sib2(tree), passed, npassed, nb); */
tree = sib2(tree); goto tailcall;
- case TSeq: /* only check 2nd child if first is nullable */
+ case TSeq: /* only check 2nd child if first is nb */
if (!verifyrule(L, sib1(tree), passed, npassed, 0))
- return nullable;
- /* else return verifyrule(L, sib2(tree), passed, npassed); */
+ return nb;
+ /* else return verifyrule(L, sib2(tree), passed, npassed, nb); */
tree = sib2(tree); goto tailcall;
case TChoice: /* must check both children */
- nullable = verifyrule(L, sib1(tree), passed, npassed, nullable);
- /* return verifyrule(L, sib2(tree), passed, npassed, nullable); */
+ nb = verifyrule(L, sib1(tree), passed, npassed, nb);
+ /* return verifyrule(L, sib2(tree), passed, npassed, nb); */
tree = sib2(tree); goto tailcall;
case TRule:
if (npassed >= MAXRULES)
@@ -3181,7 +3188,7 @@ static void verifygrammar (lua_State *L, TTree *grammar) {
*/
static void initialrulename (lua_State *L, TTree *grammar, int frule) {
if (sib1(grammar)->key == 0) { /* initial rule is not referenced? */
- int n = lua_objlen(L, -1) + 1; /* index for name */
+ int n = lua_rawlen(L, -1) + 1; /* index for name */
lua_pushvalue(L, frule); /* rule's name */
lua_rawseti(L, -2, n); /* ktable was on the top of the stack */
sib1(grammar)->key = n;
@@ -3197,9 +3204,9 @@ static TTree *newgrammar (lua_State *L, int arg) {
luaL_argcheck(L, n <= MAXRULES, arg, "grammar has too many rules");
g->tag = TGrammar; g->u.n = n;
lua_newtable(L); /* create 'ktable' */
- lua_setfenv(L, -2);
+ lua_setuservalue(L, -2);
buildgrammar(L, g, frule, n);
- lua_getfenv(L, -1); /* get 'ktable' for new tree */
+ lua_getuservalue(L, -1); /* get 'ktable' for new tree */
finalfix(L, frule - 1, g, sib1(g));
initialrulename(L, g, frule);
verifygrammar(L, g);
@@ -3213,7 +3220,7 @@ static TTree *newgrammar (lua_State *L, int arg) {
static Instruction *prepcompile (lua_State *L, Pattern *p, int idx) {
- lua_getfenv(L, idx); /* push 'ktable' (may be used by 'finalfix') */
+ lua_getuservalue(L, idx); /* push 'ktable' (may be used by 'finalfix') */
finalfix(L, 0, NULL, p->tree);
lua_pop(L, 1); /* remove 'ktable' */
return compile(L, p);
@@ -3224,7 +3231,7 @@ static int lp_printtree (lua_State *L) {
TTree *tree = getpatt(L, 1, NULL);
int c = lua_toboolean(L, 2);
if (c) {
- lua_getfenv(L, 1); /* push 'ktable' (may be used by 'finalfix') */
+ lua_getuservalue(L, 1); /* push 'ktable' (may be used by 'finalfix') */
finalfix(L, 0, NULL, tree);
lua_pop(L, 1); /* remove 'ktable' */
}
@@ -3277,7 +3284,7 @@ static int lp_match (lua_State *L) {
int ptop = lua_gettop(L);
lua_pushnil(L); /* initialize subscache */
lua_pushlightuserdata(L, capture); /* initialize caplistidx */
- lua_getfenv(L, 1); /* initialize penvidx */
+ lua_getuservalue(L, 1); /* initialize penvidx */
r = match(L, s, s + i, s + l, code, capture, ptop);
if (r == NULL) {
lua_pushnil(L);
@@ -3294,8 +3301,12 @@ static int lp_match (lua_State *L) {
** =======================================================
*/
+/* maximum limit for stack size */
+#define MAXLIM (INT_MAX / 100)
+
static int lp_setmax (lua_State *L) {
- luaL_optinteger(L, 1, -1);
+ lua_Integer lim = luaL_checkinteger(L, 1);
+ luaL_argcheck(L, 0 < lim && lim <= MAXLIM, 1, "out of range");
lua_settop(L, 1);
lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX);
return 0;
@@ -3319,8 +3330,7 @@ static int lp_type (lua_State *L) {
int lp_gc (lua_State *L) {
Pattern *p = getpattern(L, 1);
- if (p->codesize > 0)
- realloccode(L, p, 0);
+ realloccode(L, p, 0); /* delete code block */
return 0;
}
@@ -3403,11 +3413,12 @@ int luaopen_lpeg (lua_State *L) {
luaL_newmetatable(L, PATTERN_T);
lua_pushnumber(L, MAXBACK); /* initialize maximum backtracking */
lua_setfield(L, LUA_REGISTRYINDEX, MAXSTACKIDX);
- luaL_register(L, NULL, metareg);
- luaL_register(L, "lpeg", pattreg);
+ luaL_setfuncs(L, metareg, 0);
+ luaL_newlib(L, pattreg);
lua_pushvalue(L, -1);
lua_setfield(L, -3, "__index");
return 1;
}
/* }====================================================== */
+
diff --git a/Build/source/texk/web2c/luatexdir/luapeg/lpeg.h b/Build/source/texk/web2c/luatexdir/luapeg/lpeg.h
index b864d0fbca1..f722b887174 100644
--- a/Build/source/texk/web2c/luatexdir/luapeg/lpeg.h
+++ b/Build/source/texk/web2c/luatexdir/luapeg/lpeg.h
@@ -1,12 +1,12 @@
/*
-** $Id: lptypes.h,v 1.11 2015/03/04 16:38:00 roberto Exp $
+** $Id: lptypes.h,v 1.14 2015/09/28 17:17:41 roberto Exp $
** LPeg - PEG pattern matching for Lua
-** Copyright 2007-2014, Lua.org & PUC-Rio (see 'lpeg.html' for license)
+** Copyright 2007-2015, Lua.org & PUC-Rio (see 'lpeg.html' for license)
** written by Roberto Ierusalimschy
*/
/*
- "Amalgamated" version for LuaTeX written by Scarso Luigi.
+ "Amalgamated" version for Lua(jit)TeX written by Scarso Luigi.
*/
@@ -20,16 +20,16 @@
#include <assert.h>
#include <limits.h>
+/* added */
#include <ctype.h>
#include <stdio.h>
#include <string.h>
-#include "lauxlib.h"
-#include "lua.h"
-
+#include "lua.h"
+#include "lauxlib.h"
-#define VERSION "0.12.2"
+#define VERSION "1.0.0"
#define PATTERN_T "lpeg-pattern"
@@ -37,31 +37,31 @@
/*
-** compatibility with Lua 5.2
+** compatibility with Lua 5.1
*/
-#if (LUA_VERSION_NUM >= 502)
+#if (LUA_VERSION_NUM == 501)
+
+#define lp_equal lua_equal
-#undef lua_equal
-#define lua_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
+#define lua_getuservalue lua_getfenv
+#define lua_setuservalue lua_setfenv
-#undef lua_getfenv
-#define lua_getfenv lua_getuservalue
-#undef lua_setfenv
-#define lua_setfenv lua_setuservalue
+#define lua_rawlen lua_objlen
-#undef lua_objlen
-#define lua_objlen lua_rawlen
+#define luaL_setfuncs(L,f,n) luaL_register(L,NULL,f)
+#define luaL_newlib(L,f) luaL_register(L,"lpeg",f)
+
+#endif
-#undef luaL_register
-#define luaL_register(L,n,f) \
- { if ((n) == NULL) luaL_setfuncs(L,f,0); else luaL_newlib(L,f); }
+#if !defined(lp_equal)
+#define lp_equal(L,idx1,idx2) lua_compare(L,(idx1),(idx2),LUA_OPEQ)
#endif
/* default maximum size for call/backtrack stack */
#if !defined(MAXBACK)
-#define MAXBACK 100
+#define MAXBACK 400
#endif
@@ -165,7 +165,7 @@ typedef struct Charset {
#define lpcap_h
-/* #include "lptypes.h"*/
+/*#include "lptypes.h"*/
/* kinds of captures */
@@ -208,7 +208,7 @@ int finddyncap (Capture *cap, Capture *last);
#define lptree_h
-/* #include "lptypes.h" */
+/*#include "lptypes.h" */
/*
@@ -277,6 +277,7 @@ extern const byte numsiblings[];
#endif
+
/*
** $Id: lpvm.h,v 1.3 2014/02/21 13:06:41 roberto Exp $
*/
@@ -284,7 +285,7 @@ extern const byte numsiblings[];
#if !defined(lpvm_h)
#define lpvm_h
-/* #include "lpcap.h"*/
+/*#include "lpcap.h"*/
/* Virtual Machine's instructions */
@@ -335,18 +336,20 @@ const char *match (lua_State *L, const char *o, const char *s, const char *e,
#endif
+
+
/*
-** $Id: lpcode.h,v 1.6 2013/11/28 14:56:02 roberto Exp $
+** $Id: lpcode.h,v 1.7 2015/06/12 18:24:45 roberto Exp $
*/
#if !defined(lpcode_h)
#define lpcode_h
-/* #include "lua.h"*/
+/*#include "lua.h"*/
-/* #include "lptypes.h"*/
-/* #include "lptree.h"*/
-/* #include "lpvm.h"*/
+/*#include "lptypes.h"*/
+/*#include "lptree.h"*/
+/*#include "lpvm.h"*/
int tocharset (TTree *tree, Charset *cs);
int checkaux (TTree *tree, int pred);
@@ -361,7 +364,15 @@ int sizei (const Instruction *i);
#define PEnullable 0
#define PEnofail 1
+/*
+** nofail(t) implies that 't' cannot fail with any input
+*/
#define nofail(t) checkaux(t, PEnofail)
+
+/*
+** (not nullable(t)) implies 't' cannot match without consuming
+** something
+*/
#define nullable(t) checkaux(t, PEnullable)
#define fixedlen(t) fixedlenx(t, 0, 0)
@@ -369,8 +380,10 @@ int sizei (const Instruction *i);
#endif
+
+
/*
-** $Id: lpprint.h,v 1.1 2013/03/21 20:25:12 roberto Exp $
+** $Id: lpprint.h,v 1.2 2015/06/12 18:18:08 roberto Exp $
*/
@@ -378,8 +391,8 @@ int sizei (const Instruction *i);
#define lpprint_h
-/* #include "lptree.h"*/
-/* #include "lpvm.h"*/
+/* #include "lptree.h" */
+/* #include "lpvm.h" */
#if defined(LPEG_DEBUG)
@@ -389,6 +402,7 @@ void printtree (TTree *tree, int ident);
void printktable (lua_State *L, int idx);
void printcharset (const byte *st);
void printcaplist (Capture *cap, Capture *limit);
+void printinst (const Instruction *op, const Instruction *p);
#else
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
index 4606d2a2c91..f14254c1996 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdfgen.w
@@ -201,6 +201,7 @@ PDF init_pdf_struct(PDF pdf)
pdf->draftmode = 0;
pdf->inclusion_copy_font = 1;
pdf->pk_resolution = 0;
+ pdf->pk_fixed_dpi = 0;
pdf->pk_scale_factor = 0;
init_dest_names(pdf);
@@ -921,6 +922,7 @@ static void init_pdf_outputparameters(PDF pdf)
pdf->objcompresslevel = fix_int(pdf_objcompresslevel, 0, MAX_OBJ_COMPRESS_LEVEL);
pdf->inclusion_copy_font = fix_int(pdf_inclusion_copy_font, 0, 1);
pdf->pk_resolution = fix_int(pdf_pk_resolution, 72, 8000);
+ pdf->pk_fixed_dpi = fix_int(pdf_pk_fixed_dpi, 0, 1);
if ((pdf->minor_version >= 5) && (pdf->objcompresslevel > 0)) {
pdf->os_enable = true;
} else {
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
index 7b508c4e161..ee1d1832103 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftables.h
@@ -131,6 +131,7 @@ typedef enum {
c_pdf_objcompresslevel,
c_pdf_inclusion_copy_font,
c_pdf_gen_tounicode,
+ c_pdf_pk_fixed_dpi,
} pdf_backend_counters ;
typedef enum {
@@ -173,6 +174,7 @@ extern int pdf_retval;
# define pdf_objcompresslevel get_tex_extension_count_register(c_pdf_objcompresslevel)
# define pdf_inclusion_copy_font get_tex_extension_count_register(c_pdf_inclusion_copy_font)
# define pdf_gen_tounicode get_tex_extension_count_register(c_pdf_gen_tounicode)
+# define pdf_pk_fixed_dpi get_tex_extension_count_register(c_pdf_pk_fixed_dpi)
# define pdf_h_origin get_tex_extension_dimen_register(d_pdf_h_origin)
# define pdf_v_origin get_tex_extension_dimen_register(d_pdf_v_origin)
@@ -193,6 +195,8 @@ extern int pdf_retval;
# define set_pdf_objcompresslevel(i) set_tex_extension_count_register(c_pdf_objcompresslevel,i)
# define set_pdf_decimal_digits(i) set_tex_extension_count_register(c_pdf_decimal_digits,i)
+# define set_pdf_pk_resolution(i) set_tex_extension_count_register(c_pdf_pk_resolution,i)
+# define set_pdf_pk_fixed_dpi(i) set_tex_extension_count_register(c_pdf_pk_fixed_dpi,i)
# define pk_decimal_digits(pdf,delta) ((pdf->decimal_digits > 4 ? 4 : 3) + delta)
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
index f3dafb0ce35..8a670a5274f 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdftypes.h
@@ -278,6 +278,7 @@ typedef struct pdf_output_file_ {
int image_apply_gamma;
int draftmode;
int pk_resolution;
+ int pk_fixed_dpi;
int decimal_digits;
int gen_tounicode;
int inclusion_copy_font;
diff --git a/Build/source/texk/web2c/luatexdir/tex/textoken.w b/Build/source/texk/web2c/luatexdir/tex/textoken.w
index 0cdbb9703c3..4b14b6ec9fe 100644
--- a/Build/source/texk/web2c/luatexdir/tex/textoken.w
+++ b/Build/source/texk/web2c/luatexdir/tex/textoken.w
@@ -2312,6 +2312,7 @@ static int do_variable_pdf(halfword c)
else if (scan_keyword("objcompresslevel")) { do_variable_backend_int(c_pdf_objcompresslevel); }
else if (scan_keyword("inclusioncopyfonts")) { do_variable_backend_int(c_pdf_inclusion_copy_font); }
else if (scan_keyword("gentounicode")) { do_variable_backend_int(c_pdf_gen_tounicode); }
+ else if (scan_keyword("pkfixeddpi")) { do_variable_backend_int(c_pdf_pk_fixed_dpi); }
else if (scan_keyword("horigin")) { do_variable_backend_dimen(d_pdf_h_origin); }
else if (scan_keyword("vorigin")) { do_variable_backend_dimen(d_pdf_v_origin); }