mirror of
https://github.com/fadden/ciderpress.git
synced 2024-12-30 11:29:32 +00:00
Minor fixes
- Drop strcasecmp / strncasecmp defines; just use the VC++ version. - Fix LOG_WARNING vs. LOG_WARN. - Fix crash when NiftyList data file not available.
This commit is contained in:
parent
af429c8bb9
commit
f8017fdee3
@ -538,7 +538,7 @@ BnyArchive::LoadContentsCallback(BnyFileEntry* pEntry)
|
||||
if (isSqueezed && strlen(fileName) > 3) {
|
||||
char* ext;
|
||||
ext = fileName + strlen(fileName) -3;
|
||||
if (strcasecmp(ext, ".qq") == 0)
|
||||
if (stricmp(ext, ".qq") == 0)
|
||||
*ext = '\0';
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ BASTokenLookup::Lookup(const char* str, int len, int* pFoundLen)
|
||||
longestIndex = longestLen = -1;
|
||||
for (i = 0; i < fNumTokens; i++) {
|
||||
if (fTokenLen[i] <= len && fTokenLen[i] > longestLen &&
|
||||
strncasecmp(str, fTokenPtr[i], fTokenLen[i]) == 0)
|
||||
strnicmp(str, fTokenPtr[i], fTokenLen[i]) == 0)
|
||||
{
|
||||
longestIndex = i;
|
||||
longestLen = fTokenLen[i];
|
||||
|
@ -535,7 +535,7 @@ NufxArchive::NufxErrorMsgHandler(NuArchive* /*pArchive*/, void* vErrorMessage)
|
||||
{
|
||||
const NuErrorMessage* pErrorMessage = (const NuErrorMessage*) vErrorMessage;
|
||||
|
||||
LOG_BASE(pErrorMessage->isDebug ? DebugLog::LOG_DEBUG : DebugLog::LOG_WARNING,
|
||||
LOG_BASE(pErrorMessage->isDebug ? DebugLog::LOG_DEBUG : DebugLog::LOG_WARN,
|
||||
pErrorMessage->file, pErrorMessage->line, "<nufxlib> %hs",
|
||||
pErrorMessage->message);
|
||||
|
||||
@ -627,10 +627,11 @@ NufxArchive::Open(const WCHAR* filename, bool readOnly, CString* pErrMsg)
|
||||
fIsReadOnly = false;
|
||||
CStringA tmpnameA(tmpname);
|
||||
nerr = NuOpenRW(filenameA, tmpnameA, 0, &fpArchive);
|
||||
}
|
||||
if (nerr == kNuErrFileAccessDenied || nerr == EACCES) {
|
||||
LOGI("Read-write failed with access denied, trying read-only");
|
||||
readOnly = true;
|
||||
|
||||
if (nerr == kNuErrFileAccessDenied || nerr == EACCES) {
|
||||
LOGI("Read-write failed with access denied, trying read-only");
|
||||
readOnly = true;
|
||||
}
|
||||
}
|
||||
if (readOnly) {
|
||||
LOGI("Opening file '%ls' ro", (LPCWSTR) filename);
|
||||
|
@ -227,7 +227,7 @@ ReformatMerlin::Examine(ReformatHolder* pHolder)
|
||||
{
|
||||
if (pHolder->GetFileType() == kTypeTXT) {
|
||||
bool isAsm = ReformatMerlin::IsMerlin(pHolder);
|
||||
bool isDotS = strcasecmp(pHolder->GetNameExt(), ".S") == 0;
|
||||
bool isDotS = stricmp(pHolder->GetNameExt(), ".S") == 0;
|
||||
|
||||
if (isAsm && isDotS) {
|
||||
/* gotta be */
|
||||
|
@ -73,7 +73,7 @@ ReformatCPMText::Examine(ReformatHolder* pHolder)
|
||||
applies = ReformatHolder::kApplicProbablyNot;
|
||||
|
||||
/* allow, but don't default to, text conversion of ".com" files */
|
||||
if (strcasecmp(nameExt, ".com") == 0) {
|
||||
if (stricmp(nameExt, ".com") == 0) {
|
||||
LOGI("Not reformatting '.com' file as text");
|
||||
goto done;
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ ReformatDisasm65xxx::ValidateOpCodeDetails(void)
|
||||
/* O(n^2) duplicate string check */
|
||||
for (int i = 0; i < NELEM(kOpCodeDetails)-1; i++) {
|
||||
for (int j = i+1; j < NELEM(kOpCodeDetails); j++) {
|
||||
if (strcasecmp(kOpCodeDetails[i].mnemonic,
|
||||
if (stricmp(kOpCodeDetails[i].mnemonic,
|
||||
kOpCodeDetails[j].mnemonic) == 0)
|
||||
{
|
||||
LOGI("OpCodeDetails GLITCH: entries %d and %d match (%hs)",
|
||||
|
@ -55,7 +55,7 @@ ReformatMacPaint::Examine(ReformatHolder* pHolder)
|
||||
}
|
||||
|
||||
version = Get32BE(ptr);
|
||||
if (strcasecmp(nameExt, ".mac") == 0 && version >= 0 && version <= 3) {
|
||||
if (stricmp(nameExt, ".mac") == 0 && version >= 0 && version <= 3) {
|
||||
LOGI(" MP: found w/o MacBinary header");
|
||||
applies = ReformatHolder::kApplicProbably;
|
||||
goto done;
|
||||
|
@ -338,17 +338,17 @@ NiftyList::DumpSection(const DataSet& dataSet)
|
||||
{
|
||||
long ent;
|
||||
|
||||
LOGI("Dumping section (count=%ld)", dataSet.numEntries);
|
||||
LOGD("Dumping section (count=%ld)", dataSet.numEntries);
|
||||
|
||||
for (ent = 0; ent < dataSet.numEntries; ent++) {
|
||||
LOGI("%4d: %04x '%hs'",
|
||||
LOGD("%4d: %04x '%hs'",
|
||||
ent, dataSet.pEntries[ent].value, dataSet.pEntries[ent].name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Look up a value in the specified table. Returns the name, or "NULL" if
|
||||
* Look up a value in the specified table. Returns the name, or NULL if
|
||||
* not found.
|
||||
*
|
||||
* This uses a binary search, so the entries must be in sorted order.
|
||||
@ -356,6 +356,9 @@ NiftyList::DumpSection(const DataSet& dataSet)
|
||||
/*static*/ const char*
|
||||
NiftyList::Lookup(const DataSet& dataSet, unsigned short key)
|
||||
{
|
||||
if (!fDataReady) {
|
||||
return NULL;
|
||||
}
|
||||
assert(dataSet.numEntries > 0);
|
||||
|
||||
int high = dataSet.numEntries-1;
|
||||
|
@ -42,7 +42,7 @@ ReformatMagicWindow::Examine(ReformatHolder* pHolder)
|
||||
{
|
||||
if (pHolder->GetFileType() == kTypeBIN) {
|
||||
bool isMW = ReformatMagicWindow::IsFormatted(pHolder);
|
||||
bool isDotMW = strcasecmp(pHolder->GetNameExt(), ".MW") == 0;
|
||||
bool isDotMW = stricmp(pHolder->GetNameExt(), ".MW") == 0;
|
||||
|
||||
if (isMW && isDotMW) {
|
||||
/* gotta be */
|
||||
|
@ -9,7 +9,7 @@
|
||||
#ifndef UTIL_FADDENSTD_H
|
||||
#define UTIL_FADDENSTD_H
|
||||
|
||||
#define NELEM(x) ((int) (sizeof(x) / sizeof(x[0])))
|
||||
#define NELEM(x) (sizeof(x) / sizeof(x[0]))
|
||||
|
||||
/*
|
||||
* Declare copy construction and operator=. Put this in a private section
|
||||
@ -19,8 +19,4 @@
|
||||
_TYPE(const _TYPE&); \
|
||||
_TYPE& operator= (const _TYPE&);
|
||||
|
||||
// Windows equivalents
|
||||
#define strcasecmp stricmp
|
||||
#define strncasecmp strnicmp
|
||||
|
||||
#endif /*UTIL_FADDENSTD_H*/
|
||||
|
@ -79,9 +79,11 @@ void DebugLog::Log(LogSeverity severity, const char* file, int line,
|
||||
time_t now = time(NULL);
|
||||
localtime_s(&tmbuf, &now);
|
||||
|
||||
// also had %05u fPid before; not sure that's useful
|
||||
fprintf(fLogFp, "%02d:%02d:%02d %c %s\n", tmbuf.tm_hour,
|
||||
tmbuf.tm_min, tmbuf.tm_sec, kSeverityChars[severity],
|
||||
// The pid is useful when we spawn a new instance of CiderPress
|
||||
// to handle a disk image or NuFX archive inside an archive. The
|
||||
// file is opened in "append" mode, so we shouldn't collide.
|
||||
fprintf(fLogFp, "%02d:%02d:%02d %05u %c %s\n", tmbuf.tm_hour,
|
||||
tmbuf.tm_min, tmbuf.tm_sec, fPid, kSeverityChars[severity],
|
||||
textBuf);
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
|
||||
typedef enum {
|
||||
LOG_UNKNOWN=0, LOG_VERBOSE=1, LOG_DEBUG=2,
|
||||
LOG_INFO=3, LOG_WARNING=4, LOG_ERROR=5
|
||||
LOG_INFO=3, LOG_WARN=4, LOG_ERROR=5
|
||||
} LogSeverity;
|
||||
|
||||
/*
|
||||
|
@ -519,14 +519,14 @@ GetPascalString(const char* buf, long maxLen, CString* pStr)
|
||||
*pStr = "";
|
||||
|
||||
if (len > maxLen) {
|
||||
LOGI("Invalid pascal string -- len=%d, maxLen=%d", len, maxLen);
|
||||
LOGW("Invalid pascal string -- len=%d, maxLen=%d", len, maxLen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (len--) {
|
||||
if (*buf == '\0') {
|
||||
/* this suggests that we're not reading a pascal string */
|
||||
LOGI("Found pascal string with '\\0' in it");
|
||||
LOGW("Found pascal string with '\\0' in it");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user