From 3444b58404e0caaf02b88dc302ca50ab9c4fb1e3 Mon Sep 17 00:00:00 2001 From: Philipp Lohmann Date: Thu, 10 May 2001 18:48:22 +0000 Subject: removed an of by one issue --- registry/source/regimpl.cxx | 57 +++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 30 deletions(-) (limited to 'registry') diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx index a99015ee66b8..a30150d71859 100644 --- a/registry/source/regimpl.cxx +++ b/registry/source/regimpl.cxx @@ -2,9 +2,9 @@ * * $RCSfile: regimpl.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: pl $ $Date: 2001-05-10 10:59:09 $ + * last change: $Author: pl $ $Date: 2001-05-10 19:48:22 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -624,6 +624,7 @@ RegError ORegistry::createKey(RegKeyHandle hKey, const OUString& keyName, } } while( nIndex != -1 ); + pKey = new ORegKey(sFullKeyName, rStoreDir, this); *phNewKey = pKey; m_openKeyTable[sFullKeyName] = pKey; @@ -1927,7 +1928,7 @@ RegError ORegistry::createLink(RegKeyHandle hKey, sFullPath += token; sFullPath += ROOT; } - } while( nIndex != -1 ); + } while( nIndex != -1 && token.getLength() > 0 ); pKey = new ORegKey(sFullLinkName, linkTarget, rStoreDir, this); delete pKey; @@ -2002,51 +2003,47 @@ RegError ORegistry::deleteLink(RegKeyHandle hKey, const OUString& linkName) OUString ORegistry::resolveLinks(ORegKey* pKey, const OUString& path, sal_Bool firstLinkOnly) { OUString resolvedPath(pKey->getName()); - sal_Int32 actToken = 0; sal_Int32 nIndex = 0; OUString token; ORegKey* pLink = NULL; - if (resolvedPath.getLength() > 1) - resolvedPath += ROOT; +// if (resolvedPath.getLength() > 1) +// resolvedPath += ROOT; if ( path.getStr()[0] == '/' ) - nIndex++, actToken++; + nIndex++; do { token = path.getToken( 0, '/', nIndex ); - actToken++; - if( token.getLength() > 0 ) + if( token.getLength() && resolvedPath.getLength() > 1 ) + resolvedPath += ROOT; + + pLink = resolveLink(pKey, resolvedPath, token); + + if (pLink) { - pLink = resolveLink(pKey, resolvedPath, token); + OUString tmpName; + sal_Int32 lastIndex; - if (pLink) + while(pLink) { - OUString tmpName; - sal_Int32 lastIndex; - - while(pLink) + if (!insertRecursionLink(pLink)) { - if (!insertRecursionLink(pLink)) - { - resetRecursionLinks(); - delete pLink; - return OUString(); - } - + resetRecursionLinks(); + delete pLink; + return OUString(); + } - lastIndex = resolvedPath.lastIndexOf('/'); - tmpName = resolvedPath.copy(lastIndex + 1); - resolvedPath = resolvedPath.copy(0, lastIndex + 1); - pLink = resolveLink(pKey, resolvedPath, tmpName); - } + lastIndex = resolvedPath.lastIndexOf('/'); + tmpName = resolvedPath.copy(lastIndex + 1); + resolvedPath = resolvedPath.copy(0, lastIndex + 1); - resetRecursionLinks(); + pLink = resolveLink(pKey, resolvedPath, tmpName); } - if( actToken > 1 ) - resolvedPath += ROOT; + + resetRecursionLinks(); } } while( nIndex != -1 ); -- cgit