- adjusted kde-am patch to support also automake 1.12 through 1.14
[packages/arts.git] / arts-extension_loader.patch
1 --- arts-1.5.5/mcop/Makefile.am.orig    2005-09-10 10:13:32.000000000 +0200
2 +++ arts-1.5.5/mcop/Makefile.am 2007-01-05 21:47:58.212920750 +0100
3 @@ -16,7 +16,9 @@
4          trader_impl.cc dynamicrequest.cc anyref.cc loopback.cc \
5          delayedreturn.cc thread.cc dynamicskeleton.cc
6  
7 +CXXFLAGS += -fexceptions
8  libmcop_la_LIBADD = $(LIBSOCKET) $(GLIB_LIBADD) $(top_builddir)/libltdl/libltdlc.la
9 +libmcop_la_LIBADD += -lboost_filesystem -lboost_regex
10  libmcop_la_LDFLAGS = -no-undefined -version-info 1:0 $(GLIB_LDFLAGS) $(all_libraries)
11  
12  artsincludedir = $(includedir)/arts
13 --- arts-1.5.5/mcop/extensionloader.cc.orig     2005-09-10 10:13:32.000000000 +0200
14 +++ arts-1.5.5/mcop/extensionloader.cc  2007-01-05 22:36:03.034272500 +0100
15 @@ -28,26 +28,58 @@
16  #include <unistd.h>
17  #include <assert.h>
18  
19 +#include <boost/filesystem/exception.hpp>
20 +#include <boost/filesystem/operations.hpp>
21 +#include <boost/regex.hpp>
22 +
23  using namespace std;
24  using namespace Arts;
25  
26 +static std::string makeLibraryName( std::string const& dir, std::string const& name )
27 +{
28 +       try
29 +       {
30 +               std::string p = dir + "/" + name;
31 +               if ( boost::filesystem::exists( p + ".so" ) )
32 +                       return ( p + ".so" );
33 +               boost::regex re( p + "(-.+){0,1}\\..+", boost::regex::extended );
34 +               for ( boost::filesystem::directory_iterator i( dir );
35 +                       i != boost::filesystem::directory_iterator(); ++i )
36 +               {
37 +                       boost::smatch m;
38 +                       if ( boost::regex_match( i->path().string(), m, re ) )
39 +                               return m.str();
40 +               }
41 +               return ( p + ".la" );
42 +       }
43 +       catch ( boost::filesystem::filesystem_error const& )
44 +       {
45 +       }
46 +       return std::string();
47 +}
48 +
49  ExtensionLoader::ExtensionLoader(const string& filename) :handle(0)
50  {
51         string dlfilename;
52 -
53         assert(filename.size());
54 -       if(filename[0] == '/')
55 -               dlfilename = filename;
56 -       else
57 +       try
58 +       {
59 +               boost::filesystem::path p( filename );
60 +               if ( p.has_root_directory() )
61 +                       dlfilename = makeLibraryName( p.branch_path().string(), p.filename().string() );
62 +       }
63 +       catch ( boost::filesystem::filesystem_error const& )
64 +       {
65 +       }
66 +       if ( dlfilename.empty() )
67         {
68                 const vector<string> *path = MCOPUtils::extensionPath();
69  
70                 vector<string>::const_iterator pi;
71                 for(pi = path->begin(); pi != path->end(); pi++)
72                 {
73 -                       dlfilename = *pi + "/" + filename;
74 -
75 -                       if(access(dlfilename.c_str(),F_OK) == 0)
76 +                       dlfilename = makeLibraryName( *pi, filename );
77 +                       if ( !dlfilename.empty() && ( access( dlfilename.c_str(), F_OK ) == 0 ) )
78                                 break;
79                 }
80         }
This page took 0.342886 seconds and 3 git commands to generate.