diff --git a/app/BNYArchive.cpp b/app/BNYArchive.cpp index 044f8a4..21eb701 100644 --- a/app/BNYArchive.cpp +++ b/app/BNYArchive.cpp @@ -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'; } diff --git a/app/BasicImport.cpp b/app/BasicImport.cpp index 46bcc5b..0c1abcc 100644 --- a/app/BasicImport.cpp +++ b/app/BasicImport.cpp @@ -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]; diff --git a/app/NufxArchive.cpp b/app/NufxArchive.cpp index 5630b09..afe8ffd 100644 --- a/app/NufxArchive.cpp +++ b/app/NufxArchive.cpp @@ -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, " %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); diff --git a/reformat/Asm.cpp b/reformat/Asm.cpp index 36edf74..d187685 100644 --- a/reformat/Asm.cpp +++ b/reformat/Asm.cpp @@ -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 */ diff --git a/reformat/CPMFiles.cpp b/reformat/CPMFiles.cpp index 909e630..cd195ac 100644 --- a/reformat/CPMFiles.cpp +++ b/reformat/CPMFiles.cpp @@ -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; } diff --git a/reformat/DisasmTable.cpp b/reformat/DisasmTable.cpp index 79ffcde..2ae4442 100644 --- a/reformat/DisasmTable.cpp +++ b/reformat/DisasmTable.cpp @@ -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)", diff --git a/reformat/MacPaint.cpp b/reformat/MacPaint.cpp index c60bbe4..d9c8ca9 100644 --- a/reformat/MacPaint.cpp +++ b/reformat/MacPaint.cpp @@ -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; diff --git a/reformat/NiftyList.cpp b/reformat/NiftyList.cpp index 58b6beb..f1825dd 100644 --- a/reformat/NiftyList.cpp +++ b/reformat/NiftyList.cpp @@ -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; diff --git a/reformat/Text8.cpp b/reformat/Text8.cpp index 709881e..a94e2bd 100644 --- a/reformat/Text8.cpp +++ b/reformat/Text8.cpp @@ -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 */ diff --git a/util/FaddenStd.h b/util/FaddenStd.h index 877c5a2..c1dd8b1 100644 --- a/util/FaddenStd.h +++ b/util/FaddenStd.h @@ -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*/ diff --git a/util/MyDebug.cpp b/util/MyDebug.cpp index 287040d..c1b6603 100644 --- a/util/MyDebug.cpp +++ b/util/MyDebug.cpp @@ -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 diff --git a/util/MyDebug.h b/util/MyDebug.h index c0080f7..615ae42 100644 --- a/util/MyDebug.h +++ b/util/MyDebug.h @@ -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; /* diff --git a/util/Util.cpp b/util/Util.cpp index 038876d..05da83f 100644 --- a/util/Util.cpp +++ b/util/Util.cpp @@ -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; }