Skip to content

Commit

Permalink
corrected comments, copyright always prints, updated help dialog, for…
Browse files Browse the repository at this point in the history
…matting
  • Loading branch information
tilkinsc committed Jun 14, 2017
1 parent e729b26 commit 48eb9a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
13 changes: 8 additions & 5 deletions src/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,13 @@ typedef enum LuaConsoleError {

// usage message
const char HELP_MESSAGE[] =
"Lua Console | Version: 5/6/2017\n"
"Lua Console | Version: 6/13/2017\n"
LUA_COPYRIGHT
LUA_CONSOLE_COPYRIGHT
"\n"
"Supports Lua5.3, Lua5.2, Lua5.1\n"
"5.2.x and 5.1.x assume that you have enough memory for initial functions.\n"
"\n"
"\t- Line by Line interpretation\n"
"\t- Files executed by passing\n"
"\t- Working directory support\n"
"\t- Built in stack-dump\n"
Expand All @@ -79,7 +78,6 @@ static lua_State* L;

// necessary to put this outside of main, print doesn't work
static int no_libraries = 0;
static int squelch = 0;



Expand Down Expand Up @@ -153,6 +151,7 @@ int main(int argc, char* argv[])
int no_file = 0;
char* start = 0;
int no_additions = 0;
int copyright_squelch = 0;

int parameters = 0;
char** parameters_argv = 0;
Expand Down Expand Up @@ -193,7 +192,7 @@ int main(int argc, char* argv[])
no_additions = 1;
break;
case 'c': case 'C':
squelch = 1;
copyright_squelch = 1;
break;
case 'n': case 'N':
parameters = argc - i - 1;
Expand Down Expand Up @@ -245,6 +244,11 @@ int main(int argc, char* argv[])
lua_close(gL);
}

// copyright
if(copyright_squelch == 0) {
fprintf(stdout, LUA_COPYRIGHT "\n");
fprintf(stdout, LUA_CONSOLE_COPYRIGHT);
}

// if there is nothing to do, then exit, as there is nothing left to do
if(no_file == 1) {
Expand All @@ -257,7 +261,6 @@ int main(int argc, char* argv[])
if(no_additions == 0)
additions_add(L);


// load function into protected mode (pcall)
int status = start_protective_mode(&lua_main_dofile, argv[1], parameters_argv, parameters);

Expand Down
21 changes: 10 additions & 11 deletions src/consolew.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#define PRIMARY_BUFFER_SIZE 1025
#define SECONDARY_BUFFER_SIZE 1033


// internal enums, represent lua error category
typedef enum LuaConsoleError {
INTERNAL_ERROR = 0,
Expand All @@ -49,7 +48,7 @@ typedef enum LuaConsoleError {

// usage message
const char HELP_MESSAGE[] =
"Lua Console | Version: 5/6/2017\n"
"Lua Console | Version: 6/13/2017\n"
LUA_COPYRIGHT
LUA_CONSOLE_COPYRIGHT
"\n"
Expand Down Expand Up @@ -78,12 +77,11 @@ const char HELP_MESSAGE[] =
static lua_State* L;


// variable to end line by line iterpretation loop
// variable to end line by line iterpretation loop, for adaption
static int should_close = 0;

// necessary to put this outside of main, print doesn't work
static int no_libraries = 0;
static int squelch = 0;



Expand Down Expand Up @@ -123,11 +121,6 @@ static int lua_main_postexist(lua_State* L) {
exit(EXIT_FAILURE);
}

if(squelch == 0) {
printf(LUA_COPYRIGHT "\n");
printf(LUA_CONSOLE_COPYRIGHT);
}

int status = 0;
while(should_close != 1) {
// reset
Expand Down Expand Up @@ -238,6 +231,7 @@ int main(int argc, char* argv[])
int no_file = 0;
char* start = 0;
int no_additions = 0;
int copyright_squelch = 0;

int parameters = 0;
char** parameters_argv = 0;
Expand Down Expand Up @@ -283,7 +277,7 @@ int main(int argc, char* argv[])
no_additions = 1;
break;
case 'c': case 'C':
squelch = 1;
copyright_squelch = 1;
break;
case 'n': case 'N':
parameters = argc - i - 1;
Expand Down Expand Up @@ -335,6 +329,12 @@ int main(int argc, char* argv[])
lua_close(gL);
}

// copyright
if(copyright_squelch == 0) {
fprintf(stdout, LUA_COPYRIGHT "\n");
fprintf(stdout, LUA_CONSOLE_COPYRIGHT);
}


// if there is nothing to do, then exit, as there is nothing left to do
if(no_file == 1 && post_exist != 1) {
Expand All @@ -347,7 +347,6 @@ int main(int argc, char* argv[])
if(no_additions == 0)
additions_add(L);


// load function into protected mode (pcall)
int status = 0;
if(post_exist == 1) {
Expand Down

0 comments on commit 48eb9a9

Please sign in to comment.