csto: change comment style to match style(9)

See http://man.openbsd.org/style.9
This commit is contained in:
Jeremy Baxter 2024-03-12 11:56:38 +13:00
parent 50ac27f569
commit 784fd5e787

114
csto.c
View file

@ -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)) {
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) {
(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
** 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;
@ -90,8 +90,8 @@ 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);
@ -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
** 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) {
@ -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) {
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
** 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;
@ -157,12 +157,12 @@ 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;
@ -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) {
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) {
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
** 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;
@ -308,9 +308,9 @@ 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;
@ -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)
@ -370,8 +370,8 @@ 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) /* { */
@ -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
** 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) /* { */
@ -416,9 +416,9 @@ 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)
@ -436,9 +436,9 @@ 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) {
@ -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) {
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
** 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 */
@ -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) {
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
** 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;
@ -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) {
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
** 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;
@ -574,8 +574,8 @@ 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);