2007-03-27 17:47:10 +00:00
|
|
|
/*
|
|
|
|
* CiderPress
|
|
|
|
* Copyright (C) 2007 by faddenSoft, LLC. All Rights Reserved.
|
|
|
|
* See the file LICENSE for distribution terms.
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Miscellaneous utility classes.
|
|
|
|
*/
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Util.h"
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* CGripper
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Fake out the hit testing so that it thinks we're over the scrollable bit
|
|
|
|
* when we're over the gripper.
|
|
|
|
*/
|
|
|
|
BEGIN_MESSAGE_MAP(CGripper, CScrollBar)
|
2014-11-04 00:26:53 +00:00
|
|
|
ON_WM_NCHITTEST()
|
2007-03-27 17:47:10 +00:00
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
LRESULT CGripper::OnNcHitTest(CPoint point)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
UINT ht = CScrollBar::OnNcHitTest(point);
|
|
|
|
if (ht == HTCLIENT) {
|
|
|
|
ht = HTBOTTOMRIGHT;
|
|
|
|
}
|
|
|
|
return ht;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* RichEditXfer
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* At the behest of a RichEditCtrl, copy "cb" bytes of data into "pbBuff".
|
|
|
|
* The actual number of bytes transferred is placed in "*pcb".
|
|
|
|
*
|
|
|
|
* (A complete implementation would allow copying either direction.)
|
|
|
|
*
|
|
|
|
* Returns 0 on success, nonzero on error.
|
|
|
|
*/
|
2014-11-25 22:34:14 +00:00
|
|
|
DWORD RichEditXfer::EditStreamCallback(DWORD dwCookie, LPBYTE pbBuff,
|
|
|
|
LONG cb, LONG* pcb)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
RichEditXfer* pThis = (RichEditXfer*) dwCookie;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(dwCookie != NULL);
|
|
|
|
ASSERT(pbBuff != NULL);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(cb != 0);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pcb != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
long copyLen = pThis->fLen;
|
|
|
|
if (copyLen > cb)
|
|
|
|
copyLen = cb;
|
|
|
|
if (copyLen == 0) {
|
|
|
|
ASSERT(pThis->fLen == 0);
|
|
|
|
goto bail;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
::memcpy(pbBuff, pThis->fBuf, copyLen);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pThis->fBuf += copyLen;
|
|
|
|
pThis->fLen -= copyLen;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI("ESC: copyLen=%d, now fLen=%d", copyLen, pThis->fLen);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
bail:
|
2014-11-04 00:26:53 +00:00
|
|
|
*pcb = copyLen;
|
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* ExpandBuffer
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int ExpandBuffer::CreateWorkBuf(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fWorkBuf != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(fWorkMax > 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
assert(fInitialSize > 0);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
fWorkBuf = new char[fInitialSize];
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fWorkBuf == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return -1;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
fWorkCount = 0;
|
|
|
|
fWorkMax = fInitialSize;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void ExpandBuffer::SeizeBuffer(char** ppBuf, long* pLen)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
*ppBuf = fWorkBuf;
|
|
|
|
*pLen = fWorkCount;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
fWorkBuf = NULL; // discard pointer so we don't free it
|
2014-11-04 00:26:53 +00:00
|
|
|
fWorkCount = 0;
|
|
|
|
fWorkMax = 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int ExpandBuffer::GrowWorkBuf(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
int newIncr = fWorkMax;
|
|
|
|
if (newIncr > kWorkBufMaxIncrement)
|
|
|
|
newIncr = kWorkBufMaxIncrement;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
LOGV("Extending buffer by %d (count=%d, max=%d)",
|
|
|
|
newIncr, fWorkCount, fWorkMax);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
fWorkMax += newIncr;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* debug-only check to catch runaways */
|
|
|
|
// ASSERT(fWorkMax < 1024*1024*24);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
char* newBuf = new char[fWorkMax];
|
2014-11-18 05:13:13 +00:00
|
|
|
if (newBuf == NULL) {
|
2014-11-25 22:34:14 +00:00
|
|
|
LOGE("ALLOC FAILURE (%ld)", fWorkMax);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(false);
|
|
|
|
fWorkMax -= newIncr; // put it back so we don't overrun
|
|
|
|
return -1;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
memcpy(newBuf, fWorkBuf, fWorkCount);
|
|
|
|
delete[] fWorkBuf;
|
|
|
|
fWorkBuf = newBuf;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return 0;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void ExpandBuffer::Write(const unsigned char* buf, long len)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fWorkBuf == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
CreateWorkBuf();
|
|
|
|
while (fWorkCount + len >= fWorkMax) {
|
|
|
|
if (GrowWorkBuf() != 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ASSERT(fWorkCount + len < fWorkMax);
|
|
|
|
memcpy(fWorkBuf + fWorkCount, buf, len);
|
|
|
|
fWorkCount += len;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void ExpandBuffer::Putc(char ch)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
Write((const unsigned char*) &ch, 1);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void ExpandBuffer::Printf(_Printf_format_string_ const char* format, ...)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(format != NULL);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (fWorkBuf == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
CreateWorkBuf();
|
2007-03-27 17:47:10 +00:00
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (format != NULL) {
|
2014-11-04 00:26:53 +00:00
|
|
|
int count;
|
2007-03-27 17:47:10 +00:00
|
|
|
count = _vsnprintf(fWorkBuf + fWorkCount, fWorkMax - fWorkCount,
|
2014-11-04 00:26:53 +00:00
|
|
|
format, args);
|
|
|
|
if (count < 0) {
|
|
|
|
if (GrowWorkBuf() != 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* try one more time, then give up */
|
|
|
|
count = _vsnprintf(fWorkBuf + fWorkCount, fWorkMax - fWorkCount,
|
|
|
|
format, args);
|
|
|
|
ASSERT(count >= 0);
|
|
|
|
if (count < 0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
fWorkCount += count;
|
|
|
|
ASSERT(fWorkCount <= fWorkMax);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* Windows helpers
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void EnableControl(CDialog* pDlg, int id, bool enable)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CWnd* pWnd = pDlg->GetDlgItem(id);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (pWnd == NULL) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("GLITCH: control %d not found in dialog", id);
|
2014-11-04 00:26:53 +00:00
|
|
|
ASSERT(false);
|
|
|
|
} else {
|
|
|
|
pWnd->EnableWindow(enable);
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void MoveControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CWnd* pWnd;
|
|
|
|
CRect rect;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd = pDlg->GetDlgItem(id);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pWnd != NULL);
|
|
|
|
if (pWnd == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->GetWindowRect(&rect);
|
|
|
|
pDlg->ScreenToClient(&rect);
|
|
|
|
rect.left += deltaX;
|
|
|
|
rect.right += deltaX;
|
|
|
|
rect.top += deltaY;
|
|
|
|
rect.bottom += deltaY;
|
|
|
|
pWnd->MoveWindow(&rect, redraw);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void StretchControl(CDialog* pDlg, int id, int deltaX, int deltaY, bool redraw)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CWnd* pWnd;
|
|
|
|
CRect rect;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd = pDlg->GetDlgItem(id);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pWnd != NULL);
|
|
|
|
if (pWnd == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->GetWindowRect(&rect);
|
|
|
|
pDlg->ScreenToClient(&rect);
|
|
|
|
rect.right += deltaX;
|
|
|
|
rect.bottom += deltaY;
|
|
|
|
pWnd->MoveWindow(&rect, redraw);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MoveStretchControl(CDialog* pDlg, int id, int moveX, int moveY,
|
2014-11-04 00:26:53 +00:00
|
|
|
int stretchX, int stretchY, bool redraw)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
MoveControl(pDlg, id, moveX, moveY, redraw);
|
|
|
|
StretchControl(pDlg, id, stretchX, stretchY, redraw);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
HDWP MoveControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
2014-11-04 00:26:53 +00:00
|
|
|
bool redraw)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CWnd* pWnd;
|
|
|
|
CRect rect;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd = pDlg->GetDlgItem(id);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pWnd != NULL);
|
|
|
|
if (pWnd == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return hdwp;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->GetWindowRect(&rect);
|
|
|
|
pDlg->ScreenToClient(&rect);
|
|
|
|
rect.left += deltaX;
|
|
|
|
rect.right += deltaX;
|
|
|
|
rect.top += deltaY;
|
|
|
|
rect.bottom += deltaY;
|
2014-11-18 05:13:13 +00:00
|
|
|
hdwp = DeferWindowPos(hdwp, pWnd->m_hWnd, NULL, rect.left, rect.top,
|
2014-11-04 00:26:53 +00:00
|
|
|
rect.Width(), rect.Height(), 0);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return hdwp;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
HDWP StretchControl(HDWP hdwp, CDialog* pDlg, int id, int deltaX, int deltaY,
|
2014-11-04 00:26:53 +00:00
|
|
|
bool redraw)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CWnd* pWnd;
|
|
|
|
CRect rect;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd = pDlg->GetDlgItem(id);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pWnd != NULL);
|
|
|
|
if (pWnd == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return hdwp;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->GetWindowRect(&rect);
|
|
|
|
pDlg->ScreenToClient(&rect);
|
|
|
|
rect.right += deltaX;
|
|
|
|
rect.bottom += deltaY;
|
2014-11-18 05:13:13 +00:00
|
|
|
hdwp = DeferWindowPos(hdwp, pWnd->m_hWnd, NULL, rect.left, rect.top,
|
2014-11-04 00:26:53 +00:00
|
|
|
rect.Width(), rect.Height(), 0);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return hdwp;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
HDWP MoveStretchControl(HDWP hdwp, CDialog* pDlg, int id, int moveX, int moveY,
|
2014-11-04 00:26:53 +00:00
|
|
|
int stretchX, int stretchY, bool redraw)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CWnd* pWnd;
|
|
|
|
CRect rect;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd = pDlg->GetDlgItem(id);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pWnd != NULL);
|
|
|
|
if (pWnd == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return hdwp;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->GetWindowRect(&rect);
|
|
|
|
pDlg->ScreenToClient(&rect);
|
|
|
|
rect.left += moveX;
|
|
|
|
rect.right += moveX;
|
|
|
|
rect.top += moveY;
|
|
|
|
rect.bottom += moveY;
|
|
|
|
rect.right += stretchX;
|
|
|
|
rect.bottom += stretchY;
|
2014-11-18 05:13:13 +00:00
|
|
|
hdwp = DeferWindowPos(hdwp, pWnd->m_hWnd, NULL, rect.left, rect.top,
|
2014-11-04 00:26:53 +00:00
|
|
|
rect.Width(), rect.Height(), 0);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return hdwp;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int GetDlgButtonCheck(CWnd* pWnd, int id)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CButton* pButton;
|
|
|
|
pButton = (CButton*) pWnd->GetDlgItem(id);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pButton != NULL);
|
|
|
|
if (pButton == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return -1;
|
|
|
|
return pButton->GetCheck();
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
2014-11-25 22:34:14 +00:00
|
|
|
|
|
|
|
void SetDlgButtonCheck(CWnd* pWnd, int id, int checkVal)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CButton* pButton;
|
|
|
|
pButton = (CButton*) pWnd->GetDlgItem(id);
|
2014-11-18 05:13:13 +00:00
|
|
|
ASSERT(pButton != NULL);
|
|
|
|
if (pButton == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
|
|
|
pButton->SetCheck(checkVal);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void CreateSimpleFont(CFont* pFont, CWnd* pWnd, const WCHAR* typeFace,
|
2014-11-04 00:26:53 +00:00
|
|
|
int pointSize)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CClientDC dc(pWnd);
|
|
|
|
int height;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
height = -((dc.GetDeviceCaps(LOGPIXELSY) * pointSize) / 72);
|
|
|
|
pFont->CreateFont(height, 0, 0, 0, FW_NORMAL, 0, 0, 0,
|
|
|
|
DEFAULT_CHARSET, OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS,
|
|
|
|
DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, typeFace);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void GetWin32ErrorString(DWORD err, CString* pStr)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
DWORD count;
|
|
|
|
LPVOID lpMsgBuf;
|
|
|
|
|
|
|
|
count = FormatMessage(
|
|
|
|
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL,
|
|
|
|
err /*GetLastError()*/,
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
|
|
|
|
(LPTSTR) &lpMsgBuf,
|
|
|
|
0,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!count) {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("FormatMessage on err=0x%08lx failed", err);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
pStr->Format(L"system error 0x%08lx.\n", err);
|
2014-11-04 00:26:53 +00:00
|
|
|
} else {
|
|
|
|
*pStr = (LPCTSTR)lpMsgBuf;
|
|
|
|
//MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
|
|
|
|
LocalFree( lpMsgBuf );
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void ShowFailureMsg(CWnd* pWnd, const CString& msg, int titleStrID)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
CString failed;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
failed.LoadString(titleStrID);
|
|
|
|
pWnd->MessageBox(msg, failed, MB_OK | MB_ICONERROR);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
BOOL ShowContextHelp(CWnd* pWnd, HELPINFO* lpHelpInfo)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
pWnd->WinHelp((DWORD) lpHelpInfo->iCtrlId, HELP_CONTEXTPOPUP);
|
|
|
|
return TRUE;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
bool IsWin9x(void)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
OSVERSIONINFO osvers;
|
|
|
|
BOOL result;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
osvers.dwOSVersionInfoSize = sizeof(osvers);
|
|
|
|
result = ::GetVersionEx(&osvers);
|
|
|
|
assert(result != FALSE);
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (osvers.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ===========================================================================
|
2014-11-04 00:26:53 +00:00
|
|
|
* Miscellaneous
|
2007-03-27 17:47:10 +00:00
|
|
|
* ===========================================================================
|
|
|
|
*/
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int GetPascalString(const uint8_t* buf, long maxLen, CString* pStr)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
int len = *buf++;
|
|
|
|
int retLen = len;
|
|
|
|
*pStr = "";
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
if (len > maxLen) {
|
2014-11-19 01:10:23 +00:00
|
|
|
LOGW("Invalid pascal string -- len=%d, maxLen=%d", len, maxLen);
|
2014-11-04 00:26:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
while (len--) {
|
|
|
|
if (*buf == '\0') {
|
|
|
|
/* this suggests that we're not reading a pascal string */
|
2014-11-19 01:10:23 +00:00
|
|
|
LOGW("Found pascal string with '\\0' in it");
|
2014-11-04 00:26:53 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
/* not the fastest approach, but it'll do */
|
|
|
|
*pStr += *buf++;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-04 00:26:53 +00:00
|
|
|
return retLen;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void LogHexDump(const void* vbuf, long len)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
const unsigned char* buf = (const unsigned char*) vbuf;
|
|
|
|
char outBuf[10 + 16*3 +1 +8]; // addr: 00 11 22 ... + 8 bytes slop
|
|
|
|
bool skipFirst;
|
2014-11-19 22:54:24 +00:00
|
|
|
uintptr_t addr;
|
2014-11-18 05:13:13 +00:00
|
|
|
char* cp = NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
int i;
|
|
|
|
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGI(" Memory at 0x%p %ld bytes:", buf, len);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (len <= 0)
|
|
|
|
return;
|
|
|
|
|
2014-11-19 22:54:24 +00:00
|
|
|
addr = (uintptr_t)buf & ~0x0f;
|
|
|
|
if (addr != (uintptr_t) buf) {
|
2014-11-04 00:26:53 +00:00
|
|
|
sprintf(outBuf, "%08lx: ", addr);
|
|
|
|
for (i = addr; i < (int) buf; i++)
|
|
|
|
strcat(outBuf, " ");
|
|
|
|
cp = outBuf + strlen(outBuf);
|
|
|
|
skipFirst = false;
|
|
|
|
} else {
|
|
|
|
skipFirst = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (len--) {
|
2014-11-19 22:54:24 +00:00
|
|
|
if (((uintptr_t) buf & 0x0f) == 0) {
|
2014-11-04 00:26:53 +00:00
|
|
|
/* output the old, start a new line */
|
|
|
|
if (skipFirst) {
|
|
|
|
skipFirst = false;
|
|
|
|
} else {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" %hs", outBuf);
|
2014-11-04 00:26:53 +00:00
|
|
|
addr += 16;
|
|
|
|
}
|
|
|
|
sprintf(outBuf, "%08lx: ", addr);
|
|
|
|
cp = outBuf + strlen(outBuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
sprintf(cp, "%02x ", *buf++);
|
|
|
|
cp += 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* output whatever is left */
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI(" %hs", outBuf);
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
int ComputePercent(LONGLONG part, LONGLONG full)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
|
|
|
LONGLONG perc;
|
|
|
|
|
|
|
|
if (!part && !full)
|
|
|
|
return 100; /* file is zero bytes long */
|
|
|
|
|
|
|
|
if (part < 21474836)
|
|
|
|
perc = (part * 100) / full;
|
|
|
|
else
|
|
|
|
perc = part / (full/100);
|
|
|
|
|
|
|
|
/* don't say "0%" if it's not actually zero... it looks dumb */
|
|
|
|
if (!perc && full)
|
|
|
|
perc = 1;
|
|
|
|
|
|
|
|
return (int) perc;
|
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void FormatDate(time_t when, CString* pStr)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
if (when == kDateNone) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pStr = L"[No Date]";
|
2014-11-04 00:26:53 +00:00
|
|
|
} else if (when == kDateInvalid) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pStr = L"<invalid>";
|
2014-11-04 00:26:53 +00:00
|
|
|
} else {
|
|
|
|
CTime modWhen(when);
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
*pStr = modWhen.Format(L"%d-%b-%y %H:%M");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
const WCHAR* Stristr(const WCHAR* string1, const WCHAR* string2)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR *cp1 = (WCHAR*)string1, *cp2, *cp1a;
|
|
|
|
WCHAR first; // get the first char in string to find
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
first = string2[0]; // first char often won't be alpha
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (iswalpha(first)) {
|
|
|
|
first = towlower(first);
|
2014-11-04 00:26:53 +00:00
|
|
|
for ( ; *cp1 != '\0'; cp1++)
|
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (towlower(*cp1) == first)
|
2014-11-04 00:26:53 +00:00
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
for (cp1a = &cp1[1], cp2 = (WCHAR*) &string2[1];;
|
2014-11-04 00:26:53 +00:00
|
|
|
cp1a++, cp2++)
|
|
|
|
{
|
|
|
|
if (*cp2 == '\0')
|
|
|
|
return cp1;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (towlower(*cp1a) != towlower(*cp2))
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for ( ; *cp1 != '\0' ; cp1++)
|
|
|
|
{
|
|
|
|
if (*cp1 == first)
|
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
for (cp1a = &cp1[1], cp2 = (WCHAR*) &string2[1];;
|
2014-11-04 00:26:53 +00:00
|
|
|
cp1a++, cp2++)
|
|
|
|
{
|
|
|
|
if (*cp2 == '\0')
|
|
|
|
return cp1;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (towlower(*cp1a) != towlower(*cp2))
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void VectorizeString(WCHAR* mangle, WCHAR** argv, int* pArgc)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
bool inWhiteSpace = true;
|
|
|
|
bool inQuote = false;
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR* cp = mangle;
|
2014-11-04 00:26:53 +00:00
|
|
|
int idx = 0;
|
|
|
|
|
|
|
|
while (*cp != '\0') {
|
|
|
|
ASSERT(!inWhiteSpace || !inQuote);
|
|
|
|
if (!inQuote && (*cp == ' ' || *cp == '\t')) {
|
|
|
|
if (!inWhiteSpace && !inQuote) {
|
|
|
|
/* end of token */
|
|
|
|
*cp = '\0';
|
|
|
|
}
|
|
|
|
inWhiteSpace = true;
|
|
|
|
} else {
|
|
|
|
if (inWhiteSpace) {
|
|
|
|
/* start of token */
|
|
|
|
if (idx >= *pArgc) {
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI("Max #of args (%d) exceeded, ignoring '%ls'",
|
2014-11-04 00:26:53 +00:00
|
|
|
// *pArgc, cp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
argv[idx++] = cp;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*cp == '"') {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
/* consume the quote; move the last '\0' down too */
|
|
|
|
memmove(cp, cp+1, wcslen(cp) * sizeof(WCHAR));
|
2014-11-04 00:26:53 +00:00
|
|
|
cp--;
|
|
|
|
inQuote = !inQuote;
|
|
|
|
}
|
|
|
|
|
|
|
|
inWhiteSpace = false;
|
|
|
|
}
|
|
|
|
cp++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (inQuote) {
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGW("WARNING: ended in quote");
|
2014-11-04 00:26:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
*pArgc = idx;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert a sub-string to lower case according to rules for English book
|
|
|
|
* titles. Assumes the initial string is in all caps.
|
|
|
|
*/
|
2014-11-25 22:34:14 +00:00
|
|
|
static void DowncaseSubstring(CString* pStr, int startPos, int endPos,
|
2014-11-04 00:26:53 +00:00
|
|
|
bool prevWasSpace)
|
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
static const WCHAR* shortWords[] = {
|
|
|
|
L"of", L"the", L"a", L"an", L"and", L"to", L"in"
|
2014-11-04 00:26:53 +00:00
|
|
|
};
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
static const WCHAR* leaveAlone[] = {
|
|
|
|
L"BBS", L"3D"
|
2014-11-04 00:26:53 +00:00
|
|
|
};
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
static const WCHAR* justLikeThis[] = {
|
|
|
|
L"ProDOS", L"IIe", L"IIc", L"IIgs"
|
2014-11-04 00:26:53 +00:00
|
|
|
};
|
|
|
|
CString token;
|
|
|
|
bool firstCap = true;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
token = pStr->Mid(startPos, endPos - startPos);
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGV(" TOKEN: '%ls'", (LPCWSTR) token);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
/* these words are left alone */
|
|
|
|
for (i = 0; i < NELEM(leaveAlone); i++) {
|
|
|
|
if (token.CompareNoCase(leaveAlone[i]) == 0) {
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGV(" Leaving alone '%ls'", (LPCWSTR) token);
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* words with specific capitalization */
|
|
|
|
for (i = 0; i < NELEM(justLikeThis); i++) {
|
|
|
|
if (token.CompareNoCase(justLikeThis[i]) == 0) {
|
2014-11-19 22:54:24 +00:00
|
|
|
LOGI(" Setting '%ls' to '%ls'", (LPCWSTR) token, justLikeThis[i]);
|
2014-11-04 00:26:53 +00:00
|
|
|
for (int j = startPos; j < endPos; j++)
|
|
|
|
pStr->SetAt(j, justLikeThis[i][j - startPos]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* these words are not capitalized unless they start a phrase */
|
|
|
|
if (prevWasSpace) {
|
|
|
|
for (i = 0; i < NELEM(shortWords); i++) {
|
|
|
|
if (token.CompareNoCase(shortWords[i]) == 0) {
|
2014-12-03 01:55:19 +00:00
|
|
|
LOGV(" No leading cap for '%ls'", (LPCWSTR) token);
|
2014-11-04 00:26:53 +00:00
|
|
|
firstCap = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check for roman numerals; we leave those capitalized */
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
CString romanTest = token.SpanIncluding(L"IVX");
|
2014-11-04 00:26:53 +00:00
|
|
|
if (romanTest.GetLength() == token.GetLength()) {
|
2014-12-03 01:55:19 +00:00
|
|
|
LOGV(" Looks like roman numerals '%ls'", (LPCWSTR) token);
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (firstCap)
|
|
|
|
startPos++;
|
|
|
|
|
|
|
|
for (i = startPos; i < endPos; i++) {
|
|
|
|
pStr->SetAt(i, tolower(pStr->GetAt(i)));
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
void InjectLowercase(CString* pStr)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
int len = pStr->GetLength();
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
static const WCHAR* kGapChars = L" .:&-+/\\()<>@*";
|
2014-11-04 00:26:53 +00:00
|
|
|
int startPos, endPos;
|
|
|
|
|
|
|
|
//*pStr = "AND PRODOS FOR THE IIGS";
|
|
|
|
//len = pStr->GetLength();
|
2014-11-18 21:05:15 +00:00
|
|
|
//LOGI("InjectLowercase: '%ls'", (LPCWSTR) *pStr);
|
2014-11-04 00:26:53 +00:00
|
|
|
|
|
|
|
for (int i = 0; i < len; i++) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR ch = pStr->GetAt(i);
|
2014-11-04 00:26:53 +00:00
|
|
|
if (ch >= 'a' && ch <= 'z') {
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("Found lowercase 0x%04x, skipping InjectLower", ch);
|
2014-11-04 00:26:53 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
startPos = 0;
|
|
|
|
while (startPos < len) {
|
|
|
|
/* find start of token */
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
WCHAR ch;
|
2014-11-04 00:26:53 +00:00
|
|
|
do {
|
|
|
|
ch = pStr->GetAt(startPos);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (wcschr(kGapChars, ch) == NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
startPos++;
|
|
|
|
} while (startPos < len);
|
|
|
|
if (startPos == len)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* find end of token */
|
|
|
|
endPos = startPos + 1;
|
|
|
|
while (endPos < len) {
|
|
|
|
ch = pStr->GetAt(endPos);
|
2014-11-18 05:13:13 +00:00
|
|
|
if (wcschr(kGapChars, ch) != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
break;
|
|
|
|
endPos++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* endPos now points at first char past end of token */
|
|
|
|
|
|
|
|
bool prevWasSpace;
|
|
|
|
if (startPos == 0)
|
|
|
|
prevWasSpace = false;
|
|
|
|
else
|
|
|
|
prevWasSpace = (pStr->GetAt(startPos-1) == ' ');
|
|
|
|
DowncaseSubstring(pStr, startPos, endPos, prevWasSpace);
|
|
|
|
|
|
|
|
startPos = endPos;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
bool MatchSemicolonList(const CString set, const CString match)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
const WCHAR* cp;
|
2014-11-04 00:26:53 +00:00
|
|
|
CString mangle(set);
|
|
|
|
int matchLen = match.GetLength();
|
|
|
|
|
|
|
|
if (!matchLen)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
mangle.Remove(' ');
|
|
|
|
for (cp = mangle; *cp != '\0'; ) {
|
Large set of changes to restore CiderPress build.
CiderPress and MDC now compile, and execute far enough to open
their respective "about" boxes, but I doubt they'll do much
more than that.
* Switch from MBCS to UNICODE APIs
Microsoft switched to UTF-16 (by way of UCS-2) a long time ago,
and the support for MBCS seems to be getting phased out. So it's
time to switch to wide strings.
This is a bit awkward for CiderPress because it works with disk
and file archives with 8-bit filenames, and I want NufxLib and
DiskImgLib to continue to work on Linux (which has largely taken
the UTF-8 approach to Unicode). The libraries will continue to
work with 8-bit filenames, with CiderPress/MDC doing the
conversion at the appropriate point.
There were a couple of places where strings from a structure
handed back by one of the libraries were used directly in the UI,
or vice-versa, which is a problem because we have nowhere to
store the result of the conversion. These currently have fixed
place-holder "xyzzy" strings.
All UI strings are now wide.
Various format strings now use "%ls" and "%hs" to explicitly
specify wide and narrow. This doesn't play well with gcc, so
only the Windows-specific parts use those.
* Various updates to vcxproj files
The project-file conversion had some cruft that is now largely
gone. The build now has a common output directory for the EXEs
and libraries, avoiding the old post-build copy steps.
* Added zlib 1.2.8 and nufxlib 2.2.2 source snapshots
The old "prebuilts" directory is now gone. The libraries are now
built as part of building the apps.
I added a minimal set of files for zlib, and a full set for nufxlib.
The Linux-specific nufxlib goodies are included for the benefit of
the Linux utilities, which are currently broken (don't build).
* Replace symbols used for include guards
Symbols with a leading "__" are reserved.
2014-11-10 23:32:55 +00:00
|
|
|
if (wcsnicmp(cp, match, matchLen) == 0 &&
|
2014-11-04 00:26:53 +00:00
|
|
|
(cp[matchLen] == ';' || cp[matchLen] == '\0'))
|
|
|
|
{
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("+++ Found '%ls' at '%ls'", (LPCWSTR) match, cp);
|
2014-11-04 00:26:53 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*cp != ';' && *cp != '\0')
|
|
|
|
cp++;
|
|
|
|
if (*cp == ';')
|
|
|
|
cp++;
|
|
|
|
}
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 21:05:15 +00:00
|
|
|
LOGI("--- No match for '%ls' in '%ls'", (LPCWSTR) match, (LPCWSTR) set);
|
2014-11-04 00:26:53 +00:00
|
|
|
return false;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:34:14 +00:00
|
|
|
char* StrcpyNew(const char* str)
|
2007-03-27 17:47:10 +00:00
|
|
|
{
|
2014-11-04 00:26:53 +00:00
|
|
|
char* newStr;
|
2007-03-27 17:47:10 +00:00
|
|
|
|
2014-11-18 05:13:13 +00:00
|
|
|
if (str == NULL)
|
|
|
|
return NULL;
|
2014-11-04 00:26:53 +00:00
|
|
|
newStr = new char[strlen(str)+1];
|
2014-11-18 05:13:13 +00:00
|
|
|
if (newStr != NULL)
|
2014-11-04 00:26:53 +00:00
|
|
|
strcpy(newStr, str);
|
|
|
|
return newStr;
|
2007-03-27 17:47:10 +00:00
|
|
|
}
|