summaryrefslogtreecommitdiffstats
path: root/scilab/modules/functions
diff options
context:
space:
mode:
authorAllan CORNET <allan.cornet@scilab.org>2010-02-05 14:40:25 +0100
committerAllan CORNET <allan.cornet@scilab.org>2010-02-05 14:40:25 +0100
commitf3b07f78ded09d01a8ead4821a6863d5231c13a5 (patch)
tree96bb3daf6f6a406a83c051e13ddcf3965b58e2a2 /scilab/modules/functions
parent3b8f558206fdcfe3579763914ef264822b0687e9 (diff)
downloadscilab-f3b07f78ded09d01a8ead4821a6863d5231c13a5.zip
scilab-f3b07f78ded09d01a8ead4821a6863d5231c13a5.tar.gz
bug 6550
Diffstat (limited to 'scilab/modules/functions')
-rw-r--r--scilab/modules/functions/sci_gateway/c/sci_lib.c31
-rw-r--r--scilab/modules/functions/tests/nonreg_tests/bug_6550.dia.ref37
-rw-r--r--scilab/modules/functions/tests/nonreg_tests/bug_6550.tst34
3 files changed, 97 insertions, 5 deletions
diff --git a/scilab/modules/functions/sci_gateway/c/sci_lib.c b/scilab/modules/functions/sci_gateway/c/sci_lib.c
index 25ab7d0..89f36a3 100644
--- a/scilab/modules/functions/sci_gateway/c/sci_lib.c
+++ b/scilab/modules/functions/sci_gateway/c/sci_lib.c
@@ -19,6 +19,7 @@
19#include "MALLOC.h" 19#include "MALLOC.h"
20#include "machine.h" 20#include "machine.h"
21#include "FileExist.h" 21#include "FileExist.h"
22#include "getFullFilename.h"
22/*--------------------------------------------------------------------------*/ 23/*--------------------------------------------------------------------------*/
23extern int C2F(intlib)(); 24extern int C2F(intlib)();
24/*--------------------------------------------------------------------------*/ 25/*--------------------------------------------------------------------------*/
@@ -30,6 +31,7 @@ int C2F(sci_lib)(char *fname,unsigned long fname_len)
30 int iType1 = 0; 31 int iType1 = 0;
31 char *pStVarOne = NULL; 32 char *pStVarOne = NULL;
32 char lib_filename[bsiz]; 33 char lib_filename[bsiz];
34 char *fullfilename = NULL;
33 int lenStVarOne = 0; 35 int lenStVarOne = 0;
34 36
35 int len = 0; 37 int len = 0;
@@ -106,16 +108,35 @@ int C2F(sci_lib)(char *fname,unsigned long fname_len)
106 } 108 }
107 } 109 }
108 110
109 if ((int)strlen(pStVarOne) >= bsiz) 111 fullfilename = getFullFilename(pStVarOne);
112 if (fullfilename)
110 { 113 {
111 strncpy(lib_filename, pStVarOne, bsiz - 1); 114 if ((int)strlen(fullfilename) >= bsiz)
112 lib_filename[bsiz - 1] = '\0'; 115 {
116 strncpy(lib_filename, fullfilename, bsiz - 1);
117 lib_filename[bsiz - 1] = '\0';
118 }
119 else
120 {
121 strcpy(lib_filename, fullfilename);
122 }
123
124 FREE(fullfilename);
125 fullfilename = NULL;
113 } 126 }
114 else 127 else
115 { 128 {
116 strcpy(lib_filename, pStVarOne); 129 if ((int)strlen(pStVarOne) >= bsiz)
130 {
131 strncpy(lib_filename, pStVarOne, bsiz - 1);
132 lib_filename[bsiz - 1] = '\0';
133 }
134 else
135 {
136 strcpy(lib_filename, pStVarOne);
137 }
117 } 138 }
118 139
119 if (pStVarOne) 140 if (pStVarOne)
120 { 141 {
121 FREE(pStVarOne); 142 FREE(pStVarOne);
diff --git a/scilab/modules/functions/tests/nonreg_tests/bug_6550.dia.ref b/scilab/modules/functions/tests/nonreg_tests/bug_6550.dia.ref
new file mode 100644
index 0000000..82ded445
--- /dev/null
+++ b/scilab/modules/functions/tests/nonreg_tests/bug_6550.dia.ref
@@ -0,0 +1,37 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2010 - DIGITEO - Allan CORNET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- Non-regression test for bug 6550 -->
8//
9// <-- Bugzilla URL -->
10// http://bugzilla.scilab.org/show_bug.cgi?id=6550
11//
12// <-- Short Description -->
13// lib(".") used relative path in library variable created
14// =============================================================================
15function z = myplus(x, y), z = x + y,endfunction
16function z = yourplus(x, y), x = x - y,endfunction
17// =============================================================================
18cd TMPDIR
19 ans =
20
21 TMPDIR
22mkdir('bug_6550');
23libdir = TMPDIR + '/bug_6550';
24save(libdir + '/myplus.bin', myplus);
25save(libdir + '/yourplus.bin', yourplus);
26//create the name file
27mputl(['myplus';'yourplus'], libdir + '/names');
28// =============================================================================
29cd(libdir);
30AAlib = lib('.');
31[f, p] = libraryinfo('AAlib');
32if pathconvert(p, %f, %f) <> pathconvert(libdir, %f, %f) then bugmes();quit;end
33// =============================================================================
34BBlib = lib(libdir + '/../bug_6550/../bug_6550');
35[f, p] = libraryinfo('BBlib');
36if pathconvert(p, %f, %f) <> pathconvert(libdir, %f, %f) then bugmes();quit;end
37// =============================================================================
diff --git a/scilab/modules/functions/tests/nonreg_tests/bug_6550.tst b/scilab/modules/functions/tests/nonreg_tests/bug_6550.tst
new file mode 100644
index 0000000..2a55e39
--- /dev/null
+++ b/scilab/modules/functions/tests/nonreg_tests/bug_6550.tst
@@ -0,0 +1,34 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2010 - DIGITEO - Allan CORNET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- Non-regression test for bug 6550 -->
8//
9// <-- Bugzilla URL -->
10// http://bugzilla.scilab.org/show_bug.cgi?id=6550
11//
12// <-- Short Description -->
13// lib(".") used relative path in library variable created
14// =============================================================================
15function z = myplus(x, y), z = x + y,endfunction
16function z = yourplus(x, y), x = x - y,endfunction
17// =============================================================================
18cd TMPDIR
19mkdir('bug_6550');
20libdir = TMPDIR + '/bug_6550';
21save(libdir + '/myplus.bin', myplus);
22save(libdir + '/yourplus.bin', yourplus);
23//create the name file
24mputl(['myplus';'yourplus'], libdir + '/names');
25// =============================================================================
26cd(libdir);
27AAlib = lib('.');
28[f, p] = libraryinfo('AAlib');
29if pathconvert(p, %f, %f) <> pathconvert(libdir, %f, %f) then pause,end
30// =============================================================================
31BBlib = lib(libdir + '/../bug_6550/../bug_6550');
32[f, p] = libraryinfo('BBlib');
33if pathconvert(p, %f, %f) <> pathconvert(libdir, %f, %f) then pause,end
34// =============================================================================