| 2970 | #endif /* Lua File Buffer Size */ |
| 2971 | |
| 2972 | static char* compat53_strerror(int en, char* buff, size_t sz) { |
| 2973 | #if COMPAT53_HAVE_STRERROR_R |
| 2974 | /* use strerror_r here, because it's available on these specific platforms */ |
| 2975 | if (sz > 0) { |
| 2976 | buff[0] = '\0'; |
| 2977 | /* we don't care whether the GNU version or the XSI version is used: */ |
| 2978 | if (strerror_r(en, buff, sz)) { |
| 2979 | /* Yes, we really DO want to ignore the return value! |
| 2980 | * GCC makes that extra hard, not even a (void) cast will do. */ |
| 2981 | } |
| 2982 | if (buff[0] == '\0') { |
| 2983 | /* Buffer is unchanged, so we probably have called GNU strerror_r which |
| 2984 | * returned a static constant string. Chances are that strerror will |
| 2985 | * return the same static constant string and therefore be thread-safe. */ |
| 2986 | return strerror(en); |
| 2987 | } |
| 2988 | } |
| 2989 | return buff; /* sz is 0 *or* strerror_r wrote into the buffer */ |
| 2990 | #elif COMPAT53_HAVE_STRERROR_S |
| 2991 | /* for MSVC and other C11 implementations, use strerror_s since it's |
| 2992 | * provided by default by the libraries */ |
| 2993 | strerror_s(buff, sz, en); |
| 2994 | return buff; |
| 2995 | #else |
| 2996 | /* fallback, but strerror is not guaranteed to be threadsafe due to modifying |
| 2997 | * errno itself and some impls not locking a static buffer for it ... but most |
| 2998 | * known systems have threadsafe errno: this might only change if the locale |
| 2999 | * is changed out from under someone while this function is being called */ |
| 3000 | (void)buff; |
| 3001 | (void)sz; |
| 3002 | return strerror(en); |
| 3003 | #endif |
| 3004 | } |
| 3005 | |
| 3006 | COMPAT53_API int lua_absindex(lua_State* L, int i) { |
| 3007 | if (i < 0 && i > LUA_REGISTRYINDEX) |
no outgoing calls
no test coverage detected