From 80c9b7851671812bbf4b797e7dd5b7091e6f8be8 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Wed, 12 Mar 2003 02:39:43 +0000 Subject: [PATCH] The test for really long filename extensions was broken. --- nulib2/Filename.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/nulib2/Filename.c b/nulib2/Filename.c index 5140197..af0d8b9 100644 --- a/nulib2/Filename.c +++ b/nulib2/Filename.c @@ -182,22 +182,27 @@ AddPreservationString(NulibState* pState, pExt = nil; else pExt = FindExtension(pState, pathBuf); - if (pExt != nil && strlen(pExt+1) < kMaxExtLen) { + if (pExt != nil) { pExt++; /* skip past the '.' */ - /* if it's strictly decimal-numeric, don't use it (.1, .2, etc) */ - (void) strtoul(pExt, &end, 10); - if (*end == '\0') { + if (strlen(pExt) >= kMaxExtLen) { + /* too long, forget it */ pExt = nil; } else { - /* if '#' appears in it, don't use it -- it'll confuse us */ - const char* ccp = pExt; - while (*ccp != '\0') { - if (*ccp == '#') { - pExt = nil; - break; + /* if strictly decimal-numeric, don't use it (.1, .2, etc) */ + (void) strtoul(pExt, &end, 10); + if (*end == '\0') { + pExt = nil; + } else { + /* if '#' appears in it, don't use it -- it'll confuse us */ + const char* ccp = pExt; + while (*ccp != '\0') { + if (*ccp == '#') { + pExt = nil; + break; + } + ccp++; } - ccp++; } }