csto: change comment style to match style(9)
See http://man.openbsd.org/style.9
This commit is contained in:
parent
50ac27f569
commit
784fd5e787
1 changed files with 81 additions and 81 deletions
162
csto.c
162
csto.c
|
@ -32,8 +32,8 @@ static const char *progname = LUA_PROGNAME;
|
|||
|
||||
|
||||
/*
|
||||
** Use 'sigaction' when available.
|
||||
*/
|
||||
* Use 'sigaction' when available.
|
||||
*/
|
||||
static void setsignal (int sig, void (*handler)(int)) {
|
||||
struct sigaction sa;
|
||||
sa.sa_handler = handler;
|
||||
|
@ -44,8 +44,8 @@ static void setsignal (int sig, void (*handler)(int)) {
|
|||
|
||||
|
||||
/*
|
||||
** Hook set by signal function to stop the interpreter.
|
||||
*/
|
||||
* Hook set by signal function to stop the interpreter.
|
||||
*/
|
||||
static void lstop (lua_State *L, lua_Debug *ar) {
|
||||
(void)ar; /* unused arg. */
|
||||
lua_sethook(L, NULL, 0, 0); /* reset hook */
|
||||
|
@ -54,11 +54,11 @@ static void lstop (lua_State *L, lua_Debug *ar) {
|
|||
|
||||
|
||||
/*
|
||||
** Function to be called at a C signal. Because a C signal cannot
|
||||
** just change a Lua state (as there is no proper synchronization),
|
||||
** this function only sets a hook that, when called, will stop the
|
||||
** interpreter.
|
||||
*/
|
||||
* Function to be called at a C signal. Because a C signal cannot
|
||||
* just change a Lua state (as there is no proper synchronization),
|
||||
* this function only sets a hook that, when called, will stop the
|
||||
* interpreter.
|
||||
*/
|
||||
static void laction (int i) {
|
||||
int flag = LUA_MASKCALL | LUA_MASKRET | LUA_MASKLINE | LUA_MASKCOUNT;
|
||||
setsignal(i, SIG_DFL); /* if another SIGINT happens, terminate process */
|
||||
|
@ -90,9 +90,9 @@ static void print_usage (const char *badoption) {
|
|||
|
||||
|
||||
/*
|
||||
** Prints an error message, adding the program name in front of it
|
||||
** (if present)
|
||||
*/
|
||||
* Prints an error message, adding the program name in front of it
|
||||
* (if present)
|
||||
*/
|
||||
static void l_message (const char *pname, const char *msg) {
|
||||
if (pname) lua_writestringerror("%s: ", pname);
|
||||
lua_writestringerror("%s\n", msg);
|
||||
|
@ -100,10 +100,10 @@ static void l_message (const char *pname, const char *msg) {
|
|||
|
||||
|
||||
/*
|
||||
** Check whether 'status' is not OK and, if so, prints the error
|
||||
** message on the top of the stack. It assumes that the error object
|
||||
** is a string, as it was either generated by Lua or by 'msghandler'.
|
||||
*/
|
||||
* Check whether 'status' is not OK and, if so, prints the error
|
||||
* message on the top of the stack. It assumes that the error object
|
||||
* is a string, as it was either generated by Lua or by 'msghandler'.
|
||||
*/
|
||||
static int report (lua_State *L, int status) {
|
||||
if (status != LUA_OK) {
|
||||
const char *msg = lua_tostring(L, -1);
|
||||
|
@ -115,8 +115,8 @@ static int report (lua_State *L, int status) {
|
|||
|
||||
|
||||
/*
|
||||
** Message handler used to run all chunks
|
||||
*/
|
||||
* Message handler used to run all chunks
|
||||
*/
|
||||
static int msghandler (lua_State *L) {
|
||||
const char *msg = lua_tostring(L, 1);
|
||||
if (msg == NULL) { /* is error object not a string? */
|
||||
|
@ -133,9 +133,9 @@ static int msghandler (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** Interface to 'lua_pcall', which sets appropriate message function
|
||||
** and C-signal handler. Used to run all chunks.
|
||||
*/
|
||||
* Interface to 'lua_pcall', which sets appropriate message function
|
||||
* and C-signal handler. Used to run all chunks.
|
||||
*/
|
||||
static int docall (lua_State *L, int narg, int nres) {
|
||||
int status;
|
||||
int base = lua_gettop(L) - narg; /* function index */
|
||||
|
@ -157,13 +157,13 @@ static void print_version (void) {
|
|||
|
||||
|
||||
/*
|
||||
** Create the 'arg' table, which stores all arguments from the
|
||||
** command line ('argv'). It should be aligned so that, at index 0,
|
||||
** it has 'argv[script]', which is the script name. The arguments
|
||||
** to the script (everything after 'script') go to positive indices;
|
||||
** other arguments (before the script name) go to negative indices.
|
||||
** If there is no script name, assume interpreter's name as base.
|
||||
*/
|
||||
* Create the 'arg' table, which stores all arguments from the
|
||||
* command line ('argv'). It should be aligned so that, at index 0,
|
||||
* it has 'argv[script]', which is the script name. The arguments
|
||||
* to the script (everything after 'script') go to positive indices;
|
||||
* other arguments (before the script name) go to negative indices.
|
||||
* If there is no script name, assume interpreter's name as base.
|
||||
*/
|
||||
static void createargtable (lua_State *L, char **argv, int argc, int script) {
|
||||
int i, narg;
|
||||
if (script == argc) script = 0; /* no script name? */
|
||||
|
@ -194,8 +194,8 @@ static int dostring (lua_State *L, const char *s, const char *name) {
|
|||
|
||||
|
||||
/*
|
||||
** Receives 'globname[=modname]' and runs 'globname = require(modname)'.
|
||||
*/
|
||||
* Receives 'globname[=modname]' and runs 'globname = require(modname)'.
|
||||
*/
|
||||
static int dolibrary (lua_State *L, char *globname) {
|
||||
int status;
|
||||
char *modname = strchr(globname, '=');
|
||||
|
@ -215,8 +215,8 @@ static int dolibrary (lua_State *L, char *globname) {
|
|||
|
||||
|
||||
/*
|
||||
** Push on the stack the contents of table 'arg' from 1 to #arg
|
||||
*/
|
||||
* Push on the stack the contents of table 'arg' from 1 to #arg
|
||||
*/
|
||||
static int pushargs (lua_State *L) {
|
||||
int i, n;
|
||||
if (lua_getglobal(L, "arg") != LUA_TTABLE)
|
||||
|
@ -253,11 +253,11 @@ static int handle_script (lua_State *L, char **argv) {
|
|||
|
||||
|
||||
/*
|
||||
** Traverses all arguments from 'argv', returning a mask with those
|
||||
** needed before running any Lua code (or an error code if it finds
|
||||
** any invalid argument). 'first' returns the first not-handled argument
|
||||
** (either the script name or a bad argument in case of error).
|
||||
*/
|
||||
* Traverses all arguments from 'argv', returning a mask with those
|
||||
* needed before running any Lua code (or an error code if it finds
|
||||
* any invalid argument). 'first' returns the first not-handled argument
|
||||
* (either the script name or a bad argument in case of error).
|
||||
*/
|
||||
static int collectargs (char **argv, int *first) {
|
||||
int args = 0;
|
||||
int i;
|
||||
|
@ -308,10 +308,10 @@ static int collectargs (char **argv, int *first) {
|
|||
|
||||
|
||||
/*
|
||||
** Processes options 'e' and 'l', which involve running Lua code, and
|
||||
** 'W', which also affects the state.
|
||||
** Returns 0 if some code raises an error.
|
||||
*/
|
||||
* Processes options 'e' and 'l', which involve running Lua code, and
|
||||
* 'W', which also affects the state.
|
||||
* Returns 0 if some code raises an error.
|
||||
*/
|
||||
static int runargs (lua_State *L, char **argv, int n) {
|
||||
int i;
|
||||
for (i = 1; i < n; i++) {
|
||||
|
@ -354,10 +354,10 @@ static int handle_luainit (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** {==================================================================
|
||||
** Read-Eval-Print Loop (REPL)
|
||||
** ===================================================================
|
||||
*/
|
||||
* {==================================================================
|
||||
* Read-Eval-Print Loop (REPL)
|
||||
* ===================================================================
|
||||
*/
|
||||
|
||||
#if !defined(LUA_PROMPT)
|
||||
#define LUA_PROMPT "> "
|
||||
|
@ -370,9 +370,9 @@ static int handle_luainit (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** lua_stdin_is_tty detects whether the standard input is a 'tty' (that
|
||||
** is, whether we're running lua interactively).
|
||||
*/
|
||||
* lua_stdin_is_tty detects whether the standard input is a 'tty' (that
|
||||
* is, whether we're running lua interactively).
|
||||
*/
|
||||
#if !defined(lua_stdin_is_tty) /* { */
|
||||
|
||||
#define lua_stdin_is_tty() isatty(0)
|
||||
|
@ -381,11 +381,11 @@ static int handle_luainit (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** lua_readline defines how to show a prompt and then read a line from
|
||||
** the standard input.
|
||||
** lua_saveline defines how to "save" a read line in a "history".
|
||||
** lua_freeline defines how to free a line read by lua_readline.
|
||||
*/
|
||||
* lua_readline defines how to show a prompt and then read a line from
|
||||
* the standard input.
|
||||
* lua_saveline defines how to "save" a read line in a "history".
|
||||
* lua_freeline defines how to free a line read by lua_readline.
|
||||
*/
|
||||
#if !defined(lua_readline) /* { */
|
||||
|
||||
#if defined(LUA_USE_READLINE) /* { */
|
||||
|
@ -416,10 +416,10 @@ static int handle_luainit (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** Return the string to be used as a prompt by the interpreter. Leave
|
||||
** the string (or nil, if using the default value) on the stack, to keep
|
||||
** it anchored.
|
||||
*/
|
||||
* Return the string to be used as a prompt by the interpreter. Leave
|
||||
* the string (or nil, if using the default value) on the stack, to keep
|
||||
* it anchored.
|
||||
*/
|
||||
static const char *get_prompt (lua_State *L, int firstline) {
|
||||
if (lua_getglobal(L, firstline ? "_PROMPT" : "_PROMPT2") == LUA_TNIL)
|
||||
return (firstline ? LUA_PROMPT : LUA_PROMPT2); /* use the default */
|
||||
|
@ -436,10 +436,10 @@ static const char *get_prompt (lua_State *L, int firstline) {
|
|||
|
||||
|
||||
/*
|
||||
** Check whether 'status' signals a syntax error and the error
|
||||
** message at the top of the stack ends with the above mark for
|
||||
** incomplete statements.
|
||||
*/
|
||||
* Check whether 'status' signals a syntax error and the error
|
||||
* message at the top of the stack ends with the above mark for
|
||||
* incomplete statements.
|
||||
*/
|
||||
static int incomplete (lua_State *L, int status) {
|
||||
if (status == LUA_ERRSYNTAX) {
|
||||
size_t lmsg;
|
||||
|
@ -454,8 +454,8 @@ static int incomplete (lua_State *L, int status) {
|
|||
|
||||
|
||||
/*
|
||||
** Prompt the user, read a line, and push it into the Lua stack.
|
||||
*/
|
||||
* Prompt the user, read a line, and push it into the Lua stack.
|
||||
*/
|
||||
static int pushline (lua_State *L, int firstline) {
|
||||
char buffer[LUA_MAXINPUT];
|
||||
char *b = buffer;
|
||||
|
@ -478,9 +478,9 @@ static int pushline (lua_State *L, int firstline) {
|
|||
|
||||
|
||||
/*
|
||||
** Try to compile line on the stack as 'return <line>;'; on return, stack
|
||||
** has either compiled chunk or original line (if compilation failed).
|
||||
*/
|
||||
* Try to compile line on the stack as 'return <line>;'; on return, stack
|
||||
* has either compiled chunk or original line (if compilation failed).
|
||||
*/
|
||||
static int addreturn (lua_State *L) {
|
||||
const char *line = lua_tostring(L, -1); /* original line */
|
||||
const char *retline = lua_pushfstring(L, "return %s;", line);
|
||||
|
@ -497,8 +497,8 @@ static int addreturn (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** Read multiple lines until a complete Lua statement
|
||||
*/
|
||||
* Read multiple lines until a complete Lua statement
|
||||
*/
|
||||
static int multiline (lua_State *L) {
|
||||
for (;;) { /* repeat until gets a complete statement */
|
||||
size_t len;
|
||||
|
@ -516,11 +516,11 @@ static int multiline (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** Read a line and try to load (compile) it first as an expression (by
|
||||
** adding "return " in front of it) and second as a statement. Return
|
||||
** the final status of load/call with the resulting function (if any)
|
||||
** in the top of the stack.
|
||||
*/
|
||||
* Read a line and try to load (compile) it first as an expression (by
|
||||
* adding "return " in front of it) and second as a statement. Return
|
||||
* the final status of load/call with the resulting function (if any)
|
||||
* in the top of the stack.
|
||||
*/
|
||||
static int loadline (lua_State *L) {
|
||||
int status;
|
||||
lua_settop(L, 0);
|
||||
|
@ -535,8 +535,8 @@ static int loadline (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** Prints (calling the Lua 'print' function) any values on the stack
|
||||
*/
|
||||
* Prints (calling the Lua 'print' function) any values on the stack
|
||||
*/
|
||||
static void l_print (lua_State *L) {
|
||||
int n = lua_gettop(L);
|
||||
if (n > 0) { /* any result to be printed? */
|
||||
|
@ -551,9 +551,9 @@ static void l_print (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** Do the REPL: repeatedly read (load) a line, evaluate (call) it, and
|
||||
** print any results.
|
||||
*/
|
||||
* Do the REPL: repeatedly read (load) a line, evaluate (call) it, and
|
||||
* print any results.
|
||||
*/
|
||||
static void doREPL (lua_State *L) {
|
||||
int status;
|
||||
const char *oldprogname = progname;
|
||||
|
@ -574,9 +574,9 @@ static void doREPL (lua_State *L) {
|
|||
|
||||
|
||||
/*
|
||||
** Main body of stand-alone interpreter (to be called in protected mode).
|
||||
** Reads the options and handles them all.
|
||||
*/
|
||||
* Main body of stand-alone interpreter (to be called in protected mode).
|
||||
* Reads the options and handles them all.
|
||||
*/
|
||||
static int pmain (lua_State *L) {
|
||||
int argc = (int)lua_tointeger(L, 1);
|
||||
char **argv = (char **)lua_touserdata(L, 2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue