Skip to content

Commit

Permalink
debug: Introduce the --quiet VM option to keep things silent
Browse files Browse the repository at this point in the history
  • Loading branch information
zecke committed May 4, 2019
1 parent 4733547 commit 83aebb1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions platforms/unix/vm/debug.c
Expand Up @@ -53,3 +53,8 @@ FILE *VM_ERR(void)
}
return VM_ERR_FILE;
}

void sqSetVmErrFile(FILE *file)
{
VM_ERR_FILE = file;
}
3 changes: 3 additions & 0 deletions platforms/unix/vm/debug.h
@@ -1,6 +1,7 @@
#ifndef __sq_debug_h
#define __sq_debug_h

#include <stdio.h>

#ifndef DEBUG
# define DEBUG 0
Expand Down Expand Up @@ -44,4 +45,6 @@ extern void __sq_eprintf(const char *fmt, ...);

extern void sqDebugAnchor(void);

extern void sqSetVmErrFile(FILE* file);

#endif /* __sq_debug_h */
5 changes: 5 additions & 0 deletions platforms/unix/vm/sqUnixMain.c
Expand Up @@ -1659,13 +1659,18 @@ static int vm_parseArgument(int argc, char **argv)
}
return 2;
}
else if (!strcmp(argv[0], VMOPTION("quiet"))) {
sqSetVmErrFile(fopen("/dev/null", "w"));
return 1;
}
return 0; /* option not recognised */
}


static void vm_printUsage(void)
{
printf("\nCommon <option>s:\n");
printf(" "VMOPTION("quiet")" don't print debugging messages from the VM\n");
printf(" "VMOPTION("encoding")" <enc> set the internal character encoding (default: MacRoman)\n");
printf(" "VMOPTION("help")" print this help message, then exit\n");
printf(" "VMOPTION("memory")" <size>[mk] use fixed heap size (added to image size)\n");
Expand Down

0 comments on commit 83aebb1

Please sign in to comment.