diff options
| -rw-r--r-- | llimits.h | 11 | ||||
| -rw-r--r-- | luaconf.h | 88 | ||||
| -rw-r--r-- | lutf8lib.c | 2 |
3 files changed, 65 insertions, 36 deletions
| @@ -14,6 +14,11 @@ | |||
| 14 | 14 | ||
| 15 | #include "lua.h" | 15 | #include "lua.h" |
| 16 | 16 | ||
| 17 | |||
| 18 | /* minimum number of bits in an integer */ | ||
| 19 | #define LUAI_BITSINT (LUAI_IS32INT ? 32 : 16) | ||
| 20 | |||
| 21 | |||
| 17 | /* | 22 | /* |
| 18 | ** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count | 23 | ** 'lu_mem' and 'l_mem' are unsigned/signed integers big enough to count |
| 19 | ** the total memory used by Lua (in bytes). Usually, 'size_t' and | 24 | ** the total memory used by Lua (in bytes). Usually, 'size_t' and |
| @@ -22,7 +27,7 @@ | |||
| 22 | #if defined(LUAI_MEM) /* { external definitions? */ | 27 | #if defined(LUAI_MEM) /* { external definitions? */ |
| 23 | typedef LUAI_UMEM lu_mem; | 28 | typedef LUAI_UMEM lu_mem; |
| 24 | typedef LUAI_MEM l_mem; | 29 | typedef LUAI_MEM l_mem; |
| 25 | #elif LUAI_BITSINT >= 32 /* }{ */ | 30 | #elif LUAI_IS32INT /* }{ */ |
| 26 | typedef size_t lu_mem; | 31 | typedef size_t lu_mem; |
| 27 | typedef ptrdiff_t l_mem; | 32 | typedef ptrdiff_t l_mem; |
| 28 | #else /* 16-bit ints */ /* }{ */ | 33 | #else /* 16-bit ints */ /* }{ */ |
| @@ -172,13 +177,11 @@ typedef LUAI_UACINT l_uacInt; | |||
| 172 | #endif | 177 | #endif |
| 173 | 178 | ||
| 174 | 179 | ||
| 175 | |||
| 176 | |||
| 177 | /* | 180 | /* |
| 178 | ** type for virtual-machine instructions; | 181 | ** type for virtual-machine instructions; |
| 179 | ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) | 182 | ** must be an unsigned with (at least) 4 bytes (see details in lopcodes.h) |
| 180 | */ | 183 | */ |
| 181 | #if LUAI_BITSINT >= 32 | 184 | #if LUAI_IS32INT |
| 182 | typedef unsigned int l_uint32; | 185 | typedef unsigned int l_uint32; |
| 183 | #else | 186 | #else |
| 184 | typedef unsigned long l_uint32; | 187 | typedef unsigned long l_uint32; |
| @@ -14,6 +14,16 @@ | |||
| 14 | 14 | ||
| 15 | /* | 15 | /* |
| 16 | ** =================================================================== | 16 | ** =================================================================== |
| 17 | ** General Configuration File for Lua | ||
| 18 | ** | ||
| 19 | ** Some definitions here can be changed externally, through the | ||
| 20 | ** compiler (e.g., with '-D' options). Those are protected by | ||
| 21 | ** '#if !defined' guards. However, several other definitions should | ||
| 22 | ** be changed directly here, either because they affect the Lua | ||
| 23 | ** ABI (by making the changes here, you ensure that all software | ||
| 24 | ** connected to Lua, such as C libraries, will be compiled with the | ||
| 25 | ** same configuration); or because they are seldom changed. | ||
| 26 | ** | ||
| 17 | ** Search for "@@" to find all configurable definitions. | 27 | ** Search for "@@" to find all configurable definitions. |
| 18 | ** =================================================================== | 28 | ** =================================================================== |
| 19 | */ | 29 | */ |
| @@ -22,8 +32,7 @@ | |||
| 22 | /* | 32 | /* |
| 23 | ** {==================================================================== | 33 | ** {==================================================================== |
| 24 | ** System Configuration: macros to adapt (if needed) Lua to some | 34 | ** System Configuration: macros to adapt (if needed) Lua to some |
| 25 | ** particular platform, for instance compiling it with 32-bit numbers or | 35 | ** particular platform, for instance restricting it to C89. |
| 26 | ** restricting it to C89. | ||
| 27 | ** ===================================================================== | 36 | ** ===================================================================== |
| 28 | */ | 37 | */ |
| 29 | 38 | ||
| @@ -43,15 +52,6 @@ | |||
| 43 | 52 | ||
| 44 | 53 | ||
| 45 | /* | 54 | /* |
| 46 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. You | ||
| 47 | ** can also define LUA_32BITS in the make file, but changing here you | ||
| 48 | ** ensure that all software connected to Lua will be compiled with the | ||
| 49 | ** same configuration. | ||
| 50 | */ | ||
| 51 | /* #define LUA_32BITS */ | ||
| 52 | |||
| 53 | |||
| 54 | /* | ||
| 55 | @@ LUA_USE_C89 controls the use of non-ISO-C89 features. | 55 | @@ LUA_USE_C89 controls the use of non-ISO-C89 features. |
| 56 | ** Define it if you want Lua to avoid the use of a few C99 features | 56 | ** Define it if you want Lua to avoid the use of a few C99 features |
| 57 | ** or Windows-specific features on Windows. | 57 | ** or Windows-specific features on Windows. |
| @@ -86,33 +86,42 @@ | |||
| 86 | 86 | ||
| 87 | 87 | ||
| 88 | /* | 88 | /* |
| 89 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for | 89 | @@ LUAI_IS32INT is true iff 'int' has (at least) 32 bits. |
| 90 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does | 90 | ** (the use of two shifts avoids undefined shifts) |
| 91 | ** not need to use this case. | ||
| 92 | */ | 91 | */ |
| 93 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) | 92 | #define LUAI_IS32INT (((UINT_MAX >> 15) >> 15) >= 3) |
| 94 | #define LUA_C89_NUMBERS | 93 | |
| 95 | #endif | 94 | /* }================================================================== */ |
| 96 | 95 | ||
| 97 | 96 | ||
| 98 | 97 | ||
| 99 | /* | 98 | /* |
| 100 | @@ LUAI_BITSINT defines the (minimum) number of bits in an 'int'. | 99 | ** {================================================================== |
| 100 | ** Configuration for Number types. | ||
| 101 | ** =================================================================== | ||
| 101 | */ | 102 | */ |
| 102 | /* avoid undefined shifts */ | 103 | |
| 103 | #if ((INT_MAX >> 15) >> 15) >= 1 | 104 | /* |
| 104 | #define LUAI_BITSINT 32 | 105 | @@ LUA_32BITS enables Lua with 32-bit integers and 32-bit floats. |
| 105 | #else | 106 | */ |
| 106 | /* 'int' always must have at least 16 bits */ | 107 | /* #define LUA_32BITS */ |
| 107 | #define LUAI_BITSINT 16 | 108 | |
| 109 | |||
| 110 | /* | ||
| 111 | @@ LUA_C89_NUMBERS ensures that Lua uses the largest types available for | ||
| 112 | ** C89 ('long' and 'double'); Windows always has '__int64', so it does | ||
| 113 | ** not need to use this case. | ||
| 114 | */ | ||
| 115 | #if defined(LUA_USE_C89) && !defined(LUA_USE_WINDOWS) | ||
| 116 | #define LUA_C89_NUMBERS | ||
| 108 | #endif | 117 | #endif |
| 109 | 118 | ||
| 110 | 119 | ||
| 111 | /* | 120 | /* |
| 112 | @@ LUA_INT_TYPE defines the type for Lua integers. | 121 | @@ LUA_INT_TYPE defines the type for Lua integers. |
| 113 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. | 122 | @@ LUA_FLOAT_TYPE defines the type for Lua floats. |
| 114 | ** Lua should work fine with any mix of these options (if supported | 123 | ** Lua should work fine with any mix of these options supported |
| 115 | ** by your C compiler). The usual configurations are 64-bit integers | 124 | ** by your C compiler. The usual configurations are 64-bit integers |
| 116 | ** and 'double' (the default), 32-bit integers and 'float' (for | 125 | ** and 'double' (the default), 32-bit integers and 'float' (for |
| 117 | ** restricted platforms), and 'long'/'double' (for C compilers not | 126 | ** restricted platforms), and 'long'/'double' (for C compilers not |
| 118 | ** compliant with C99, which may not have support for 'long long'). | 127 | ** compliant with C99, which may not have support for 'long long'). |
| @@ -132,7 +141,7 @@ | |||
| 132 | /* | 141 | /* |
| 133 | ** 32-bit integers and 'float' | 142 | ** 32-bit integers and 'float' |
| 134 | */ | 143 | */ |
| 135 | #if LUAI_BITSINT >= 32 /* use 'int' if big enough */ | 144 | #if LUAI_IS32INT /* use 'int' if big enough */ |
| 136 | #define LUA_INT_TYPE LUA_INT_INT | 145 | #define LUA_INT_TYPE LUA_INT_INT |
| 137 | #else /* otherwise use 'long' */ | 146 | #else /* otherwise use 'long' */ |
| 138 | #define LUA_INT_TYPE LUA_INT_LONG | 147 | #define LUA_INT_TYPE LUA_INT_LONG |
| @@ -164,7 +173,6 @@ | |||
| 164 | 173 | ||
| 165 | 174 | ||
| 166 | 175 | ||
| 167 | |||
| 168 | /* | 176 | /* |
| 169 | ** {================================================================== | 177 | ** {================================================================== |
| 170 | ** Configuration for Paths. | 178 | ** Configuration for Paths. |
| @@ -192,6 +200,7 @@ | |||
| 192 | ** hierarchy or if you want to install your libraries in | 200 | ** hierarchy or if you want to install your libraries in |
| 193 | ** non-conventional directories. | 201 | ** non-conventional directories. |
| 194 | */ | 202 | */ |
| 203 | |||
| 195 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR | 204 | #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR |
| 196 | #if defined(_WIN32) /* { */ | 205 | #if defined(_WIN32) /* { */ |
| 197 | /* | 206 | /* |
| @@ -201,27 +210,40 @@ | |||
| 201 | #define LUA_LDIR "!\\lua\\" | 210 | #define LUA_LDIR "!\\lua\\" |
| 202 | #define LUA_CDIR "!\\" | 211 | #define LUA_CDIR "!\\" |
| 203 | #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" | 212 | #define LUA_SHRDIR "!\\..\\share\\lua\\" LUA_VDIR "\\" |
| 213 | |||
| 214 | #if !defined(LUA_PATH_DEFAULT) | ||
| 204 | #define LUA_PATH_DEFAULT \ | 215 | #define LUA_PATH_DEFAULT \ |
| 205 | LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ | 216 | LUA_LDIR"?.lua;" LUA_LDIR"?\\init.lua;" \ |
| 206 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ | 217 | LUA_CDIR"?.lua;" LUA_CDIR"?\\init.lua;" \ |
| 207 | LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ | 218 | LUA_SHRDIR"?.lua;" LUA_SHRDIR"?\\init.lua;" \ |
| 208 | ".\\?.lua;" ".\\?\\init.lua" | 219 | ".\\?.lua;" ".\\?\\init.lua" |
| 220 | #endif | ||
| 221 | |||
| 222 | #if !defined(LUA_CPATH_DEFAULT) | ||
| 209 | #define LUA_CPATH_DEFAULT \ | 223 | #define LUA_CPATH_DEFAULT \ |
| 210 | LUA_CDIR"?.dll;" \ | 224 | LUA_CDIR"?.dll;" \ |
| 211 | LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ | 225 | LUA_CDIR"..\\lib\\lua\\" LUA_VDIR "\\?.dll;" \ |
| 212 | LUA_CDIR"loadall.dll;" ".\\?.dll" | 226 | LUA_CDIR"loadall.dll;" ".\\?.dll" |
| 227 | #endif | ||
| 213 | 228 | ||
| 214 | #else /* }{ */ | 229 | #else /* }{ */ |
| 215 | 230 | ||
| 216 | #define LUA_ROOT "/usr/local/" | 231 | #define LUA_ROOT "/usr/local/" |
| 217 | #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" | 232 | #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" |
| 218 | #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" | 233 | #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" |
| 234 | |||
| 235 | #if !defined(LUA_PATH_DEFAULT) | ||
| 219 | #define LUA_PATH_DEFAULT \ | 236 | #define LUA_PATH_DEFAULT \ |
| 220 | LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ | 237 | LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ |
| 221 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ | 238 | LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua;" \ |
| 222 | "./?.lua;" "./?/init.lua" | 239 | "./?.lua;" "./?/init.lua" |
| 240 | #endif | ||
| 241 | |||
| 242 | #if !defined(LUA_CPATH_DEFAULT) | ||
| 223 | #define LUA_CPATH_DEFAULT \ | 243 | #define LUA_CPATH_DEFAULT \ |
| 224 | LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" | 244 | LUA_CDIR"?.so;" LUA_CDIR"loadall.so;" "./?.so" |
| 245 | #endif | ||
| 246 | |||
| 225 | #endif /* } */ | 247 | #endif /* } */ |
| 226 | 248 | ||
| 227 | 249 | ||
| @@ -230,12 +252,16 @@ | |||
| 230 | ** CHANGE it if your machine does not use "/" as the directory separator | 252 | ** CHANGE it if your machine does not use "/" as the directory separator |
| 231 | ** and is not Windows. (On Windows Lua automatically uses "\".) | 253 | ** and is not Windows. (On Windows Lua automatically uses "\".) |
| 232 | */ | 254 | */ |
| 255 | #if !defined(LUA_DIRSEP) | ||
| 256 | |||
| 233 | #if defined(_WIN32) | 257 | #if defined(_WIN32) |
| 234 | #define LUA_DIRSEP "\\" | 258 | #define LUA_DIRSEP "\\" |
| 235 | #else | 259 | #else |
| 236 | #define LUA_DIRSEP "/" | 260 | #define LUA_DIRSEP "/" |
| 237 | #endif | 261 | #endif |
| 238 | 262 | ||
| 263 | #endif | ||
| 264 | |||
| 239 | /* }================================================================== */ | 265 | /* }================================================================== */ |
| 240 | 266 | ||
| 241 | 267 | ||
| @@ -632,7 +658,7 @@ | |||
| 632 | /* | 658 | /* |
| 633 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). | 659 | @@ lua_getlocaledecpoint gets the locale "radix character" (decimal point). |
| 634 | ** Change that if you do not want to use C locales. (Code using this | 660 | ** Change that if you do not want to use C locales. (Code using this |
| 635 | ** macro must include header 'locale.h'.) | 661 | ** macro must include the header 'locale.h'.) |
| 636 | */ | 662 | */ |
| 637 | #if !defined(lua_getlocaledecpoint) | 663 | #if !defined(lua_getlocaledecpoint) |
| 638 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) | 664 | #define lua_getlocaledecpoint() (localeconv()->decimal_point[0]) |
| @@ -673,7 +699,7 @@ | |||
| 673 | ** {================================================================== | 699 | ** {================================================================== |
| 674 | ** Macros that affect the API and must be stable (that is, must be the | 700 | ** Macros that affect the API and must be stable (that is, must be the |
| 675 | ** same when you compile Lua and when you compile code that links to | 701 | ** same when you compile Lua and when you compile code that links to |
| 676 | ** Lua). You probably do not want/need to change them. | 702 | ** Lua). |
| 677 | ** ===================================================================== | 703 | ** ===================================================================== |
| 678 | */ | 704 | */ |
| 679 | 705 | ||
| @@ -684,7 +710,7 @@ | |||
| 684 | ** space (and to reserve some numbers for pseudo-indices). | 710 | ** space (and to reserve some numbers for pseudo-indices). |
| 685 | ** (It must fit into max(size_t)/32.) | 711 | ** (It must fit into max(size_t)/32.) |
| 686 | */ | 712 | */ |
| 687 | #if LUAI_BITSINT >= 32 | 713 | #if LUAI_IS32INT |
| 688 | #define LUAI_MAXSTACK 1000000 | 714 | #define LUAI_MAXSTACK 1000000 |
| 689 | #else | 715 | #else |
| 690 | #define LUAI_MAXSTACK 15000 | 716 | #define LUAI_MAXSTACK 15000 |
| @@ -28,7 +28,7 @@ | |||
| 28 | /* | 28 | /* |
| 29 | ** Integer type for decoded UTF-8 values; MAXUTF needs 31 bits. | 29 | ** Integer type for decoded UTF-8 values; MAXUTF needs 31 bits. |
| 30 | */ | 30 | */ |
| 31 | #if LUAI_BITSINT >= 31 | 31 | #if ((UINT_MAX >> 15) >> 15) >= 1 |
| 32 | typedef unsigned int utfint; | 32 | typedef unsigned int utfint; |
| 33 | #else | 33 | #else |
| 34 | typedef unsigned long utfint; | 34 | typedef unsigned long utfint; |
