From c454c86b1d7a2a572d34b878b719eb267864383e Mon Sep 17 00:00:00 2001 From: Sam Fredrickson Date: Sat, 31 Jan 2009 15:34:29 -0800 Subject: [PATCH] Re-wrote Port::Print() to be variadic. Also, printing the version now shows the GCC version and compilation date/time. I haven't tested the PSP and Wii ports, but they compile, so hopefully this change works for them, too. --- src/Commands.cpp | 20 ++++++++++---------- src/console/port.h | 9 +++++++-- src/psp/port.h | 14 ++++++++++++-- src/typedefs.h | 1 + src/wii/port.h | 8 ++++++-- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/Commands.cpp b/src/Commands.cpp index 4d5ce91..f946c16 100644 --- a/src/Commands.cpp +++ b/src/Commands.cpp @@ -169,16 +169,16 @@ void Calculator::printVariablesDetailed(vector& args) void Calculator::printVersion(vector& args) { - Print("RPN "); - Print(VERSION_MAJOR); - Print('.'); - Print(VERSION_MINOR); - Print('.'); - Print(VERSION_REVIS); - Print('.'); - Print(VERSION_BUILD); - Print(' '); - Print(VERSION_EXTRA); + Port::Print("RPN %i.%i.%i.%i", VERSION_MAJOR, VERSION_MINOR, + VERSION_REVIS, VERSION_BUILD); + Port::Print(" (%s) ", VERSION_EXTRA.c_str()); + +#ifdef __GNUC__ + Port::Print("(GCC %i.%i.%i on %s at %s)", __GNUC__, + __GNUC_MINOR__, + __GNUC_PATCHLEVEL__, + __DATE__, __TIME__); +#endif Print("\nBy Sam Fredrickson \n"); } diff --git a/src/console/port.h b/src/console/port.h index 873212c..3149c35 100644 --- a/src/console/port.h +++ b/src/console/port.h @@ -32,6 +32,7 @@ #ifndef _CONSOLE_PORT_H_ #define _CONSOLE_PORT_H_ +#include #include #include #include @@ -59,9 +60,13 @@ namespace RPN { } - static void Print(const char* str) + static void Print(const char* str, ...) { - printf(str); + va_list args; + + va_start(args, str); + vprintf(str, args); + va_end(args); } static void Setup() diff --git a/src/psp/port.h b/src/psp/port.h index 65b7326..434199e 100644 --- a/src/psp/port.h +++ b/src/psp/port.h @@ -39,6 +39,8 @@ extern "C" { #include } +#include +#include #include #include @@ -97,6 +99,8 @@ namespace RPN */ static char GetCharacter(); + static char output_buffer[1024]; + public: static bool CanRun() @@ -111,9 +115,15 @@ namespace RPN sceKernelExitGame(); } - static void Print(const char* str) + static void Print(const char* str, ...) { - pspDebugScreenPrintf(str); + va_list args; + + va_start(args, str); + vsprintf(output_buffer, str, args); + pspDebugScreenPrintf(output_buffer); + va_end(args); + //pspDebugScreenPrintf(str); } static void Setup(); diff --git a/src/typedefs.h b/src/typedefs.h index ef3f881..04b5cc6 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -34,6 +34,7 @@ #include #include #include +#include namespace RPN { diff --git a/src/wii/port.h b/src/wii/port.h index 7330cab..7370375 100644 --- a/src/wii/port.h +++ b/src/wii/port.h @@ -76,9 +76,13 @@ namespace RPN { } - static void Print(const char* str) + static void Print(const char* str, ...) { - printf(str); + va_list args; + + va_start(args, str); + vprintf(str, args); + va_end(args); } static void Setup() -- 2.11.4.GIT