if ( REGERR_OK == err && versionStr != NULL) {
if ( REGERR_OK == err && versionStr != NULL && *versionStr != '\0') {
static REGERR vr_SetCurrentNav( char *installation, char *programPath, char *versionStr){    REGERR      err;    REGENUM     state;	RKEY        navKey;    int         bFound;    int         nCopy;    char        regname[MAXREGNAMELEN];    char        dirbuf[MAXREGNAMELEN];	err = NR_RegAddKey( vreg, ROOTKEY_VERSIONS, NAVIGATOR_NODE, &navKey );	if (err != REGERR_OK)		goto done;    /* ...look for "Current Version" entry */    err = NR_RegGetEntryString( vreg, navKey, CURRENT_VER, curstr, sizeof(curstr));    if ( err == REGERR_NOFIND )    {        /* No current installation, we can simply add a new one  */    	err = NR_RegAddKey( vreg, navKey, installation, &curver );        /* ... add Path and Version properties */        if ( err == REGERR_OK ) {            err = vr_SetPathname( vreg, curver, NAVHOME, programPath );            if ( REGERR_OK == err && versionStr != NULL) {                err = NR_RegSetEntryString( vreg, curver, VERSTR, versionStr );            }        }        if ( REGERR_OK == err ) {            /* successfully added, make it the current version */            err = NR_RegSetEntryString(vreg, navKey, CURRENT_VER, installation);        }    	if (err != REGERR_OK)    		goto done;    }    else if ( REGERR_OK == err )    {        /* found one: if we're lucky we got the right one */        bFound = FALSE;        err = NR_RegGetKey( vreg, navKey, curstr, &curver );        if ( REGERR_OK == err ) {            err = vr_GetPathname( vreg, curver, NAVHOME, dirbuf, sizeof(dirbuf) );            if ( REGERR_OK == err ) {                bFound = vr_CompareDirs(dirbuf, programPath);            }            else if ( REGERR_NOFIND == err ) {                /* assume this is the right one since it's 'Current' */                err = vr_SetPathname( vreg, curver, NAVHOME, programPath );                bFound = TRUE;            }        }                /* Look for an existing installation if not found */        state = 0;        while (!bFound && ((err == REGERR_OK) || (err == REGERR_NOFILE)) ) {            err = NR_RegEnumSubkeys( vreg, navKey, &state, curstr,                    sizeof(curstr), REGENUM_NORMAL );            if (REGERR_OK == err ) {                err = vr_GetPathname( vreg, state, NAVHOME, dirbuf, sizeof(dirbuf) );                if (REGERR_OK == err ) {                    if (vr_CompareDirs( dirbuf, programPath )) {                        bFound = TRUE;                        curver = (RKEY)state;                    }                }                else if ( err == REGERR_NOFIND ) {                    /* wasn't a navigator node */                    err = REGERR_OK;                }            }        }        /* found the right one, make it current */        if (bFound) {            err = NR_RegSetEntryString( vreg, navKey, CURRENT_VER, curstr );            /* update version (curver already set) */            if ( REGERR_OK == err && versionStr != NULL ) {                err = NR_RegSetEntryString( vreg, curver, VERSTR, versionStr );            }        }        /* otherwise if no current installation matches */        else if ( err == REGERR_NOMORE )        {            /* look for an empty slot to put new installation */            nCopy = 1;            XP_STRCPY( regname, installation );            do {                err = NR_RegGetKey( vreg, navKey, regname, &curver );                if (err == REGERR_OK) {                    nCopy++;                    sprintf( regname, "%s #%d", installation, nCopy );                }            } while (err==REGERR_OK);            if (err != REGERR_NOFIND)                goto done;  /* real error, bail */            /* found an unused name -- add it */            err = NR_RegAddKey( vreg, navKey, regname, &curver );            if ( err != REGERR_OK )                goto done;            /* add path and version properties */            err = vr_SetPathname( vreg, curver, NAVHOME, programPath );            if ( REGERR_OK == err && versionStr != NULL ) {                err = NR_RegSetEntryString( vreg, curver, VERSTR, versionStr );            }            if ( REGERR_OK == err ) {                /* everything's OK, make it current */                err = NR_RegSetEntryString(vreg,navKey,CURRENT_VER,regname);            }        }    }done:    return err;}