mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-09-22 10:43:39 -04:00
There is no reason to not use an archive manager to build our executables. If there really are systems which don't have any kind of archive manager, we can simply link all the objects. This also drops any use of configure to detect library objects. Instead just use HAVE_* and let the archive manager delete them. A lot of additional functions could be declared library functions and reorganized. ***FIX*** Mkfiles/*.mak have not yet been updated. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
51 lines
1.0 KiB
C
51 lines
1.0 KiB
C
/*
|
|
* vsnprintf()
|
|
*
|
|
* Poor substitute for a real vsnprintf() function for systems
|
|
* that don't have them...
|
|
*/
|
|
|
|
#include "compiler.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <stdarg.h>
|
|
#include <string.h>
|
|
|
|
#include "nasmlib.h"
|
|
|
|
#if !defined(HAVE_VSNPRINTF) && !defined(HAVE__VSNPRINTF)
|
|
|
|
#define BUFFER_SIZE 65536 /* Bigger than any string we might print... */
|
|
|
|
static char snprintf_buffer[BUFFER_SIZE];
|
|
|
|
int vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
|
{
|
|
int rv, bytes;
|
|
|
|
if (size > BUFFER_SIZE) {
|
|
nasm_panic(ERR_NOFILE,
|
|
"vsnprintf: size (%d) > BUFFER_SIZE (%d)",
|
|
size, BUFFER_SIZE);
|
|
size = BUFFER_SIZE;
|
|
}
|
|
|
|
rv = vsprintf(snprintf_buffer, format, ap);
|
|
if (rv >= BUFFER_SIZE)
|
|
nasm_panic(ERR_NOFILE, "vsnprintf buffer overflow");
|
|
|
|
if (size > 0) {
|
|
if ((size_t)rv < size-1)
|
|
bytes = rv;
|
|
else
|
|
bytes = size-1;
|
|
memcpy(str, snprintf_buffer, bytes);
|
|
str[bytes] = '\0';
|
|
}
|
|
|
|
return rv;
|
|
}
|
|
|
|
#endif
|