Merge pull request #12 from DavidKinder/master

Remove PLATFORM_SNPRINTF, just use snprintf()
This commit is contained in:
Graham Nelson 2022-05-05 09:04:10 +01:00 committed by GitHub
commit c4f6da8a38
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 2 additions and 24 deletions

View file

@ -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

View file

@ -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)

View file

@ -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;
}