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