From 920f60048330db2dd94e0f45022a5aeaaf7854ac Mon Sep 17 00:00:00 2001 From: David Kinder Date: Wed, 4 May 2022 11:26:18 +0100 Subject: [PATCH] Remove PLATFORM_SNPRINTF, just use snprintf() --- foundation-module/Chapter 1/POSIX Platforms.w | 11 ----------- foundation-module/Chapter 1/Windows Platform.w | 11 ----------- foundation-module/Chapter 2/Writers and Loggers.w | 4 ++-- 3 files changed, 2 insertions(+), 24 deletions(-) diff --git a/foundation-module/Chapter 1/POSIX Platforms.w b/foundation-module/Chapter 1/POSIX Platforms.w index c8a5843..df00ace 100644 --- a/foundation-module/Chapter 1/POSIX Platforms.w +++ b/foundation-module/Chapter 1/POSIX Platforms.w @@ -187,17 +187,6 @@ int Platform::system(const char *cmd) { return system(cmd); } -@h Snprintf. -The C standard library function |snprintf| is not as standard as one might -like, and is oddly represented in some Cygwin libraries for Windows, -sometimes being differently named. - -We would like to provide a wrapper function but this is troublesome with -variadic arguments, so instead here is a macro for the function name. -Happily, the Inform tools make very little use of this. - -@d PLATFORM_SNPRINTF snprintf - @ ^"ifdef-PLATFORM_MACOS" In MacOS 10.5, a new implementation of the C standard library crippled performance of |system()| by placing it behind a global mutex, so diff --git a/foundation-module/Chapter 1/Windows Platform.w b/foundation-module/Chapter 1/Windows Platform.w index b4f3655..9c05d75 100644 --- a/foundation-module/Chapter 1/Windows Platform.w +++ b/foundation-module/Chapter 1/Windows Platform.w @@ -95,17 +95,6 @@ void Platform::where_am_i(wchar_t *p, size_t length) { if ((result == 0) || (result == length)) p[0] = 0; } -@h Snprintf. -The C standard library function |snprintf| is not as standard as one might -like, and is oddly represented in some Cygwin libraries for Windows, -sometimes being differently named. - -We would like to provide a wrapper function but this is troublesome with -variadic arguments, so instead here is a macro for the function name. -Happily, the Inform tools make very little use of this. - -@d PLATFORM_SNPRINTF snprintf - @h Shell commands. = (very early code) diff --git a/foundation-module/Chapter 2/Writers and Loggers.w b/foundation-module/Chapter 2/Writers and Loggers.w index 44e3c70..a35058c 100644 --- a/foundation-module/Chapter 2/Writers and Loggers.w +++ b/foundation-module/Chapter 2/Writers and Loggers.w @@ -240,14 +240,14 @@ file encodings, but expanding |%s| does not. case 'c': case 'd': case 'i': case 'x': { /* |char| is promoted to |int| in variable arguments */ int ival = va_arg(ap, int); char temp[256]; - if (PLATFORM_SNPRINTF(temp, 255, format_string, ival) >= 255) strcpy(temp, "?"); + if (snprintf(temp, 255, format_string, ival) >= 255) strcpy(temp, "?"); for (int j = 0; temp[j]; j++) Streams::putc(temp[j], stream); break; } case 'g': { double dval = va_arg(ap, double); char temp[256]; - if (PLATFORM_SNPRINTF(temp, 255, format_string, dval) >= 255) strcpy(temp, "?"); + if (snprintf(temp, 255, format_string, dval) >= 255) strcpy(temp, "?"); for (int j = 0; temp[j]; j++) Streams::putc(temp[j], stream); break; }