| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | $NetBSD: patch-texk_web2c_luatexdir_lua_lepdflib.cc,v 1.6 2018/12/04 13:00:42 ryoon Exp $ | | 1 | $NetBSD: patch-texk_web2c_luatexdir_lua_lepdflib.cc,v 1.7 2018/12/11 13:35:12 ryoon Exp $ |
2 | | | 2 | |
3 | --- texk/web2c/luatexdir/lua/lepdflib.cc.orig 2018-02-14 14:44:38.000000000 +0000 | | 3 | --- texk/web2c/luatexdir/lua/lepdflib.cc.orig 2018-02-14 14:44:38.000000000 +0000 |
4 | +++ texk/web2c/luatexdir/lua/lepdflib.cc | | 4 | +++ texk/web2c/luatexdir/lua/lepdflib.cc |
5 | @@ -221,6 +221,7 @@ static int l_new_Attribute(lua_State * L | | 5 | @@ -221,6 +221,7 @@ static int l_new_Attribute(lua_State * L |
6 | const char *n; | | 6 | const char *n; |
7 | int nlen; | | 7 | int nlen; |
8 | udstruct *uobj, *uout; | | 8 | udstruct *uobj, *uout; |
9 | + GooString *gs; | | 9 | + GooString *gs; |
10 | | | 10 | |
11 | if (lua_type(L,1)==LUA_TNUMBER) { | | 11 | if (lua_type(L,1)==LUA_TNUMBER) { |
12 | uobj = (udstruct *) luaL_checkudata(L, 2, M_Object); | | 12 | uobj = (udstruct *) luaL_checkudata(L, 2, M_Object); |
13 | @@ -240,7 +241,8 @@ static int l_new_Attribute(lua_State * L | | 13 | @@ -240,7 +241,8 @@ static int l_new_Attribute(lua_State * L |
14 | if (uobj->pd != NULL && uobj->pd->pc != uobj->pc) | | 14 | if (uobj->pd != NULL && uobj->pd->pc != uobj->pc) |
| @@ -37,92 +37,152 @@ $NetBSD: patch-texk_web2c_luatexdir_lua_ | | | @@ -37,92 +37,152 @@ $NetBSD: patch-texk_web2c_luatexdir_lua_ |
37 | + const out *o; \ | | 37 | + const out *o; \ |
38 | udstruct *uin, *uout; \ | | 38 | udstruct *uin, *uout; \ |
39 | uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ | | 39 | uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ |
40 | if (uin->pd != NULL && uin->pd->pc != uin->pc) \ | | 40 | if (uin->pd != NULL && uin->pd->pc != uin->pc) \ |
41 | @@ -599,7 +601,7 @@ static int m_##in##_##function(lua_State | | 41 | @@ -599,7 +601,7 @@ static int m_##in##_##function(lua_State |
42 | o = ((in *) uin->d)->function(); \ | | 42 | o = ((in *) uin->d)->function(); \ |
43 | if (o != NULL) { \ | | 43 | if (o != NULL) { \ |
44 | uout = new_##out##_userdata(L); \ | | 44 | uout = new_##out##_userdata(L); \ |
45 | - uout->d = o; \ | | 45 | - uout->d = o; \ |
46 | + uout->d = const_cast<out *>(o); \ | | 46 | + uout->d = const_cast<out *>(o); \ |
47 | uout->pc = uin->pc; \ | | 47 | uout->pc = uin->pc; \ |
48 | uout->pd = uin->pd; \ | | 48 | uout->pd = uin->pd; \ |
49 | } else \ | | 49 | } else \ |
50 | @@ -669,7 +671,7 @@ static int m_##in##_##function(lua_State | | 50 | @@ -669,14 +671,14 @@ static int m_##in##_##function(lua_State |
51 | #define m_poppler_get_GOOSTRING(in, function) \ | | 51 | #define m_poppler_get_GOOSTRING(in, function) \ |
52 | static int m_##in##_##function(lua_State * L) \ | | 52 | static int m_##in##_##function(lua_State * L) \ |
53 | { \ | | 53 | { \ |
54 | - GooString *gs; \ | | 54 | - GooString *gs; \ |
55 | + const GooString *gs; \ | | 55 | + const GooString *gs; \ |
56 | udstruct *uin; \ | | 56 | udstruct *uin; \ |
57 | uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ | | 57 | uin = (udstruct *) luaL_checkudata(L, 1, M_##in); \ |
58 | if (uin->pd != NULL && uin->pd->pc != uin->pc) \ | | 58 | if (uin->pd != NULL && uin->pd->pc != uin->pc) \ |
| | | 59 | pdfdoc_changed_error(L); \ |
| | | 60 | gs = ((in *) uin->d)->function(); \ |
| | | 61 | if (gs != NULL) \ |
| | | 62 | - lua_pushlstring(L, gs->getCString(), gs->getLength()); \ |
| | | 63 | + lua_pushlstring(L, gs->c_str(), gs->getLength()); \ |
| | | 64 | else \ |
| | | 65 | lua_pushnil(L); \ |
| | | 66 | return 1; \ |
| | | 67 | @@ -911,7 +913,7 @@ static int m_Array_getString(lua_State * |
| | | 68 | if (i > 0 && i <= len) { |
| | | 69 | gs = new GooString(); |
| | | 70 | if (((Array *) uin->d)->getString(i - 1, gs)) |
| | | 71 | - lua_pushlstring(L, gs->getCString(), gs->getLength()); |
| | | 72 | + lua_pushlstring(L, gs->c_str(), gs->getLength()); |
| | | 73 | else |
| | | 74 | lua_pushnil(L); |
| | | 75 | delete gs; |
| | | 76 | @@ -1063,7 +1065,7 @@ static int m_Catalog_getJS(lua_State * L |
| | | 77 | if (i > 0 && i <= len) { |
| | | 78 | gs = ((Catalog *) uin->d)->getJS(i - 1); |
| | | 79 | if (gs != NULL) |
| | | 80 | - lua_pushlstring(L, gs->getCString(), gs->getLength()); |
| | | 81 | + lua_pushlstring(L, gs->c_str(), gs->getLength()); |
| | | 82 | else |
| | | 83 | lua_pushnil(L); |
| | | 84 | delete gs; |
59 | @@ -1125,7 +1127,7 @@ m_poppler_get_INT(Dict, getLength); | | 85 | @@ -1125,7 +1127,7 @@ m_poppler_get_INT(Dict, getLength); |
60 | | | 86 | |
61 | static int m_Dict_add(lua_State * L) | | 87 | static int m_Dict_add(lua_State * L) |
62 | { | | 88 | { |
63 | - char *s; | | 89 | - char *s; |
64 | + const char *s; | | 90 | + const char *s; |
65 | udstruct *uin, *uobj; | | 91 | udstruct *uin, *uobj; |
66 | uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); | | 92 | uin = (udstruct *) luaL_checkudata(L, 1, M_Dict); |
67 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | | 93 | if (uin->pd != NULL && uin->pd->pc != uin->pc) |
| | | 94 | @@ -1378,7 +1380,7 @@ static int m_GooString__tostring(lua_Sta |
| | | 95 | uin = (udstruct *) luaL_checkudata(L, 1, M_GooString); |
| | | 96 | if (uin->pd != NULL && uin->pd->pc != uin->pc) |
| | | 97 | pdfdoc_changed_error(L); |
| | | 98 | - lua_pushlstring(L, ((GooString *) uin->d)->getCString(), |
| | | 99 | + lua_pushlstring(L, ((GooString *) uin->d)->c_str(), |
| | | 100 | ((GooString *) uin->d)->getLength()); |
| | | 101 | return 1; |
| | | 102 | } |
68 | @@ -1527,9 +1529,9 @@ static int m_Object_initBool(lua_State * | | 103 | @@ -1527,9 +1529,9 @@ static int m_Object_initBool(lua_State * |
69 | pdfdoc_changed_error(L); | | 104 | pdfdoc_changed_error(L); |
70 | luaL_checktype(L, 2, LUA_TBOOLEAN); | | 105 | luaL_checktype(L, 2, LUA_TBOOLEAN); |
71 | if (lua_toboolean(L, 2) != 0) | | 106 | if (lua_toboolean(L, 2) != 0) |
72 | - *((Object *) uin->d) = Object(gTrue); | | 107 | - *((Object *) uin->d) = Object(gTrue); |
73 | + *((Object *) uin->d) = Object(true); | | 108 | + *((Object *) uin->d) = Object(true); |
74 | else | | 109 | else |
75 | - *((Object *) uin->d) = Object(gFalse); | | 110 | - *((Object *) uin->d) = Object(gFalse); |
76 | + *((Object *) uin->d) = Object(false); | | 111 | + *((Object *) uin->d) = Object(false); |
77 | return 0; | | 112 | return 0; |
78 | } | | 113 | } |
79 | | | 114 | |
80 | @@ -1807,7 +1809,7 @@ static int m_Object_getNum(lua_State * L | | 115 | @@ -1807,14 +1809,14 @@ static int m_Object_getNum(lua_State * L |
81 | | | 116 | |
82 | static int m_Object_getString(lua_State * L) | | 117 | static int m_Object_getString(lua_State * L) |
83 | { | | 118 | { |
84 | - GooString *gs; | | 119 | - GooString *gs; |
85 | + const GooString *gs; | | 120 | + const GooString *gs; |
86 | udstruct *uin; | | 121 | udstruct *uin; |
87 | uin = (udstruct *) luaL_checkudata(L, 1, M_Object); | | 122 | uin = (udstruct *) luaL_checkudata(L, 1, M_Object); |
88 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | | 123 | if (uin->pd != NULL && uin->pd->pc != uin->pc) |
| | | 124 | pdfdoc_changed_error(L); |
| | | 125 | if (((Object *) uin->d)->isString()) { |
| | | 126 | gs = ((Object *) uin->d)->getString(); |
| | | 127 | - lua_pushlstring(L, gs->getCString(), gs->getLength()); |
| | | 128 | + lua_pushlstring(L, gs->c_str(), gs->getLength()); |
| | | 129 | } else |
| | | 130 | lua_pushnil(L); |
| | | 131 | return 1; |
89 | @@ -2051,7 +2053,7 @@ static int m_Object_dictAdd(lua_State * | | 132 | @@ -2051,7 +2053,7 @@ static int m_Object_dictAdd(lua_State * |
90 | pdfdoc_changed_error(L); | | 133 | pdfdoc_changed_error(L); |
91 | if (!((Object *) uin->d)->isDict()) | | 134 | if (!((Object *) uin->d)->isDict()) |
92 | luaL_error(L, "Object is not a Dict"); | | 135 | luaL_error(L, "Object is not a Dict"); |
93 | - ((Object *) uin->d)->dictAdd(copyString(s), std::move(*((Object *) uobj->d))); | | 136 | - ((Object *) uin->d)->dictAdd(copyString(s), std::move(*((Object *) uobj->d))); |
94 | + ((Object *) uin->d)->dictAdd(s, std::move(*((Object *) uobj->d))); | | 137 | + ((Object *) uin->d)->dictAdd(s, std::move(*((Object *) uobj->d))); |
95 | return 0; | | 138 | return 0; |
96 | } | | 139 | } |
97 | | | 140 | |
98 | @@ -2465,7 +2467,7 @@ m_PDFDoc_INT(getErrorCode); | | 141 | @@ -2465,14 +2467,14 @@ m_PDFDoc_INT(getErrorCode); |
99 | | | 142 | |
100 | static int m_PDFDoc_getFileName(lua_State * L) | | 143 | static int m_PDFDoc_getFileName(lua_State * L) |
101 | { | | 144 | { |
102 | - GooString *gs; | | 145 | - GooString *gs; |
103 | + const GooString *gs; | | 146 | + const GooString *gs; |
104 | udstruct *uin; | | 147 | udstruct *uin; |
105 | uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); | | 148 | uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); |
106 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | | 149 | if (uin->pd != NULL && uin->pd->pc != uin->pc) |
| | | 150 | pdfdoc_changed_error(L); |
| | | 151 | gs = ((PdfDocument *) uin->d)->doc->getFileName(); |
| | | 152 | if (gs != NULL) |
| | | 153 | - lua_pushlstring(L, gs->getCString(), gs->getLength()); |
| | | 154 | + lua_pushlstring(L, gs->c_str(), gs->getLength()); |
| | | 155 | else |
| | | 156 | lua_pushnil(L); |
| | | 157 | return 1; |
107 | @@ -2553,7 +2555,7 @@ m_PDFDoc_INT(getNumPages); | | 158 | @@ -2553,7 +2555,7 @@ m_PDFDoc_INT(getNumPages); |
108 | | | 159 | |
109 | static int m_PDFDoc_readMetadata(lua_State * L) | | 160 | static int m_PDFDoc_readMetadata(lua_State * L) |
110 | { | | 161 | { |
111 | - GooString *gs; | | 162 | - GooString *gs; |
112 | + const GooString *gs; | | 163 | + const GooString *gs; |
113 | udstruct *uin; | | 164 | udstruct *uin; |
114 | uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); | | 165 | uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); |
115 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | | 166 | if (uin->pd != NULL && uin->pd->pc != uin->pc) |
| | | 167 | @@ -2561,7 +2563,7 @@ static int m_PDFDoc_readMetadata(lua_Sta |
| | | 168 | if (((PdfDocument *) uin->d)->doc->getCatalog()->isOk()) { |
| | | 169 | gs = ((PdfDocument *) uin->d)->doc->readMetadata(); |
| | | 170 | if (gs != NULL) |
| | | 171 | - lua_pushlstring(L, gs->getCString(), gs->getLength()); |
| | | 172 | + lua_pushlstring(L, gs->c_str(), gs->getLength()); |
| | | 173 | else |
| | | 174 | lua_pushnil(L); |
| | | 175 | } else |
116 | @@ -2571,7 +2573,7 @@ static int m_PDFDoc_readMetadata(lua_Sta | | 176 | @@ -2571,7 +2573,7 @@ static int m_PDFDoc_readMetadata(lua_Sta |
117 | | | 177 | |
118 | static int m_PDFDoc_getStructTreeRoot(lua_State * L) | | 178 | static int m_PDFDoc_getStructTreeRoot(lua_State * L) |
119 | { | | 179 | { |
120 | - StructTreeRoot *obj; | | 180 | - StructTreeRoot *obj; |
121 | + const StructTreeRoot *obj; | | 181 | + const StructTreeRoot *obj; |
122 | udstruct *uin, *uout; | | 182 | udstruct *uin, *uout; |
123 | uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); | | 183 | uin = (udstruct *) luaL_checkudata(L, 1, M_PDFDoc); |
124 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | | 184 | if (uin->pd != NULL && uin->pd->pc != uin->pc) |
125 | @@ -2579,7 +2581,7 @@ static int m_PDFDoc_getStructTreeRoot(lu | | 185 | @@ -2579,7 +2581,7 @@ static int m_PDFDoc_getStructTreeRoot(lu |
126 | if (((PdfDocument *) uin->d)->doc->getCatalog()->isOk()) { | | 186 | if (((PdfDocument *) uin->d)->doc->getCatalog()->isOk()) { |
127 | obj = ((PdfDocument *) uin->d)->doc->getStructTreeRoot(); | | 187 | obj = ((PdfDocument *) uin->d)->doc->getStructTreeRoot(); |
128 | uout = new_StructTreeRoot_userdata(L); | | 188 | uout = new_StructTreeRoot_userdata(L); |
| @@ -145,42 +205,46 @@ $NetBSD: patch-texk_web2c_luatexdir_lua_ | | | @@ -145,42 +205,46 @@ $NetBSD: patch-texk_web2c_luatexdir_lua_ |
145 | + i = (bool) lua_toboolean(L, 2); | | 205 | + i = (bool) lua_toboolean(L, 2); |
146 | ((Attribute *) uin->d)->setHidden(i); | | 206 | ((Attribute *) uin->d)->setHidden(i); |
147 | return 0; | | 207 | return 0; |
148 | } | | 208 | } |
149 | @@ -3180,7 +3182,7 @@ static int m_StructElement_getParentRef( | | 209 | @@ -3180,7 +3182,7 @@ static int m_StructElement_getParentRef( |
150 | // Ref is false if the C++ functione return false | | 210 | // Ref is false if the C++ functione return false |
151 | static int m_StructElement_getPageRef(lua_State * L) | | 211 | static int m_StructElement_getPageRef(lua_State * L) |
152 | { | | 212 | { |
153 | - GBool b; | | 213 | - GBool b; |
154 | + bool b; | | 214 | + bool b; |
155 | Ref *r; | | 215 | Ref *r; |
156 | udstruct *uin, *uout; | | 216 | udstruct *uin, *uout; |
157 | uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); | | 217 | uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); |
158 | @@ -3226,13 +3228,13 @@ static int m_StructElement_setRevision(l | | 218 | @@ -3226,16 +3228,16 @@ static int m_StructElement_setRevision(l |
159 | | | 219 | |
160 | static int m_StructElement_getText(lua_State * L) | | 220 | static int m_StructElement_getText(lua_State * L) |
161 | { | | 221 | { |
162 | - GBool i; | | 222 | - GBool i; |
163 | + bool i; | | 223 | + bool i; |
164 | GooString *gs; | | 224 | GooString *gs; |
165 | udstruct *uin; | | 225 | udstruct *uin; |
166 | uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); | | 226 | uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); |
167 | if (uin->pd != NULL && uin->pd->pc != uin->pc) | | 227 | if (uin->pd != NULL && uin->pd->pc != uin->pc) |
168 | pdfdoc_changed_error(L); | | 228 | pdfdoc_changed_error(L); |
169 | - i = (GBool) lua_toboolean(L, 2); | | 229 | - i = (GBool) lua_toboolean(L, 2); |
170 | + i = (bool) lua_toboolean(L, 2); | | 230 | + i = (bool) lua_toboolean(L, 2); |
171 | gs = ((StructElement *) uin->d)->getText(i); | | 231 | gs = ((StructElement *) uin->d)->getText(i); |
172 | if (gs != NULL) | | 232 | if (gs != NULL) |
173 | lua_pushlstring(L, gs->getCString(), gs->getLength()); | | 233 | - lua_pushlstring(L, gs->getCString(), gs->getLength()); |
| | | 234 | + lua_pushlstring(L, gs->c_str(), gs->getLength()); |
| | | 235 | else |
| | | 236 | lua_pushnil(L); |
| | | 237 | return 1; |
174 | @@ -3321,7 +3323,7 @@ static int m_StructElement_findAttribute | | 238 | @@ -3321,7 +3323,7 @@ static int m_StructElement_findAttribute |
175 | { | | 239 | { |
176 | Attribute::Type t; | | 240 | Attribute::Type t; |
177 | Attribute::Owner o; | | 241 | Attribute::Owner o; |
178 | - GBool g; | | 242 | - GBool g; |
179 | + bool g; | | 243 | + bool g; |
180 | udstruct *uin, *uout; | | 244 | udstruct *uin, *uout; |
181 | const Attribute *a; | | 245 | const Attribute *a; |
182 | uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); | | 246 | uin = (udstruct *) luaL_checkudata(L, 1, M_StructElement); |
183 | @@ -3329,7 +3331,7 @@ static int m_StructElement_findAttribute | | 247 | @@ -3329,7 +3331,7 @@ static int m_StructElement_findAttribute |
184 | pdfdoc_changed_error(L); | | 248 | pdfdoc_changed_error(L); |
185 | t = (Attribute::Type) luaL_checkint(L,1); | | 249 | t = (Attribute::Type) luaL_checkint(L,1); |
186 | o = (Attribute::Owner) luaL_checkint(L,2); | | 250 | o = (Attribute::Owner) luaL_checkint(L,2); |