Change in policy for duplicate libraries.

* Change: In CRL Core, replace duplicated libraries, even when performing
    a Append/Prepend operation. Also correct a bug in library name
    uniquification, event if it's no used. The policy in cas of duplicate
    libraries is not completly clear for me, still.
This commit is contained in:
Jean-Paul Chaput 2015-06-07 11:05:01 +02:00
parent 445104eaf7
commit 9ac199f11b
4 changed files with 37 additions and 38 deletions

View File

@ -336,8 +336,8 @@ namespace CRL {
AllianceLibrary* library = getAllianceLibrary ( dupLibName, flags );
if (library == NULL) break;
ostringstream oss (libName);
oss << "." << duplicate;
ostringstream oss;
oss << libName << "." << duplicate;
dupLibName = oss.str();
}

View File

@ -702,8 +702,14 @@ namespace CRL {
void Environment::addSYSTEM_LIBRARY ( const char* value, const char* libName, unsigned int mode )
{
if ( mode == Prepend ) { _LIBRARIES.prepend(value,libName); return; }
if ( mode == Append ) { _LIBRARIES.append (value,libName); return; }
if ((mode == Prepend) or (mode == Append)) {
size_t duplicate = _LIBRARIES.hasLib(libName);
if (duplicate != SearchPath::npos) _LIBRARIES.remove( duplicate );
if (mode == Prepend) _LIBRARIES.prepend(value,libName);
if (mode == Append ) _LIBRARIES.append (value,libName);
return;
}
string newLibName = libName;
for ( size_t i=0 ; i < _LIBRARIES.getSize() ; ++i ) {

View File

@ -1,15 +1,9 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
// Copyright (c) UPMC 2008-2015, All Rights Reserved
//
// ===================================================================
//
// $Id$
//
// x-----------------------------------------------------------------x
// | |
// +-----------------------------------------------------------------+
// | C O R I O L I S |
// | Alliance / Hurricane Interface |
// | |
@ -17,21 +11,10 @@
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
// | =============================================================== |
// | C++ Module : "./SearchPath.cpp" |
// | *************************************************************** |
// | U p d a t e s |
// | |
// x-----------------------------------------------------------------x
// +-----------------------------------------------------------------+
# include "crlcore/SearchPath.h"
namespace {
using namespace std;
} // End of anonymous namespace.
#include "crlcore/SearchPath.h"
namespace CRL {
@ -106,6 +89,10 @@ namespace CRL {
}
void SearchPath::remove ( size_t index )
{ if (index < _paths.size()) _paths.erase( _paths.begin()+index ); }
void SearchPath::select ( const string& path )
{
for ( size_t ipath=0 ; ipath < _paths.size() ; ++ipath ) {
@ -143,6 +130,14 @@ namespace CRL {
}
size_t SearchPath::hasLib ( const string& name ) const
{
for ( size_t i=0 ; i < _paths.size() ; i++ )
if ( _paths[i].getName() == name ) return i;
return npos;
}
const SearchPath::Element& SearchPath::operator[] ( size_t index ) const
{
static Element nullElement;

View File

@ -1,8 +1,7 @@
// -*- C++ -*-
//
// This file is part of the Coriolis Software.
// Copyright (c) UPMC/LIP6 2008-2012, All Rights Reserved
// Copyright (c) UPMC 2008-2015, All Rights Reserved
//
// +-----------------------------------------------------------------+
// | C O R I O L I S |
@ -15,20 +14,17 @@
// +-----------------------------------------------------------------+
#ifndef __CRL_SEARCH_PATH__
# define __CRL_SEARCH_PATH__
#ifndef CRL_SEARCH_PATH_H
#define CRL_SEARCH_PATH_H
#include <string>
#include <vector>
#include "hurricane/Commons.h"
#include "hurricane/Slot.h"
#include <string>
#include <vector>
#include "hurricane/Commons.h"
#include "hurricane/Slot.h"
namespace CRL {
using Hurricane::Record;
using Hurricane::_TName;
@ -57,6 +53,7 @@ namespace CRL {
inline void append ( const std::string& path, const std::string& name="" );
void prepend ( const std::string& path, const std::string& name="");
void replace ( const std::string& path, const std::string&, size_t index );
void remove ( size_t index );
size_t locate ( const std::string& file
, std::ios::openmode mode =std::ios::in
, int first=0
@ -66,6 +63,7 @@ namespace CRL {
inline const std::string& getSelected () const;
inline size_t getIndex () const;
inline bool hasSelected () const;
size_t hasLib ( const std::string& name ) const;
size_t hasPath ( const std::string& path ) const;
const Element& operator[] ( size_t index ) const;
private:
@ -109,11 +107,11 @@ namespace CRL {
inline std::string SearchPath::Element::_getTypeName () const { return "SearchPath::Element"; }
} // End of CRL namespace.
} // CRL namespace.
INSPECTOR_P_SUPPORT(CRL::SearchPath);
INSPECTOR_V_SUPPORT(CRL::SearchPath::Element);
# endif
#endif // CRL_SEARCH_PATH_H