summaryrefslogtreecommitdiffstats
path: root/scilab/modules/spreadsheet
diff options
context:
space:
mode:
authorPierre MARECHAL <pierre.marechal@scilab.org>2009-12-14 10:22:25 +0100
committerPierre MARECHAL <pierre.marechal@scilab.org>2009-12-14 10:22:25 +0100
commit2c1d094107eb669f9502aeb04bfbe632545a955d (patch)
tree162176763ece25ebd093f53027268f2679990b28 /scilab/modules/spreadsheet
parent438c4a5f77e8729849e6ea40797c11efdd0e101b (diff)
parentcdf5b0159ff1d58e89bf33e73fa4569298c46d68 (diff)
downloadscilab-2c1d094107eb669f9502aeb04bfbe632545a955d.zip
scilab-2c1d094107eb669f9502aeb04bfbe632545a955d.tar.gz
Merge commit 'origin/5.2'
Diffstat (limited to 'scilab/modules/spreadsheet')
-rw-r--r--scilab/modules/spreadsheet/sci_gateway/c/sci_xls_open.c23
-rw-r--r--scilab/modules/spreadsheet/tests/nonreg_tests/bug_5615.dia.ref22
-rw-r--r--scilab/modules/spreadsheet/tests/nonreg_tests/bug_5615.tst25
3 files changed, 70 insertions, 0 deletions
diff --git a/scilab/modules/spreadsheet/sci_gateway/c/sci_xls_open.c b/scilab/modules/spreadsheet/sci_gateway/c/sci_xls_open.c
index 6f2efc2..920902e 100644
--- a/scilab/modules/spreadsheet/sci_gateway/c/sci_xls_open.c
+++ b/scilab/modules/spreadsheet/sci_gateway/c/sci_xls_open.c
@@ -30,6 +30,7 @@
30#include "Scierror.h" 30#include "Scierror.h"
31#include "localization.h" 31#include "localization.h"
32#include "freeArrayOfString.h" 32#include "freeArrayOfString.h"
33#include "FileExist.h"
33/*--------------------------------------------------------------------------*/ 34/*--------------------------------------------------------------------------*/
34static char *xls_basename (char *name); 35static char *xls_basename (char *name);
35/*--------------------------------------------------------------------------*/ 36/*--------------------------------------------------------------------------*/
@@ -69,6 +70,28 @@ int sci_xls_open(char *fname,unsigned long fname_len)
69 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1); 70 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
70 71
71 filename_IN = expandPathVariable(cstk(l1)); 72 filename_IN = expandPathVariable(cstk(l1));
73 if (filename_IN)
74 {
75 /* bug 5615 */
76 /* remove blank characters @ the end */
77 int len =(int)strlen(filename_IN);
78 int i = 0;
79
80 if (len >= 1)
81 {
82 for (i = len - 1; i >= 0 ; i--)
83 {
84 if (filename_IN[i] == ' ') filename_IN[i] = '\0';
85 else break;
86 }
87 }
88
89 if (!FileExist(filename_IN))
90 {
91 Scierror(999,_("The file %s does not exist.\n"), filename_IN);
92 return 0;
93 }
94 }
72 95
73 TMPDIR = getTMPDIR(); 96 TMPDIR = getTMPDIR();
74 strcpy(TMP, TMPDIR); 97 strcpy(TMP, TMPDIR);
diff --git a/scilab/modules/spreadsheet/tests/nonreg_tests/bug_5615.dia.ref b/scilab/modules/spreadsheet/tests/nonreg_tests/bug_5615.dia.ref
new file mode 100644
index 0000000..c41f837
--- /dev/null
+++ b/scilab/modules/spreadsheet/tests/nonreg_tests/bug_5615.dia.ref
@@ -0,0 +1,22 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2009 - DIGITEO - Allan CORNET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- Non-regression test for bug 5615 -->
8//
9// <-- Bugzilla URL -->
10// http://bugzilla.scilab.org/show_bug.cgi?id=5615
11//
12// <-- Short Description -->
13// xls_open failed if there was a trailing space after the file extension
14//
15xls_filename = SCI + '/modules/spreadsheet/demos/xls/Test1.xls';
16ierr = execstr('[fd,SST,Sheetnames,Sheetpos] = xls_open(xls_filename);','errcatch');
17if ierr <> 0 then bugmes();quit;end
18mclose(fd);
19xls_filename = SCI + '/modules/spreadsheet/demos/xls/Test1.xls ';
20ierr = execstr('[fd,SST,Sheetnames,Sheetpos] = xls_open(xls_filename);','errcatch');
21if ierr <> 0 then bugmes();quit;end
22mclose(fd);
diff --git a/scilab/modules/spreadsheet/tests/nonreg_tests/bug_5615.tst b/scilab/modules/spreadsheet/tests/nonreg_tests/bug_5615.tst
new file mode 100644
index 0000000..4345018
--- /dev/null
+++ b/scilab/modules/spreadsheet/tests/nonreg_tests/bug_5615.tst
@@ -0,0 +1,25 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2009 - DIGITEO - Allan CORNET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- Non-regression test for bug 5615 -->
9//
10// <-- Bugzilla URL -->
11// http://bugzilla.scilab.org/show_bug.cgi?id=5615
12//
13// <-- Short Description -->
14// xls_open failed if there was a trailing space after the file extension
15//
16
17xls_filename = SCI + '/modules/spreadsheet/demos/xls/Test1.xls';
18ierr = execstr('[fd,SST,Sheetnames,Sheetpos] = xls_open(xls_filename);','errcatch');
19if ierr <> 0 then pause,end
20mclose(fd);
21
22xls_filename = SCI + '/modules/spreadsheet/demos/xls/Test1.xls ';
23ierr = execstr('[fd,SST,Sheetnames,Sheetpos] = xls_open(xls_filename);','errcatch');
24if ierr <> 0 then pause,end
25mclose(fd);