1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-28 03:31:46 +02:00

Back port changes to squirrel library. Separate mdoule speciffic changes and/or additions to squirrel into their own files.

This commit is contained in:
Sandu Liviu Catalin
2019-04-24 22:33:42 +03:00
parent 21a00e20b7
commit 1f27146e6c
28 changed files with 254 additions and 43 deletions

View File

@@ -6,6 +6,7 @@
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
#include <stdarg.h>
#define MAX_FORMAT_LEN 20
#define MAX_WFORMAT_LEN 3
@@ -153,6 +154,25 @@ SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen
return SQ_OK;
}
void sqstd_pushstringf(HSQUIRRELVM v,const SQChar *s,...)
{
SQInteger n=256;
va_list args;
begin:
va_start(args,s);
SQChar *b=sq_getscratchpad(v,n);
SQInteger r=scvsprintf(b,n,s,args);
va_end(args);
if (r>=n) {
n=r+1;//required+null
goto begin;
} else if (r<0) {
sq_pushnull(v);
} else {
sq_pushstring(v,b,r);
}
}
static SQInteger _string_printf(HSQUIRRELVM v)
{
SQChar *dest = NULL;