lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


With respect to the output stream problem on Windows. ie. you cannot
redirect stdout easily to catch Lua output.

How about adding:

typedef void (*lua_print)(char*,...);
lua_print lua_stderr = lua_defaulterr;
lua_print lua_stdout = lua_defaultout;

then all Lua output can be sent to lua_stdout & lua_stderr,

eg.
lua_stderr("An error occured %s", "this file.");

instead of


fprintf(stderr,"An error occured %s", "this file.");

with default values:

void lua_defaulterr(char* p_print,...)
{
 va_list ap;
    va_start(ap, p_print);
 vfprintf(stderr,p_print, ap);
    va_end(ap);
}

void lua_defaultout(char* p_print,...)
{
 va_list ap;
    va_start(ap, p_print);
 vfprintf(stdout,p_print, ap);
    va_end(ap);
}

then you can use change lua_stdout to, say:

void lua_mystdout(char* fmt,...)
{
 char buff[256];
 va_list arglist;

 va_start(arglist, fmt);
 vsprintf(buff, fmt, arglist);
 va_end(arglist);

 lua_error(luastate,buff);
}


It's a bit more elegant than macros?

Nick



----------------------------------------------------------------------------
------------
This email transmission and the information contained herein or attached
hereto is intended only for the person or entity to which it is addressed
and may contain confidential and/or privileged material.

Any review, transmission, disclosure, distribution, copying, dissemination
or other use of, or taking of action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.

If you have received this communication in error, please contact Video
System Ltd. at mailerror@videosystem.co.uk and delete the material from any
computer.

Video System Ltd. +44 (0)161 955 4402
----------------------------------------------------------------------------
------------