From 46c7579f577889e81b6930c2bceeba2df7879b6a Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 9 Oct 2002 00:04:18 +0000 Subject: [PATCH] Minor tweaks, mostly to comments and "assert" vs "Assert". --- nulib2/Delete.c | 4 +-- nulib2/Filename.c | 68 +++++++++++++++++++++++----------------------- nulib2/MiscStuff.c | 4 +-- nulib2/MiscUtils.c | 2 +- nulib2/README.txt | 16 +++++++++++ 5 files changed, 55 insertions(+), 39 deletions(-) diff --git a/nulib2/Delete.c b/nulib2/Delete.c index 06675e5..1458dcc 100644 --- a/nulib2/Delete.c +++ b/nulib2/Delete.c @@ -21,13 +21,13 @@ DoDelete(NulibState* pState) NuError err; NuArchive* pArchive = nil; - assert(pState != nil); + Assert(pState != nil); err = OpenArchiveReadWrite(pState); if (err != kNuErrNone) goto bail; pArchive = NState_GetNuArchive(pState); - assert(pArchive != nil); + Assert(pArchive != nil); NState_SetMatchCount(pState, 0); diff --git a/nulib2/Filename.c b/nulib2/Filename.c index 5faf42c..2895ae3 100644 --- a/nulib2/Filename.c +++ b/nulib2/Filename.c @@ -20,7 +20,7 @@ #define kFilenameExtDelim '.' /* separates extension from filename */ #define kResourceFlag 'r' #define kDiskImageFlag 'i' -#define kMaxExtLen 4 /* ".1234" */ +#define kMaxExtLen 4 /* ".123" */ #define kResourceStr "_rsrc_" /* must be longer then strlen(kResourceStr)... no problem there */ @@ -68,7 +68,7 @@ static const char gFileTypeNames[256][4] = { * preservation mode, we try to assign types to files that weren't * explicitly preserved, but nevertheless have a recognizeable type. * - * geoff@gwlink.net points out that this really ought to be in an external + * geoff @ gwlink.net points out that this really ought to be in an external * file rather than a hard-coded table. Ought to fix that someday. */ static const struct { @@ -127,15 +127,15 @@ AddPreservationString(NulibState* pState, NuThreadID threadID; char* cp; - assert(pState != nil); - assert(pPathProposal != nil); - assert(pathBuf != nil); - assert(NState_GetModPreserveType(pState)); + Assert(pState != nil); + Assert(pPathProposal != nil); + Assert(pathBuf != nil); + Assert(NState_GetModPreserveType(pState)); pRecord = pPathProposal->pRecord; pThread = pPathProposal->pThread; - assert(pRecord != nil); - assert(pThread != nil); + Assert(pRecord != nil); + Assert(pThread != nil); cp = extBuf; @@ -224,7 +224,7 @@ AddPreservationString(NulibState* pState, /* make sure it's terminated */ *cp = '\0'; - assert(cp - extBuf <= kMaxPathGrowth); + Assert(cp - extBuf <= kMaxPathGrowth); strcat(pathBuf, extBuf); } @@ -238,7 +238,7 @@ AddPreservationString(NulibState* pState, * The new pathname may be shorter (because characters were removed) or * longer (if we add a "#XXYYYYZ" extension or replace chars with '%' codes). * - * This returns the new pathname, which is held in NState's temporary + * This returns the new pathname, which is held in NulibState's temporary * pathname buffer. */ const char* @@ -251,9 +251,9 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) char* dstp; char localFssep; - assert(pState != nil); - assert(pPathProposal != nil); - assert(pPathProposal->pathname != nil); + Assert(pState != nil); + Assert(pPathProposal != nil); + Assert(pPathProposal->pathname != nil); localFssep = NState_GetSystemPathSeparator(pState); @@ -265,7 +265,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) NState_SetTempPathnameLen(pState, strlen(pPathProposal->pathname)*3 + kMaxPathGrowth +1); pathBuf = NState_GetTempPathnameBuf(pState); - assert(pathBuf != nil); + Assert(pathBuf != nil); if (pathBuf == nil) return nil; @@ -316,7 +316,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) pPathProposal->newFilenameSeparator = localFssep; /* check for overflow */ - assert(dstp - pathBuf <= + Assert(dstp - pathBuf <= (int)(strlen(pPathProposal->pathname) + kMaxPathGrowth)); /* @@ -326,7 +326,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal) char* lastFssep; lastFssep = strrchr(pathBuf, localFssep); if (lastFssep != nil) { - assert(*(lastFssep+1) != '\0'); /* should already have been caught*/ + Assert(*(lastFssep+1) != '\0'); /* should already have been caught*/ memmove(pathBuf, lastFssep+1, strlen(lastFssep+1)+1); } } @@ -358,7 +358,7 @@ LookupExtension(NulibState* pState, const char* ext, ulong* pFileType, int i, extLen; extLen = strlen(ext); - assert(extLen > 0); + Assert(extLen > 0); /* * First step is to try to find it in the recognized types list. @@ -408,10 +408,10 @@ InterpretExtension(NulibState* pState, const char* pathName, ulong* pFileType, { const char* pExt; - assert(pState != nil); - assert(pathName != nil); - assert(pFileType != nil); - assert(pAuxType != nil); + Assert(pState != nil); + Assert(pathName != nil); + Assert(pFileType != nil); + Assert(pAuxType != nil); pExt = FindExtension(pState, pathName); if (pExt != nil) @@ -438,11 +438,11 @@ ExtractPreservationString(NulibState* pState, char* pathname, ulong* pFileType, char* cp; int digitCount; - assert(pState != nil); - assert(pathname != nil); - assert(pFileType != nil); - assert(pAuxType != nil); - assert(pThreadID != nil); + Assert(pState != nil); + Assert(pathname != nil); + Assert(pFileType != nil); + Assert(pAuxType != nil); + Assert(pThreadID != nil); pPreserve = strrchr(pathname, kPreserveIndic); if (pPreserve == nil) @@ -460,20 +460,20 @@ ExtractPreservationString(NulibState* pState, char* pathname, ulong* pFileType, memcpy(numBuf, pPreserve+1, 2); numBuf[2] = 0; fileType = strtoul(numBuf, &cp, 16); - assert(cp == numBuf + 2); + Assert(cp == numBuf + 2); auxType = strtoul(pPreserve+3, &cp, 16); - assert(cp == pPreserve + 7); + Assert(cp == pPreserve + 7); break; case 16: /* HFS 4-byte type and 4-byte creator */ memcpy(numBuf, pPreserve+1, 8); numBuf[8] = 0; fileType = strtoul(numBuf, &cp, 16); - assert(cp == numBuf + 8); + Assert(cp == numBuf + 8); auxType = strtoul(pPreserve+9, &cp, 16); - assert(cp == pPreserve + 17); + Assert(cp == pPreserve + 17); break; default: /* not valid */ @@ -561,7 +561,7 @@ DenormalizePath(NulibState* pState, char* pathBuf) } *dstp = '\0'; - assert(dstp <= srcp); + Assert(dstp <= srcp); } @@ -584,8 +584,8 @@ FilenameOnly(NulibState* pState, const char* pathname) const char* pSlash; char* tmpStr = nil; - assert(pState != nil); - assert(pathname != nil); + Assert(pState != nil); + Assert(pathname != nil); pSlash = strrchr(pathname, NState_GetSystemPathSeparator(pState)); if (pSlash == nil) { @@ -648,7 +648,7 @@ FindExtension(NulibState* pState, const char* pathname) * about "/foo.bar/file". */ pFilename = FilenameOnly(pState, pathname); - assert(pFilename != nil); + Assert(pFilename != nil); pExt = strrchr(pFilename, kFilenameExtDelim); /* also check for "/blah/foo.", which doesn't count */ diff --git a/nulib2/MiscStuff.c b/nulib2/MiscStuff.c index ce94151..08544e2 100644 --- a/nulib2/MiscStuff.c +++ b/nulib2/MiscStuff.c @@ -46,8 +46,8 @@ Nu_memmove(void* dst, const void* src, size_t n) char* dstp = (char*)dst; /* you can normally get away with this if n==0 */ - assert(dst != NULL); - assert(src != NULL); + Assert(dst != NULL); + Assert(src != NULL); if (dstp == srcp || !n) { /* nothing to do */ diff --git a/nulib2/MiscUtils.c b/nulib2/MiscUtils.c index d709d87..8e62e29 100644 --- a/nulib2/MiscUtils.c +++ b/nulib2/MiscUtils.c @@ -22,7 +22,7 @@ ReportError(NuError err, const char* format, ...) const char* msg; va_list args; - assert(format != nil); + Assert(format != nil); va_start(args, format); diff --git a/nulib2/README.txt b/nulib2/README.txt index 9e7aced..d686446 100644 --- a/nulib2/README.txt +++ b/nulib2/README.txt @@ -120,3 +120,19 @@ The largest archive I've tried had 4700 files for a total of 76MB ProDOS hard drive partitions. NuLib2 under Linux handled it without breaking a sweat. + +Legalese +======== + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +