Publish VCC Plus OSS source distribution for 3.6.2 build 60
This commit is contained in:
commit
c652a5276d
1192 files changed
+272368
No files matched your search
@@ -0,0 +1,37 @@
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#include <stdio.h>
|
||||
#include "format-internal.h"
|
||||
|
||||
// Keep the stream dependency in a separate archive member so snprintf-only
|
||||
// programs can link without a Disk BASIC runtime.
|
||||
static int storeFile(void *context, const char *source, char fill, unsigned count)
|
||||
{
|
||||
FILE *stream = (FILE *) context;
|
||||
if (source)
|
||||
return fwrite(source, 1, count, stream) == count ? 0 : -1;
|
||||
char padding[32];
|
||||
unsigned chunk = count < sizeof(padding) ? count : sizeof(padding);
|
||||
memset(padding, fill, chunk);
|
||||
while (count) {
|
||||
if (chunk > count) chunk = count;
|
||||
if (fwrite(padding, 1, chunk, stream) != chunk) return -1;
|
||||
count -= chunk;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vfprintf(FILE *stream, const char *format, va_list args)
|
||||
{
|
||||
// Check stream direction and pending errors even for an empty format.
|
||||
if (fputs("", stream) == EOF) return -1;
|
||||
return vcc_format_to(storeFile, stream, format, args);
|
||||
}
|
||||
|
||||
int fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start(args, format);
|
||||
int result = vfprintf(stream, format, args);
|
||||
va_end(args);
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user