* bug 3630 fixed - functions added by 'addinter' are not visible by 'what'
* bug 3604 fixed - Problems with getting Frame uicontrol position (Scilab crash)
+
+* bug 3647 fixed - 'call' doesn't manage external functions named with more 23 characters
lib_suf = getdynlibext();
if libname=="" then libname = names(1);end
-
+
+ if ( length(libname) + length('_path') ) > 24 then
+ shortlibname_path = part(libname,1:(24 - length('_path')));
+ else
+ shortlibname_path = libname;
+ end
+
fd=mopen(loadername,"w");
mfprintf(fd,"// ------------------------------------------------------\n");
mfprintf(fd,"// generated by builder.sce: Please do not edit this file\n");
mfprintf(fd,"// ------------------------------------------------------\n");
mfprintf(fd,"\n");
- mfprintf(fd,"%s_path = get_absolute_file_path(''%s'');\n",libname,basename(loadername+'.x'));
+ mfprintf(fd,"%s_path = get_absolute_file_path(''%s'');\n",shortlibname_path,basename(loadername+'.x'));
mfprintf(fd,"\n");
//** first "link" : external libraries
else
[diri, basenamei, exti] = fileparts(libs(i));
if (diri == '') then
- mfprintf(fd,"link(%s_path+''%s%s'');\n",libname,libs(i),lib_suf);
+ mfprintf(fd,"link(%s_path+''%s%s'');\n",shortlibname_path,libs(i),lib_suf);
else
mfprintf(fd,"link(''%s%s'');\n",libs(i),lib_suf);
end
end
//** second "link" : user defined functions
- mfprintf(fd,"link(%s_path+''lib%s%s'',[",libname,libname,lib_suf);
+ mfprintf(fd,"link(%s_path+''lib%s%s'',[",shortlibname_path,libname,lib_suf);
names = names(:)';
n = size(names,'*');
mfprintf(fd,"''%s'');\n",flag);
mfprintf(fd,"// remove temp. variables on stack\n");
- mfprintf(fd,"clear %s_path;\n",libname);
+ mfprintf(fd,"clear %s_path;\n",shortlibname_path);
mfprintf(fd,"clear get_file_path;\n");
mfprintf(fd,"// ------------------------------------------------------\n");
mclose(fd);
end
end
+ if length(name) + length('_path') > 24 then
+ name_path = part(name,1:(24 - length('_path')));
+ else
+ name_path = name;
+ end
+
fd=mopen('loader.sce',"wt");
mfprintf(fd,"// ------------------------------------------------------\n");
mfprintf(fd,"// generated by builder.sce: Please do not edit this file\n");
mfprintf(fd,"// ------------------------------------------------------\n");
mfprintf(fd,"\n");
- mfprintf(fd,"%s_path = get_file_path(''loader.sce'');\n",name);
+ mfprintf(fd,"%s_path = get_file_path(''loader.sce'');\n",name_path);
nl = size(libs,'*');
for i=1:nl
- mfprintf(fd,"link(%s_path+''/%s%s'');\n",name,libs(i),getdynlibext());
+ mfprintf(fd,"link(%s_path+''/%s%s'');\n",name_path,libs(i),getdynlibext());
end
if L == 1 then
end
mfprintf(fd,"];\n");
- mfprintf(fd,"addinter(%s_path+''/%s%s'',''%s'',list_functions);\n",name, ..
+ mfprintf(fd,"addinter(%s_path+''/%s%s'',''%s'',list_functions);\n",name_path, ..
name,getdynlibext(),name);
else
// on link then a set of addinter
- mfprintf(fd,"ilib = link(%s_path+filesep()+''%s%s'');\n",name, ..
+ mfprintf(fd,"ilib = link(%s_path+filesep()+''%s%s'');\n",name_path, ..
name,getdynlibext());
for itable=1:L
// loop on a list of tables
end
mfprintf(fd,"// remove temp. variables on stack\n");
- mfprintf(fd,"clear %s_path;\n",name);
+ mfprintf(fd,"clear %s_path;\n",name_path);
mfprintf(fd,"clear list_functions;\n");
mfprintf(fd,"clear get_file_path;\n");
mfprintf(fd,"// ------------------------------------------------------\n");
top2=top-rhs+1
if(.not.getsmat(fname,top,top2,m1,n1,1,1,lrc,nc))return
name=' '
- if ( nc.gt.fortname ) then
- buf = fname // ' first argument must be of length < 24'
- call error(999)
- return
- endif
call cvstr(nc,istk(lrc),name,1)
name(nc+1:nc+1)=char(0)
C Check the name in the <<fort>> table
#include "dynamic_link.h"
#include "MALLOC.h"
/*--------------------------------------------------------------------------*/
-#define MAXNAME 32
-static char buf[MAXNAME];
-/*--------------------------------------------------------------------------*/
static BOOL SearchComp(FTAB *Ftab, char *op, void (**realop) ());
static void Emptyfunc(void) {}
/*--------------------------------------------------------------------------*/
voidf AddFunctionInTable (char *name, int *rep, FTAB *table)
{
void (*loc)();
- char *s = NULL;
-
- strncpy(buf,name,MAXNAME);
- s=buf;
- while ( *s != ' ' && *s != '\0') { s++;};
- *s= '\0';
- if ( ( SearchComp(table,buf,&loc) == TRUE) || ( SearchInDynLinks(buf,&loc) >= 0 ) )
+ if (name)
{
- *rep = 0;
+ char *buf = (char*)MALLOC(sizeof(char)*(strlen(name)+1));
+ if (buf)
+ {
+ char *s = NULL;
+ strncpy(buf,name,(int)strlen(name));
+ /* remove space */
+ s = buf;
+ while ( *s != ' ' && *s != '\0') { s++;};
+ *s= '\0';
+ /* search name in functions table */
+ if ( ( SearchComp(table,buf,&loc) == TRUE) || ( SearchInDynLinks(buf,&loc) >= 0 ) )
+ {
+ *rep = 0;
+ }
+ else
+ {
+ loc = Emptyfunc;
+ *rep = 1;
+ }
+
+ FREE(buf);
+ buf = NULL;
+ }
+ else
+ {
+ *rep = 0;
+ }
}
else
{
- loc = Emptyfunc;
- *rep = 1;
+ *rep = 0;
}
return(loc);
}
--- /dev/null
+// =============================================================================\r
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab\r
+// Copyright (C) 2008 - DIGITEO - Allan CORNET\r
+//\r
+// This file is distributed under the same license as the Scilab package.\r
+// =============================================================================\r
+\r
+// <-- Non-regression test for bug 3647 -->\r
+//\r
+// <-- Bugzilla URL -->\r
+// http://bugzilla.scilab.org/show_bug.cgi?id=3647\r
+//\r
+// <-- Short Description -->\r
+// C functions having more than 23 characters are not usable with scilab\r
+\r
+\r
+foo=['void verylongfunctionnamewithmore24characters(double *a,double *b,double *c)';\r
+ '{ *c = *a + *b; }' ];\r
+\r
+// we use TMPDIR for compilation \r
+ \r
+if ~c_link('foo') then\r
+ curPath = getcwd(); \r
+ chdir(TMPDIR); \r
+ mputl(foo,'foo.c');\r
+ \r
+ ilib_for_link(['verylongfunctionnamewithmore24characters'],'foo.o',[],"c");\r
+ \r
+ // disable message\r
+ warning_mode = warning('query');\r
+ warning('off');\r
+ // load the shared library \r
+ exec loader.sce ;\r
+ // enable message\r
+ warning(warning_mode);\r
+ chdir(curPath) \r
+end \r
+\r
+//5+7 by C function\r
+v = call('verylongfunctionnamewithmore24characters',5,1,'d',7,2,'d','out',[1,1],3,'d')\r
+if v <> 12 then pause,end\r
+//================================================\r
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2008 - DIGITEO - Allan CORNET
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- Non-regression test for bug 3647 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=3647
+//
+// <-- Short Description -->
+// C functions having more than 23 characters are not usable with scilab
+foo=['void verylongfunctionnamewithmore24characters(double *a,double *b,double *c)';
+ '{ *c = *a + *b; }' ];
+// we use TMPDIR for compilation
+
+if ~c_link('foo') then
+ curPath = getcwd();
+ chdir(TMPDIR);
+ mputl(foo,'foo.c');
+ ilib_for_link(['verylongfunctionnamewithmore24characters'],'foo.o',[],"c");
+ Generate a loader file
+ Generate a Makefile
+ Running the Makefile
+ Compilation of foo
+ Building shared library (be patient)
+ // disable message
+ warning_mode = warning('query');
+ warning('off');
+ // load the shared library
+ exec loader.sce ;
+ // enable message
+ warning(warning_mode);
+ chdir(curPath)
+ ans =
+
+ T
+end
+//5+7 by C function
+v = call('verylongfunctionnamewithmore24characters',5,1,'d',7,2,'d','out',[1,1],3,'d')
+ v =
+
+ 12.
+if v <> 12 then bugmes();quit;end
+//================================================