Update of /cvsroot/rtk/rtk/src/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7855/src/core
Modified Files:
CMakeLists.txt
Added Files:
rchar.cpp
Log Message:
Made a temporary solution for the printf problemt
It now converts %s to %S, its good until we get a better one
--- NEW FILE: rchar.cpp ---
#include <rtk/rchar.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
RCHAR* rstrlwr(const RCHAR* str)
{
RCHAR* ret = (RCHAR*)malloc(sizeof(RCHAR)*rstrlen(str));
RCHAR* ptr = ret;
while (*str) {
*ptr++ = rtolower(*str++);
}
return ret;
}
RCHAR* rstrupr(const RCHAR* str)
{
RCHAR* ret = (RCHAR*)malloc(sizeof(RCHAR)*rstrlen(str));
RCHAR* ptr = ret;
while (*str) {
*ptr++ = rtoupper(*str++);
}
return ret;
}
#if UNICODE
static RCHAR* convert(const RCHAR* fmt)
{
RCHAR* fmt2 = rstrdup(fmt);
RCHAR* ptr = fmt2;
while (*ptr) {
if (ptr[0] == '%' && ptr[1] == 's') {
ptr[1] = 'S';
ptr+=2;
} else {
ptr++;
}
}
return fmt2;
}
// printf
int rvsnprintf(RCHAR* dst, int max_len, const RCHAR* fmt, va_list args)
{
RCHAR* fmt2 = convert(fmt);
int ret = vswprintf(dst, max_len, fmt2, args);
free(fmt2);
return ret;
}
int rvfprintf(FILE* f, const RCHAR* fmt, va_list args)
{
RCHAR* fmt2 = convert(fmt);
int ret = vfwprintf(f, fmt2, args);
free(fmt2);
return ret;
}
int rvprintf(const RCHAR* fmt, va_list args)
{
RCHAR* fmt2 = convert(fmt);
int ret = vfwprintf(stdout, fmt2, args);
free(fmt2);
return ret;
}
int rsnprintf(RCHAR* dst, int max_len, const RCHAR* fmt, ...)
{
va_list args;
va_start(args, fmt);
int ret = rvsnprintf(dst, max_len, fmt, args);
va_end(args);
return ret;
}
int rfprintf(FILE* f, const RCHAR* fmt, ...)
{
va_list args;
va_start(args, fmt);
int ret = rvfprintf(f, fmt, args);
va_end(args);
return ret;
}
int rprintf(const RCHAR* fmt, ...)
{
va_list args;
va_start(args, fmt);
int ret = rvfprintf(stdout, fmt, args);
va_end(args);
return ret;
}
// scanf
int rvsscanf(const RCHAR* src, const RCHAR* fmt, va_list args)
{
RCHAR* fmt2 = convert(fmt);
int ret = vswscanf(src, fmt2, args);
free(fmt2);
return ret;
}
int rvfscanf(FILE* f, const RCHAR* fmt, va_list args)
{
RCHAR* fmt2 = convert(fmt);
int ret = vfwscanf(f, fmt2, args);
free(fmt2);
return ret;
}
int rvscanf(const RCHAR* fmt, va_list args)
{
RCHAR* fmt2 = convert(fmt);
int ret = vfwscanf(stdin, fmt2, args);
free(fmt2);
return ret;
}
int rsscanf(const RCHAR* src, const RCHAR* fmt, ...)
{
va_list args;
va_start(args, fmt);
int ret = rvsscanf(src, fmt, args);
va_end(args);
return ret;
}
int rfscanf(FILE* f, const RCHAR* fmt, ...)
{
va_list args;
va_start(args, fmt);
int ret = rvfscanf(f, fmt, args);
va_end(args);
return ret;
}
int rscanf(const RCHAR* fmt, ...)
{
va_list args;
va_start(args, fmt);
int ret = rvfscanf(stdin, fmt, args);
va_end(args);
return ret;
}
#else /* !UNICODE */
#endif /* !UNICODE */
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/rtk/rtk/src/core/CMakeLists.txt,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** CMakeLists.txt 22 Feb 2004 19:02:06 -0000 1.7
--- CMakeLists.txt 23 Feb 2004 20:16:43 -0000 1.8
***************
*** 36,39 ****
--- 36,40 ----
SList.cpp Dict.cpp debug.cpp
error.cpp String.cpp Array.cpp
+ rchar.cpp
)
|