Go to the documentation of this file.
32 #if !defined(l_checkmode)
35 #if !defined(L_MODEEXT)
41 return (*mode !=
'\0' && strchr(
"rwa", *(mode++)) != NULL &&
42 (*mode !=
'+' || ((
void)(++mode), 1)) &&
43 (strspn(mode,
L_MODEEXT) == strlen(mode)));
57 #if defined(LUA_USE_POSIX)
59 #define l_popen(L,c,m) (fflush(NULL), popen(c,m))
60 #define l_pclose(L,file) (pclose(file))
62 #elif defined(LUA_USE_WINDOWS)
64 #define l_popen(L,c,m) (_popen(c,m))
65 #define l_pclose(L,file) (_pclose(file))
67 #if !defined(l_checkmodep)
69 #define l_checkmodep(m) ((m[0] == 'r' || m[0] == 'w') && \
70 (m[1] == '\0' || ((m[1] == 'b' || m[1] == 't') && m[2] == '\0')))
76 #define l_popen(L,c,m) \
78 luaL_error(L, "'popen' not supported"), \
80 #define l_pclose(L,file) ((void)L, (void)file, -1)
87 #if !defined(l_checkmodep)
89 #define l_checkmodep(m) ((m[0] == 'r' || m[0] == 'w') && m[1] == '\0')
97 #if defined(LUA_USE_POSIX)
98 #define l_getc(f) getc_unlocked(f)
99 #define l_lockfile(f) flockfile(f)
100 #define l_unlockfile(f) funlockfile(f)
102 #define l_getc(f) getc(f)
103 #define l_lockfile(f) ((void)0)
104 #define l_unlockfile(f) ((void)0)
116 #if !defined(l_fseek)
118 #if defined(LUA_USE_POSIX)
120 #include <sys/types.h>
122 #define l_fseek(f,o,w) fseeko(f,o,w)
123 #define l_ftell(f) ftello(f)
124 #define l_seeknum off_t
126 #elif defined(LUA_USE_WINDOWS) && !defined(_CRTIMP_TYPEINFO) \
127 && defined(_MSC_VER) && (_MSC_VER >= 1400)
130 #define l_fseek(f,o,w) _fseeki64(f,o,w)
131 #define l_ftell(f) _ftelli64(f)
132 #define l_seeknum __int64
137 #define l_fseek(f,o,w) fseek(f,o,w)
138 #define l_ftell(f) ftell(f)
139 #define l_seeknum long
149 #define IO_PREFIX "_IO_"
150 #define IOPREF_LEN (sizeof(IO_PREFIX)/sizeof(char) - 1)
151 #define IO_INPUT (IO_PREFIX "input")
152 #define IO_OUTPUT (IO_PREFIX "output")
158 #define tolstream(L) ((LStream *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
160 #define isclosed(p) ((p)->closef == NULL)
190 luaL_error(L,
"attempt to use a closed file");
248 int res = fclose(p->
f);
263 p->
f = fopen(fname, mode);
264 if (l_unlikely(p->
f == NULL))
265 luaL_error(L,
"cannot open file '%s' (%s)", fname, strerror(errno));
273 const char *md = mode;
275 p->
f = fopen(filename, mode);
352 #define MAXARGLINE 250
421 #if !defined (L_MAXLENNUM)
422 #define L_MAXLENNUM 200
444 rn->
buff[rn->
n++] = rn->
c;
455 if (rn->
c ==
set[0] || rn->
c ==
set[1])
466 while ((hex ? isxdigit(rn->
c) : isdigit(rn->
c)) &&
nextc(rn))
486 do { rn.
c =
l_getc(rn.
f); }
while (isspace(rn.
c));
488 if (
test2(&rn,
"00")) {
489 if (
test2(&rn,
"xX")) hex = 1;
493 if (
test2(&rn, decp))
495 if (
count > 0 &&
test2(&rn, (hex ?
"pP" :
"eE"))) {
501 rn.
buff[rn.
n] =
'\0';
531 }
while (c != EOF && c !=
'\n');
532 if (!chop && c ==
'\n')
559 nr = fread(p,
sizeof(
char), n,
f);
578 for (n =
first; nargs-- && success; n++) {
634 return luaL_error(L,
"file is already closed");
637 for (i = 1; i <= n; i++)
663 for (; nargs--;
arg++) {
671 status = status && (len > 0);
676 status = status && (fwrite(
s,
sizeof(
char), l,
f) == l);
679 if (l_likely(status))
698 static const int mode[] = {SEEK_SET, SEEK_CUR, SEEK_END};
699 static const char *
const modenames[] = {
"set",
"cur",
"end", NULL};
705 "not an integer in proper range");
717 static const int mode[] = {_IONBF, _IOFBF, _IOLBF};
718 static const char *
const modenames[] = {
"no",
"full",
"line", NULL};
722 int res = setvbuf(
f, NULL, mode[
op], (
size_t)sz);
#define luaL_optstring(L, n, d)
static int read_line(lua_State *L, FILE *f, int chop)
#define lua_pushliteral(L, s)
LUA_API void lua_rotate(lua_State *L, int idx, int n)
auto first(const T &value, const Tail &...) -> const T &
static int read_chars(lua_State *L, FILE *f, size_t n)
static int io_noclose(lua_State *L)
static int f_flush(lua_State *L)
static int io_readline(lua_State *L)
static int io_popen(lua_State *L)
static int f_setvbuf(lua_State *L)
#define lua_tostring(L, i)
static int io_write(lua_State *L)
static LStream * newfile(lua_State *L)
#define luaL_checkstring(L, n)
static void read_all(lua_State *L, FILE *f)
span_CONFIG_SIZE_TYPE size_t
#define lua_replace(L, idx)
LUA_API int lua_getfield(lua_State *L, int idx, const char *k)
LUALIB_API void luaL_buffinit(lua_State *L, luaL_Buffer *B)
LUA_API void lua_pushinteger(lua_State *L, lua_Integer n)
static const luaL_Reg metameth[]
#define luaL_newlibtable(L, l)
static int g_read(lua_State *L, FILE *f, int first)
const LUA_API char * lua_pushfstring(lua_State *L, const char *fmt,...)
static int io_pclose(lua_State *L)
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
LUALIB_API int luaL_checkoption(lua_State *L, int arg, const char *def, const char *const lst[])
static void createstdfile(lua_State *L, FILE *f, const char *k, const char *fname)
LUA_API lua_Unsigned lua_rawlen(lua_State *L, int idx)
#define lua_isnoneornil(L, n)
LUA_API int lua_type(lua_State *L, int idx)
static int f_close(lua_State *L)
const LUALIB_API char * luaL_checklstring(lua_State *L, int arg, size_t *len)
static int g_write(lua_State *L, FILE *f, int arg)
static int io_output(lua_State *L)
LUA_API int lua_isinteger(lua_State *L, int idx)
LUALIB_API void luaL_pushresult(luaL_Buffer *B)
LUALIB_API void * luaL_testudata(lua_State *L, int ud, const char *tname)
LUALIB_API int luaL_fileresult(lua_State *L, int stat, const char *fname)
static void createmeta(lua_State *L)
static int readdigits(RN *rn, int hex)
LUALIB_API int luaL_newmetatable(lua_State *L, const char *tname)
constexpr auto count() -> size_t
static const luaL_Reg meth[]
static void aux_lines(lua_State *L, int toclose)
#define lua_tointeger(L, i)
LUA_API void lua_setfield(lua_State *L, int idx, const char *k)
LUA_API void lua_pushcclosure(lua_State *L, lua_CFunction fn, int n)
LUAMOD_API int luaopen_io(lua_State *L)
static int f_lines(lua_State *L)
LUALIB_API int luaL_execresult(lua_State *L, int stat)
static const luaL_Reg iolib[]
static int io_fclose(lua_State *L)
LUALIB_API int luaL_argerror(lua_State *L, int arg, const char *extramsg)
LUALIB_API void luaL_checkany(lua_State *L, int arg)
static int g_iofile(lua_State *L, const char *f, const char *mode)
static int aux_close(lua_State *L)
#define l_pclose(L, file)
#define LUA_REGISTRYINDEX
static int read_number(lua_State *L, FILE *f)
LUA_API void * lua_touserdata(lua_State *L, int idx)
static int f_read(lua_State *L)
static FILE * tofile(lua_State *L)
static int f_gc(lua_State *L)
#define luaL_prepbuffer(B)
#define luaL_argcheck(L, cond, arg, extramsg)
#define luaL_addchar(B, c)
constexpr auto set(type rhs) -> int
LUA_API int lua_gettop(lua_State *L)
LUA_API void lua_settop(lua_State *L, int idx)
LUA_API void lua_pushboolean(lua_State *L, int b)
LUA_API void lua_pushvalue(lua_State *L, int idx)
static int io_open(lua_State *L)
static int f_tostring(lua_State *L)
static int io_tmpfile(lua_State *L)
static int io_input(lua_State *L)
static int io_lines(lua_State *L)
static int test_eof(lua_State *L, FILE *f)
#define lua_getlocaledecpoint()
LUALIB_API char * luaL_prepbuffsize(luaL_Buffer *B, size_t sz)
static int io_type(lua_State *L)
static int f_seek(lua_State *L)
static FILE * getiofile(lua_State *L, const char *findex)
LUALIB_API void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
LUALIB_API lua_Integer luaL_optinteger(lua_State *L, int arg, lua_Integer def)
LUALIB_API void luaL_checkstack(lua_State *L, int space, const char *msg)
#define luaL_newlib(L, l)
#define lua_tonumber(L, i)
LUALIB_API int luaL_error(lua_State *L, const char *fmt,...)
LUA_API void * lua_newuserdatauv(lua_State *L, size_t size, int nuvalue)
LUALIB_API lua_Integer luaL_checkinteger(lua_State *L, int arg)
LUA_API size_t lua_stringtonumber(lua_State *L, const char *s)
int(* lua_CFunction)(lua_State *L)
LUA_API void lua_pushnil(lua_State *L)
LUA_API int lua_toboolean(lua_State *L, int idx)
static void opencheck(lua_State *L, const char *fname, const char *mode)
static int io_flush(lua_State *L)
#define lua_upvalueindex(i)
static int io_read(lua_State *L)
#define luaL_addsize(B, s)
static int f_write(lua_State *L)
static int test2(RN *rn, const char *set)
static int io_close(lua_State *L)
static LStream * newprefile(lua_State *L)
LUALIB_API void luaL_setmetatable(lua_State *L, const char *tname)
static int l_checkmode(const char *mode)
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44