Skip to content

Commit

Permalink
cleaned up extra variable, organized parameter switch, removed extra …
Browse files Browse the repository at this point in the history
…printf
  • Loading branch information
tilkinsc committed Jun 1, 2017
1 parent 1fa899b commit 68dcdcc
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#define CHDIR_FUNC chdir
#else
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#endif

#include <stdio.h>
#include <string.h>

#include "lua.h"
Expand Down Expand Up @@ -129,8 +127,7 @@ static int lua_main_dofile(lua_State* L) {
int start_protective_mode(lua_CFunction func, const char* file, char** parameters_argv, int param_len) {
lua_pushcclosure(L, func, 0); /* possible out of memory error in 5.2/5.1 */
lua_pushlstring(L, file, strlen(file)); /* possible out of memory error in 5.2/5.1 */
if(param_len != 0) {
printf("Creating table\n");
if(param_len != 0) { // load parameters in
lua_createtable(L, param_len, 0);
int i;
for (i=0; i<param_len; i++) {
Expand Down Expand Up @@ -167,7 +164,6 @@ int main(int argc, char* argv[])
// don't try to execute file if it isn't first argument
if(argv[1][0] == '-')
no_file = 1;
int last = 0;
int i;
for (i=1; i<argc; i++) {
// if we have args around, break
Expand All @@ -193,16 +189,16 @@ int main(int argc, char* argv[])
change_start = 1;
start = argv[i+1];
break;
case 'n': case 'N':
parameters = argc - i - 1;
parameters_argv = &(argv[i+1]);
break;
case 'a': case 'A':
no_additions = 1;
break;
case 'c': case 'C':
squelch = 1;
break;
case 'n': case 'N':
parameters = argc - i - 1;
parameters_argv = &(argv[i+1]);
break;
case '?':
fprintf(stdout, "%s\n", HELP_MESSAGE);
return EXIT_SUCCESS;
Expand Down

0 comments on commit 68dcdcc

Please sign in to comment.