Minor tweaks, mostly to comments and "assert" vs "Assert".

This commit is contained in:
Andy McFadden 2002-10-09 00:04:18 +00:00
parent afe82def33
commit 46c7579f57
5 changed files with 55 additions and 39 deletions

View File

@ -21,13 +21,13 @@ DoDelete(NulibState* pState)
NuError err; NuError err;
NuArchive* pArchive = nil; NuArchive* pArchive = nil;
assert(pState != nil); Assert(pState != nil);
err = OpenArchiveReadWrite(pState); err = OpenArchiveReadWrite(pState);
if (err != kNuErrNone) if (err != kNuErrNone)
goto bail; goto bail;
pArchive = NState_GetNuArchive(pState); pArchive = NState_GetNuArchive(pState);
assert(pArchive != nil); Assert(pArchive != nil);
NState_SetMatchCount(pState, 0); NState_SetMatchCount(pState, 0);

View File

@ -20,7 +20,7 @@
#define kFilenameExtDelim '.' /* separates extension from filename */ #define kFilenameExtDelim '.' /* separates extension from filename */
#define kResourceFlag 'r' #define kResourceFlag 'r'
#define kDiskImageFlag 'i' #define kDiskImageFlag 'i'
#define kMaxExtLen 4 /* ".1234" */ #define kMaxExtLen 4 /* ".123" */
#define kResourceStr "_rsrc_" #define kResourceStr "_rsrc_"
/* must be longer then strlen(kResourceStr)... no problem there */ /* 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 * preservation mode, we try to assign types to files that weren't
* explicitly preserved, but nevertheless have a recognizeable type. * 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. * file rather than a hard-coded table. Ought to fix that someday.
*/ */
static const struct { static const struct {
@ -127,15 +127,15 @@ AddPreservationString(NulibState* pState,
NuThreadID threadID; NuThreadID threadID;
char* cp; char* cp;
assert(pState != nil); Assert(pState != nil);
assert(pPathProposal != nil); Assert(pPathProposal != nil);
assert(pathBuf != nil); Assert(pathBuf != nil);
assert(NState_GetModPreserveType(pState)); Assert(NState_GetModPreserveType(pState));
pRecord = pPathProposal->pRecord; pRecord = pPathProposal->pRecord;
pThread = pPathProposal->pThread; pThread = pPathProposal->pThread;
assert(pRecord != nil); Assert(pRecord != nil);
assert(pThread != nil); Assert(pThread != nil);
cp = extBuf; cp = extBuf;
@ -224,7 +224,7 @@ AddPreservationString(NulibState* pState,
/* make sure it's terminated */ /* make sure it's terminated */
*cp = '\0'; *cp = '\0';
assert(cp - extBuf <= kMaxPathGrowth); Assert(cp - extBuf <= kMaxPathGrowth);
strcat(pathBuf, extBuf); strcat(pathBuf, extBuf);
} }
@ -238,7 +238,7 @@ AddPreservationString(NulibState* pState,
* The new pathname may be shorter (because characters were removed) or * The new pathname may be shorter (because characters were removed) or
* longer (if we add a "#XXYYYYZ" extension or replace chars with '%' codes). * 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. * pathname buffer.
*/ */
const char* const char*
@ -251,9 +251,9 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal)
char* dstp; char* dstp;
char localFssep; char localFssep;
assert(pState != nil); Assert(pState != nil);
assert(pPathProposal != nil); Assert(pPathProposal != nil);
assert(pPathProposal->pathname != nil); Assert(pPathProposal->pathname != nil);
localFssep = NState_GetSystemPathSeparator(pState); localFssep = NState_GetSystemPathSeparator(pState);
@ -265,7 +265,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal)
NState_SetTempPathnameLen(pState, NState_SetTempPathnameLen(pState,
strlen(pPathProposal->pathname)*3 + kMaxPathGrowth +1); strlen(pPathProposal->pathname)*3 + kMaxPathGrowth +1);
pathBuf = NState_GetTempPathnameBuf(pState); pathBuf = NState_GetTempPathnameBuf(pState);
assert(pathBuf != nil); Assert(pathBuf != nil);
if (pathBuf == nil) if (pathBuf == nil)
return nil; return nil;
@ -316,7 +316,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal)
pPathProposal->newFilenameSeparator = localFssep; pPathProposal->newFilenameSeparator = localFssep;
/* check for overflow */ /* check for overflow */
assert(dstp - pathBuf <= Assert(dstp - pathBuf <=
(int)(strlen(pPathProposal->pathname) + kMaxPathGrowth)); (int)(strlen(pPathProposal->pathname) + kMaxPathGrowth));
/* /*
@ -326,7 +326,7 @@ NormalizePath(NulibState* pState, NuPathnameProposal* pPathProposal)
char* lastFssep; char* lastFssep;
lastFssep = strrchr(pathBuf, localFssep); lastFssep = strrchr(pathBuf, localFssep);
if (lastFssep != nil) { 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); memmove(pathBuf, lastFssep+1, strlen(lastFssep+1)+1);
} }
} }
@ -358,7 +358,7 @@ LookupExtension(NulibState* pState, const char* ext, ulong* pFileType,
int i, extLen; int i, extLen;
extLen = strlen(ext); extLen = strlen(ext);
assert(extLen > 0); Assert(extLen > 0);
/* /*
* First step is to try to find it in the recognized types list. * 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; const char* pExt;
assert(pState != nil); Assert(pState != nil);
assert(pathName != nil); Assert(pathName != nil);
assert(pFileType != nil); Assert(pFileType != nil);
assert(pAuxType != nil); Assert(pAuxType != nil);
pExt = FindExtension(pState, pathName); pExt = FindExtension(pState, pathName);
if (pExt != nil) if (pExt != nil)
@ -438,11 +438,11 @@ ExtractPreservationString(NulibState* pState, char* pathname, ulong* pFileType,
char* cp; char* cp;
int digitCount; int digitCount;
assert(pState != nil); Assert(pState != nil);
assert(pathname != nil); Assert(pathname != nil);
assert(pFileType != nil); Assert(pFileType != nil);
assert(pAuxType != nil); Assert(pAuxType != nil);
assert(pThreadID != nil); Assert(pThreadID != nil);
pPreserve = strrchr(pathname, kPreserveIndic); pPreserve = strrchr(pathname, kPreserveIndic);
if (pPreserve == nil) if (pPreserve == nil)
@ -460,20 +460,20 @@ ExtractPreservationString(NulibState* pState, char* pathname, ulong* pFileType,
memcpy(numBuf, pPreserve+1, 2); memcpy(numBuf, pPreserve+1, 2);
numBuf[2] = 0; numBuf[2] = 0;
fileType = strtoul(numBuf, &cp, 16); fileType = strtoul(numBuf, &cp, 16);
assert(cp == numBuf + 2); Assert(cp == numBuf + 2);
auxType = strtoul(pPreserve+3, &cp, 16); auxType = strtoul(pPreserve+3, &cp, 16);
assert(cp == pPreserve + 7); Assert(cp == pPreserve + 7);
break; break;
case 16: case 16:
/* HFS 4-byte type and 4-byte creator */ /* HFS 4-byte type and 4-byte creator */
memcpy(numBuf, pPreserve+1, 8); memcpy(numBuf, pPreserve+1, 8);
numBuf[8] = 0; numBuf[8] = 0;
fileType = strtoul(numBuf, &cp, 16); fileType = strtoul(numBuf, &cp, 16);
assert(cp == numBuf + 8); Assert(cp == numBuf + 8);
auxType = strtoul(pPreserve+9, &cp, 16); auxType = strtoul(pPreserve+9, &cp, 16);
assert(cp == pPreserve + 17); Assert(cp == pPreserve + 17);
break; break;
default: default:
/* not valid */ /* not valid */
@ -561,7 +561,7 @@ DenormalizePath(NulibState* pState, char* pathBuf)
} }
*dstp = '\0'; *dstp = '\0';
assert(dstp <= srcp); Assert(dstp <= srcp);
} }
@ -584,8 +584,8 @@ FilenameOnly(NulibState* pState, const char* pathname)
const char* pSlash; const char* pSlash;
char* tmpStr = nil; char* tmpStr = nil;
assert(pState != nil); Assert(pState != nil);
assert(pathname != nil); Assert(pathname != nil);
pSlash = strrchr(pathname, NState_GetSystemPathSeparator(pState)); pSlash = strrchr(pathname, NState_GetSystemPathSeparator(pState));
if (pSlash == nil) { if (pSlash == nil) {
@ -648,7 +648,7 @@ FindExtension(NulibState* pState, const char* pathname)
* about "/foo.bar/file". * about "/foo.bar/file".
*/ */
pFilename = FilenameOnly(pState, pathname); pFilename = FilenameOnly(pState, pathname);
assert(pFilename != nil); Assert(pFilename != nil);
pExt = strrchr(pFilename, kFilenameExtDelim); pExt = strrchr(pFilename, kFilenameExtDelim);
/* also check for "/blah/foo.", which doesn't count */ /* also check for "/blah/foo.", which doesn't count */

View File

@ -46,8 +46,8 @@ Nu_memmove(void* dst, const void* src, size_t n)
char* dstp = (char*)dst; char* dstp = (char*)dst;
/* you can normally get away with this if n==0 */ /* you can normally get away with this if n==0 */
assert(dst != NULL); Assert(dst != NULL);
assert(src != NULL); Assert(src != NULL);
if (dstp == srcp || !n) { if (dstp == srcp || !n) {
/* nothing to do */ /* nothing to do */

View File

@ -22,7 +22,7 @@ ReportError(NuError err, const char* format, ...)
const char* msg; const char* msg;
va_list args; va_list args;
assert(format != nil); Assert(format != nil);
va_start(args, format); va_start(args, format);

View File

@ -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 ProDOS hard drive partitions. NuLib2 under Linux handled it without
breaking a sweat. 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.