From 67660c5c59defffb825a23d1b8b0074fd8018a95 Mon Sep 17 00:00:00 2001 From: Eliot Miranda Date: Sat, 25 Jun 2022 14:26:28 -0700 Subject: [PATCH] Get the cogits to compile given that they now need the null define. Implement reporting the trace flags on Windows. --- platforms/Cross/vm/sq.h | 4 --- platforms/Cross/vm/sqMemoryAccess.h | 4 +++ platforms/win32/vm/sqWin32Window.c | 39 +++++++++++++++++++++++++---- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/platforms/Cross/vm/sq.h b/platforms/Cross/vm/sq.h index edb9ff4bc0..ec3354fa6c 100755 --- a/platforms/Cross/vm/sq.h +++ b/platforms/Cross/vm/sq.h @@ -41,10 +41,6 @@ #include "sqMemoryAccess.h" #include "sqVirtualMachine.h" -#define true 1 -#define false 0 -#define null 0 /* using "null" because nil is predefined in Think C */ - #if !defined(IMAGE_DIALECT_NAME) # if NewspeakVM # define IMAGE_DIALECT_NAME "Newspeak" diff --git a/platforms/Cross/vm/sqMemoryAccess.h b/platforms/Cross/vm/sqMemoryAccess.h index b858660b94..602ff288db 100644 --- a/platforms/Cross/vm/sqMemoryAccess.h +++ b/platforms/Cross/vm/sqMemoryAccess.h @@ -23,6 +23,10 @@ #include "config.h" #include "interp.h" +#define true 1 +#define false 0 +#define null 0 /* using "null" because nil is predefined in Think C */ + #ifndef SIZEOF_LONG # if LLP64 # define SIZEOF_LONG 4 diff --git a/platforms/win32/vm/sqWin32Window.c b/platforms/win32/vm/sqWin32Window.c index 03addc3dc0..69ed8acaf4 100644 --- a/platforms/win32/vm/sqWin32Window.c +++ b/platforms/win32/vm/sqWin32Window.c @@ -3190,6 +3190,21 @@ HideSplashScreen(void) # define VMOPTION(arg) "-"arg # define TVMOPTION(arg) TEXT("-") TEXT(arg) +# if _UNICODE +static TCHAR * +asTCharString(char *charString) +{ + int len = MultiByteToWideChar(CP_UTF8, 0, charString, -1, NULL, 0); + if (len <= 0) + return 0; /* invalid UTF8 ? */ + LPWSTR tcharString = malloc(len*sizeof(WCHAR)); + if (MultiByteToWideChar(CP_UTF8, 0, charString, -1, tcharString, len) == 0) + return 0; + return tcharString; +} +# else +# define asTCharString(charString) charString +# endif /* print usage with different output levels */ int @@ -3199,9 +3214,19 @@ printUsage(int level) case 0: /* No command line given */ abortMessage(TEXT("Usage: ") TEXT(VM_NAME) TEXT(" [options] \n")); break; - case 1: /* full usage */ - abortMessage(TEXT("%s\n"), - TEXT("Usage: ") TEXT(VM_NAME) TEXT(" [vmOptions] imageFile [imageOptions]\n\n") + case 1: { // full usage +#if COGVM + char traceFlags[1024]; + extern const char *traceFlagsMeanings[]; + bzero(traceFlags,1024); + int i = 0; + while (traceFlagsMeanings[i]) { + strcat(traceFlags, "\n\t\t"); + strcat(traceFlags, traceFlagsMeanings[i]); + ++i; + } +#endif + abortMessage(TEXT("Usage: ") TEXT(VM_NAME) TEXT(" [vmOptions] imageFile [imageOptions]\n\n") TEXT("vmOptions:") TEXT("\n\t") TVMOPTION("service:") TEXT(" ServiceName \t(install VM as NT service)") TEXT("\n\t") TVMOPTION("headless") TEXT(" \t\t(force VM to run headless)") @@ -3222,8 +3247,8 @@ printUsage(int level) #endif /* STACKVM */ #if STACKVM || NewspeakVM # if COGVM - TEXT("\n\t") TVMOPTION("logplugin") TEXT(" name\t\tonly log primitives in plugin\n") - TEXT("\n\t") TVMOPTION("trace") TEXT("[=num]\t\tenable tracing (optionally to a specific value)") + TEXT("\n\t") TVMOPTION("logplugin") TEXT(" name\t\tonly log primitives in plugin") + TEXT("\n\t") TVMOPTION("trace") TEXT("[=num]\t\tenable tracing (optionally to a specific value)%s") # else TEXT("\n\t") TVMOPTION("sendtrace") TEXT(" \t\t(trace sends to stdout for debug)") # endif @@ -3243,7 +3268,11 @@ printUsage(int level) #endif TEXT("\n") TEXT("Options begin with single -, but -- prefix is silently accepted") TEXT("\n") TEXT("Options with arguments -opt:n are also accepted with separators -opt n") +#if COGVM + , asTCharString(traceFlags) +#endif ); + } break; case 2: /* No image found */ default: