summaryrefslogtreecommitdiffstats
path: root/scilab/modules/output_stream
diff options
context:
space:
mode:
authorAllan CORNET <allan.cornet@scilab.org>2010-03-01 15:40:36 +0100
committerAllan CORNET <allan.cornet@scilab.org>2010-03-01 15:40:36 +0100
commit92ee389c1c4e5e4bf3afd85994044b01019e9f95 (patch)
tree4d5aaecd439914afb58dce5226839df5997546a7 /scilab/modules/output_stream
parent284955c1d77392c379a7a0b1a997f62fad6c0c4b (diff)
downloadscilab-92ee389c1c4e5e4bf3afd85994044b01019e9f95.zip
scilab-92ee389c1c4e5e4bf3afd85994044b01019e9f95.tar.gz
bug 6435
Diffstat (limited to 'scilab/modules/output_stream')
-rw-r--r--scilab/modules/output_stream/src/c/errmsg.c68
-rw-r--r--scilab/modules/output_stream/tests/nonreg_tests/bug_6435.tst25
2 files changed, 70 insertions, 23 deletions
diff --git a/scilab/modules/output_stream/src/c/errmsg.c b/scilab/modules/output_stream/src/c/errmsg.c
index 0ee7395..43ad66c 100644
--- a/scilab/modules/output_stream/src/c/errmsg.c
+++ b/scilab/modules/output_stream/src/c/errmsg.c
@@ -33,6 +33,9 @@ static void strip_blank(char *source);
33static void displayAndStoreError(const char *msg,...); 33static void displayAndStoreError(const char *msg,...);
34static void resetLastError(void); 34static void resetLastError(void);
35static char *getConvertedNameFromStack(int cvnametype); 35static char *getConvertedNameFromStack(int cvnametype);
36static char *defaultStringError(void);
37/*--------------------------------------------------------------------------*/
38#define EMPTY_BUFFER "00000000000000000000000"
36/*--------------------------------------------------------------------------*/ 39/*--------------------------------------------------------------------------*/
37#ifdef _MSC_VER 40#ifdef _MSC_VER
38#define vsnprintf _vsnprintf 41#define vsnprintf _vsnprintf
@@ -81,13 +84,22 @@ int C2F(errmsg)(int *n,int *errtyp)
81 break; 84 break;
82 case 4: 85 case 4:
83 { 86 {
87 /* bug 6435 */
84 char *NameVarOnStack = getConvertedNameFromStack(CVNAME_READING_TYPE_6); 88 char *NameVarOnStack = getConvertedNameFromStack(CVNAME_READING_TYPE_6);
85 if (NameVarOnStack) 89 if (NameVarOnStack)
86 { 90 {
87 displayAndStoreError(_("Undefined variable: %s\n"),NameVarOnStack); 91 if (NameVarOnStack[0] != '0')
92 {
93 displayAndStoreError(_("Undefined variable: %s\n"), NameVarOnStack);
94 FREE(NameVarOnStack);
95 NameVarOnStack = NULL;
96 break;
97 }
98
88 FREE(NameVarOnStack); 99 FREE(NameVarOnStack);
89 NameVarOnStack = NULL; 100 NameVarOnStack = NULL;
90 } 101 }
102 displayAndStoreError(_("Undefined variable.\n"));
91 } 103 }
92 break; 104 break;
93 case 5: 105 case 5:
@@ -502,7 +514,7 @@ int C2F(errmsg)(int *n,int *errtyp)
502 displayAndStoreError(_("Fatal error!!! Your variables have been saved in the file : %s\n\ 514 displayAndStoreError(_("Fatal error!!! Your variables have been saved in the file : %s\n\
503Bad call to a scilab function ?\n\ 515Bad call to a scilab function ?\n\
504Otherwise, send a bug report to :\n"),get_sci_data_strings(SAVE_ID)); 516Otherwise, send a bug report to :\n"),get_sci_data_strings(SAVE_ID));
505 displayAndStoreError("http://bugzilla.scilab.org/index.cgi\n"); 517 displayAndStoreError("http://bugzilla.scilab.org/\n");
506 } 518 }
507 break; 519 break;
508 case 69: 520 case 69:
@@ -832,7 +844,7 @@ Otherwise, send a bug report to :\n"),get_sci_data_strings(SAVE_ID));
832 case 115: 844 case 115:
833 { 845 {
834 displayAndStoreError(_("Stack problem detected within a loop.\nA primitive function has been called with a wrong number of output arguments.\nNo output argument test has been made for this function.\nPlease report this bug :\n")); 846 displayAndStoreError(_("Stack problem detected within a loop.\nA primitive function has been called with a wrong number of output arguments.\nNo output argument test has been made for this function.\nPlease report this bug :\n"));
835 displayAndStoreError("http://bugzilla.scilab.org/index.cgi\n"); 847 displayAndStoreError("http://bugzilla.scilab.org/\n");
836 848
837 C2F(showstack)(); /* display of calling tree */ 849 C2F(showstack)(); /* display of calling tree */
838 } 850 }
@@ -1553,29 +1565,17 @@ Otherwise, send a bug report to :\n"),get_sci_data_strings(SAVE_ID));
1553 1565
1554 default: 1566 default:
1555 { 1567 {
1556 int bufl; 1568 char *buffer = defaultStringError();
1557 char *buffer = NULL;
1558 /* message d'erreur soft */
1559 /* Bug 1422 corrected - Francois VOGEL June 2006 */
1560 bufl = 1;
1561 while(*(unsigned char *)&C2F(cha1).buf[bufl - 1] != '\0' && bufl < 80)
1562 {
1563 ++bufl;
1564 }
1565 --bufl;
1566 /* remove blank */
1567 buffer = (char*)MALLOC((strlen(C2F(cha1).buf)+1)*sizeof(char));
1568 if (buffer) 1569 if (buffer)
1569 { 1570 {
1570 strcpy(buffer,C2F(cha1).buf);
1571 strip_blank(buffer);
1572 displayAndStoreError(buffer); 1571 displayAndStoreError(buffer);
1573 FREE(buffer); 1572 FREE(buffer);
1573 buffer = NULL;
1574 } 1574 }
1575 } 1575 }
1576 break; 1576 break;
1577 } 1577 }
1578 return 0; 1578 return 0;
1579} 1579}
1580/*--------------------------------------------------------------------------*/ 1580/*--------------------------------------------------------------------------*/
1581static void strip_blank(char *source) 1581static void strip_blank(char *source)
@@ -1603,7 +1603,7 @@ static char *getConvertedNameFromStack(int cvnametype)
1603 case CVNAME_READING_TYPE_1 : 1603 case CVNAME_READING_TYPE_1 :
1604 { 1604 {
1605 C2F(cvname)(&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], C2F(cha1).buf, &one, bsiz); 1605 C2F(cvname)(&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], C2F(cha1).buf, &one, bsiz);
1606 strncpy(local_variable_buffer, C2F(cha1).buf,nlgh); 1606 strncpy(local_variable_buffer, C2F(cha1).buf, nlgh);
1607 local_variable_buffer[nlgh-1] = '\0'; 1607 local_variable_buffer[nlgh-1] = '\0';
1608 } 1608 }
1609 break; 1609 break;
@@ -1618,7 +1618,7 @@ static char *getConvertedNameFromStack(int cvnametype)
1618 case CVNAME_READING_TYPE_3 : 1618 case CVNAME_READING_TYPE_3 :
1619 { 1619 {
1620 C2F(cvname)(&C2F(recu).ids[C2F(recu).pt * nsiz - nsiz], C2F(cha1).buf, &one, bsiz); 1620 C2F(cvname)(&C2F(recu).ids[C2F(recu).pt * nsiz - nsiz], C2F(cha1).buf, &one, bsiz);
1621 strncpy(local_variable_buffer, C2F(cha1).buf,nlgh); 1621 strncpy(local_variable_buffer, C2F(cha1).buf, nlgh);
1622 local_variable_buffer[nlgh-1] = '\0'; 1622 local_variable_buffer[nlgh-1] = '\0';
1623 } 1623 }
1624 break; 1624 break;
@@ -1626,8 +1626,8 @@ static char *getConvertedNameFromStack(int cvnametype)
1626 case CVNAME_READING_TYPE_4 : 1626 case CVNAME_READING_TYPE_4 :
1627 { 1627 {
1628 #define SHIFT_CHAR 3 1628 #define SHIFT_CHAR 3
1629 cvname_(&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], C2F(cha1).buf + SHIFT_CHAR, &one, nlgh+1); 1629 C2F(cvname)(&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], C2F(cha1).buf + SHIFT_CHAR, &one, nlgh+1);
1630 strncpy(local_variable_buffer, C2F(cha1).buf+SHIFT_CHAR,nlgh); 1630 strncpy(local_variable_buffer, C2F(cha1).buf+SHIFT_CHAR, nlgh);
1631 local_variable_buffer[nlgh] = '\0'; 1631 local_variable_buffer[nlgh] = '\0';
1632 } 1632 }
1633 break; 1633 break;
@@ -1642,7 +1642,7 @@ static char *getConvertedNameFromStack(int cvnametype)
1642 case CVNAME_READING_TYPE_6 : 1642 case CVNAME_READING_TYPE_6 :
1643 { 1643 {
1644 C2F(cvname)(&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], C2F(cha1).buf, &one, nlgh+1); 1644 C2F(cvname)(&C2F(recu).ids[(C2F(recu).pt + 1) * nsiz - nsiz], C2F(cha1).buf, &one, nlgh+1);
1645 strncpy(local_variable_buffer, C2F(cha1).buf,nlgh); 1645 strncpy(local_variable_buffer, C2F(cha1).buf, nlgh);
1646 local_variable_buffer[nlgh-1] = '\0'; 1646 local_variable_buffer[nlgh-1] = '\0';
1647 } 1647 }
1648 break; 1648 break;
@@ -1695,4 +1695,26 @@ static void resetLastError(void)
1695 C2F(freemsgtable)(); 1695 C2F(freemsgtable)();
1696} 1696}
1697/*--------------------------------------------------------------------------*/ 1697/*--------------------------------------------------------------------------*/
1698static char *defaultStringError(void)
1699{
1700 char *buffer = NULL;
1701 int bufl = 1;
1698 1702
1703 while(*(unsigned char *)&C2F(cha1).buf[bufl - 1] != '\0' && bufl < 80)
1704 {
1705 ++bufl;
1706 }
1707 --bufl;
1708
1709
1710 buffer = (char*)MALLOC( ((int)strlen(C2F(cha1).buf) + 1) * sizeof(char));
1711
1712 /* remove blank */
1713 if (buffer)
1714 {
1715 strcpy(buffer, C2F(cha1).buf);
1716 strip_blank(buffer);
1717 }
1718 return buffer;
1719}
1720/*--------------------------------------------------------------------------*/ \ No newline at end of file
diff --git a/scilab/modules/output_stream/tests/nonreg_tests/bug_6435.tst b/scilab/modules/output_stream/tests/nonreg_tests/bug_6435.tst
new file mode 100644
index 0000000..79ddffa
--- /dev/null
+++ b/scilab/modules/output_stream/tests/nonreg_tests/bug_6435.tst
@@ -0,0 +1,25 @@
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// <-- JVM NOT MANDATORY -->
8// <-- INTERACTIVE TEST -->
9
10// <-- Non-regression test for bug 6435 -->
11//
12// <-- Short Description -->
13// error 4 returned a wrong message
14//
15// <-- Bugzilla URL -->
16// http://bugzilla.scilab.org/show_bug.cgi?id=6435
17//
18
19timelib1
20
21timelib1.
22
23timelib1.calendar
24
25timelib1.calendar()