mirror of
				https://github.com/VCMP-SqMod/SqMod.git
				synced 2025-11-04 08:17:19 +01:00 
			
		
		
		
	Update the standard printf function to use the dynamic string retrieval method.
Remove leftover includes from the string and crypt libraries.
This commit is contained in:
		@@ -6,9 +6,6 @@
 | 
			
		||||
#include <cstdlib>
 | 
			
		||||
#include <cstring>
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------------------------------
 | 
			
		||||
#include <sqstdstring.h>
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------------------------------
 | 
			
		||||
#include <crc32.h>
 | 
			
		||||
#include <keccak.h>
 | 
			
		||||
 
 | 
			
		||||
@@ -3,9 +3,6 @@
 | 
			
		||||
#include "Base/Shared.hpp"
 | 
			
		||||
#include "Base/Buffer.hpp"
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------------------------------
 | 
			
		||||
#include <sqstdstring.h>
 | 
			
		||||
 | 
			
		||||
// ------------------------------------------------------------------------------------------------
 | 
			
		||||
#include <cctype>
 | 
			
		||||
#include <cstdio>
 | 
			
		||||
@@ -1206,17 +1203,15 @@ static CSStr FromArray(Array & arr)
 | 
			
		||||
// ------------------------------------------------------------------------------------------------
 | 
			
		||||
static SQInteger StdPrintF(HSQUIRRELVM vm)
 | 
			
		||||
{
 | 
			
		||||
    CStr msg = nullptr;
 | 
			
		||||
    SQInteger length = 0;
 | 
			
		||||
    // Attempt to run the specified format and save the result
 | 
			
		||||
    const SQRESULT res = sqstd_format(vm, 2, &length, &msg);
 | 
			
		||||
    // Validate the result for errors and propagate them to the VM
 | 
			
		||||
    if(SQ_FAILED(res))
 | 
			
		||||
    // Attempt to retrieve the value from the stack as a string
 | 
			
		||||
    StackStrF val(vm, 2);
 | 
			
		||||
    // Have we failed to retrieve the string?
 | 
			
		||||
    if (SQ_FAILED(val.mRes))
 | 
			
		||||
    {
 | 
			
		||||
        return res; // Return the error!
 | 
			
		||||
        return val.mRes; // Propagate the error!
 | 
			
		||||
    }
 | 
			
		||||
    // Send the resulted string to console as a user message
 | 
			
		||||
    LogUsr("%s", msg);
 | 
			
		||||
    LogUsr("%s", val.mPtr);
 | 
			
		||||
    // This function doesn't return anything
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user