diff options
Diffstat (limited to 'src/3rdParty/lua/lstrlib.c')
| -rw-r--r-- | src/3rdParty/lua/lstrlib.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/3rdParty/lua/lstrlib.c b/src/3rdParty/lua/lstrlib.c index 47e5b27..74501f7 100644 --- a/src/3rdParty/lua/lstrlib.c +++ b/src/3rdParty/lua/lstrlib.c | |||
| @@ -1352,15 +1352,6 @@ static const union { | |||
| 1352 | } nativeendian = {1}; | 1352 | } nativeendian = {1}; |
| 1353 | 1353 | ||
| 1354 | 1354 | ||
| 1355 | /* dummy structure to get native alignment requirements */ | ||
| 1356 | struct cD { | ||
| 1357 | char c; | ||
| 1358 | union { double d; void *p; lua_Integer i; lua_Number n; } u; | ||
| 1359 | }; | ||
| 1360 | |||
| 1361 | #define MAXALIGN (offsetof(struct cD, u)) | ||
| 1362 | |||
| 1363 | |||
| 1364 | /* | 1355 | /* |
| 1365 | ** information to pack/unpack stuff | 1356 | ** information to pack/unpack stuff |
| 1366 | */ | 1357 | */ |
| @@ -1435,6 +1426,8 @@ static void initheader (lua_State *L, Header *h) { | |||
| 1435 | ** Read and classify next option. 'size' is filled with option's size. | 1426 | ** Read and classify next option. 'size' is filled with option's size. |
| 1436 | */ | 1427 | */ |
| 1437 | static KOption getoption (Header *h, const char **fmt, int *size) { | 1428 | static KOption getoption (Header *h, const char **fmt, int *size) { |
| 1429 | /* dummy structure to get native alignment requirements */ | ||
| 1430 | struct cD { char c; union { LUAI_MAXALIGN; } u; }; | ||
| 1438 | int opt = *((*fmt)++); | 1431 | int opt = *((*fmt)++); |
| 1439 | *size = 0; /* default */ | 1432 | *size = 0; /* default */ |
| 1440 | switch (opt) { | 1433 | switch (opt) { |
| @@ -1465,7 +1458,11 @@ static KOption getoption (Header *h, const char **fmt, int *size) { | |||
| 1465 | case '<': h->islittle = 1; break; | 1458 | case '<': h->islittle = 1; break; |
| 1466 | case '>': h->islittle = 0; break; | 1459 | case '>': h->islittle = 0; break; |
| 1467 | case '=': h->islittle = nativeendian.little; break; | 1460 | case '=': h->islittle = nativeendian.little; break; |
| 1468 | case '!': h->maxalign = getnumlimit(h, fmt, MAXALIGN); break; | 1461 | case '!': { |
| 1462 | const int maxalign = offsetof(struct cD, u); | ||
| 1463 | h->maxalign = getnumlimit(h, fmt, maxalign); | ||
| 1464 | break; | ||
| 1465 | } | ||
| 1469 | default: luaL_error(h->L, "invalid format option '%c'", opt); | 1466 | default: luaL_error(h->L, "invalid format option '%c'", opt); |
| 1470 | } | 1467 | } |
| 1471 | return Knop; | 1468 | return Knop; |
