replaces strsubst by filepart
Allan CORNET [Mon, 20 Oct 2008 12:52:31 +0000 (14:52 +0200)]
scilab/modules/dynamic_link/macros/ilib_compile.sci
scilab/modules/dynamic_link/macros/ilib_gen_Make.sci
scilab/modules/dynamic_link/macros/ilib_gen_gateway.sci

index 37fdc94..9fd9727 100644 (file)
@@ -32,7 +32,17 @@ function libn = ilib_compile(lib_name,makename,files, ..
   
   oldpath = getcwd();
   files = files(:)';
-  files1 = strsubst(strsubst(files,'.obj','') ,'.o','');
+  
+  managed_ext = ['.obj','.o'];
+  for i=1:size(files,'*') // compatibility scilab 4.x
+    [path_f, file_f, ext_f] = fileparts(files(i));
+    if or(managed_ext == ext_f) then
+      files1(i) = path_f + file_f;
+    else
+      files1(i) = path_f + file_f + ext_f;
+    end
+  end
+  
   [make_command,lib_name_make,lib_name,path,makename,files]= ...
       ilib_compile_get_names(lib_name,makename,files);
 
@@ -121,7 +131,6 @@ function libn = ilib_compile(lib_name,makename,files, ..
 
          // Copy the produce lib to the working path
          copyfile(".libs/" + lib_name, oldPath);
-   
   end
        
   libn = path + lib_name_make ; 
@@ -130,13 +139,20 @@ function libn = ilib_compile(lib_name,makename,files, ..
 endfunction
 //==========================================
 
-
 //==========================================
 // function only defined in ilib_compile
 //==========================================
 function [make_command,lib_name_make,lib_name,path,makename,files] = ilib_compile_get_names(lib_name,makename,files) 
-
-  files = strsubst(strsubst(files,'.obj','') ,'.o',''); //compatibility
+  
+  managed_ext = ['.obj','.o'];
+  for i=1:size(files,'*') // compatibility scilab 4.x
+    [path_f, file_f, ext_f] = fileparts(files(i));
+    if or(managed_ext == ext_f) then
+      files(i) = path_f + file_f;
+    else
+      files(i) = path_f + file_f + ext_f;
+    end
+  end
     
   k = strindex(makename,['/','\']);
   
index b5b4af4..2f72fa6 100644 (file)
@@ -13,7 +13,15 @@ function Makename=ilib_gen_Make(name,tables,files,libs,makename,with_gateway,ldf
 // generate a Makefile for gateway
 
   if argn(2)<6 then with_gateway=%t,ldflags='',cflags='',fflags='', cc='';end
-  files=strsubst(strsubst(files,'.obj','') ,'.o',''); //compat
+  for i=1:size(files,'*') // compatibility scilab 4.x
+    [path_f, file_f, ext_f] = fileparts(files(i));
+    if or(ext_f == ['.o','.obj']) then
+      files(i) = path_f + file_f;
+    else
+      files(i) = path_f + file_f + ext_f;
+    end
+  end
+  
   // change table if necessary 
   if typeof(tables)<>'list' then 
     tables= list(tables)
@@ -60,10 +68,17 @@ endfunction
 
 
 function ilib_gen_Make_win32(name,table,files,libs,Makename,with_gateway,ldflags,cflags,fflags)
-  files = strsubst(files,'.f90','');
-  files = strsubst(strsubst(files,'.cxx','') ,'.f','');
-  files = strsubst(strsubst(files,'.cpp','') ,'.f','');
-  files = strsubst(strsubst(files,'.c','') ,'.f','');
+
+  managed_ext = ['.f90','.cxx','.cpp','.c','.f'];
+  for i=1:size(files,'*') // compatibility scilab 4.x
+    [path_f, file_f, ext_f] = fileparts(files(i));
+    if or(managed_ext == ext_f) then
+      files(i) = path_f + file_f;
+    else
+      files(i) = path_f + file_f + ext_f;
+    end
+  end
+
   fd=mopen(Makename,"w");
   mfprintf(fd,"# generated by builder.sce: Please do not edit this file\n");
   mfprintf(fd,"# ------------------------------------------------------\n");
@@ -125,9 +140,17 @@ endfunction
 function ilib_gen_Make_lcc(name,table,files,libs,Makename,with_gateway,ldflags,cflags,fflags,flag)
 // Allan CORNET
 //INRIA 2004
-  files = strsubst(strsubst(files,'.cxx','') ,'.f','');
-  files = strsubst(strsubst(files,'.cpp','') ,'.f','');
-  files = strsubst(strsubst(files,'.c','') ,'.f','');
+
+  managed_ext = ['.cxx','.cpp','.c','.f'];
+  for i=1:size(files,'*') // compatibility scilab 4.x
+    [path_f, file_f, ext_f] = fileparts(files(i));
+    if or(managed_ext == ext_f) then
+      files(i) = path_f + file_f;
+    else
+      files(i) = path_f + file_f + ext_f;
+    end
+  end
+
   fd=mopen(Makename,"w");
   mfprintf(fd,"# ------------------------------------------------------------\n");
   mfprintf(fd,"# generated by builder.sce (lcc 1): Please do not edit this file\n");
@@ -189,16 +212,19 @@ function ilib_gen_Make_lcc(name,table,files,libs,Makename,with_gateway,ldflags,c
   mfprintf(fd,"\n$(LIBRARY).dll: $(OBJS)\n");
   mfprintf(fd,"        $(DUMPEXTS) -o ""$(LIBRARY).def"" ""$*"" $(OBJS)\n");
   mfprintf(fd,"        $(LINKER) $(LINKER_FLAGS) $(OBJS) $(OTHERLIBS) $(SCIIMPLIB) $(XLIBSBIN) $(TERMCAPLIB) $(EXTRA_LDFLAGS) $*.def -o $(LIBRARY).dll\n\n");
 
   for x=files(:)' ;
-       x=strsubst(x,".obj","");
-       x=strsubst(x,".o","");
+    managed_ext_obj = ['.obj','.o'];
+    [path_f, file_f, ext_f] = fileparts(x);
+    if or(managed_ext == ext_f) then
+      files(i) = path_f + file_f;
+    else
+      files(i) = path_f + file_f + ext_f;
+    end
        mfprintf(fd,"%s$(O):\n",x);
        mfprintf(fd,"   $(CC) $(CFLAGS) $*.c\n\n");
   end
 
-
   if with_gateway then 
     if L==1 then 
       mfprintf(fd,"\n%s$(O):\n",name);
@@ -211,7 +237,6 @@ function ilib_gen_Make_lcc(name,table,files,libs,Makename,with_gateway,ldflags,c
     end
   end
   
-       
   mfprintf(fd,"\nclean:\n");
   mfprintf(fd,"        del *.obj\n");
   mfprintf(fd,"        del *.dll\n");
index 6859184..5e2f257 100644 (file)
@@ -25,7 +25,12 @@ function ilib_gen_gateway(name,tables)
      path='';
   end
   
-  name = strsubst(name,'.c','');
+  [path_name, file_name, ext_name] = fileparts(name);
+  if ext_name == '.c' then
+    name = path_name + file_name;
+  else
+    name = path_name + file_name + ext_name;
+  end
   
   if typeof(tables)<>'list' then 
     tables = list(tables);