fix cmdline-level printf wrapper for Windows
It was broken in a way that made gracket-text crash Merge to v5.0
This commit is contained in:
parent
91ecad670c
commit
bb4b04082a
|
@ -2292,6 +2292,7 @@ static void MrEdSchemeMessages(char *msg, ...)
|
|||
waiting_sema = CreateSemaphore(NULL, 0, 1, NULL);
|
||||
SetConsoleCtrlHandler(ConsoleHandler, TRUE);
|
||||
|
||||
|
||||
{
|
||||
HMODULE hm;
|
||||
gcw_proc gcw;
|
||||
|
@ -2336,10 +2337,14 @@ static void MrEdSchemeMessages(char *msg, ...)
|
|||
|
||||
WriteConsole(console_out, s XFORM_OK_PLUS d, l, &wrote, NULL);
|
||||
} else {
|
||||
long sz, wrt;
|
||||
char *buffer;
|
||||
DWORD wrote;
|
||||
buffer = (char *)malloc(5 * strlen(msg));
|
||||
vsprintf(buffer, msg, args);
|
||||
/* FIXME: multiplying by 5 and adding 80 works for
|
||||
all the cases where printf mode is currently used
|
||||
for the function, but it's completely a hack. */
|
||||
buffer = (char *)malloc((5 * strlen(msg)) + 80);
|
||||
wrt = vsprintf(buffer, msg, args);
|
||||
WriteConsole(console_out, buffer, strlen(buffer), &wrote, NULL);
|
||||
free(buffer);
|
||||
}
|
||||
|
|
|
@ -113,10 +113,12 @@ extern "C" Scheme_Object *scheme_initialize(Scheme_Env *env);
|
|||
#define GET_INIT_FILENAME get_init_filename
|
||||
#if REDIRECT_STDIO || WINDOW_STDIO || WCONSOLE_STDIO
|
||||
# define PRINTF mred_console_printf
|
||||
# define CMDLINE_FFLUSH(x) /* nothing */
|
||||
static void (*mred_console_printf)(char *str, ...);
|
||||
# define NEED_MRED_CONSOLE_PRINTF
|
||||
#else
|
||||
# define PRINTF printf
|
||||
# define CMDLINE_FFLUSH fflush
|
||||
#endif
|
||||
#define PROGRAM "GRacket"
|
||||
#define PROGRAM_LC "gracket"
|
||||
|
|
|
@ -1078,7 +1078,7 @@ static int run_from_cmd_line(int argc, char *_argv[],
|
|||
#endif
|
||||
|
||||
#if defined(USE_FD_PORTS) || defined(WINDOWS_FILE_HANDLES)
|
||||
fflush(stdout);
|
||||
CMDLINE_FFLUSH(stdout);
|
||||
#endif
|
||||
}
|
||||
#endif /* DONT_PARSE_COMMAND_LINE */
|
||||
|
@ -1286,7 +1286,7 @@ static int run_from_cmd_line(int argc, char *_argv[],
|
|||
);
|
||||
PRINTF(prog, BANNER);
|
||||
#if defined(WINDOWS_FILE_HANDLES)
|
||||
fflush(stdout);
|
||||
CMDLINE_FFLUSH(stdout);
|
||||
#endif
|
||||
return 0;
|
||||
bad_switch:
|
||||
|
@ -1298,7 +1298,7 @@ static int run_from_cmd_line(int argc, char *_argv[],
|
|||
show_need_help:
|
||||
PRINTF("Use the --help or -h flag for help.\n");
|
||||
#if defined(DETECT_WIN32_CONSOLE_STDIN)
|
||||
fflush(stdout);
|
||||
CMDLINE_FFLUSH(stdout);
|
||||
#endif
|
||||
return 1;
|
||||
#endif
|
||||
|
|
|
@ -146,6 +146,7 @@ extern Scheme_Object *scheme_initialize(Scheme_Env *env);
|
|||
#endif
|
||||
#define GET_INIT_FILENAME get_init_filename
|
||||
#define PRINTF printf
|
||||
#define CMDLINE_FFLUSH fflush
|
||||
#define PROGRAM "Racket"
|
||||
#define PROGRAM_LC "racket"
|
||||
#define INITIAL_BIN_TYPE "zi"
|
||||
|
|
Loading…
Reference in New Issue
Block a user