* bug 4943 fixed - execstr does not check input arguments.
+* bug 4964 fixed - set or get 'format_n' property from an axes crash scilab.
+
{
if ( sciGetEntityType (pobj) != SCI_AXES )
{
- Scierror(999, _("%s property does not exist for this handle.\n"),"format_n");
+ Scierror(999, _("'%s' property does not exist for this handle.\n"),"format_n");
return -1;
}
+ if(pAXES_FEATURE (pobj)->format == NULL)
+ return sciReturnString("");
+
return sciReturnString( pAXES_FEATURE (pobj)->format ) ;
}
/*------------------------------------------------------------------------*/
* Copyright (C) 2004-2006 - INRIA - Fabrice Leray
* Copyright (C) 2006 - INRIA - Allan Cornet
* Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
+ * Copyright (C) 2009 - DIGITEO - Pierre Lando
*
* This file must be used under the terms of the CeCILL.
* This source file is licensed as described in the file COPYING, which
#include "GetProperty.h"
#include "Scierror.h"
#include "localization.h"
+#include "MALLOC.h"
+#include "string.h"
+
/*------------------------------------------------------------------------*/
int set_format_n_property( sciPointObj * pobj, size_t stackPointer, int valueType, int nbRow, int nbCol )
{
+ char* format;
+ int formatLength;
if ( !isParameterStringMatrix( valueType ) )
{
- Scierror(999, _("Incompatible type for property %s.\n"),"format_n") ;
+ Scierror(999, _("Wrong type for '%s' property: String expected.\n"), "format_n");
return SET_PROPERTY_ERROR ;
}
if ( sciGetEntityType(pobj) != SCI_AXES )
{
- Scierror(999, _("%s property does not exist for this handle.\n"),"format_n") ;
+ Scierror(999, _("'%s' property does not exist for this handle.\n"),"format_n") ;
+ return SET_PROPERTY_ERROR ;
+ }
+
+ if(pAXES_FEATURE(pobj)->format != NULL)
+ FREE(pAXES_FEATURE(pobj)->format);
+
+ format = getStringFromStack(stackPointer);
+ formatLength = strlen(format);
+
+ if(formatLength <= 1)
+ {
+ pAXES_FEATURE(pobj)->format = NULL;
+ return SET_PROPERTY_SUCCEED;
+ }
+
+ pAXES_FEATURE(pobj)->format = MALLOC((formatLength + 1) * sizeof(char));
+ if(pAXES_FEATURE(pobj)->format != NULL)
+ {
+ strcpy(pAXES_FEATURE(pobj)->format, format);
+ return SET_PROPERTY_SUCCEED ;
+ }
+ else
+ {
+ Scierror(999, _("%s: No more memory.\n"),"set_format_n_property");
return SET_PROPERTY_ERROR ;
}
- pAXES_FEATURE(pobj)->format[0] = getStringFromStack(stackPointer)[0] ;
return SET_PROPERTY_SUCCEED ;
}
/*------------------------------------------------------------------------*/
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - pierre.lando@scilab.org
+//
+//// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 4964 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4964
+//
+// <-- Short Description -->
+// set or get 'format_n' property from an axes crash scilab.
+plot2d(1:10,1:10,1,"020")
+drawaxis(x=2:7,y=4,dir='u',tics='v')
+e=gce();
+e.format_n
+ ans =
+
+
+e.format_n='%0.0fcm'
+ e =
+
+Handle of type "Axis" with properties:
+======================================
+parent: Axes
+visible = "on"
+tics_direction = "top"
+xtics_coord = [2,3,4,5,6,7]
+ytics_coord = 4
+tics_color = -1
+tics_segment = "on"
+tics_style = "v"
+sub_tics = 2
+tics_labels = ["2cm","3cm","4cm","5cm","6cm","7cm"]
+labels_font_size = 0
+labels_font_color = -1
+fractional_font = "off"
+clip_state = "off"
+clip_box = []
+user_data = []
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009 - DIGITEO - pierre.lando@scilab.org
+//
+//// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH GRAPHIC -->
+//
+// <-- Non-regression test for bug 4964 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=4964
+//
+// <-- Short Description -->
+// set or get 'format_n' property from an axes crash scilab.
+
+
+plot2d(1:10,1:10,1,"020")
+drawaxis(x=2:7,y=4,dir='u',tics='v')
+e=gce();
+e.format_n
+e.format_n='%0.0fcm'
+