mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 10:37:41 -04:00
Fixes from review by @Hoikas
This commit is contained in:
@ -185,46 +185,6 @@ static inline void ICopyString (wchar_t ** plhs, const wchar_t rhs[]) {
|
||||
*plhs = StrDup(L"");
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
template <typename T>
|
||||
static bool IStrSqlEscape (const T src[], T * dst, unsigned dstChars) {
|
||||
|
||||
// count the number of ' chars
|
||||
unsigned ticks = 0;
|
||||
{
|
||||
const T * cur = src;
|
||||
while (*cur) {
|
||||
if (*cur == L'\'')
|
||||
++ticks;
|
||||
cur++;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned reqChars = StrLen(src) + ticks + 1;
|
||||
|
||||
if (dstChars < reqChars)
|
||||
// failure!
|
||||
return false;
|
||||
|
||||
T * cur = dst;
|
||||
|
||||
// copy src to dst, escaping ' chars
|
||||
while (*src) {
|
||||
if (*src == L'\'') {
|
||||
*cur++ = L'\'';
|
||||
*cur++ = *src++;
|
||||
continue;
|
||||
}
|
||||
*cur++ = *src++;
|
||||
}
|
||||
|
||||
// null-terminate dst string
|
||||
*cur = 0;
|
||||
|
||||
// success!
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} using namespace pnNpCommon;
|
||||
|
||||
|
@ -1476,7 +1476,7 @@ static void IGetStringFieldValue (
|
||||
) {
|
||||
wchar_t * tmp = (wchar_t*)malloc(sizeof(wchar_t) * dstChars);
|
||||
IStrSqlEscape(value, tmp, dstChars);
|
||||
StrPrintf(dst, dstChars, L"'%s'", tmp);
|
||||
swprintf(dst, dstChars, L"'%s'", tmp);
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
@ -1485,7 +1485,7 @@ static void IGetUuidFieldValue (
|
||||
wchar_t * dst,
|
||||
size_t dstChars
|
||||
) {
|
||||
StrPrintf(dst, dstChars, L"hextoraw('%s')", value.AsString().c_str());
|
||||
swprintf(dst, dstChars, L"hextoraw('%S')", value.AsString().c_str());
|
||||
}
|
||||
|
||||
static void IGetUintFieldValue (
|
||||
@ -1493,7 +1493,7 @@ static void IGetUintFieldValue (
|
||||
wchar_t * dst,
|
||||
size_t dstChars
|
||||
) {
|
||||
StrPrintf(dst, dstChars, L"%u", value);
|
||||
swprintf(dst, dstChars, L"%u", value);
|
||||
}
|
||||
|
||||
static void IGetIntFieldValue (
|
||||
@ -1501,7 +1501,7 @@ static void IGetIntFieldValue (
|
||||
wchar_t * dst,
|
||||
size_t dstChars
|
||||
) {
|
||||
StrPrintf(dst, dstChars, L"%d", value);
|
||||
swprintf(dst, dstChars, L"%d", value);
|
||||
}
|
||||
|
||||
void RelVaultNode::Print (const wchar_t tag[], FStateDump dumpProc, unsigned level) {
|
||||
@ -1526,12 +1526,12 @@ void RelVaultNode::Print (const wchar_t tag[], FStateDump dumpProc, unsigned lev
|
||||
break;
|
||||
|
||||
#define STPRINT(flag, func) case k##flag: { \
|
||||
StrPack(str, L", " L ## #flag L"=", arrsize(str)); \
|
||||
const size_t chars = StrLen(str); \
|
||||
wcsncat(str, L", " L ## #flag L"=", arrsize(str)); \
|
||||
const size_t chars = wcslen(str); \
|
||||
func(Get##flag(), str + chars, arrsize(str) - chars * sizeof(str[0])); \
|
||||
}; break
|
||||
#define STNAME(flag) case k##flag: { \
|
||||
StrPack(str, L", " L ## #flag, arrsize(str)); \
|
||||
wcsncat(str, L", " L ## #flag, arrsize(str)); \
|
||||
}; break
|
||||
switch (bit) {
|
||||
STPRINT(NodeId, IGetUintFieldValue);
|
||||
|
@ -187,7 +187,7 @@ void VaultTextNoteNode::SetVisitInfo (const plAgeInfoStruct & info) {
|
||||
bool VaultTextNoteNode::GetVisitInfo (plAgeInfoStruct * info) {
|
||||
|
||||
wchar_t * mem;
|
||||
const wchar_t * str = mem = StrDup(GetNoteText());
|
||||
const wchar_t * str = mem = wcsdup(GetNoteText());
|
||||
|
||||
for (unsigned i = 0; i < kNumAgeInfoFields; ++i) {
|
||||
|
||||
|
Reference in New Issue
Block a user